create-waku 0.0.0 → 0.4.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/cli.js +46 -0
  2. package/package.json +2 -1
package/cli.js ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require("node:path");
4
+ const fs = require("node:fs");
5
+ const https = require("node:https");
6
+
7
+ const dirName = "waku-example";
8
+
9
+ if (fs.existsSync(dirName)) {
10
+ console.error(`Directory "${dirName}" already exists!`);
11
+ process.exit(1);
12
+ }
13
+
14
+ const baseUrl =
15
+ "https://raw.githubusercontent.com/dai-shi/waku/v0.10.0/examples/01_counter/";
16
+
17
+ const files = `
18
+ entries.ts
19
+ index.html
20
+ package.json
21
+ tsconfig.json
22
+ src/index.tsx
23
+ src/App.tsx
24
+ src/Counter.tsx
25
+ `
26
+ .split(/\s/)
27
+ .filter((file) => file);
28
+
29
+ const getFiles = (index = 0) => {
30
+ const file = files[index];
31
+ if (!file) return;
32
+ const destFile = path.join(dirName, file.replace("/", path.sep));
33
+ fs.mkdirSync(path.dirname(destFile), { recursive: true });
34
+ https.get(baseUrl + file, (res) => {
35
+ res.pipe(fs.createWriteStream(destFile));
36
+ res.on("end", () => getFiles(index + 1));
37
+ });
38
+ };
39
+
40
+ getFiles();
41
+
42
+ process.on("exit", (code) => {
43
+ if (!code) {
44
+ console.info(`Done! Change directory "${dirName}"`);
45
+ }
46
+ });
package/package.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "name": "create-waku",
3
- "version": "0.0.0"
3
+ "version": "0.4.0",
4
+ "bin": "./cli.js"
4
5
  }