create-uix-app 1.3.4 → 1.4.0-rc2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/package.json +1 -1
- package/src/index.js +67 -10
package/README.md
ADDED
package/package.json
CHANGED
package/src/index.js
CHANGED
@@ -15,12 +15,13 @@ program
|
|
15
15
|
.version(pkg.version)
|
16
16
|
.argument("<project-name>", "directory where a project will be created")
|
17
17
|
.option("--re-frame", "add re-frame setup")
|
18
|
-
.option("--react-native", "setup in existing React Native project")
|
18
|
+
.option("--react-native", "setup in existing React Native project")
|
19
|
+
.option("--expo", "create a new React Native project using Expo");
|
19
20
|
|
20
21
|
program.parse();
|
21
22
|
|
22
23
|
const [projectName] = program.args;
|
23
|
-
const { reFrame, reactNative } = program.opts();
|
24
|
+
const { reFrame, reactNative, reactNativeExpo } = program.opts();
|
24
25
|
|
25
26
|
const masterUrl =
|
26
27
|
"https://github.com/pitch-io/uix-starter/archive/master.tar.gz";
|
@@ -28,14 +29,22 @@ const reframeUrl =
|
|
28
29
|
"https://github.com/pitch-io/uix-starter/archive/re-frame.tar.gz";
|
29
30
|
const reactNativeUrl =
|
30
31
|
"https://github.com/pitch-io/uix-starter/archive/react-native.tar.gz";
|
32
|
+
const reactNativeExpoUrl =
|
33
|
+
"https://github.com/pitch-io/uix-starter/archive/react-native-expo.tar.gz";
|
31
34
|
|
32
|
-
|
33
|
-
? reactNativeUrl
|
34
|
-
: reFrame
|
35
|
-
? reframeUrl
|
36
|
-
: masterUrl;
|
35
|
+
let downloadUrl;
|
37
36
|
|
38
|
-
if (
|
37
|
+
if (reactNative) {
|
38
|
+
downloadUrl = reactNativeUrl;
|
39
|
+
} else if (reactNativeExpo) {
|
40
|
+
downloadUrl = reactNativeExpoUrl;
|
41
|
+
} else if (reFrame) {
|
42
|
+
downloadUrl = reframeUrl;
|
43
|
+
} else {
|
44
|
+
downloadUrl = masterUrl;
|
45
|
+
}
|
46
|
+
|
47
|
+
if (!projectName && !reFrame && !reactNative && !reactNativeExpo) {
|
39
48
|
program.help();
|
40
49
|
} else {
|
41
50
|
console.log(
|
@@ -55,7 +64,11 @@ if (!projectName && !reactNative) {
|
|
55
64
|
fs.renameSync(
|
56
65
|
path.join(
|
57
66
|
process.cwd(),
|
58
|
-
reFrame
|
67
|
+
reFrame
|
68
|
+
? "uix-starter-re-frame"
|
69
|
+
: reactNativeExpo
|
70
|
+
? "uix-starter-react-native-expo"
|
71
|
+
: "uix-starter-main"
|
59
72
|
),
|
60
73
|
path.join(process.cwd(), projectName)
|
61
74
|
);
|
@@ -66,7 +79,51 @@ if (!projectName && !reactNative) {
|
|
66
79
|
})
|
67
80
|
)
|
68
81
|
.then(() => {
|
69
|
-
if (
|
82
|
+
if (reactNativeExpo) {
|
83
|
+
const pkgjson = JSON.parse(
|
84
|
+
fs.readFileSync(
|
85
|
+
path.join(process.cwd(), projectName, "package.json"),
|
86
|
+
"utf8"
|
87
|
+
)
|
88
|
+
);
|
89
|
+
pkgjson.name = projectName;
|
90
|
+
fs.writeFileSync(
|
91
|
+
path.join(process.cwd(), projectName, "package.json"),
|
92
|
+
prettier.format(JSON.stringify(pkgjson), {
|
93
|
+
parser: "json",
|
94
|
+
})
|
95
|
+
);
|
96
|
+
const readme = fs.readFileSync(
|
97
|
+
path.join(process.cwd(), projectName, "README.md"),
|
98
|
+
"utf8"
|
99
|
+
);
|
100
|
+
fs.writeFileSync(
|
101
|
+
path.join(process.cwd(), projectName, "README.md"),
|
102
|
+
readme
|
103
|
+
.replace("uix-starter", projectName)
|
104
|
+
.split("\n")
|
105
|
+
.filter((l) => !l.startsWith("Template project"))
|
106
|
+
.join("\n")
|
107
|
+
);
|
108
|
+
console.log("Installing dependencies...");
|
109
|
+
exec(`cd ${projectName} && yarn install`, (err) => {
|
110
|
+
if (err) {
|
111
|
+
console.error(err);
|
112
|
+
} else {
|
113
|
+
console.log("Done.");
|
114
|
+
console.log("\n");
|
115
|
+
console.log("Using:");
|
116
|
+
Object.entries(pkgjson.dependencies)
|
117
|
+
.map(([k, v]) => `${k}@${v}`)
|
118
|
+
.join("\n");
|
119
|
+
console.log("\n");
|
120
|
+
console.log(
|
121
|
+
"yarn dev # run dev build with Expo and cljs build in watch mode"
|
122
|
+
);
|
123
|
+
console.log("yarn cljs:release # build production bundle");
|
124
|
+
}
|
125
|
+
});
|
126
|
+
} else if (reactNative) {
|
70
127
|
const pkgjsonTmpl = JSON.parse(
|
71
128
|
fs.readFileSync(
|
72
129
|
path.join(
|