revine 0.8.0 → 0.9.0

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 (55) hide show
  1. package/README.md +81 -81
  2. package/dist/commands/createProject.js +20 -2
  3. package/dist/config/package.js +4 -0
  4. package/dist/index.js +64 -2
  5. package/dist/prompts/project.js +11 -8
  6. package/dist/runtime/bundler/defaults/vite.js +17 -0
  7. package/dist/runtime/bundler/generateConfig.js +27 -0
  8. package/dist/runtime/bundler/revinePlugin.js +68 -0
  9. package/dist/runtime/bundler/utils/loadUserConfig.js +20 -0
  10. package/dist/runtime/bundler/vite.config.js +7 -0
  11. package/dist/runtime/bundler/viteLoggerPlugin.js +27 -0
  12. package/dist/runtime/routing/fileBased.js +29 -0
  13. package/dist/setup/dependencies.js +8 -0
  14. package/dist/setup/tailwind.js +128 -133
  15. package/package.json +44 -29
  16. package/src/commands/createProject.ts +88 -65
  17. package/src/config/package.ts +28 -23
  18. package/src/config/readme.ts +7 -7
  19. package/src/config/vite.ts +19 -19
  20. package/src/index.ts +91 -15
  21. package/src/prompts/git.ts +61 -61
  22. package/src/prompts/index.ts +3 -3
  23. package/src/prompts/project.ts +34 -31
  24. package/src/prompts/tailwind.ts +13 -13
  25. package/{template/.revine → src/runtime}/bundler/defaults/vite.ts +18 -18
  26. package/src/runtime/bundler/generateConfig.ts +36 -0
  27. package/src/runtime/bundler/revinePlugin.ts +71 -0
  28. package/src/runtime/bundler/utils/loadUserConfig.ts +19 -0
  29. package/{template/.revine → src/runtime}/bundler/vite.config.ts +8 -8
  30. package/{template/.revine → src/runtime}/bundler/viteLoggerPlugin.ts +33 -33
  31. package/{template/.revine → src/runtime}/routing/fileBased.tsx +46 -44
  32. package/src/setup/dependencies.ts +26 -16
  33. package/src/setup/tailwind.ts +151 -163
  34. package/src/utils/file.ts +9 -9
  35. package/src/utils/logger.ts +9 -9
  36. package/template/README.md +62 -62
  37. package/template/index.html +19 -19
  38. package/template/package.json +21 -24
  39. package/template/revine.config.ts +13 -13
  40. package/template/src/NotFound.tsx +13 -13
  41. package/template/src/pages/index.tsx +62 -62
  42. package/template/src/root.tsx +14 -14
  43. package/template/src/styles/global.css +191 -191
  44. package/template/tsconfig.json +20 -24
  45. package/tsconfig.json +15 -14
  46. package/dist/commands/create.js +0 -65
  47. package/dist/installers/dependencies.js +0 -15
  48. package/dist/lib/setup/directory.js +0 -21
  49. package/dist/lib/setup/package.js +0 -17
  50. package/dist/lib/setup/tailwind.js +0 -22
  51. package/dist/lib/utils/exec.js +0 -15
  52. package/dist/lib/utils/paths.js +0 -6
  53. package/template/.revine/bundler/generateConfig.ts +0 -18
  54. package/template/.revine/bundler/utils/loadUserConfig.ts +0 -13
  55. /package/{template/.revine → src/runtime}/bundler/types/vite-env.d.ts +0 -0
