create-evikit 2.11.0 → 2.14.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.
@@ -5,7 +5,7 @@ import { dirname, join, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
 
7
7
  import ownPackage from "../package.json" with { type: "json" };
8
- import { template } from "../src/routes/api/server.js";
8
+ import { template, templateIndexJs } from "../src/routes/api/server.js";
9
9
 
10
10
  const ownRoot = dirname(dirname(fileURLToPath(import.meta.url)));
11
11
  const name = process.argv[2];
@@ -118,6 +118,10 @@ writeFileSync(
118
118
 
119
119
  // ---
120
120
 
121
+ writeFileSync(join(target, "index.js"), templateIndexJs);
122
+
123
+ // ---
124
+
121
125
  writeFileSync(
122
126
  join(target, ".env"),
123
127
  `
@@ -135,8 +139,8 @@ const pkg = {
135
139
  version: "0.1.0",
136
140
  private: true,
137
141
  scripts: {
138
- dev: scripts.dev,
139
- build: scripts.build,
142
+ dev: "vite dev",
143
+ build: "tsc && vite build",
140
144
  start: scripts.start,
141
145
  extract: scripts.extract,
142
146
  format: scripts.format,
package/index.css CHANGED
@@ -1,5 +1,4 @@
1
- @import "tailwindcss";
2
- @plugin "daisyui";
1
+ @import "evikit/css";
3
2
 
4
3
  [lang="uk"] p {
5
4
  text-wrap: balance;
package/index.js CHANGED
@@ -1,21 +1,16 @@
1
1
  import { listen, production } from "evikit/server";
2
2
  import express from "express";
3
- import { readFile } from "node:fs/promises";
4
3
  import swaggerUi from "swagger-ui-express";
5
4
 
6
5
  import { api } from "./src/api.js";
7
6
  import { prerender } from "./src/prerender.js";
8
7
 
9
8
  const app = express();
9
+ app.use("/node_modules", express.static("./node_modules"));
10
10
  app.use("/static", express.static("./static"));
11
11
  app.use("/robots.txt", express.static("./static/robots.txt"));
12
12
  app.use(api().onRequest);
13
13
  app.use("/openapi", swaggerUi.serve, swaggerUi.setup(api().openapi));
14
14
  app.use("/", express.static("./dist", { index: false, redirect: false }));
15
- app.use(
16
- production({
17
- html: await readFile("./dist/index.html", "utf-8"),
18
- prerender,
19
- }),
20
- );
15
+ app.use(production({ prerender }));
21
16
  listen(app);
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "create-evikit",
3
- "version": "2.11.0",
3
+ "version": "2.14.0",
4
4
  "type": "module",
5
5
  "bin": "bin/create-evikit.js",
6
6
  "scripts": {
7
- "dev": "vite dev",
8
- "build": "tsc && vite build",
9
- "start": "cross-env NODE_ENV=production node --env-file=.env index.js",
7
+ "dev": "node --env-file-if-exists=.env index.js dev",
8
+ "build": "tsc && node --env-file-if-exists=.env index.js build",
9
+ "start": "cross-env NODE_ENV=production node --env-file-if-exists=.env index.js",
10
10
  "extract": "evikit-extract",
11
11
  "format": "prettier --write . && eslint --fix .",
12
12
  "lint": "prettier --check . && eslint ."
@@ -22,6 +22,7 @@
22
22
  "@types/node": "^26.6.2",
23
23
  "@types/swagger-ui-express": "^4.1.8",
24
24
  "daisyui": "^5.7.46",
25
+ "esbuild": "^0.28.2",
25
26
  "eslint": "^10.11.0",
26
27
  "eslint-config-prettier": "^10.1.8",
27
28
  "eslint-plugin-perfectionist": "^5.12.1",
@@ -37,7 +38,7 @@
37
38
  "accept-language": "^3.0.20",
38
39
  "classnames": "^2.5.1",
39
40
  "cross-env": "^10.1.0",
40
- "evikit": "^2.11.0",
41
+ "evikit": "^2.14.1",
41
42
  "express": "^5.2.1",
42
43
  "file-type": "^22.1.1",
43
44
  "hoofd": "^1.7.3",
@@ -47,6 +48,7 @@
47
48
  "valibot": "^1.5.0"
48
49
  },
49
50
  "allowScripts": {
50
- "@scarf/scarf": false
51
+ "@scarf/scarf": false,
52
+ "esbuild": true
51
53
  }
52
54
  }
@@ -20,6 +20,28 @@ export const template = [
20
20
  "index.html",
21
21
  ];
22
22
 
23
+ export const templateIndexJs = `
24
+ import { listen, production } from "evikit/server";
25
+ import express from "express";
26
+ import { readFile } from "node:fs/promises";
27
+ import swaggerUi from "swagger-ui-express";
28
+
29
+ import { api } from "./src/api.js";
30
+ import { prerender } from "./src/prerender.js";
31
+
32
+ const app = express();
33
+ app.use(api().onRequest);
34
+ app.use("/openapi", swaggerUi.serve, swaggerUi.setup(api().openapi));
35
+ app.use("/", express.static("./dist", { index: false, redirect: false }));
36
+ app.use(
37
+ production({
38
+ html: await readFile("./dist/index.html", "utf-8"),
39
+ prerender,
40
+ }),
41
+ );
42
+ listen(app);
43
+ `.trimStart();
44
+
23
45
  export const HomeServer = {
24
46
  get: endpoint(HomeGet, async () => {
25
47
  const latest = Object.entries(
@@ -38,7 +60,10 @@ export const HomeServer = {
38
60
  return json({
39
61
  File: Object.fromEntries(
40
62
  await Promise.all(
41
- template.map(async (path) => [path, await readFile(path, "utf8")]),
63
+ template.map(async (path) => [
64
+ path,
65
+ path == "index.js" ? templateIndexJs : await readFile(path, "utf8"),
66
+ ]),
42
67
  ),
43
68
  ),
44
69
  npm: { publishedAt: latest[1], version: latest[0] },
@@ -9,11 +9,11 @@ export const TodoServer = {
9
9
  ),
10
10
 
11
11
  post: endpoint(TodoPost, async ({ input }) => {
12
- const [todo] = db.Todo.select({ where: { text: input.text } });
12
+ const [todo] = db.Todo.select({ text: input.text });
13
13
  if (todo) {
14
14
  db.Todo.update({
15
15
  set: { doneAt: todo.doneAt ? undefined : Date.now() },
16
- where: { text: todo.text },
16
+ text: todo.text,
17
17
  });
18
18
  } else {
19
19
  db.Todo.upsert({ createdAt: Date.now(), text: input.text });
@@ -132,7 +132,7 @@ export function HomePage() {
132
132
  pre(
133
133
  null,
134
134
  code(
135
- { class: "!bg-transparent !border-0 shj-lang-bash" },
135
+ { class: "!bg-transparent !border-none shj-lang-bash" },
136
136
  `
137
137
  npx create-evikit my-app
138
138
  cd my-app
@@ -307,7 +307,7 @@ function Code({ children, class: className, file, lang, note, tag }) {
307
307
  const inner = pre(
308
308
  { class: "mt-4 overflow-auto text-sm" },
309
309
  code(
310
- { class: `!border-0 shj-lang-${lang} w-full` },
310
+ { class: `!border-none shj-lang-${lang} w-full` },
311
311
  file
312
312
  ?.replace(/.*EviKit.*\r?\n/g, "")
313
313
  .replace(/\{[0-9a-z,\s]*?\} from/gi, (match) =>
@@ -322,7 +322,7 @@ function Code({ children, class: className, file, lang, note, tag }) {
322
322
  .replace(/.*\/static.*\s+/g, ""),
323
323
  ),
324
324
  );
325
- const more = note ? p({ class: "mt-5", ...sanitize(note) }) : undefined;
325
+ const more = note ? p({ class: "mt-6", ...sanitize(note) }) : undefined;
326
326
  const style = `${className || ""} ${darkBg} mx-0 overflow-hidden p-4 rounded-xl`;
327
327
  return tag == "details"
328
328
  ? details({ class: style }, summary(null, children), inner, more)