gmoonc 0.0.6 → 0.0.7

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/README.md CHANGED
@@ -13,15 +13,15 @@ npm install gmoonc
13
13
  After installing, run the installer in your React project root:
14
14
 
15
15
  ```bash
16
- npm exec -- gmoonc --auto
16
+ npx gmoonc
17
17
  ```
18
18
 
19
- This command works reliably on all platforms (Windows, macOS, Linux) and with all npm versions.
19
+ The installer runs automatically without prompts. Works on all platforms (Windows, macOS, Linux).
20
20
 
21
21
  With custom base path:
22
22
 
23
23
  ```bash
24
- npm exec -- gmoonc --auto --base /dashboard
24
+ npx gmoonc --base /dashboard
25
25
  ```
26
26
 
27
27
  ## What it does
@@ -33,9 +33,8 @@ npm exec -- gmoonc --auto --base /dashboard
33
33
 
34
34
  ## Options
35
35
 
36
- - `--auto`: Skip confirmations and install automatically (no prompts)
37
36
  - `--base <path>`: Base path for dashboard routes (default: `/app`)
38
- - `--skip-router-patch`: Skip automatic router integration
37
+ - `--skip-router-patch`: Skip automatic router integration (only copy files and inject CSS)
39
38
  - `--dry-run`: Show what would be done without making changes
40
39
 
41
40
  ## After installation
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
 
3
4
  // src/cli/index.ts
@@ -378,13 +379,69 @@ function matchComponentsWithImports(routes, imports) {
378
379
  }
379
380
  }
380
381
  }
382
+ function resolveImportToFile(importPath, fromDir) {
383
+ if (!importPath.startsWith("./") && !importPath.startsWith("../")) {
384
+ return null;
385
+ }
386
+ const basePath = (0, import_path5.resolve)(fromDir, importPath);
387
+ const extensions = [".tsx", ".ts", ".jsx", ".js"];
388
+ const indexFiles = ["index.tsx", "index.ts", "index.jsx", "index.js"];
389
+ if ((0, import_fs8.existsSync)(basePath)) {
390
+ const { statSync: statSync2 } = require("fs");
391
+ const stats = statSync2(basePath);
392
+ if (stats.isFile()) {
393
+ return basePath;
394
+ }
395
+ if (stats.isDirectory()) {
396
+ for (const indexFile of indexFiles) {
397
+ const indexPath = (0, import_path5.join)(basePath, indexFile);
398
+ if ((0, import_fs8.existsSync)(indexPath)) {
399
+ return indexPath;
400
+ }
401
+ }
402
+ }
403
+ }
404
+ for (const ext of extensions) {
405
+ const fullPath = basePath + ext;
406
+ if ((0, import_fs8.existsSync)(fullPath)) {
407
+ const { statSync: statSync2 } = require("fs");
408
+ const stats = statSync2(fullPath);
409
+ if (stats.isFile()) {
410
+ return fullPath;
411
+ }
412
+ }
413
+ }
414
+ if ((0, import_fs8.existsSync)(basePath)) {
415
+ const { statSync: statSync2 } = require("fs");
416
+ const stats = statSync2(basePath);
417
+ if (stats.isDirectory()) {
418
+ for (const indexFile of indexFiles) {
419
+ const indexPath = (0, import_path5.join)(basePath, indexFile);
420
+ if ((0, import_fs8.existsSync)(indexPath)) {
421
+ return indexPath;
422
+ }
423
+ }
424
+ }
425
+ }
426
+ return null;
427
+ }
381
428
  function convertImportToRelative(importLine, originalPath, appRoutesDir, appDir) {
382
429
  if (!originalPath.startsWith("./") && !originalPath.startsWith("../")) {
383
430
  return importLine;
384
431
  }
385
- const resolvedPath = (0, import_path5.resolve)(appDir, originalPath);
386
- const relativePath = (0, import_path5.relative)(appRoutesDir, resolvedPath);
387
- const normalizedPath = relativePath.replace(/\\/g, "/");
432
+ const resolvedFile = resolveImportToFile(originalPath, appDir);
433
+ if (!resolvedFile) {
434
+ logWarning(`Could not resolve import "${originalPath}" to actual file, using original path`);
435
+ const resolvedPath = (0, import_path5.resolve)(appDir, originalPath);
436
+ const relativePath2 = (0, import_path5.relative)(appRoutesDir, resolvedPath);
437
+ const normalizedPath2 = relativePath2.replace(/\\/g, "/");
438
+ const finalPath2 = normalizedPath2.startsWith(".") ? normalizedPath2 : "./" + normalizedPath2;
439
+ return importLine.replace(originalPath, finalPath2);
440
+ }
441
+ const relativePath = (0, import_path5.relative)(appRoutesDir, resolvedFile);
442
+ const ext = (0, import_path5.extname)(relativePath);
443
+ const pathWithoutExt = ext ? relativePath.slice(0, -ext.length) : relativePath;
444
+ const normalizedPath = pathWithoutExt.replace(/\\/g, "/");
388
445
  const finalPath = normalizedPath.startsWith(".") ? normalizedPath : "./" + normalizedPath;
389
446
  return importLine.replace(originalPath, finalPath);
390
447
  }
