create-uix-app 1.2.2 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +3 -2
- package/src/index.js +131 -45
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "create-uix-app",
|
3
|
-
"description": "Creates a starter project for
|
4
|
-
"version": "1.
|
3
|
+
"description": "Creates a starter project for UIx web app",
|
4
|
+
"version": "1.3.1",
|
5
5
|
"author": {
|
6
6
|
"name": "Roman Liutikov"
|
7
7
|
},
|
@@ -18,6 +18,7 @@
|
|
18
18
|
"dependencies": {
|
19
19
|
"axios": "^1.3.4",
|
20
20
|
"commander": "^10.0.0",
|
21
|
+
"deepmerge": "^4.3.1",
|
21
22
|
"prettier": "^2.8.7",
|
22
23
|
"tar": "^6.1.13"
|
23
24
|
}
|
package/src/index.js
CHANGED
@@ -6,6 +6,7 @@ const axios = require("axios");
|
|
6
6
|
const tar = require("tar");
|
7
7
|
const { program } = require("commander");
|
8
8
|
const prettier = require("prettier");
|
9
|
+
const deepmerge = require("deepmerge");
|
9
10
|
const pkg = require("../package.json");
|
10
11
|
|
11
12
|
program
|
@@ -13,21 +14,28 @@ program
|
|
13
14
|
.description(pkg.description)
|
14
15
|
.version(pkg.version)
|
15
16
|
.argument("<project-name>", "directory where a project will be created")
|
16
|
-
.option("--re-frame", "add re-frame setup")
|
17
|
+
.option("--re-frame", "add re-frame setup")
|
18
|
+
.option("--react-native", "setup in existing React Native project");
|
17
19
|
|
18
20
|
program.parse();
|
19
21
|
|
20
22
|
const [projectName] = program.args;
|
21
|
-
const { reFrame } = program.opts();
|
23
|
+
const { reFrame, reactNative } = program.opts();
|
22
24
|
|
23
25
|
const masterUrl =
|
24
26
|
"https://github.com/pitch-io/uix-starter/archive/master.tar.gz";
|
25
27
|
const reframeUrl =
|
26
28
|
"https://github.com/pitch-io/uix-starter/archive/re-frame.tar.gz";
|
29
|
+
const reactNativeUrl =
|
30
|
+
"https://github.com/pitch-io/uix-starter/archive/react-native.tar.gz";
|
27
31
|
|
28
|
-
const downloadUrl =
|
32
|
+
const downloadUrl = reactNative
|
33
|
+
? reactNativeUrl
|
34
|
+
: reFrame
|
35
|
+
? reframeUrl
|
36
|
+
: masterUrl;
|
29
37
|
|
30
|
-
if (!projectName) {
|
38
|
+
if (!projectName && !reactNative) {
|
31
39
|
program.help();
|
32
40
|
} else {
|
33
41
|
console.log(
|
@@ -43,54 +51,132 @@ if (!projectName) {
|
|
43
51
|
r.data
|
44
52
|
.pipe(tar.extract({ cwd: process.cwd() }))
|
45
53
|
.on("end", () => {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
if (!reactNative) {
|
55
|
+
fs.renameSync(
|
56
|
+
path.join(
|
57
|
+
process.cwd(),
|
58
|
+
reFrame ? "uix-starter-re-frame" : "uix-starter-main"
|
59
|
+
),
|
60
|
+
path.join(process.cwd(), projectName)
|
61
|
+
);
|
62
|
+
}
|
53
63
|
resolve();
|
54
64
|
})
|
55
65
|
.on("error", (err) => reject(err));
|
56
66
|
})
|
57
67
|
)
|
58
68
|
.then(() => {
|
59
|
-
|
60
|
-
|
69
|
+
if (reactNative) {
|
70
|
+
const pkgjsonTmpl = JSON.parse(
|
71
|
+
fs.readFileSync(
|
72
|
+
path.join(
|
73
|
+
process.cwd(),
|
74
|
+
"uix-starter-react-native",
|
75
|
+
"package.json"
|
76
|
+
),
|
77
|
+
"utf8"
|
78
|
+
)
|
79
|
+
);
|
80
|
+
const pkgjsonPrjct = JSON.parse(
|
81
|
+
fs.readFileSync(
|
82
|
+
path.join(
|
83
|
+
process.cwd(),
|
84
|
+
"uix-starter-react-native",
|
85
|
+
"package.json"
|
86
|
+
),
|
87
|
+
"utf8"
|
88
|
+
)
|
89
|
+
);
|
90
|
+
|
91
|
+
// update package.json
|
92
|
+
fs.writeFileSync(
|
93
|
+
path.join(process.cwd(), "package.json"),
|
94
|
+
prettier.format(
|
95
|
+
JSON.stringify(deepmerge(pkgjsonPrjct, pkgjsonTmpl)),
|
96
|
+
{
|
97
|
+
parser: "json",
|
98
|
+
}
|
99
|
+
)
|
100
|
+
);
|
101
|
+
|
102
|
+
fs.renameSync(
|
103
|
+
path.join(process.cwd(), "uix-starter-react-native", "src"),
|
104
|
+
path.join(process.cwd(), "src")
|
105
|
+
);
|
106
|
+
|
107
|
+
fs.renameSync(
|
108
|
+
path.join(process.cwd(), "uix-starter-react-native", "dev"),
|
109
|
+
path.join(process.cwd(), "dev")
|
110
|
+
);
|
111
|
+
|
112
|
+
fs.renameSync(
|
113
|
+
path.join(process.cwd(), "uix-starter-react-native", "deps.edn"),
|
114
|
+
path.join(process.cwd(), "deps.edn")
|
115
|
+
);
|
116
|
+
|
117
|
+
fs.renameSync(
|
118
|
+
path.join(
|
119
|
+
process.cwd(),
|
120
|
+
"uix-starter-react-native",
|
121
|
+
"shadow-cljs.edn"
|
122
|
+
),
|
123
|
+
path.join(process.cwd(), "shadow-cljs.edn")
|
124
|
+
);
|
125
|
+
|
126
|
+
fs.rmdirSync("uix-starter-react-native", { recursive: true });
|
127
|
+
|
128
|
+
const coreNs = fs.readFileSync(
|
129
|
+
path.join(process.cwd(), "src/app/core.cljs"),
|
130
|
+
"utf8"
|
131
|
+
);
|
132
|
+
fs.writeFileSync(
|
133
|
+
path.join(process.cwd(), "src/app/core.cljs"),
|
134
|
+
coreNs.replace("{{app-name}}", projectName)
|
135
|
+
);
|
136
|
+
|
137
|
+
console.log("Done.");
|
138
|
+
console.log("\n");
|
139
|
+
console.log("yarn cljs:dev # run dev build in watch mode");
|
140
|
+
console.log("yarn cljs:release # build production bundle");
|
141
|
+
} else {
|
142
|
+
const pkgjson = JSON.parse(
|
143
|
+
fs.readFileSync(
|
144
|
+
path.join(process.cwd(), projectName, "package.json"),
|
145
|
+
"utf8"
|
146
|
+
)
|
147
|
+
);
|
148
|
+
pkgjson.name = projectName;
|
149
|
+
fs.writeFileSync(
|
61
150
|
path.join(process.cwd(), projectName, "package.json"),
|
151
|
+
prettier.format(JSON.stringify(pkgjson), {
|
152
|
+
parser: "json",
|
153
|
+
})
|
154
|
+
);
|
155
|
+
const readme = fs.readFileSync(
|
156
|
+
path.join(process.cwd(), projectName, "README.md"),
|
62
157
|
"utf8"
|
63
|
-
)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if (err) {
|
87
|
-
console.error(err);
|
88
|
-
} else {
|
89
|
-
console.log("Done.");
|
90
|
-
console.log("\n");
|
91
|
-
console.log("yarn dev # run dev build in watch mode with CLJS REPL");
|
92
|
-
console.log("yarn release # build production bundle");
|
93
|
-
}
|
94
|
-
});
|
158
|
+
);
|
159
|
+
fs.writeFileSync(
|
160
|
+
path.join(process.cwd(), projectName, "README.md"),
|
161
|
+
readme
|
162
|
+
.replace("uix-starter", projectName)
|
163
|
+
.split("\n")
|
164
|
+
.filter((l) => !l.startsWith("Template project"))
|
165
|
+
.join("\n")
|
166
|
+
);
|
167
|
+
console.log("Installing dependencies...");
|
168
|
+
exec(`cd ${projectName} && yarn install`, (err) => {
|
169
|
+
if (err) {
|
170
|
+
console.error(err);
|
171
|
+
} else {
|
172
|
+
console.log("Done.");
|
173
|
+
console.log("\n");
|
174
|
+
console.log(
|
175
|
+
"yarn dev # run dev build in watch mode with CLJS REPL"
|
176
|
+
);
|
177
|
+
console.log("yarn release # build production bundle");
|
178
|
+
}
|
179
|
+
});
|
180
|
+
}
|
95
181
|
});
|
96
182
|
}
|