-
-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add react-native-bootsplash generate command
- Loading branch information
Showing
9 changed files
with
193 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
#!/usr/bin/env node | ||
|
||
const { Command } = require("commander"); | ||
|
||
const program = new Command(); | ||
const pkg = require("./package.json"); | ||
|
||
const validProjectTypes = ["detect", "bare", "expo"]; | ||
const validPlatforms = ["android", "ios", "web"]; | ||
|
||
program | ||
.name(pkg.name) | ||
.description(pkg.description) | ||
.version(pkg.version) | ||
.command("generate", { isDefault: true }) | ||
.description("Generate a launch screen using a logo file path (PNG or SVG)") | ||
.argument("<logo>", "Logo file path (PNG or SVG)") | ||
.option( | ||
"--project-type <string>", | ||
'Project type ("detect", "bare" or "expo")', | ||
"detect", | ||
) | ||
.option( | ||
"--platforms <list>", | ||
"Platforms to generate for, separated by a comma", | ||
validPlatforms.join(","), | ||
) | ||
.option( | ||
"--background <string>", | ||
"Background color (in hexadecimal format)", | ||
"#fff", | ||
) | ||
.option( | ||
"--logo-width <number>", | ||
"Logo width at @1x (in dp - we recommend approximately ~100)", | ||
100, | ||
) | ||
.option( | ||
"--assets-output <string>", | ||
"Assets output directory path", | ||
"assets/bootsplash", | ||
) | ||
.option( | ||
"--flavor <string>", | ||
"Android flavor build variant (where your resource directory is)", | ||
"main", | ||
) | ||
.option( | ||
"--html <string>", | ||
"HTML template file path (your web app entry point)", | ||
"public/index.html", | ||
) | ||
.option( | ||
"--license-key <string>", | ||
"License key to enable brand and dark mode assets generation", | ||
) | ||
.option("--brand <string>", "Brand file path (PNG or SVG)") | ||
.option( | ||
"--brand-width <number>", | ||
"Brand width at @1x (in dp - we recommend approximately ~80)", | ||
80, | ||
) | ||
.option( | ||
"--dark-background <string>", | ||
"[dark mode] Background color (in hexadecimal format)", | ||
) | ||
.option("--dark-logo <string>", "[dark mode] Logo file path (PNG or SVG)") | ||
.option("--dark-brand <string>", "[dark mode] Brand file path (PNG or SVG)") | ||
.action((logo, options) => { | ||
const { projectType, platforms, logoWidth, brandWidth, ...rest } = options; | ||
|
||
const args = { | ||
...rest, | ||
|
||
projectType: validProjectTypes.includes(projectType.toLowerCase()) | ||
? projectType.toLowerCase() | ||
: "detect", | ||
|
||
platforms: [ | ||
...new Set( | ||
platforms | ||
.toLowerCase() | ||
.split(/[ ,;|]/) | ||
.map((platform) => platform.trim()) | ||
.filter((item) => validPlatforms.includes(item)), | ||
), | ||
], | ||
|
||
logoWidth: Number.parseInt(logoWidth, 10), | ||
brandWidth: Number.parseInt(brandWidth, 10), | ||
}; | ||
|
||
const { generate } = require("./dist/commonjs/generate"); | ||
|
||
generate({ logo, ...args }).catch((error) => { | ||
console.error(error); | ||
process.exit(1); | ||
}); | ||
}); | ||
|
||
program.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1353,6 +1353,26 @@ | |
execa "^5.0.0" | ||
fast-glob "^3.3.2" | ||
|
||
"@react-native-community/cli-config-android@^15.0.0": | ||
version "15.1.2" | ||
resolved "https://registry.yarnpkg.com/@react-native-community/cli-config-android/-/cli-config-android-15.1.2.tgz#623d8d4a6693ed9c28e0d6fa41372466ebc32a7a" | ||
integrity sha512-A6YQPl+0pTG0vuTcYLHJODkLy8qgZ2YIfy5XiZEAyxAbkSFbyOf7XR7hzjTw6S0BUJzF+eizHeAsKQ2b1bO75A== | ||
dependencies: | ||
"@react-native-community/cli-tools" "15.1.2" | ||
chalk "^4.1.2" | ||
fast-glob "^3.3.2" | ||
fast-xml-parser "^4.4.1" | ||
|
||
"@react-native-community/cli-config-apple@^15.0.0": | ||
version "15.1.2" | ||
resolved "https://registry.yarnpkg.com/@react-native-community/cli-config-apple/-/cli-config-apple-15.1.2.tgz#2a9f245f6f158eff60495f9e3cce698b35adb4ea" | ||
integrity sha512-BoCLHAFyPwYV9GcbXd9tzrmjJbuRFhuMQ808+gR9exGqVhcK16z60V71z44I5tvOcwvnOtu5fmiVMC5FvcxyNA== | ||
dependencies: | ||
"@react-native-community/cli-tools" "15.1.2" | ||
chalk "^4.1.2" | ||
execa "^5.0.0" | ||
fast-glob "^3.3.2" | ||
|
||
"@react-native-community/[email protected]": | ||
version "15.0.0" | ||
resolved "https://registry.yarnpkg.com/@react-native-community/cli-config/-/cli-config-15.0.0.tgz#c49b1f6b0cc374175a827467bbaf3cee9e9f4ceb" | ||
|
@@ -1457,7 +1477,7 @@ | |
shell-quote "^1.7.3" | ||
sudo-prompt "^9.0.0" | ||
|
||
"@react-native-community/cli-tools@^15.0.0": | ||
"@react-native-community/cli-tools@15.1.2", "@react-native-community/cli-tools@^15.0.0": | ||
version "15.1.2" | ||
resolved "https://registry.yarnpkg.com/@react-native-community/cli-tools/-/cli-tools-15.1.2.tgz#31e0456171f161870f725fd13f9e9ac79f58d344" | ||
integrity sha512-eShBHf/K1e2xJTumiy7CF/akh0DiKfW3YSJ/jpp0RVBgwaXPK6JMrVdGRdbSVad6VqaXVFVtPOe3gSDRa5GDKg== | ||
|
@@ -2852,7 +2872,7 @@ commander@^10.0.1: | |
resolved "https://registry.yarnpkg.com/commander/-/commander-10.0.1.tgz#881ee46b4f77d1c1dccc5823433aa39b022cbe06" | ||
integrity sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug== | ||
|
||
commander@^12.0.0: | ||
commander@^12.0.0, commander@^12.1.0: | ||
version "12.1.0" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-12.1.0.tgz#01423b36f501259fdaac4d0e4d60c96c991585d3" | ||
integrity sha512-Vw8qHK3bZM9y/P10u3Vib8o/DdkvA2OtPtZvD871QKjy74Wj1WSKFILMPRPSdUSx5RFK1arlJzEtA4PkFgnbuA== | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "react-native-bootsplash", | ||
"version": "6.2.6", | ||
"version": "6.3.0", | ||
"license": "MIT", | ||
"description": "Display a bootsplash on your app starts. Hide it when you want.", | ||
"author": "Mathieu Acthernoene <[email protected]>", | ||
|
@@ -20,8 +20,12 @@ | |
"!src/addon", | ||
"RNBootSplash.podspec", | ||
"app.plugin.js", | ||
"cli.js", | ||
"react-native.config.js" | ||
], | ||
"bin": { | ||
"react-native-bootsplash": "./cli.js" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/zoontek/react-native-bootsplash.git" | ||
|
@@ -66,7 +70,10 @@ | |
}, | ||
"dependencies": { | ||
"@expo/config-plugins": "^8.0.4", | ||
"@react-native-community/cli-config-android": "^15.0.0", | ||
"@react-native-community/cli-config-apple": "^15.0.0", | ||
"@react-native-community/cli-tools": "^15.0.0", | ||
"commander": "^12.1.0", | ||
"detect-indent": "^6.1.0", | ||
"fs-extra": "^11.2.0", | ||
"node-html-parser": "^6.1.13", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.