-
-
Notifications
You must be signed in to change notification settings - Fork 259
/
cli.js
executable file
·101 lines (90 loc) · 2.64 KB
/
cli.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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);