create-waku 0.0.0 → 0.4.2

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 +48 -0
  2. package/package.json +2 -1
package/cli.js ADDED
@@ -0,0 +1,48 @@
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.11.1/examples/01_counter/";
16
+
17
+ const files = `
18
+ entries.ts
19
+ index.html
20
+ vite.prd.config.ts
21
+ package.json
22
+ tsconfig.json
23
+ vite.config.ts
24
+ src/index.tsx
25
+ src/App.tsx
26
+ src/Counter.tsx
27
+ `
28
+ .split(/\s/)
29
+ .filter((file) => file);
30
+
31
+ const getFiles = (index = 0) => {
32
+ const file = files[index];
33
+ if (!file) return;
34
+ const destFile = path.join(dirName, file.replace("/", path.sep));
35
+ fs.mkdirSync(path.dirname(destFile), { recursive: true });
36
+ https.get(baseUrl + file, (res) => {
37
+ res.pipe(fs.createWriteStream(destFile));
38
+ res.on("end", () => getFiles(index + 1));
39
+ });
40
+ };
41
+
42
+ getFiles();
43
+
44
+ process.on("exit", (code) => {
45
+ if (!code) {
46
+ console.info(`Done! Change directory "${dirName}"`);
47
+ }
48
+ });
package/package.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "name": "create-waku",
3
- "version": "0.0.0"
3
+ "version": "0.4.2",
4
+ "bin": "./cli.js"
4
5
  }