@evjs/create-app 0.0.5 → 0.0.7

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.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
+ import fs from "node:fs";
2
3
  import path from "node:path";
3
4
  import { fileURLToPath } from "node:url";
4
5
  import { Command } from "commander";
5
- import fs from "fs-extra";
6
6
  import pc from "picocolors";
7
7
  import prompts from "prompts";
8
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
- const pkg = fs.readJsonSync(path.resolve(__dirname, "../package.json"));
9
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, "../package.json"), "utf-8"));
10
10
  const program = new Command();
11
11
  program
12
12
  .name("create-evjs-app")
@@ -65,7 +65,8 @@ program
65
65
  process.exit(1);
66
66
  }
67
67
  console.log(pc.cyan(`⚡ Scaffolding project in ${targetDir}...`));
68
- await fs.copy(templateDir, targetDir, {
68
+ fs.cpSync(templateDir, targetDir, {
69
+ recursive: true,
69
70
  dereference: true,
70
71
  filter: (src) => {
71
72
  const basename = path.basename(src);
@@ -75,7 +76,7 @@ program
75
76
  // Post-process package.json: sync @evjs/* versions and set project name
76
77
  const pkgPath = path.join(targetDir, "package.json");
77
78
  if (fs.existsSync(pkgPath)) {
78
- const projPkg = await fs.readJson(pkgPath);
79
+ const projPkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
79
80
  projPkg.name = projectName;
80
81
  delete projPkg.private; // Templates shouldn't be private by default
81
82
  const updateDeps = (deps) => {
@@ -91,7 +92,7 @@ program
91
92
  };
92
93
  updateDeps(projPkg.dependencies);
93
94
  updateDeps(projPkg.devDependencies);
94
- await fs.writeJson(pkgPath, projPkg, { spaces: 2 });
95
+ await fs.writeFileSync(pkgPath, JSON.stringify(projPkg, null, 2));
95
96
  }
96
97
  console.log(pc.green("✔ Done! Now run:"));
97
98
  console.log(` cd ${projectName}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/create-app",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Scaffold a new evjs project",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -23,12 +23,10 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "commander": "^12.1.0",
26
- "fs-extra": "^11.3.4",
27
26
  "picocolors": "^1.1.1",
28
27
  "prompts": "^2.4.2"
29
28
  },
30
29
  "devDependencies": {
31
- "@types/fs-extra": "^11.0.4",
32
30
  "@types/node": "^22.19.15",
33
31
  "@types/prompts": "^2.4.9",
34
32
  "typescript": "^6.0.2"
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-basic-csr",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "ev dev",
7
- "build": "ev build",
6
+ "dev": "npx ev dev",
7
+ "build": "npx ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-basic-server-fns",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "ev dev",
7
- "build": "ev build",
6
+ "dev": "npx ev dev",
7
+ "build": "npx ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-basic-server-routes",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "ev dev",
7
- "build": "ev build",
6
+ "dev": "npx ev dev",
7
+ "build": "npx ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-complex-routing",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "ev dev",
7
- "build": "ev build",
6
+ "dev": "npx ev dev",
7
+ "build": "npx ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -6,7 +6,7 @@ const posts = [
6
6
  {
7
7
  id: "1",
8
8
  title: "Getting Started with evjs",
9
- body: "evjs is a zero-config React meta-framework...",
9
+ body: "evjs is a zero-config React fullstack framework...",
10
10
  author: "alice",
11
11
  tags: ["intro", "tutorial"],
12
12
  },
@@ -7,44 +7,24 @@ import { defineConfig } from "@evjs/cli";
7
7
  * All fields are optional — evjs works out of the box.
8
8
  */
9
9
  export default defineConfig({
10
- client: {
11
- // Client entry point (default: "./src/main.tsx")
12
- entry: "./src/main.tsx",
13
-
14
- // HTML template (default: "./index.html")
15
- html: "./index.html",
16
-
17
- // Build plugins
18
- plugins: [
19
- {
20
- name: "example-txt-plugin",
21
- module: {
22
- rules: [
23
- {
24
- test: /\.txt$/,
25
- use: "raw-loader",
26
- },
27
- ],
28
- },
29
- },
30
- ],
10
+ // Client entry point (default: "./src/main.tsx")
11
+ entry: "./src/main.tsx",
31
12
 
32
- // Dev server options (merged with built-in defaults)
33
- dev: {
34
- // Dev server port (default: 3000)
35
- port: 4000,
13
+ // HTML template (default: "./index.html")
14
+ html: "./index.html",
36
15
 
37
- // Any dev server options can be added here:
38
- // https: true,
39
- },
16
+ // Dev server options (merged with built-in defaults)
17
+ dev: {
18
+ // Dev server port (default: 3000)
19
+ port: 4000,
20
+
21
+ // Any dev server options can be added here:
22
+ // https: true,
40
23
  },
41
24
 
42
25
  server: {
43
- // Server function configuration
44
- functions: {
45
- // Server function endpoint path (default: "/api/fn")
46
- endpoint: "/api/fn",
47
- },
26
+ // Server function endpoint path (default: "/api/fn")
27
+ endpoint: "/api/fn",
48
28
 
49
29
  // Server backend command (default: "node")
50
30
  // Supports: "node", "bun", "deno run --allow-net", etc.
@@ -56,4 +36,21 @@ export default defineConfig({
56
36
  port: 4001,
57
37
  },
58
38
  },
39
+
40
+ // Build-time plugins (can also use the `bundler` escape hatch directly)
41
+ plugins: [
42
+ {
43
+ name: "example-txt-plugin",
44
+ bundler(bundlerConfig, ctx) {
45
+ // Direct access to the bundler (e.g. Webpack) configuration
46
+ if (ctx.config.bundler.name === "webpack") {
47
+ const webpackConfig = bundlerConfig as any;
48
+ webpackConfig.module.rules.push({
49
+ test: /\.txt$/,
50
+ use: "raw-loader",
51
+ });
52
+ }
53
+ },
54
+ },
55
+ ],
59
56
  });
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-configured-server-fns",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "ev dev",
7
- "build": "ev build",
6
+ "dev": "npx ev dev",
7
+ "build": "npx ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createAppRootRoute,
3
3
  createRoute,
4
+ getFnQueryKey,
4
5
  Link,
5
6
  Outlet,
6
- serverFn,
7
7
  useMutation,
8
8
  useQuery,
9
9
  useQueryClient,
@@ -51,7 +51,7 @@ function UsersPage() {
51
51
  const { mutateAsync: doCreateUser } = useMutation({
52
52
  mutationFn: createUser,
53
53
  onSuccess: () => {
54
- queryClient.invalidateQueries({ queryKey: serverFn(getUsers).queryKey });
54
+ queryClient.invalidateQueries({ queryKey: getFnQueryKey(getUsers) });
55
55
  },
56
56
  });
57
57
 
@@ -1,22 +1,11 @@
1
1
  import { defineConfig } from "@evjs/cli";
2
2
 
3
3
  /**
4
- * Example: Using client plugins to add Tailwind CSS support.
4
+ * Example: Using Tailwind CSS.
5
+ *
6
+ * Tailwind is supported out-of-the-box by the framework.
7
+ * Because a `postcss.config.js` file exists in this directory,
8
+ * `evjs` automatically applies `postcss-loader` alongside `css-loader`.
9
+ * No custom loaders or `bundler` hooks are needed!
5
10
  */
6
- export default defineConfig({
7
- client: {
8
- plugins: [
9
- {
10
- name: "tailwind",
11
- module: {
12
- rules: [
13
- {
14
- test: /\.css$/,
15
- use: ["style-loader", "css-loader", "postcss-loader"],
16
- },
17
- ],
18
- },
19
- },
20
- ],
21
- },
22
- });
11
+ export default defineConfig({});
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "example-with-tailwind",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "private": true,
5
5
  "scripts": {
6
- "dev": "ev dev",
7
- "build": "ev build",
6
+ "dev": "npx ev dev",
7
+ "build": "npx ev build",
8
8
  "check-types": "tsc --noEmit"
9
9
  },
10
10
  "dependencies": {