@@ -1,24 +1,20 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "useDefineForClassFields": true,
5
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
- "module": "ESNext",
7
- "skipLibCheck": true,
8
- "moduleResolution": "bundler",
9
- "resolveJsonModule": true,
10
- "isolatedModules": true,
11
- "noEmit": true,
12
- "jsx": "react-jsx",
13
- "strict": true,
14
- "noUnusedLocals": true,
15
- "noUnusedParameters": true,
16
- "noFallthroughCasesInSwitch": true,
17
- "types": ["vite/client"],
18
- "baseUrl": ".",
19
- "paths": {
20
- "@/*": ["./src/*"]
21
- }
22
- },
23
- "include": ["src", ".revine/**/*"]
24
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+ "moduleResolution": "bundler",
9
+ "resolveJsonModule": true,
10
+ "isolatedModules": true,
11
+ "noEmit": true,
12
+ "jsx": "react-jsx",
13
+ "strict": true,
14
+ "baseUrl": ".",
15
+ "paths": {
16
+ "@/*": ["./src/*"]
17
+ }
18
+ },
19
+ "include": ["src"]
20
+ }
package/tsconfig.json CHANGED
@@ -1,14 +1,15 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ES2020",
5
- "moduleResolution": "node",
6
- "outDir": "dist",
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "forceConsistentCasingInFileNames": true
11
- },
12
- "include": ["src/**/*"],
13
- "exclude": ["src/template/**/*"]
14
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ES2020",
5
+ "moduleResolution": "node",
6
+ "outDir": "dist",
7
+ "strict": true,
8
+ "esModuleInterop": true,
9
+ "skipLibCheck": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "jsx": "react-jsx"
12
+ },
13
+ "include": ["src/**/*"],
14
+ "exclude": ["src/template/**/*"]
15
+ }
@@ -1,65 +0,0 @@
1
- import { Command } from "commander";
2
- import chalk from "chalk";
3
- import fs from "fs-extra";
4
- import path from "path";
5
- import inquirer from "inquirer";
6
- // locals
7
- import { getDirname } from "../lib/utils/paths.js";
8
- import { validateDirectory } from "../lib/setup/directory.js";
9
- import { updatePackageJson } from "../lib/setup/package.js";
10
- import { setupTailwind } from "../lib/setup/tailwind.js";
11
- import { runInstall } from "../lib/utils/exec.js";
12
- const __dirname = getDirname(import.meta.url);
13
- export function createCommand() {
14
- const command = new Command("create")
15
- .description("Create a new Revine project")
16
- .argument("<project-name>")
17
- .option("-f, --force", "Force creation in non-empty directory")
18
- .action(async (projectName, options) => {
19
- try {
20
- const templateDir = path.join(__dirname, "../../template");
21
- const projectDir = path.resolve(projectName);
22
- const isCurrentDir = [".", "./"].includes(projectName);
23
- // Validate directory
24
- validateDirectory(projectDir, isCurrentDir, options.force);
25
- // Copy template
26
- console.log(chalk.cyan(`Creating project in ${projectDir}...`));
27
- fs.copySync(templateDir, projectDir, { overwrite: options.force });
28
- // Update package.json
29
- const { useTailwind } = await inquirer.prompt([
30
- {
31
- type: "confirm",
32
- name: "useTailwind",
33
- message: "Would you like to set up Tailwind CSS?",
34
- default: true,
35
- },
36
- ]);
37
- await updatePackageJson(projectDir, isCurrentDir ? path.basename(projectDir) : projectName, useTailwind);
38
- // Update README
39
- const readmePath = path.join(projectDir, "README.md");
40
- let readmeContent = fs.readFileSync(readmePath, "utf-8");
41
- fs.writeFileSync(readmePath, readmeContent.replace(/%PROJECT_NAME%/g, projectName));
42
- // Install dependencies
43
- console.log(chalk.cyan("\nInstalling dependencies..."));
44
- runInstall(projectDir);
45
- // Setup Tailwind
46
- if (useTailwind) {
47
- setupTailwind(projectDir);
48
- }
49
- // Final message
50
- console.log(chalk.green("\nSuccess! Created project at"), chalk.yellow(projectDir));
51
- console.log(chalk.cyan("\nStart developing with:"));
52
- if (!isCurrentDir)
53
- console.log(` cd ${projectName}`);
54
- console.log(" npm run dev\n");
55
- }
56
- catch (error) {
57
- let message = "Unknown error occurred";
58
- if (error instanceof Error)
59
- message = error.message;
60
- console.log(chalk.red("Error:"), message);
61
- process.exit(1);
62
- }
63
- });
64
- return command;
65
- }
@@ -1,15 +0,0 @@
1
- import { spawnSync } from "child_process";
2
- import { logError, logInfo } from "../utils/logger.js";
3
- export async function installDependencies(projectDir) {
4
- const npmCmd = process.platform === "win32" ? "npm.cmd" : "npm";
5
- const installResult = spawnSync(npmCmd, ["install"], {
6
- stdio: "inherit",
7
- cwd: projectDir,
8
- shell: true,
9
- });
10
- if (installResult.error || installResult.status !== 0) {
11
- logError("Error installing dependencies:", installResult.error);
12
- logInfo("Try running manually: npm install");
13
- process.exit(1);
14
- }
15
- }
@@ -1,21 +0,0 @@
1
- import fs from "fs-extra";
2
- import chalk from "chalk";
3
- export function validateDirectory(projectDir, isCurrentDir, force) {
4
- if (fs.existsSync(projectDir)) {
5
- if (!isCurrentDir && !force) {
6
- console.log(chalk.red(`Error: Directory "${projectDir}" already exists.`));
7
- process.exit(1);
8
- }
9
- const existingFiles = fs
10
- .readdirSync(projectDir)
11
- .filter((file) => file !== ".git");
12
- if (existingFiles.length > 0 && !force) {
13
- console.log(chalk.red(`Error: Directory "${projectDir}" is not empty.`));
14
- console.log(chalk.yellow("Use --force to override existing files"));
15
- process.exit(1);
16
- }
17
- }
18
- else {
19
- fs.mkdirpSync(projectDir);
20
- }
21
- }
@@ -1,17 +0,0 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- export async function updatePackageJson(projectDir, projectName, useTailwind) {
4
- const packageJsonPath = path.join(projectDir, "package.json");
5
- const packageJson = await fs.readJson(packageJsonPath);
6
- packageJson.name = projectName;
7
- packageJson.type = "module";
8
- if (useTailwind) {
9
- packageJson.devDependencies = {
10
- ...packageJson.devDependencies,
11
- tailwindcss: "^4.0.0",
12
- "@tailwindcss/vite": "^4.0.0",
13
- };
14
- }
15
- await fs.writeJson(packageJsonPath, packageJson, { spaces: 2 });
16
- return packageJson;
17
- }
@@ -1,22 +0,0 @@
1
- import fs from "fs-extra";
2
- import path from "path";
3
- import chalk from "chalk";
4
- export function setupTailwind(projectDir) {
5
- console.log(chalk.cyan("\nSetting up Tailwind CSS..."));
6
- // Update Vite config
7
- const viteConfigPath = path.join(projectDir, "vite.config.ts");
8
- let viteConfig = fs.readFileSync(viteConfigPath, "utf-8");
9
- viteConfig = viteConfig
10
- .replace("import react from '@vitejs/plugin-react';", "import react from '@vitejs/plugin-react';\nimport tailwindcss from '@tailwindcss/vite';")
11
- .replace("plugins: [react()]", "plugins: [\n react(),\n tailwindcss()\n ]");
12
- fs.writeFileSync(viteConfigPath, viteConfig);
13
- // Create styles directory
14
- const cssDir = path.join(projectDir, "src", "styles");
15
- fs.ensureDirSync(cssDir);
16
- // Create CSS file
17
- fs.writeFileSync(path.join(cssDir, "global.css"), "@import 'tailwindcss';\n");
18
- // Update main entry file
19
- const mainTsxPath = path.join(projectDir, "src", "main.tsx");
20
- const mainContent = `import './styles/global.css';\n${fs.readFileSync(mainTsxPath, "utf-8")}`;
21
- fs.writeFileSync(mainTsxPath, mainContent);
22
- }
@@ -1,15 +0,0 @@
1
- import { spawnSync } from "child_process";
2
- import { platform } from "os";
3
- export function getNpmCommand() {
4
- return platform() === "win32" ? "npm.cmd" : "npm";
5
- }
6
- export function runInstall(cwd) {
7
- const result = spawnSync(getNpmCommand(), ["install"], {
8
- stdio: "inherit",
9
- cwd,
10
- shell: true,
11
- });
12
- if (result.error || result.status !== 0) {
13
- throw new Error("Dependency installation failed");
14
- }
15
- }
@@ -1,6 +0,0 @@
1
- import { fileURLToPath } from 'url';
2
- import path from 'path';
3
- export function getDirname(metaUrl) {
4
- const __filename = fileURLToPath(metaUrl);
5
- return path.dirname(__filename);
6
- }
@@ -1,18 +0,0 @@
1
- import { merge } from "lodash-es";
2
- import { defaultViteConfig } from "./defaults/vite.js";
3
- import { loadUserConfig } from "./utils/loadUserConfig.js";
4
-
5
- interface UserConfig {
6
- vite?: Record<string, unknown>;
7
- }
8
-
9
- export async function generateRevineViteConfig() {
10
- // Load the user's revine.config.ts
11
- const userConfig = (await loadUserConfig()) as UserConfig;
12
-
13
-
14
- // Merge user "vite" overrides with your default config
15
- const finalConfig = merge({}, defaultViteConfig, userConfig.vite || {});
16
-
17
- return finalConfig;
18
- }
@@ -1,13 +0,0 @@
1
- export async function loadUserConfig() {
2
- try {
3
- // relative path to the user's revine.config.ts
4
- const configModule = await import("../../../revine.config");
5
- return configModule.default || {};
6
- } catch (error) {
7
- console.error(
8
- "[Revine] Could not load revine.config.ts, using defaults.",
9
- error
10
- );
11
- return {};
12
- }
13
- }