@evjs/create-app 0.3.14 → 0.3.16

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/dist/index.d.ts CHANGED
@@ -1,4 +1 @@
1
- export declare function shouldCopyTemplatePath(src: string): boolean;
2
- export declare function withGeneratedFrameworkIgnores(source: string): string;
3
- export declare function restoreScaffoldGitignore(targetDir: string): void;
4
- export declare function runCreateAppCli(argv?: string[]): Promise<void>;
1
+ export { restoreScaffoldGitignore, runCreateAppCli, shouldCopyTemplatePath, withGeneratedFrameworkIgnores, } from "./scaffolding/run.js";
package/dist/index.js CHANGED
@@ -1,155 +1 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import { fileURLToPath } from "node:url";
4
- import { Command } from "commander";
5
- import pc from "picocolors";
6
- import prompts from "prompts";
7
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
- const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf-8"));
9
- const templateCopyExcludedBasenames = new Set([
10
- "node_modules",
11
- "dist",
12
- ".turbo",
13
- ".turbopack",
14
- ".ev",
15
- ".evjs",
16
- "route-types.d.ts",
17
- "plugin-types.d.ts",
18
- ]);
19
- const generatedFrameworkTypeFiles = [
20
- "route-types.d.ts",
21
- "plugin-types.d.ts",
22
- ];
23
- const packagedTemplateGitignore = "_gitignore";
24
- export function shouldCopyTemplatePath(src) {
25
- return !src
26
- .split(/[\\/]+/)
27
- .some((segment) => templateCopyExcludedBasenames.has(segment));
28
- }
29
- export function withGeneratedFrameworkIgnores(source) {
30
- const lineEnding = source.includes("\r\n") ? "\r\n" : "\n";
31
- const ignoredPaths = new Set(source.split(/\r?\n/));
32
- const missing = generatedFrameworkTypeFiles.filter((file) => !ignoredPaths.has(file));
33
- if (missing.length === 0)
34
- return source;
35
- const separator = source.length === 0 || /\r?\n$/.test(source) ? "" : lineEnding;
36
- return `${source}${separator}${missing.join(lineEnding)}${lineEnding}`;
37
- }
38
- export function restoreScaffoldGitignore(targetDir) {
39
- const gitignorePath = path.join(targetDir, ".gitignore");
40
- const packagedGitignorePath = path.join(targetDir, packagedTemplateGitignore);
41
- let sourcePath = gitignorePath;
42
- if (fs.existsSync(packagedGitignorePath)) {
43
- sourcePath = packagedGitignorePath;
44
- }
45
- else if (!fs.existsSync(gitignorePath)) {
46
- return;
47
- }
48
- const source = fs.readFileSync(sourcePath, "utf-8");
49
- fs.writeFileSync(gitignorePath, withGeneratedFrameworkIgnores(source));
50
- if (sourcePath === packagedGitignorePath) {
51
- fs.rmSync(packagedGitignorePath);
52
- }
53
- }
54
- export async function runCreateAppCli(argv = process.argv) {
55
- const program = new Command();
56
- program
57
- .name("create-evjs-app")
58
- .description("Scaffold a new evjs project")
59
- .version(pkg.version)
60
- .argument("[name]", "Project name")
61
- .option("-t, --template <template>", "Template to use")
62
- .action(async (name, options) => {
63
- const response = await prompts([
64
- {
65
- type: name ? null : "text",
66
- name: "projectName",
67
- message: "Project name:",
68
- initial: name || "my-evjs-app",
69
- },
70
- {
71
- type: options.template ? null : "select",
72
- name: "template",
73
- message: "Select a template:",
74
- choices: [
75
- { title: "Basic (Routing + Server Functions)", value: "basic" },
76
- { title: "MPA (Multi-Page Application)", value: "mpa" },
77
- {
78
- title: "API Routes (REST API via server file routes)",
79
- value: "api-routes",
80
- },
81
- {
82
- title: "Complex Routing (nested Pages, params, search, redirects)",
83
- value: "complex-routing",
84
- },
85
- {
86
- title: "With Tailwind CSS (plugin loaders example)",
87
- value: "with-tailwind",
88
- },
89
- { title: "With tRPC Interop", value: "with-trpc" },
90
- { title: "With SQLite (Full-stack CRUD)", value: "with-sqlite" },
91
- {
92
- title: "Custom Transport (WebSockets)",
93
- value: "custom-ws-transport",
94
- },
95
- { title: "Plugin Authoring", value: "plugin-authoring" },
96
- ],
97
- },
98
- ], {
99
- onCancel: () => {
100
- process.exit(1);
101
- },
102
- });
103
- const projectName = response.projectName || name;
104
- const template = response.template || options.template;
105
- const targetDir = path.resolve(process.cwd(), projectName);
106
- if (fs.existsSync(targetDir)) {
107
- console.error(pc.red(`✖ Directory ${projectName} already exists!`));
108
- process.exit(1);
109
- }
110
- const templatesRoot = path.resolve(__dirname, "../templates");
111
- const templateDir = path.resolve(templatesRoot, template);
112
- // Prevent path traversal outside the templates directory
113
- if (!templateDir.startsWith(templatesRoot + path.sep)) {
114
- console.error(pc.red(`✖ Invalid template: ${template}`));
115
- process.exit(1);
116
- }
117
- if (!fs.existsSync(templateDir)) {
118
- console.error(pc.red(`✖ Template ${template} not found!`));
119
- process.exit(1);
120
- }
121
- console.log(pc.cyan(`⚡ Scaffolding project in ${targetDir}...`));
122
- fs.cpSync(templateDir, targetDir, {
123
- recursive: true,
124
- dereference: true,
125
- filter: shouldCopyTemplatePath,
126
- });
127
- restoreScaffoldGitignore(targetDir);
128
- // Post-process package.json: sync @evjs/* versions and set project name
129
- const pkgPath = path.join(targetDir, "package.json");
130
- if (fs.existsSync(pkgPath)) {
131
- const projPkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
132
- projPkg.name = projectName;
133
- delete projPkg.private; // Templates shouldn't be private by default
134
- const updateDeps = (deps) => {
135
- if (!deps)
136
- return;
137
- for (const [depName, val] of Object.entries(deps)) {
138
- if (depName.startsWith("@evjs/") &&
139
- (val === "*" ||
140
- (typeof val === "string" && val.includes("workspace")))) {
141
- deps[depName] = `^${pkg.version}`;
142
- }
143
- }
144
- };
145
- updateDeps(projPkg.dependencies);
146
- updateDeps(projPkg.devDependencies);
147
- fs.writeFileSync(pkgPath, JSON.stringify(projPkg, null, 2));
148
- }
149
- console.log(pc.green("✔ Done! Now run:"));
150
- console.log(` cd ${projectName}`);
151
- console.log(" npm install");
152
- console.log(" npm run dev");
153
- });
154
- await program.parseAsync(argv);
155
- }
1
+ export { restoreScaffoldGitignore, runCreateAppCli, shouldCopyTemplatePath, withGeneratedFrameworkIgnores, } from "./scaffolding/run.js";
@@ -0,0 +1,4 @@
1
+ export declare function shouldCopyTemplatePath(src: string): boolean;
2
+ export declare function withGeneratedFrameworkIgnores(source: string): string;
3
+ export declare function restoreScaffoldGitignore(targetDir: string): void;
4
+ export declare function runCreateAppCli(argv?: string[]): Promise<void>;
@@ -0,0 +1,155 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { Command } from "commander";
5
+ import pc from "picocolors";
6
+ import prompts from "prompts";
7
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
8
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../../package.json"), "utf-8"));
9
+ const templateCopyExcludedBasenames = new Set([
10
+ "node_modules",
11
+ "dist",
12
+ ".turbo",
13
+ ".turbopack",
14
+ ".ev",
15
+ ".evjs",
16
+ "route-types.d.ts",
17
+ "plugin-types.d.ts",
18
+ ]);
19
+ const generatedFrameworkTypeFiles = [
20
+ "route-types.d.ts",
21
+ "plugin-types.d.ts",
22
+ ];
23
+ const packagedTemplateGitignore = "_gitignore";
24
+ export function shouldCopyTemplatePath(src) {
25
+ return !src
26
+ .split(/[\\/]+/)
27
+ .some((segment) => templateCopyExcludedBasenames.has(segment));
28
+ }
29
+ export function withGeneratedFrameworkIgnores(source) {
30
+ const lineEnding = source.includes("\r\n") ? "\r\n" : "\n";
31
+ const ignoredPaths = new Set(source.split(/\r?\n/));
32
+ const missing = generatedFrameworkTypeFiles.filter((file) => !ignoredPaths.has(file));
33
+ if (missing.length === 0)
34
+ return source;
35
+ const separator = source.length === 0 || /\r?\n$/.test(source) ? "" : lineEnding;
36
+ return `${source}${separator}${missing.join(lineEnding)}${lineEnding}`;
37
+ }
38
+ export function restoreScaffoldGitignore(targetDir) {
39
+ const gitignorePath = path.join(targetDir, ".gitignore");
40
+ const packagedGitignorePath = path.join(targetDir, packagedTemplateGitignore);
41
+ let sourcePath = gitignorePath;
42
+ if (fs.existsSync(packagedGitignorePath)) {
43
+ sourcePath = packagedGitignorePath;
44
+ }
45
+ else if (!fs.existsSync(gitignorePath)) {
46
+ return;
47
+ }
48
+ const source = fs.readFileSync(sourcePath, "utf-8");
49
+ fs.writeFileSync(gitignorePath, withGeneratedFrameworkIgnores(source));
50
+ if (sourcePath === packagedGitignorePath) {
51
+ fs.rmSync(packagedGitignorePath);
52
+ }
53
+ }
54
+ export async function runCreateAppCli(argv = process.argv) {
55
+ const program = new Command();
56
+ program
57
+ .name("create-evjs-app")
58
+ .description("Scaffold a new evjs project")
59
+ .version(pkg.version)
60
+ .argument("[name]", "Project name")
61
+ .option("-t, --template <template>", "Template to use")
62
+ .action(async (name, options) => {
63
+ const response = await prompts([
64
+ {
65
+ type: name ? null : "text",
66
+ name: "projectName",
67
+ message: "Project name:",
68
+ initial: name || "my-evjs-app",
69
+ },
70
+ {
71
+ type: options.template ? null : "select",
72
+ name: "template",
73
+ message: "Select a template:",
74
+ choices: [
75
+ { title: "Basic (Routing + Server Functions)", value: "basic" },
76
+ { title: "MPA (Multi-Page Application)", value: "mpa" },
77
+ {
78
+ title: "API Routes (REST API via server file routes)",
79
+ value: "api-routes",
80
+ },
81
+ {
82
+ title: "Complex Routing (nested Pages, params, search, redirects)",
83
+ value: "complex-routing",
84
+ },
85
+ {
86
+ title: "With Tailwind CSS (plugin loaders example)",
87
+ value: "with-tailwind",
88
+ },
89
+ { title: "With tRPC Interop", value: "with-trpc" },
90
+ { title: "With SQLite (Full-stack CRUD)", value: "with-sqlite" },
91
+ {
92
+ title: "Custom Transport (WebSockets)",
93
+ value: "custom-ws-transport",
94
+ },
95
+ { title: "Plugin Authoring", value: "plugin-authoring" },
96
+ ],
97
+ },
98
+ ], {
99
+ onCancel: () => {
100
+ process.exit(1);
101
+ },
102
+ });
103
+ const projectName = response.projectName || name;
104
+ const template = response.template || options.template;
105
+ const targetDir = path.resolve(process.cwd(), projectName);
106
+ if (fs.existsSync(targetDir)) {
107
+ console.error(pc.red(`✖ Directory ${projectName} already exists!`));
108
+ process.exit(1);
109
+ }
110
+ const templatesRoot = path.resolve(__dirname, "../../templates");
111
+ const templateDir = path.resolve(templatesRoot, template);
112
+ // Prevent path traversal outside the templates directory
113
+ if (!templateDir.startsWith(templatesRoot + path.sep)) {
114
+ console.error(pc.red(`✖ Invalid template: ${template}`));
115
+ process.exit(1);
116
+ }
117
+ if (!fs.existsSync(templateDir)) {
118
+ console.error(pc.red(`✖ Template ${template} not found!`));
119
+ process.exit(1);
120
+ }
121
+ console.log(pc.cyan(`⚡ Scaffolding project in ${targetDir}...`));
122
+ fs.cpSync(templateDir, targetDir, {
123
+ recursive: true,
124
+ dereference: true,
125
+ filter: shouldCopyTemplatePath,
126
+ });
127
+ restoreScaffoldGitignore(targetDir);
128
+ // Post-process package.json: sync @evjs/* versions and set project name
129
+ const pkgPath = path.join(targetDir, "package.json");
130
+ if (fs.existsSync(pkgPath)) {
131
+ const projPkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
132
+ projPkg.name = projectName;
133
+ delete projPkg.private; // Templates shouldn't be private by default
134
+ const updateDeps = (deps) => {
135
+ if (!deps)
136
+ return;
137
+ for (const [depName, val] of Object.entries(deps)) {
138
+ if (depName.startsWith("@evjs/") &&
139
+ (val === "*" ||
140
+ (typeof val === "string" && val.includes("workspace")))) {
141
+ deps[depName] = `^${pkg.version}`;
142
+ }
143
+ }
144
+ };
145
+ updateDeps(projPkg.dependencies);
146
+ updateDeps(projPkg.devDependencies);
147
+ fs.writeFileSync(pkgPath, JSON.stringify(projPkg, null, 2));
148
+ }
149
+ console.log(pc.green("✔ Done! Now run:"));
150
+ console.log(` cd ${projectName}`);
151
+ console.log(" npm install");
152
+ console.log(" npm run dev");
153
+ });
154
+ await program.parseAsync(argv);
155
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/create-app",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "description": "Scaffold a new evjs project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -24,7 +24,7 @@
24
24
  "access": "public"
25
25
  },
