create-uix-app 1.3.4 → 1.4.0-rc1

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