gmoonc 0.0.18 → 0.0.19

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
@@ -63,6 +63,12 @@ The logo is installed at `src/gmoonc/assets/gmoonc-logo.png`. You can replace it
63
63
 
64
64
  ## Changelog
65
65
 
66
+ ### 0.0.19
67
+ - Fix: Added Navigate import to GMooncAppLayout.tsx template
68
+ - Fix: Corrected route protection order - isLoading checked before isAuthenticated
69
+ - Fix: Automatic update of all session context imports to use GMooncSupabaseSessionProvider
70
+ - Fix: All components now use Supabase provider instead of mock context
71
+
66
72
  ### 0.0.18
67
73
  - Fix: env.ts no longer throws when .env is missing - only logs warning
68
74
  - Fix: client.ts import corrected - hasSupabaseEnv imported from env.ts
package/dist/index.cjs CHANGED
@@ -388,8 +388,8 @@ function resolveImportToFile(importPath, fromDir) {
388
388
  const extensions = [".tsx", ".ts", ".jsx", ".js"];
389
389
  const indexFiles = ["index.tsx", "index.ts", "index.jsx", "index.js"];
390
390
  if ((0, import_fs8.existsSync)(basePath)) {
391
- const { statSync: statSync2 } = require("fs");
392
- const stats = statSync2(basePath);
391
+ const { statSync: statSync3 } = require("fs");
392
+ const stats = statSync3(basePath);
393
393
  if (stats.isFile()) {
394
394
  return basePath;
395
395
  }
@@ -405,16 +405,16 @@ function resolveImportToFile(importPath, fromDir) {
405
405
  for (const ext of extensions) {
406
406
  const fullPath = basePath + ext;
407
407
  if ((0, import_fs8.existsSync)(fullPath)) {
408
- const { statSync: statSync2 } = require("fs");
409
- const stats = statSync2(fullPath);
408
+ const { statSync: statSync3 } = require("fs");
409
+ const stats = statSync3(fullPath);
410
410
  if (stats.isFile()) {
411
411
  return fullPath;
412
412
  }
413
413
  }
414
414
  }
415
415
  if ((0, import_fs8.existsSync)(basePath)) {
416
- const { statSync: statSync2 } = require("fs");
417
- const stats = statSync2(basePath);
416
+ const { statSync: statSync3 } = require("fs");
417
+ const stats = statSync3(basePath);
418
418
  if (stats.isDirectory()) {
419
419
  for (const indexFile of indexFiles) {
420
420
  const indexPath = (0, import_path5.join)(basePath, indexFile);
@@ -1679,7 +1679,7 @@ function patchExistingCode(projectDir, gmooncDir) {
1679
1679
  );
1680
1680
  }
1681
1681
  content = content.replace(/GMooncSessionProvider/g, "GMooncSupabaseSessionProvider");
1682
- if (!content.includes("!isLoading && !isAuthenticated")) {
1682
+ if (!content.includes("!isAuthenticated")) {
1683
1683
  content = content.replace(
1684
1684
  /const\s+{\s*roles,\s*logout\s*}\s+=\s+useGMooncSession\(\);/,
1685
1685
  "const { roles, logout, isLoading, isAuthenticated } = useGMooncSession();"
@@ -1688,12 +1688,35 @@ function patchExistingCode(projectDir, gmooncDir) {
1688
1688
  /(\s+}, \[navigate, getBasePath\]\);)\s+(\s+return\s+\()/,
1689
1689
  `$1
1690
1690
 
1691
+ // Show loading state while checking authentication (verificar primeiro)
1692
+ if (isLoading) {
1693
+ return (
1694
+ <div className="gmoonc-root">
1695
+ <div style={{
1696
+ display: 'flex',
1697
+ justifyContent: 'center',
1698
+ alignItems: 'center',
1699
+ height: '100vh',
1700
+ fontSize: 'var(--gmoonc-font-size-base, 16px)',
1701
+ color: 'var(--gmoonc-color-text, #333)'
1702
+ }}>
1703
+ Loading...
1704
+ </div>
1705
+ </div>
1706
+ );
1707
+ }
1708
+
1691
1709
  // Route protection: redirect to login if not authenticated
1692
- if (!isLoading && !isAuthenticated) {
1710
+ if (!isAuthenticated) {
1693
1711
  return <Navigate to="/login" replace />;
1694
1712
  }
1695
1713
 
1696
- // Show loading state while checking authentication
1714
+ $2`
1715
+ );
1716
+ } else {
1717
+ content = content.replace(
1718
+ /\/\/ Route protection: redirect to login if not authenticated\s+if\s+\(!isLoading\s+&&\s+!isAuthenticated\)\s+\{[\s\S]*?return\s+<Navigate[^>]+>;[\s\S]*?\}\s+(\/\/ Show loading state)/,
1719
+ `// Show loading state while checking authentication (verificar primeiro)
1697
1720
  if (isLoading) {
1698
1721
  return (
1699
1722
  <div className="gmoonc-root">
@@ -1711,18 +1734,74 @@ function patchExistingCode(projectDir, gmooncDir) {
1711
1734
  );
1712
1735
  }
1713
1736
 
1714
- $2`
1737
+ // Route protection: redirect to login if not authenticated
1738
+ if (!isAuthenticated) {
1739
+ return <Navigate to="/login" replace />;
1740
+ }
1741
+
1742
+ $1`
1715
1743
  );
1716
1744
  }
1717
1745
  writeFileSafe(layoutPath, content);
1718
1746
  logSuccess("Patched layout/GMooncAppLayout.tsx to use GMooncSupabaseSessionProvider and add route protection");
1719
1747
  }
1720
- logInfo("Auth pages will use Supabase via GMooncSupabaseSessionProvider");
1748
+ updateAllSessionImports(gmooncDir);
1749
+ }
1750
+ function updateAllSessionImports(gmooncDir) {
1751
+ const filesToUpdate = [];
1752
+ function findFiles(dir) {
1753
+ if (!(0, import_fs9.existsSync)(dir)) return;
1754
+ const entries = (0, import_fs9.readdirSync)(dir, { withFileTypes: true });
1755
+ for (const entry of entries) {
1756
+ const fullPath = (0, import_path6.join)(dir, entry.name);
1757
+ if (entry.name.includes(".bak-") || entry.name === "supabase") {
1758
+ continue;
1759
+ }
1760
+ if (entry.isDirectory()) {
1761
+ findFiles(fullPath);
1762
+ } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx"))) {
1763
+ filesToUpdate.push(fullPath);
1764
+ }
1765
+ }
1766
+ }
1767
+ findFiles(gmooncDir);
1768
+ let updatedCount = 0;
1769
+ for (const filePath of filesToUpdate) {
1770
+ let content = (0, import_fs9.readFileSync)(filePath, "utf-8");
1771
+ let modified = false;
1772
+ const fileDir = (0, import_path6.dirname)(filePath);
1773
+ const supabaseProviderPath = (0, import_path6.join)(gmooncDir, "supabase", "auth", "GMooncSupabaseSessionProvider");
1774
+ let relativePath = (0, import_path6.relative)(fileDir, supabaseProviderPath).replace(/\\/g, "/");
1775
+ if (!relativePath.startsWith(".")) {
1776
+ relativePath = "./" + relativePath;
1777
+ }
1778
+ const oldImportPattern = /from\s+['"](\.\.?\/)+session\/GMooncSessionContext['"]/g;
1779
+ if (oldImportPattern.test(content)) {
1780
+ content = content.replace(
1781
+ /from\s+['"](\.\.?\/)+session\/GMooncSessionContext['"]/g,
1782
+ `from '${relativePath}'`
1783
+ );
1784
+ modified = true;
1785
+ }
1786
+ if (content.includes("GMooncSessionProvider") && !content.includes("GMooncSupabaseSessionProvider")) {
1787
+ content = content.replace(/GMooncSessionProvider/g, "GMooncSupabaseSessionProvider");
1788
+ modified = true;
1789
+ }
1790
+ if (modified) {
1791
+ writeFileSafe(filePath, content);
1792
+ updatedCount++;
1793
+ }
1794
+ }
1795
+ if (updatedCount > 0) {
1796
+ logSuccess(`Updated ${updatedCount} file(s) to use GMooncSupabaseSessionProvider`);
1797
+ } else {
1798
+ logInfo("All files already use GMooncSupabaseSessionProvider");
1799
+ }
1721
1800
  }
1722
1801
 
1723
1802
  // src/cli/index.ts
1724
1803
  var program = new import_commander.Command();
1725
- program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete dashboard into your React project").version("0.0.18").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) => {
1804
+ program.name("gmoonc").description("Goalmoon Ctrl (gmoonc): Install complete dashboard into your React project").version("0.0.19").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) => {
1726
1805
  try {
1727
1806
  logInfo("\u{1F680} Starting gmoonc installer...");
1728
1807
  logInfo("\u{1F4E6} Installing complete dashboard into your React project\n");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gmoonc",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "description": "Goalmoon Ctrl (gmoonc): Complete dashboard installer for React projects",
5
5
  "license": "MIT",
6
6
  "homepage": "https://gmoonc.com",
@@ -47,12 +47,7 @@ function GMooncAppLayoutInner() {
47
47
  navigate(normalizedBasePath);
48
48
  }, [navigate, getBasePath]);
49
49
 
50
- // Route protection: redirect to login if not authenticated
51
- if (!isLoading && !isAuthenticated) {
52
- return <Navigate to="/login" replace />;
53
- }
54
-
55
- // Show loading state while checking authentication
50
+ // Show loading state while checking authentication (verificar primeiro)
56
51
  if (isLoading) {
57
52
  return (
58
53
  <div className="gmoonc-root">
@@ -70,6 +65,11 @@ function GMooncAppLayoutInner() {
70
65
  );
71
66
  }
72
67
 
68
+ // Route protection: redirect to login if not authenticated
69
+ if (!isAuthenticated) {
70
+ return <Navigate to="/login" replace />;
71
+ }
72
+
73
73
  return (
74
74
  <div className="gmoonc-root">
75
75
  <GmooncShell