this.gui 1.2.15 → 1.2.17
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.
- package/bin/cli.ts +53 -0
- package/dist/bin/cli.d.ts +10 -0
- package/dist/bin/cli.js +43 -30
- package/dist/{this.gui.umd.js → this-gui.umd.js} +17 -17
- package/package.json +4 -4
- package/templates/index.html +13 -0
- package/templates/package.json +29 -0
- package/templates/vite.config.ts +11 -0
- package/tsconfig.cli.json +9 -0
- package/bin/cli.cjs +0 -30
- /package/dist/{this.gui.es.js → this-gui.es.js} +0 -0
package/bin/cli.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This.GUI CLI (ESM version)
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* npx this.gui my-app
|
|
8
|
+
*
|
|
9
|
+
* This runs in native ESM mode.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { execSync } from "node:child_process";
|
|
13
|
+
import fsExtra from "fs-extra";
|
|
14
|
+
import path from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = path.dirname(__filename);
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
20
|
+
console.log(`This.GUI CLI
|
|
21
|
+
|
|
22
|
+
Usage:
|
|
23
|
+
npx this.gui <project-name>
|
|
24
|
+
|
|
25
|
+
Examples:
|
|
26
|
+
npx this.gui my-app
|
|
27
|
+
`);
|
|
28
|
+
process.exit(0);
|
|
29
|
+
}
|
|
30
|
+
const appName = args[0] || "my-app";
|
|
31
|
+
const distTemplateDir = path.resolve(__dirname, "../templates");
|
|
32
|
+
const srcTemplateDir = path.resolve(__dirname, "../../templates");
|
|
33
|
+
const templateDir = fsExtra.existsSync(distTemplateDir)
|
|
34
|
+
? distTemplateDir
|
|
35
|
+
: srcTemplateDir;
|
|
36
|
+
const targetDir = path.resolve(process.cwd(), appName);
|
|
37
|
+
console.log(`\n🧩 Creating .GUI project: ${appName}\n`);
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
if (!fsExtra.existsSync(templateDir)) {
|
|
41
|
+
throw new Error(`Template directory not found at: ${templateDir}`);
|
|
42
|
+
}
|
|
43
|
+
fsExtra.copySync(templateDir, targetDir);
|
|
44
|
+
console.log(`📁 Project files copied to ${targetDir}`);
|
|
45
|
+
process.chdir(targetDir);
|
|
46
|
+
console.log(`📦 Installing dependencies...\n`);
|
|
47
|
+
execSync("npm install", { stdio: "inherit" });
|
|
48
|
+
console.log(`\n✅ Done!\n`);
|
|
49
|
+
console.log(`Next steps:\n cd ${appName}\n npm run storybook\n`);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error("❌ Error creating project:", error);
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
package/dist/bin/cli.js
CHANGED
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
var child_process = require('child_process');
|
|
5
|
-
var fsExtra = require('fs-extra');
|
|
6
|
-
var path = require('path');
|
|
7
|
-
var url = require('url');
|
|
8
|
-
|
|
9
|
-
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
2
|
/**
|
|
11
|
-
* This.GUI CLI (
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* Compiles to dist/bin/cli.js when the package is built.
|
|
3
|
+
* This.GUI CLI (ESM version)
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* npx this.gui my-app
|
|
7
|
+
*
|
|
8
|
+
* This runs in native ESM mode.
|
|
18
9
|
*/
|
|
10
|
+
import { execSync } from "node:child_process";
|
|
11
|
+
import fsExtra from "fs-extra";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
14
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
15
|
+
const __dirname = path.dirname(__filename);
|
|
16
|
+
const args = process.argv.slice(2);
|
|
17
|
+
if (args.includes("--help") || args.includes("-h")) {
|
|
18
|
+
console.log(`This.GUI CLI
|
|
19
|
+
|
|
20
|
+
Usage:
|
|
21
|
+
npx this.gui <project-name>
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
Examples:
|
|
24
|
+
npx this.gui my-app
|
|
25
|
+
`);
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
const appName = args[0] || "my-app";
|
|
29
|
+
const distTemplateDir = path.resolve(__dirname, "../templates");
|
|
30
|
+
const srcTemplateDir = path.resolve(__dirname, "../../templates");
|
|
31
|
+
const templateDir = fsExtra.existsSync(distTemplateDir)
|
|
32
|
+
? distTemplateDir
|
|
33
|
+
: srcTemplateDir;
|
|
25
34
|
const targetDir = path.resolve(process.cwd(), appName);
|
|
26
35
|
console.log(`\n🧩 Creating .GUI project: ${appName}\n`);
|
|
27
36
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
if (!fsExtra.existsSync(templateDir)) {
|
|
38
|
+
throw new Error(`Template directory not found at: ${templateDir}`);
|
|
39
|
+
}
|
|
40
|
+
fsExtra.copySync(templateDir, targetDir);
|
|
41
|
+
console.log(`📁 Project files copied to ${targetDir}`);
|
|
42
|
+
process.chdir(targetDir);
|
|
43
|
+
console.log(`📦 Installing dependencies...\n`);
|
|
44
|
+
execSync("npm install", { stdio: "inherit" });
|
|
45
|
+
console.log(`\n✅ Done!\n`);
|
|
46
|
+
console.log(`Next steps:\n cd ${appName}\n npm run storybook\n`);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
console.error("❌ Error creating project:", error);
|
|
50
|
+
process.exit(1);
|
|
38
51
|
}
|