revine 0.9.0 → 1.0.1

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.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/dist/client.d.ts +8 -0
  3. package/dist/client.d.ts.map +1 -0
  4. package/dist/client.js +4 -0
  5. package/dist/commands/createProject.d.ts +4 -0
  6. package/dist/commands/createProject.d.ts.map +1 -0
  7. package/dist/components/Link.d.ts +8 -0
  8. package/dist/components/Link.d.ts.map +1 -0
  9. package/dist/components/Link.js +5 -0
  10. package/dist/components/NavLink.d.ts +8 -0
  11. package/dist/components/NavLink.d.ts.map +1 -0
  12. package/dist/components/NavLink.js +5 -0
  13. package/dist/config/package.d.ts +6 -0
  14. package/dist/config/package.d.ts.map +1 -0
  15. package/dist/config/readme.d.ts +2 -0
  16. package/dist/config/readme.d.ts.map +1 -0
  17. package/dist/config/vite.d.ts +2 -0
  18. package/dist/config/vite.d.ts.map +1 -0
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +33 -26
  22. package/dist/prompts/git.d.ts +6 -0
  23. package/dist/prompts/git.d.ts.map +1 -0
  24. package/dist/prompts/index.d.ts +4 -0
  25. package/dist/prompts/index.d.ts.map +1 -0
  26. package/dist/prompts/project.d.ts +8 -0
  27. package/dist/prompts/project.d.ts.map +1 -0
  28. package/dist/prompts/tailwind.d.ts +2 -0
  29. package/dist/prompts/tailwind.d.ts.map +1 -0
  30. package/dist/runtime/bundler/defaults/vite.d.ts +21 -0
  31. package/dist/runtime/bundler/defaults/vite.d.ts.map +1 -0
  32. package/dist/runtime/bundler/defaults/vite.js +8 -2
  33. package/dist/runtime/bundler/generateConfig.d.ts +2 -0
  34. package/dist/runtime/bundler/generateConfig.d.ts.map +1 -0
  35. package/dist/runtime/bundler/revinePlugin.d.ts +2 -0
  36. package/dist/runtime/bundler/revinePlugin.d.ts.map +1 -0
  37. package/dist/runtime/bundler/revinePlugin.js +70 -27
  38. package/dist/runtime/bundler/utils/loadUserConfig.d.ts +2 -0
  39. package/dist/runtime/bundler/utils/loadUserConfig.d.ts.map +1 -0
  40. package/dist/runtime/bundler/vite.config.d.ts +3 -0
  41. package/dist/runtime/bundler/vite.config.d.ts.map +1 -0
  42. package/dist/runtime/bundler/viteLoggerPlugin.d.ts +3 -0
  43. package/dist/runtime/bundler/viteLoggerPlugin.d.ts.map +1 -0
  44. package/dist/runtime/bundler/viteLoggerPlugin.js +2 -2
  45. package/dist/runtime/defineConfig.d.ts +6 -0
  46. package/dist/runtime/defineConfig.d.ts.map +1 -0
  47. package/dist/runtime/defineConfig.js +3 -0
  48. package/dist/runtime/routing.d.ts +2 -0
  49. package/dist/runtime/routing.d.ts.map +1 -0
  50. package/dist/runtime/routing.js +1 -0
  51. package/dist/runtime/types.d.ts +5 -0
  52. package/dist/runtime/types.d.ts.map +1 -0
  53. package/dist/runtime/types.js +1 -0
  54. package/dist/setup/dependencies.d.ts +2 -0
  55. package/dist/setup/dependencies.d.ts.map +1 -0
  56. package/dist/setup/dependencies.js +1 -8
  57. package/dist/setup/tailwind.d.ts +2 -0
  58. package/dist/setup/tailwind.d.ts.map +1 -0
  59. package/dist/utils/file.d.ts +2 -0
  60. package/dist/utils/file.d.ts.map +1 -0
  61. package/dist/utils/logger.d.ts +3 -0
  62. package/dist/utils/logger.d.ts.map +1 -0
  63. package/package.json +11 -6
  64. package/src/client.ts +14 -0
  65. package/src/components/Link.tsx +18 -0
  66. package/src/components/NavLink.tsx +18 -0
  67. package/src/index.ts +41 -31
  68. package/src/runtime/bundler/defaults/vite.ts +8 -2
  69. package/src/runtime/bundler/revinePlugin.ts +71 -28
  70. package/src/runtime/bundler/viteLoggerPlugin.ts +4 -3
  71. package/src/runtime/defineConfig.ts +9 -0
  72. package/src/runtime/routing.ts +4 -0
  73. package/src/runtime/types.ts +5 -0
  74. package/src/setup/dependencies.ts +1 -9
  75. package/template/package.json +1 -2
  76. package/template/revine.config.ts +5 -3
  77. package/template/src/pages/index.tsx +18 -16
  78. package/template/src/root.tsx +4 -4
  79. package/tsconfig.json +7 -2
  80. package/dist/runtime/routing/fileBased.js +0 -29
  81. package/src/runtime/routing/fileBased.tsx +0 -46