26
26
  "scripts": {
27
- "build": "tsc",
27
+ "build": "rm -rf dist && tsc",
28
28
  "test": "vitest run",
29
29
  "check-types": "tsc --noEmit",
30
30
  "prepack": "node scripts/deref-templates.js",
@@ -38,7 +38,7 @@
38
38
  "devDependencies": {
39
39
  "@types/node": "^22.19.15",
40
40
  "@types/prompts": "^2.4.9",
41
- "typescript": "^6.0.2"
41
+ "typescript": "^7.0.2"
42
42
  },
43
43
  "homepage": "https://github.com/afx-team/evjs#readme",
44
44
  "bugs": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-api-routes",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -16,6 +16,6 @@
16
16
  "@evjs/cli": "*",
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
- "typescript": "^6.0.2"
19
+ "typescript": "^7.0.2"
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-basic",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -16,6 +16,6 @@
16
16
  "@evjs/cli": "*",
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
- "typescript": "^6.0.2"
19
+ "typescript": "^7.0.2"
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-complex-routing",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -16,6 +16,6 @@
16
16
  "@evjs/cli": "*",
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
- "typescript": "^6.0.2"
19
+ "typescript": "^7.0.2"
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-custom-ws-transport",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -17,7 +17,7 @@
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
19
  "@types/ws": "^8.18.1",
20
- "typescript": "^6.0.2",
20
+ "typescript": "^7.0.2",
21
21
  "ws": "^8.18.2"
22
22
  }
