gmoonc 0.0.8 → 0.0.9
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 +10 -0
- package/dist/index.cjs +29 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,6 +46,16 @@ Your dashboard is now available at:
|
|
|
46
46
|
|
|
47
47
|
The dashboard code is in `src/gmoonc/` and is independent. You can remove `gmoonc` from `package.json` if desired.
|
|
48
48
|
|
|
49
|
+
## Changelog
|
|
50
|
+
|
|
51
|
+
### 0.0.9
|
|
52
|
+
- Fix: ensure BrowserRouter import when patched into App.tsx
|
|
53
|
+
|
|
54
|
+
### 0.0.8
|
|
55
|
+
- Fix: BIN corrected to use CommonJS (.cjs) for Windows compatibility
|
|
56
|
+
- Fix: Router patch now ensures BrowserRouter import is always present
|
|
57
|
+
- Fix: Route order corrected (NotFound "*" route is always last)
|
|
58
|
+
|
|
49
59
|
## Uninstalling
|
|
50
60
|
|
|
51
61
|
To remove gmoonc:
|
package/dist/index.cjs
CHANGED
|
@@ -565,12 +565,19 @@ function patchBrowserRouter(consumerDir, basePath, dryRun) {
|
|
|
565
565
|
let hasBrowserRouterImport = false;
|
|
566
566
|
let reactRouterImportIndex = -1;
|
|
567
567
|
let reactRouterImportLine = null;
|
|
568
|
+
let quoteStyle = '"';
|
|
568
569
|
for (let i = 0; i < lines.length; i++) {
|
|
569
|
-
const line = lines[i]
|
|
570
|
-
|
|
570
|
+
const line = lines[i];
|
|
571
|
+
const trimmed = line.trim();
|
|
572
|
+
if (trimmed.startsWith("import ") && (trimmed.includes("'") || trimmed.includes('"'))) {
|
|
573
|
+
if (trimmed.includes("'")) quoteStyle = "'";
|
|
574
|
+
else if (trimmed.includes('"')) quoteStyle = '"';
|
|
575
|
+
}
|
|
576
|
+
if (trimmed.includes("from") && trimmed.includes("react-router-dom")) {
|
|
571
577
|
reactRouterImportIndex = i;
|
|
572
|
-
reactRouterImportLine =
|
|
573
|
-
|
|
578
|
+
reactRouterImportLine = line;
|
|
579
|
+
const browserRouterPattern = /\bBrowserRouter\b/;
|
|
580
|
+
if (browserRouterPattern.test(trimmed)) {
|
|
574
581
|
hasBrowserRouterImport = true;
|
|
575
582
|
}
|
|
576
583
|
}
|
|
@@ -578,20 +585,29 @@ function patchBrowserRouter(consumerDir, basePath, dryRun) {
|
|
|
578
585
|
if (!hasBrowserRouterImport) {
|
|
579
586
|
if (reactRouterImportIndex >= 0 && reactRouterImportLine) {
|
|
580
587
|
const existingLine = reactRouterImportLine;
|
|
581
|
-
const
|
|
588
|
+
const indent2 = existingLine.match(/^(\s*)/)?.[1] || "";
|
|
589
|
+
const namedMatch = existingLine.match(/^(\s*)import\s+\{([^}]+)\}\s+from\s+(["'])react-router-dom\2/);
|
|
582
590
|
if (namedMatch) {
|
|
583
|
-
const
|
|
584
|
-
const
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
591
|
+
const importListStr = namedMatch[2];
|
|
592
|
+
const quote = namedMatch[3];
|
|
593
|
+
const importItems = importListStr.split(",").map((s) => s.trim()).filter(Boolean);
|
|
594
|
+
const hasBrowserRouter = importItems.some(
|
|
595
|
+
(item) => item === "BrowserRouter" || item === "type BrowserRouter" || item.includes("BrowserRouter")
|
|
596
|
+
);
|
|
597
|
+
if (!hasBrowserRouter) {
|
|
598
|
+
importItems.push("BrowserRouter");
|
|
599
|
+
const hasTrailingComma = importListStr.trim().endsWith(",");
|
|
600
|
+
const separator = importListStr.includes(",\n") ? ",\n" : ", ";
|
|
601
|
+
const formatted = importItems.join(separator) + (hasTrailingComma ? "," : "");
|
|
602
|
+
const updatedLine = `${indent2}import { ${formatted} } from ${quote}react-router-dom${quote};`;
|
|
588
603
|
lines[reactRouterImportIndex] = updatedLine;
|
|
589
604
|
}
|
|
590
605
|
} else {
|
|
591
|
-
|
|
606
|
+
const newImportLine = `${indent2}import { BrowserRouter } from ${quoteStyle}react-router-dom${quoteStyle};`;
|
|
607
|
+
lines.splice(reactRouterImportIndex + 1, 0, newImportLine);
|
|
592
608
|
}
|
|
593
609
|
} else {
|
|
594
|
-
const importLine2 = `import { BrowserRouter } from
|
|
610
|
+
const importLine2 = `import { BrowserRouter } from ${quoteStyle}react-router-dom${quoteStyle};`;
|
|
595
611
|
let lastImportIndex2 = -1;
|
|
596
612
|
for (let i = 0; i < lines.length; i++) {
|
|
597
613
|
const line = lines[i].trim();
|
|
@@ -673,7 +689,7 @@ function patchBrowserRouter(consumerDir, basePath, dryRun) {
|
|
|
673
689
|
|
|
674
690
|
// src/cli/index.ts
|
|
675
691
|
var program = new import_commander.Command();
|
|
676
|
-
program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete dashboard into your React project").version("0.0.
|
|
692
|
+
program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete dashboard into your React project").version("0.0.9").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) => {
|
|
677
693
|
try {
|
|
678
694
|
logInfo("\u{1F680} Starting gmoonc installer...");
|
|
679
695
|
logInfo("\u{1F4E6} Installing complete dashboard into your React project\n");
|