this.gui 1.2.15 → 1.2.16

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 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
+ }
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * This.GUI CLI (ESM version)
4
+ *
5
+ * Usage:
6
+ * npx this.gui my-app
7
+ *
8
+ * This runs in native ESM mode.
9
+ */
10
+ export {};
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 (TypeScript)
12
- *
13
- * Initializes a new This.GUI project using:
14
- *
15
- * npx thisgui my-app
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
- const { copySync } = fsExtra;
21
- const __filename$1 = url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cli.js', document.baseURI).href)));
22
- const __dirname$1 = path.dirname(__filename$1);
23
- const appName = process.argv[2] || 'my-app';
24
- const templateDir = path.resolve(__dirname$1, '../templates');
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
- copySync(templateDir, targetDir);
29
- console.log(`šŸ“ Project files copied to ${targetDir}`);
30
- process.chdir(targetDir);
31
- console.log(`šŸ“¦ Installing dependencies...\n`);
32
- child_process.execSync('npm install', { stdio: 'inherit' });
33
- console.log(`\nāœ… Done!\n`);
34
- console.log(`Next steps:\n cd ${appName}\n npm run storybook\n`);
35
- } catch (error) {
36
- console.error('āŒ Error creating project:', error);
37
- process.exit(1);
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
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "this.gui",
3
3
  "private": false,
4
- "version": "1.2.15",
4
+ "version": "1.2.16",
5
5
  "type": "module",
6
6
  "main": "dist/this-gui.umd.js",
7
7
  "module": "dist/this-gui.es.js",
@@ -14,11 +14,11 @@
14
14
  }
15
15
  },
16
16
  "bin": {
17
- "gui": "./dist/bin/cli.cjs"
17
+ "gui": "./dist/bin/cli.ts"
18
18
  },
19
19
  "scripts": {
20
- "build": "vite build && node -e \"import('./vite.config.js').then(m => m.buildFinished())\"",
21
- "lint": "eslint .",
20
+ "build": "vite build && npm run build:cli",
21
+ "build:cli": "tsc --project tsconfig.cli.json",
22
22
  "dev": "vite",
23
23
  "dev:lib": "vite build --watch",
24
24
  "preview": "vite preview",
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'><circle cx='32' cy='32' r='32' fill='%23006688'/><text x='50%' y='54%' text-anchor='middle' font-size='28' font-family='sans-serif' fill='white'>GUI</text></svg>" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>This.GUI Demo</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,28 @@
1
+ {
2
+ "name": "thisgui-demo",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc --noEmit && vite build",
9
+ "preview": "vite preview",
10
+ "storybook": "storybook dev -p 6006",
11
+ "build-storybook": "storybook build"
12
+ },
13
+ "dependencies": {
14
+ "react": "^19.0.0",
15
+ "react-dom": "^19.0.0",
16
+ "this.gui": "latest"
17
+ },
18
+ "devDependencies": {
19
+ "@storybook/addon-essentials": "^8.2.0",
20
+ "@storybook/react-vite": "^8.2.0",
21
+ "@types/react": "^19.0.0",
22
+ "@types/react-dom": "^19.0.0",
23
+ "@vitejs/plugin-react": "^5.0.0",
24
+ "storybook": "^8.2.0",
25
+ "typescript": "^5.9.0",
26
+ "vite": "^6.0.0"
27
+ }
28
+ }
@@ -0,0 +1,11 @@
1
+ import { defineConfig } from 'vite';
2
+ import react from '@vitejs/plugin-react';
3
+
4
+ export default defineConfig({
5
+ plugins: [react()],
6
+ resolve: {
7
+ alias: {
8
+ '@': '/src'
9
+ }
10
+ }
11
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "ES2022",
5
+ "target": "ES2022",
6
+ "outDir": "dist/bin"
7
+ },
8
+ "include": ["bin/**/*.ts"]
9
+ }
package/bin/cli.cjs DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * This.GUI CLI (TypeScript)
4
- *
5
- * Initializes a new This.GUI project using:
6
- *
7
- * npx thisgui my-app
8
- *
9
- * Compiles to dist/bin/cli.js when the package is built.
10
- */
11
- const { execSync } = require('child_process');
12
- const fsExtra = require('fs-extra');
13
- const { copySync } = fsExtra;
14
- const path = require('path');
15
- const appName = process.argv[2] || 'my-app';
16
- const templateDir = path.resolve(__dirname, '../templates');
17
- const targetDir = path.resolve(process.cwd(), appName);
18
- console.log(`\n🧩 Creating .GUI project: ${appName}\n`);
19
- try {
20
- copySync(templateDir, targetDir);
21
- console.log(`šŸ“ Project files copied to ${targetDir}`);
22
- process.chdir(targetDir);
23
- console.log(`šŸ“¦ Installing dependencies...\n`);
24
- execSync('npm install', { stdio: 'inherit' });
25
- console.log(`\nāœ… Done!\n`);
26
- console.log(`Next steps:\n cd ${appName}\n npm run storybook\n`);
27
- } catch (error) {
28
- console.error('āŒ Error creating project:', error);
29
- process.exit(1);
30
- }