package/README.md CHANGED
@@ -58,7 +58,7 @@ src/pages/blog/[slug].tsx → /blog/:slug
58
58
  ### Clone repository
59
59
 
60
60
  ```bash
61
- git clone https://github.com/your-username/revine.git
61
+ git clone [https://github.com/your-username/revine.git](https://github.com/rachit-bharadwaj/revine)
62
62
  ```
63
63
 
64
64
  ### Install dependencies
@@ -0,0 +1,8 @@
1
+ export { Outlet, RouterProvider, useLocation, useNavigate, useParams, useSearchParams } from "react-router-dom";
2
+ export type { NavLinkProps } from "./components/NavLink.js";
3
+ export { Link } from "./components/Link.js";
4
+ export { NavLink } from "./components/NavLink.js";
5
+ export { defineConfig } from "./runtime/defineConfig.js";
6
+ export type { LayoutProps } from "./runtime/types.js";
7
+ export type { LinkProps } from "./components/Link.js";
8
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,cAAc,EACd,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EAChB,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,YAAY,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,4 @@
1
+ export { Outlet, RouterProvider, useLocation, useNavigate, useParams, useSearchParams } from "react-router-dom";
2
+ export { Link } from "./components/Link.js";
3
+ export { NavLink } from "./components/NavLink.js";
4
+ export { defineConfig } from "./runtime/defineConfig.js";
@@ -0,0 +1,4 @@
1
+ export declare function createProject(projectName: string, options: {
2
+ force?: boolean;
3
+ }): Promise<void>;
4
+ //# sourceMappingURL=createProject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createProject.d.ts","sourceRoot":"","sources":["../../src/commands/createProject.ts"],"names":[],"mappings":"AAcA,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,iBAuE7B"}
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from "react";
2
+ import { type LinkProps as RouterLinkProps } from "react-router-dom";
3
+ export interface LinkProps extends Omit<RouterLinkProps, "to"> {
4
+ href: string;
5
+ children?: ReactNode;
6
+ }
7
+ export declare function Link({ href, children, ...rest }: LinkProps): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=Link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/components/Link.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,SAAS,IAAI,eAAe,EAClC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,SAAS,2CAM1D"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Link as RouterLink, } from "react-router-dom";
3
+ export function Link({ href, children, ...rest }) {
4
+ return (_jsx(RouterLink, { to: href, ...rest, children: children }));
5
+ }
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from "react";
2
+ import { type NavLinkProps as RouterNavLinkProps } from "react-router-dom";
3
+ export interface NavLinkProps extends Omit<RouterNavLinkProps, "to"> {
4
+ href: string;
5
+ children?: ReactNode;
6
+ }
7
+ export declare function NavLink({ href, children, ...rest }: NavLinkProps): import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=NavLink.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavLink.d.ts","sourceRoot":"","sources":["../../src/components/NavLink.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,YAAY,IAAI,kBAAkB,EACxC,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC;IAClE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,YAAY,2CAMhE"}
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { NavLink as RouterNavLink, } from "react-router-dom";
3
+ export function NavLink({ href, children, ...rest }) {
4
+ return (_jsx(RouterNavLink, { to: href, ...rest, children: children }));
5
+ }
@@ -0,0 +1,6 @@
1
+ interface UpdatePackageOptions {
2
+ useTailwind?: boolean;
3
+ }
4
+ export declare function updatePackageJson(filePath: string, projectName: string, options?: UpdatePackageOptions): Promise<void>;
5
+ export {};
6
+ //# sourceMappingURL=package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.d.ts","sourceRoot":"","sources":["../../src/config/package.ts"],"names":[],"mappings":"AAEA,UAAU,oBAAoB;IAC5B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,iBAAiB,CACrC,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,oBAAyB,iBAkBnC"}
@@ -0,0 +1,2 @@
1
+ export declare function updateReadme(filePath: string, projectName: string): Promise<void>;
2
+ //# sourceMappingURL=readme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/config/readme.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,iBAIvE"}
@@ -0,0 +1,2 @@
1
+ export declare function updateViteConfig(filePath: string): Promise<void>;
2
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/config/vite.ts"],"names":[],"mappings":"AAEA,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,iBAgBtD"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js CHANGED
@@ -1,48 +1,55 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command } from "commander";
3
- import { createProject } from "./commands/createProject.js";
4
- import { spawn } from "child_process";
3
+ import { readFileSync } from "fs";
5
4
  import path from "path";