@@ -602,7 +659,7 @@ function patchBrowserRouter(consumerDir, basePath, dryRun) {
602
659
 
603
660
  // src/cli/index.ts
604
661
  var program = new import_commander.Command();
605
- program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete dashboard into your React project").version("0.0.6").option("--auto", "Skip confirmations and install automatically (no prompts)").option("--base <path>", "Base path for dashboard routes", "/app").option("--skip-router-patch", "Skip automatic router integration (only copy files and inject CSS)").option("--dry-run", "Show what would be done without making changes").action(async (options) => {
662
+ program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete dashboard into your React project").version("0.0.7").option("--base <path>", "Base path for dashboard routes", "/app").option("--skip-router-patch", "Skip automatic router integration (only copy files and inject CSS)").option("--dry-run", "Show what would be done without making changes").action(async (options) => {
606
663
  try {
607
664
  logInfo("\u{1F680} Starting gmoonc installer...");
608
665
  logInfo("\u{1F4E6} Installing complete dashboard into your React project\n");
@@ -610,7 +667,6 @@ program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete das
610
667
  const basePath = options.base || "/app";
611
668
  const dryRun = options.dryRun || false;
612
669
  const skipRouterPatch = options.skipRouterPatch || false;
613
- const autoInstall = options.auto || false;
614
670
  const safeBasePath = basePath === "/" ? "/app" : basePath;
615
671
  logInfo("\u{1F50D} Detecting React project...");
616
672
  const project = detectProject(projectDir);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gmoonc",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Goalmoon Ctrl (gmoonc): Complete dashboard installer for React projects",
5
5
  "license": "MIT",
6
6
  "homepage": "https://gmoonc.com",
@@ -14,7 +14,7 @@
14
14
  },
15
15
  "type": "module",
16
16
  "bin": {
17
- "gmoonc": "./dist/index.cjs"
17
+ "gmoonc": "./dist/index.js"
18
18
  },
19
19
  "files": [
20
20
  "dist",
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "scripts": {
27
27
  "sync:templates": "node scripts/sync-templates.mjs",
28
- "build": "tsup src/cli/index.ts --format cjs --no-splitting --out-dir dist && node -e \"const fs=require('fs');const path=require('path');const distDir='dist';const files=fs.readdirSync(distDir);const indexFile=files.find(f=>f.startsWith('index')&&f.endsWith('.js'));if(indexFile){const oldPath=path.join(distDir,indexFile);const newPath=path.join(distDir,'index.cjs');fs.renameSync(oldPath,newPath);const content=fs.readFileSync(newPath,'utf8');if(!content.startsWith('#!/usr/bin/env node')){fs.writeFileSync(newPath,'#!/usr/bin/env node\\n'+content)}}\"",
28
+ "build": "tsup src/cli/index.ts --format cjs --no-splitting --out-dir dist && node -e \"const fs=require('fs');const path=require('path');const distDir='dist';const files=fs.readdirSync(distDir);const indexFile=files.find(f=>(f.startsWith('index')&&(f.endsWith('.js')||f.endsWith('.cjs'))));if(indexFile){const oldPath=path.join(distDir,indexFile);const newPath=path.join(distDir,'index.js');if(oldPath!==newPath){fs.renameSync(oldPath,newPath);}const content=fs.readFileSync(newPath,'utf8');if(!content.startsWith('#!/usr/bin/env node')){fs.writeFileSync(newPath,'#!/usr/bin/env node\\n'+content)}}\"",
29
29
  "clean": "rimraf dist",
30
30
  "prepublishOnly": "npm run clean && npm run build",
31
31
  "postinstall": "node scripts/block-global-install.cjs"