create-uix-app 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +24 -0
  2. package/src/index.js +80 -0
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "create-uix-app",
3
+ "description": "Creates a starter project for UIx2 web app",
4
+ "version": "1.0.0",
5
+ "author": {
6
+ "name": "Roman Liutikov"
7
+ },
8
+ "bin": {
9
+ "create-uix-app": "./src/index.js"
10
+ },
11
+ "main": "./src/index.js",
12
+ "keywords": [
13
+ "clojurescript",
14
+ "cljs",
15
+ "uix"
16
+ ],
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "axios": "^1.3.4",
20
+ "commander": "^10.0.0",
21
+ "prettier": "^2.8.7",
22
+ "tar-pack": "^3.4.1"
23
+ }
24
+ }
package/src/index.js ADDED
@@ -0,0 +1,80 @@
1
+ const fs = require("fs");
2
+ const path = require("path");
3
+ const { exec } = require("child_process");
4
+ const axios = require("axios");
5
+ const pack = require("tar-pack");
6
+ const { program } = require("commander");
7
+ const prettier = require("prettier");
8
+ const pkg = require("../package.json");
9
+
10
+ program
11
+ .name(pkg.name)
12
+ .description(pkg.description)
13
+ .version(pkg.version)
14
+ .argument("<project-name>", "directory where a project will be created");
15
+
16
+ program.parse();
17
+
18
+ const [projectName] = program.args;
19
+
20
+ if (!projectName) {
21
+ program.help();
22
+ } else {
23
+ console.log(
24
+ "Downloading project template from https://github.com/pitch-io/uix-starter..."
25
+ );
26
+ axios
27
+ .get("https://github.com/pitch-io/uix-starter/archive/master.tar.gz", {
28
+ responseType: "stream",
29
+ })
30
+ .then(
31
+ (r) =>
32
+ new Promise((resolve, reject) => {
33
+ console.log(`Unpacking into ${projectName}...`);
34
+ r.data.pipe(
35
+ pack.unpack(projectName, (err) => {
36
+ if (err) {
37
+ reject(err);
38
+ } else {
39
+ resolve();
40
+ }
41
+ })
42
+ );
43
+ })
44
+ )
45
+ .then(() => {
46
+ const pkgjson = JSON.parse(
47
+ fs.readFileSync(path.join(projectName, "package.json"), "utf8")
48
+ );
49
+ pkgjson.name = projectName;
50
+ fs.writeFileSync(
51
+ path.join(projectName, "package.json"),
52
+ prettier.format(JSON.stringify(pkgjson), {
53
+ parser: "json",
54
+ })
55
+ );
56
+ const readme = fs.readFileSync(
57
+ path.join(projectName, "README.md"),
58
+ "utf8"
59
+ );
60
+ fs.writeFileSync(
61
+ path.join(projectName, "README.md"),
62
+ readme
63
+ .replace("uix-starter", projectName)
64
+ .split("\n")
65
+ .filter((l) => !l.startsWith("Template project"))
66
+ .join("\n")
67
+ );
68
+ console.log("Installing dependencies...");
69
+ exec(`cd ${projectName} && yarn install`, (err) => {
70
+ if (err) {
71
+ console.error(err);
72
+ } else {
73
+ console.log("Done.");
74
+ console.log("\n");
75
+ console.log("yarn dev # run dev build in watch mode with CLJS REPL");
76
+ console.log("yarn release # build production bundle");
77
+ }
78
+ });
79
+ });
80
+ }