6
5
  import { fileURLToPath } from "url";
6
+ import { createProject } from "./commands/createProject.js";
7
7
  const __filename = fileURLToPath(import.meta.url);
8
8
  const __dirname = path.dirname(__filename);
9
+ const pkgPath = path.resolve(__dirname, "../package.json");
10
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
9
11
  const program = new Command();
10
- // Main command handler for direct project creation
11
12
  const handleProjectCreation = async (projectName, options) => {
12
13
  await createProject(projectName, options);
13
14
  };
14
- // Helper to run vite with internal config
15
- const runViteCommand = (command) => {
16
- // Path to the compiled vite.config.js in dist
15
+ const runViteCommand = async (command) => {
17
16
  const configPath = path.resolve(__dirname, "runtime/bundler/vite.config.js");
18
- const args = [command, "--config", configPath];
17
+ // Set the config path as env variable — vite reads VITE_CONFIG_FILE
18
+ process.env.VITE_CONFIG_PATH = configPath;
19
+ // Dynamically import vite's programmatic API
20
+ const vitePath = path.resolve(process.cwd(), "node_modules/vite/dist/node/index.js");
21
+ const vite = await import(vitePath);
22
+ // Load the revine config
23
+ const { generateRevineViteConfig } = await import(path.resolve(__dirname, "runtime/bundler/generateConfig.js"));
24
+ const config = await generateRevineViteConfig();
19
25
  if (command === "dev") {
20
- // Vite dev doesn't need 'dev' argument, just calling vite is enough
21
- args.shift();
26
+ const server = await vite.createServer({
27
+ ...config,
28
+ configFile: false, // we pass config directly, no file needed
29
+ });
30
+ await server.listen();
31
+ server.printUrls();
22
32
  }
23
- spawn("npx", ["vite", ...args], {
24
- stdio: "inherit",
25
- shell: true,
26
- });
27
- };
28
- // Main command handler for direct project creation with command check
29
- const handleRootAction = async (projectName, options) => {
30
- const knownCommands = ["create", "dev", "build", "preview"];
31
- if (projectName && !knownCommands.includes(projectName)) {
32
- await handleProjectCreation(projectName, options);
33
+ else if (command === "build") {
34
+ await vite.build({
35
+ ...config,
36
+ configFile: false,
37
+ });
33
38
  }
34
- else if (!projectName) {
35
- program.help();
39
+ else if (command === "preview") {
40
+ const server = await vite.preview({
41
+ ...config,
42
+ configFile: false,
43
+ });
44
+ server.printUrls();
36
45
  }
37
46
  };
38
- // Root command
47
+ // Root command — handles: npx revine <project-name>
39
48
  program
40
- .version("0.8.0")
49
+ .version(pkg.version)
41
50
  .argument("[project-name/command]")
42
51
  .option("-f, --force", "Force creation in non-empty directory")
43
52
  .action(async (arg, options) => {
44
- // If it's a known command, Commander will handle it in the subcommand action.
45
- // We only handle it here if it's NOT a known command.
46
53
  const knownCommands = ["create", "dev", "build", "preview"];
47
54
  if (arg && !knownCommands.includes(arg)) {
48
55
  await handleProjectCreation(arg, options);
@@ -51,7 +58,7 @@ program
51
58
  program.help();
52
59
  }
53
60
  });
54
- // Create subcommand (npx revine create my-app)
61
+ // npx revine create <project-name>
55
62
  program
56
63
  .command("create")
57
64
  .argument("<project-name>")
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Initialize a Git repository in the project directory.
3
+ * @param projectDir - The directory where the project was set up.
4
+ */
5
+ export default function initGit(projectDir: string): Promise<void>;
6
+ //# sourceMappingURL=git.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/prompts/git.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,wBAA8B,OAAO,CAAC,UAAU,EAAE,MAAM,iBAuCvD"}
@@ -0,0 +1,4 @@
1
+ export { default as askForTailwindSetup } from "./tailwind.js";
2
+ export { default as runProject } from "./project.js";
3
+ export { default as initGit } from "./git.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Ask the user if they want to run the project after setup is complete.
3
+ * If the user confirms, it will start the dev server using the same revine
4
+ * binary that was invoked (i.e. the local build), rather than the npm package.
5
+ * @param projectDir - The directory where the project was set up.
6
+ */
7
+ export default function runProject(projectDir: string): Promise<void>;
8
+ //# sourceMappingURL=project.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../src/prompts/project.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,wBAA8B,UAAU,CAAC,UAAU,EAAE,MAAM,iBAuB1D"}
@@ -0,0 +1,2 @@
1
+ export default function askForTailwindSetup(): Promise<boolean>;
2
+ //# sourceMappingURL=tailwind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../src/prompts/tailwind.ts"],"names":[],"mappings":"AAEA,wBAA8B,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAUpE"}
@@ -0,0 +1,21 @@
1
+ export declare const defaultViteConfig: {
2
+ plugins: any[];
3
+ logLevel: string;
4
+ server: {
5
+ clearScreen: boolean;
6
+ open: boolean;
7
+ port: number;
8
+ host: boolean;
9
+ };
10
+ build: {
11
+ outDir: string;
12
+ emptyOutDir: boolean;
13
+ rollupOptions: {
14
+ external: string[];
15
+ };
16
+ };
17
+ optimizeDeps: {
18
+ exclude: string[];
19
+ };
20
+ };
21
+ //# sourceMappingURL=vite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/defaults/vite.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;CAmB7B,CAAC"}
@@ -1,17 +1,23 @@
1
1
  import react from "@vitejs/plugin-react";
2
- import { revineLoggerPlugin } from "../viteLoggerPlugin.js";
3
2
  import { revinePlugin } from "../revinePlugin.js";
3
+ import { revineLoggerPlugin } from "../viteLoggerPlugin.js";
4
4
  export const defaultViteConfig = {
5
5
  plugins: [react(), revinePlugin(), revineLoggerPlugin()],
6
6
  logLevel: "silent",
7
7
  server: {
8
8
  clearScreen: false,
9
- open: true,
9
+ open: false,
10
10
  port: 3000,
11
11
  host: true,
12
12
  },
13
13
  build: {
14
14
  outDir: "build",
15
15
  emptyOutDir: true,
16
+ rollupOptions: {
17
+ external: ["revine"],
18
+ },
19
+ },
20
+ optimizeDeps: {
21
+ exclude: ["revine"],
16
22
  },
17
23
  };
@@ -0,0 +1,2 @@
1
+ export declare function generateRevineViteConfig(): Promise<any>;
2
+ //# sourceMappingURL=generateConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateConfig.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/generateConfig.ts"],"names":[],"mappings":"AAUA,wBAAsB,wBAAwB,iBAyB7C"}
@@ -0,0 +1,2 @@
1
+ export declare function revinePlugin(): any;
2
+ //# sourceMappingURL=revinePlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revinePlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/revinePlugin.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,IAAI,GAAG,CA+GlC"}
@@ -1,58 +1,101 @@
1
1
  const VIRTUAL_ROUTING_ID = "\0revine:routing";
2
- /**
3
- * The Revine Vite plugin.
4
- *
5
- * Provides a virtual module for `revine/routing` so that:
6
- * - `import.meta.glob` is resolved by Vite in the *project* context (not node_modules)
7
- * - React runtime is resolved from the project's own node_modules
8
- */
9
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
2
  export function revinePlugin() {
11
3
  return {
12
4
  name: "revine",
5
+ enforce: "pre",
13
6
  resolveId(id) {
14
7
  if (id === "revine/routing") {
15
8
  return VIRTUAL_ROUTING_ID;
16
9
  }
17
10
  },
18
- // Return the routing source as a virtual module.
19
- // Because it's virtual (not inside node_modules), Vite processes
20
- // import.meta.glob and all imports normally in the project context.
21
11
  load(id) {
22
12
  if (id === VIRTUAL_ROUTING_ID) {
23
13
  return `
24
14
  import { createBrowserRouter } from "react-router-dom";
25
15
  import { lazy, Suspense, createElement } from "react";
26
16
 
27
- // Eagerly load NotFound from the project's src directory.
28
17
  const notFoundModules = import.meta.glob("/src/NotFound.tsx", { eager: true });
29
18
  const NotFoundComponent = Object.values(notFoundModules)[0]?.default;
30
19
 
31
- // Lazily load all page components under /src/pages.
32
20
  const pages = import.meta.glob("/src/pages/**/*.tsx");
21
+ const layoutModules = import.meta.glob("/src/pages/**/layout.tsx", { eager: true });
22
+ const loadingModules = import.meta.glob("/src/pages/**/loading.tsx", { eager: true });
33
23
 
34
- const routes = Object.entries(pages).map(([filePath, component]) => {
35
- let cleaned = filePath.replace(/\\\\/g, "/");
36
- cleaned = cleaned.replace(/.*\\/pages\\//, "");
37
- cleaned = cleaned.replace(/\\.tsx$/i, "");
38
- cleaned = cleaned.replace(/\\/index$/, "");
39
- cleaned = cleaned.replace(/\\[(\\w+)\\]/g, ":$1");
40
- if (cleaned === "index") cleaned = "";
24
+ function getLayoutsForPath(filePath) {
25
+ const parts = filePath.split("/");
26
+ parts.pop();
27
+ const layouts = [];
28
+ const accumulated = [];
29
+ for (const part of parts) {
30
+ accumulated.push(part);
31
+ const key = accumulated.join("/") + "/layout.tsx";
32
+ if (layoutModules[key] && layoutModules[key].default) {
33
+ layouts.push(layoutModules[key].default);
34
+ }
35
+ }
36
+ return layouts;
37
+ }
38
+
39
+ function getLoadingForPath(filePath) {
40
+ const parts = filePath.split("/");
41
+ parts.pop();
42
+ while (parts.length >= 2) {
43
+ const key = parts.join("/") + "/loading.tsx";
44
+ if (loadingModules[key] && loadingModules[key].default) {
45
+ return loadingModules[key].default;
46
+ }
47
+ parts.pop();
48
+ }
49
+ return null;
50
+ }
41
51
 
42
- const routePath = cleaned === "" ? "/" : \`/\${cleaned}\`;
52
+ function wrapWithLayouts(element, layouts) {
53
+ return layouts.reduceRight((wrapped, Layout) => {
54
+ return createElement(Layout, null, wrapped);
55
+ }, element);
56
+ }
57
+
58
+ function toRoutePath(filePath) {
59
+ let p = filePath;
60
+ p = p.replace(/[\\\\]/g, "/");
61
+ p = p.replace(/.*[/]pages[/]/, "");
62
+ p = p.replace(/[.]tsx$/i, "");
63
+ p = p.replace(/[/]index$/, "");
64
+ p = p.replace(/[(][^)]+[)][/]/g, "");
65
+ p = p.replace(/[[]([\\w]+)[\\]]/g, ":$1");
66
+ if (p === "index" || p === "") return "/";
67
+ return "/" + p;
68
+ }
69
+
70
+ const pageEntries = Object.entries(pages).filter(([filePath]) => {
71
+ if (filePath.endsWith("/layout.tsx")) return false;
72
+ if (filePath.endsWith("/loading.tsx")) return false;
73
+ const segments = filePath.split("/");
74
+ return !segments.some((s) => s.startsWith("_"));
75
+ });
76
+
77
+ const routes = pageEntries.map(([filePath, component]) => {
78
+ const routePath = toRoutePath(filePath);
43
79
  const Component = lazy(component);
80
+ const layouts = getLayoutsForPath(filePath);
81
+ const Loading = getLoadingForPath(filePath);
82
+
83
+ const fallback = Loading
84
+ ? createElement(Loading)
85
+ : createElement("div", null, "Loading\\u2026");
86
+
87
+ const pageElement = createElement(
88
+ Suspense,
89
+ { fallback },
90
+ createElement(Component)
91
+ );
44
92
 
45
93
  return {
46
94
  path: routePath,
47
- element: createElement(
48
- Suspense,
49
- { fallback: createElement("div", null, "Loading\u2026") },
50
- createElement(Component)
51
- ),
95
+ element: layouts.length > 0 ? wrapWithLayouts(pageElement, layouts) : pageElement,
52
96
  };
53
97
  });
54
98
 
55
- // 404 fallback
56
99
  routes.push({
57
100
  path: "*",
58
101
  element: NotFoundComponent
@@ -0,0 +1,2 @@
1
+ export declare function loadUserConfig(): Promise<any>;
2
+ //# sourceMappingURL=loadUserConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadUserConfig.d.ts","sourceRoot":"","sources":["../../../../src/runtime/bundler/utils/loadUserConfig.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,iBAenC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("vite").UserConfigExport;
2
+ export default _default;
3
+ //# sourceMappingURL=vite.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite.config.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/vite.config.ts"],"names":[],"mappings":";AAIA,wBAGG"}
@@ -0,0 +1,3 @@
1
+ import type { Plugin } from "vite";
2
+ export declare function revineLoggerPlugin(): Plugin;
3
+ //# sourceMappingURL=viteLoggerPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viteLoggerPlugin.d.ts","sourceRoot":"","sources":["../../../src/runtime/bundler/viteLoggerPlugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,MAAM,CAAC;AAElD,wBAAgB,kBAAkB,IAAI,MAAM,CA8B3C"}
@@ -7,13 +7,13 @@ export function revineLoggerPlugin() {
7
7
  configureServer(server) {
8
8
  server.httpServer?.once("listening", () => {
9
9
  const protocol = server.config.server.https ? "https" : "http";
10
- const host = server.resolvedUrls?.local[0] || "localhost:3000";
10
+ const localUrl = server.resolvedUrls?.local[0] || `http://localhost:3000`;
11
11
  const { network = [] } = server.resolvedUrls ?? {};
12
12
  // Use the 'indigo' instance in place of 'chalk.cyan'
13
13
  console.log(indigo("─────────────────────────────────────────────"));
14
14
  console.log(indigo.bold("🚀 Revine Dev Server is now running!"));
15
15
  console.log(indigo("─────────────────────────────────────────────"));
16
- console.log(indigo(`Local: ${chalk.green(`${protocol}://${host}`)}`));
16
+ console.log(indigo(`Local: ${chalk.green(localUrl)}`));
17
17
  if (network.length) {
18
18
  network.forEach((url) => {
19
19
  console.log(indigo(`Network: ${chalk.green(url)}`));
@@ -0,0 +1,6 @@
1
+ import type { UserConfig } from "vite";
2
+ export interface RevineConfig {
3
+ vite?: UserConfig;
4
+ }
5
+ export declare function defineConfig(config: RevineConfig): RevineConfig;
6
+ //# sourceMappingURL=defineConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineConfig.d.ts","sourceRoot":"","sources":["../../src/runtime/defineConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAE/D"}
@@ -0,0 +1,3 @@
1
+ export function defineConfig(config) {
2
+ return config;
3
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/runtime/routing.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ReactNode } from "react";
2
+ export interface LayoutProps {
3
+ children: ReactNode;
4
+ }
5
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function installDependencies(projectDir: string): Promise<void>;
2
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../src/setup/dependencies.ts"],"names":[],"mappings":"AAGA,wBAAsB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc3E"}
@@ -6,18 +6,11 @@ export async function installDependencies(projectDir) {
6
6
  const installResult = spawnSync(npmCmd, ["install"], {
7
7
  stdio: "inherit",
8
8
  cwd: projectDir,
9
- shell: true,
9
+ shell: false,
10
10
  });
11
11
  if (installResult.error || installResult.status !== 0) {
12
12
  logError("Error installing dependencies:", installResult.error);
13
13
  logInfo("Try running manually: npm install");
14
14
  process.exit(1);
15
15
  }
16
- // Step 2: Link local revine if available (replaces npm version with local build)
17
- // This is a no-op if revine hasn't been globally linked via `npm link` in the revine repo.
18
- spawnSync(npmCmd, ["link", "revine"], {
19
- stdio: "pipe", // suppress output — silently skip if not linked
20
- cwd: projectDir,
21
- shell: true,
22
- });
23
16
  }
@@ -0,0 +1,2 @@
1
+ export declare function setupTailwind(projectDir: string): Promise<void>;
2
+ //# sourceMappingURL=tailwind.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.d.ts","sourceRoot":"","sources":["../../src/setup/tailwind.ts"],"names":[],"mappings":"AAKA,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,iBAiJrD"}
@@ -0,0 +1,2 @@
1
+ export declare function copyTemplate(templateDir: string, destinationDir: string, force?: boolean): Promise<void>;
2
+ //# sourceMappingURL=file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAEA,wBAAsB,YAAY,CAChC,WAAW,EAAE,MAAM,EACnB,cAAc,EAAE,MAAM,EACtB,KAAK,CAAC,EAAE,OAAO,GACd,OAAO,CAAC,IAAI,CAAC,CAEf"}
@@ -0,0 +1,3 @@
1
+ export declare function logInfo(message: string): void;
2
+ export declare function logError(message: string, error?: any): void;
3
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,QAEtC;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,QAEpD"}