23
23
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-mpa",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -16,6 +16,6 @@
16
16
  "@evjs/cli": "*",
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
- "typescript": "^6.0.2"
19
+ "typescript": "^7.0.2"
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-plugin-authoring",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -17,6 +17,6 @@
17
17
  "@evjs/cli": "*",
18
18
  "@types/react": "^19.1.8",
19
19
  "@types/react-dom": "^19.1.8",
20
- "typescript": "^6.0.2"
20
+ "typescript": "^7.0.2"
21
21
  }
22
22
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-with-sqlite",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -16,6 +16,6 @@
16
16
  "@evjs/cli": "*",
17
17
  "@types/react": "^19.1.8",
18
18
  "@types/react-dom": "^19.1.8",
19
- "typescript": "^6.0.2"
19
+ "typescript": "^7.0.2"
20
20
  }
21
21
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-with-tailwind",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -23,6 +23,6 @@
23
23
  "postcss-loader": "^8.1.1",
24
24
  "style-loader": "^4.0.0",
25
25
  "tailwindcss": "^4.1.10",
26
- "typescript": "^6.0.2"
26
+ "typescript": "^7.0.2"
27
27
  }
28
28
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "example-with-trpc",
3
- "version": "0.3.14",
3
+ "version": "0.3.16",
4
4
  "private": true,
5
5
  "scripts": {
6
6
  "dev": "ev dev",
@@ -19,6 +19,6 @@
19
19
  "@evjs/cli": "*",
20
20
  "@types/react": "^19.1.8",
21
21
  "@types/react-dom": "^19.1.8",
22
- "typescript": "^6.0.2"
22
+ "typescript": "^7.0.2"
23
23
  }
24
24
  }