primate 0.34.0 → 0.35.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.
- package/lib/app.tsconfig.json +3 -50
- package/lib/commands/build.d.ts +1 -2
- package/lib/commands/build.js +10 -6
- package/lib/commands/dev.d.ts +1 -1
- package/lib/commands/dev.js +2 -6
- package/lib/commands/get-flag.d.ts +2 -0
- package/lib/commands/get-flag.js +5 -0
- package/lib/commands/index.d.ts +3 -1
- package/lib/commands/init.js +119 -98
- package/lib/commands/serve.d.ts +1 -2
- package/lib/commands/serve.js +6 -2
- package/lib/commands/test.js +2 -2
- package/lib/init.js +2 -2
- package/lib/public/database/Store.d.ts +2 -0
- package/lib/public/database/Store.js +2 -0
- package/lib/public/fs/FileRef.d.ts +2 -0
- package/lib/public/fs/FileRef.js +2 -0
- package/lib/public/pema.d.ts +2 -0
- package/lib/public/pema.js +2 -0
- package/lib/public/response.d.ts +2 -1
- package/package.json +5 -6
- package/lib/public/Loader.d.ts +0 -2
- package/lib/public/Loader.js +0 -2
- package/lib/public/load-text.d.ts +0 -4
- package/lib/public/load-text.js +0 -3
- package/lib/public/session/Manager.d.ts +0 -2
- package/lib/public/session/Manager.js +0 -2
package/lib/app.tsconfig.json
CHANGED
|
@@ -4,58 +4,11 @@
|
|
|
4
4
|
"baseUrl": "${configDir}",
|
|
5
5
|
"target": "esnext",
|
|
6
6
|
"module": "nodenext",
|
|
7
|
-
"moduleResolution": "
|
|
7
|
+
"moduleResolution": "bundler",
|
|
8
8
|
"strict": true,
|
|
9
9
|
"skipLibCheck": true,
|
|
10
|
-
"customConditions": ["apekit"],
|
|
11
10
|
"erasableSyntaxOnly": true,
|
|
12
11
|
"exactOptionalPropertyTypes": true,
|
|
13
|
-
"allowImportingTsExtensions": true
|
|
14
|
-
|
|
15
|
-
"paths": {
|
|
16
|
-
"#route/*": ["routes/*"],
|
|
17
|
-
"#component/*": [
|
|
18
|
-
"components/*",
|
|
19
|
-
"components/*.tsx",
|
|
20
|
-
"components/*.jsx",
|
|
21
|
-
"components/*.vue",
|
|
22
|
-
"components/*.svelte",
|
|
23
|
-
"components/*.component.ts",
|
|
24
|
-
"components/*.ts",
|
|
25
|
-
"components/*.js"
|
|
26
|
-
],
|
|
27
|
-
"#hook/*": ["hooks/*", "hooks/*.ts", "hooks/*.js"],
|
|
28
|
-
"#lib/*": ["lib/*", "lib/*.ts", "lib/*.js"],
|
|
29
|
-
"#store/*": ["stores/*", "stores/*.ts", "stores/*.js"],
|
|
30
|
-
"#locale/*": ["locales/*", "locales/*.ts", "locales/*.js"],
|
|
31
|
-
"#module/*": ["modules/*", "modules/*.ts", "modules/*.js"],
|
|
32
|
-
"#config/*": ["config/*", "config/*.ts", "config/*.js"],
|
|
33
|
-
"#static/*": ["static/*", "static/*.ts", "static/*.js"],
|
|
34
|
-
"#database/*": ["config/database/*.ts", "config/database/*.js"],
|
|
35
|
-
"#app": ["config/app.ts", "config/app.js"],
|
|
36
|
-
"#session": ["config/session.ts", "config/session.js"],
|
|
37
|
-
"#i18n": ["config/i18n.ts", "config/i18n.js"],
|
|
38
|
-
"#database": [
|
|
39
|
-
"config/database/index.ts",
|
|
40
|
-
"config/database/index.js",
|
|
41
|
-
"config/database/default.js",
|
|
42
|
-
"config/database/default.ts"
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
"include": [
|
|
47
|
-
"${configDir}/config",
|
|
48
|
-
"${configDir}/routes",
|
|
49
|
-
"${configDir}/views",
|
|
50
|
-
"${configDir}/components",
|
|
51
|
-
"${configDir}/hooks",
|
|
52
|
-
"${configDir}/lib",
|
|
53
|
-
"${configDir}/stores",
|
|
54
|
-
"${configDir}/modules",
|
|
55
|
-
"${configDir}/test",
|
|
56
|
-
"${configDir}/static",
|
|
57
|
-
"${configDir}/primate.config.js",
|
|
58
|
-
"${configDir}/primate.config.ts"
|
|
59
|
-
],
|
|
60
|
-
"exclude": ["node_modules"]
|
|
12
|
+
"allowImportingTsExtensions": true
|
|
13
|
+
}
|
|
61
14
|
}
|
package/lib/commands/build.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import type Mode from "@primate/core/Mode";
|
|
2
|
-
|
|
3
|
-
export default _default;
|
|
2
|
+
export default function app(flags: string[], mode?: Mode): Promise<true | undefined>;
|
|
4
3
|
//# sourceMappingURL=build.d.ts.map
|
package/lib/commands/build.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import build from "@primate/core/build";
|
|
2
|
-
|
|
2
|
+
import get_flag from "./get-flag.js";
|
|
3
3
|
// build for production
|
|
4
|
-
export default (flags, mode = "production")
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export default function app(flags, mode = "production") {
|
|
5
|
+
const build_flags = {
|
|
6
|
+
mode: mode,
|
|
7
|
+
target: get_flag(flags, "target"),
|
|
8
|
+
dir: get_flag(flags, "dir"),
|
|
9
|
+
};
|
|
10
|
+
return build(build_flags);
|
|
11
|
+
}
|
|
12
|
+
;
|
|
9
13
|
//# sourceMappingURL=build.js.map
|
package/lib/commands/dev.d.ts
CHANGED
package/lib/commands/dev.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import build from "./build.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export default async () => {
|
|
5
|
-
// will only serve is build is successful
|
|
6
|
-
await build(["--target=web"], "development") === true && serve();
|
|
7
|
-
};
|
|
2
|
+
// build for development
|
|
3
|
+
export default () => build([], "development");
|
|
8
4
|
//# sourceMappingURL=dev.js.map
|
package/lib/commands/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { default as build } from "./build.js";
|
|
2
|
+
import { default as serve } from "./serve.js";
|
|
3
|
+
declare const _default: (name: string) => typeof build | typeof serve;
|
|
2
4
|
export default _default;
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/commands/init.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
+
import dim from "@rcompat/cli/color/dim";
|
|
2
|
+
import green from "@rcompat/cli/color/green";
|
|
1
3
|
import cancel from "@rcompat/cli/prompts/cancel";
|
|
2
4
|
import intro from "@rcompat/cli/prompts/intro";
|
|
3
|
-
import
|
|
5
|
+
import is_cancel from "@rcompat/cli/prompts/is-cancel";
|
|
4
6
|
import multiselect from "@rcompat/cli/prompts/multiselect";
|
|
5
7
|
import outro from "@rcompat/cli/prompts/outro";
|
|
6
8
|
import select from "@rcompat/cli/prompts/select";
|
|
7
9
|
import text from "@rcompat/cli/prompts/text";
|
|
8
10
|
import FileRef from "@rcompat/fs/FileRef";
|
|
9
|
-
|
|
11
|
+
function abort() {
|
|
12
|
+
return cancel("Aborted");
|
|
13
|
+
}
|
|
10
14
|
const FRONTEND_OPTIONS = [
|
|
11
15
|
{ label: "Angular", value: "angular" },
|
|
12
16
|
{ label: "Eta", value: "eta" },
|
|
@@ -56,34 +60,33 @@ export default async function init() {
|
|
|
56
60
|
let directory;
|
|
57
61
|
let target;
|
|
58
62
|
while (true) {
|
|
59
|
-
const ans = await text({
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
const ans = await text({
|
|
64
|
+
message: "Directory to create app?", initial: ".",
|
|
65
|
+
});
|
|
66
|
+
if (typeof ans === "symbol" || is_cancel(ans))
|
|
67
|
+
return abort();
|
|
62
68
|
target = new FileRef(ans);
|
|
63
69
|
if (await empty(target)) {
|
|
64
70
|
directory = ans;
|
|
65
|
-
break; //
|
|
71
|
+
break; // valid directory found, exit loop
|
|
66
72
|
}
|
|
67
|
-
//
|
|
73
|
+
// directory not empty, show error but continue loop
|
|
68
74
|
console.log("Directory not empty, choose another.");
|
|
69
75
|
}
|
|
70
|
-
|
|
71
|
-
const fronts = await multiselect({
|
|
76
|
+
const frontends = await multiselect({
|
|
72
77
|
message: "Choose frontend (press Enter to skip)",
|
|
73
78
|
options: FRONTEND_OPTIONS,
|
|
74
|
-
initial: [],
|
|
79
|
+
initial: [],
|
|
75
80
|
});
|
|
76
|
-
if (typeof
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
const backs = await multiselect({
|
|
81
|
+
if (typeof frontends === "symbol" || is_cancel(frontends))
|
|
82
|
+
return abort();
|
|
83
|
+
const backends = await multiselect({
|
|
80
84
|
message: "Choose backend (press Enter to skip)",
|
|
81
85
|
options: BACKEND_OPTIONS,
|
|
82
|
-
initial: [],
|
|
86
|
+
initial: [],
|
|
83
87
|
});
|
|
84
|
-
if (typeof
|
|
85
|
-
return
|
|
86
|
-
// runtime (must choose one)
|
|
88
|
+
if (typeof backends === "symbol" || is_cancel(backends))
|
|
89
|
+
return abort();
|
|
87
90
|
const runtime = await select({
|
|
88
91
|
message: "Choose runtime",
|
|
89
92
|
options: [
|
|
@@ -93,18 +96,16 @@ export default async function init() {
|
|
|
93
96
|
],
|
|
94
97
|
initial: 0,
|
|
95
98
|
});
|
|
96
|
-
if (typeof runtime === "symbol" ||
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
const dbChoices = await multiselect({
|
|
99
|
+
if (typeof runtime === "symbol" || is_cancel(runtime))
|
|
100
|
+
return abort();
|
|
101
|
+
const dbs = await multiselect({
|
|
100
102
|
message: "Choose a database (press Enter to skip)",
|
|
101
103
|
options: DATABASE_OPTIONS,
|
|
102
|
-
initial: [],
|
|
104
|
+
initial: [],
|
|
103
105
|
});
|
|
104
|
-
if (typeof
|
|
105
|
-
return
|
|
106
|
-
const db =
|
|
107
|
-
// i18n
|
|
106
|
+
if (typeof dbs === "symbol" || is_cancel(dbs))
|
|
107
|
+
return abort();
|
|
108
|
+
const db = dbs[0];
|
|
108
109
|
const i18n = await select({
|
|
109
110
|
message: "Enable i18n?",
|
|
110
111
|
options: [
|
|
@@ -113,10 +114,9 @@ export default async function init() {
|
|
|
113
114
|
],
|
|
114
115
|
initial: 1,
|
|
115
116
|
});
|
|
116
|
-
if (typeof i18n === "symbol" ||
|
|
117
|
-
return
|
|
118
|
-
const
|
|
119
|
-
// sessions
|
|
117
|
+
if (typeof i18n === "symbol" || is_cancel(i18n))
|
|
118
|
+
return abort();
|
|
119
|
+
const with_i18n = i18n === "yes";
|
|
120
120
|
const sessions = await select({
|
|
121
121
|
message: "Configure sessions?",
|
|
122
122
|
options: [
|
|
@@ -125,32 +125,28 @@ export default async function init() {
|
|
|
125
125
|
],
|
|
126
126
|
initial: 1,
|
|
127
127
|
});
|
|
128
|
-
if (typeof sessions === "symbol" ||
|
|
129
|
-
return
|
|
128
|
+
if (typeof sessions === "symbol" || is_cancel(sessions))
|
|
129
|
+
return abort();
|
|
130
130
|
const withSessions = sessions === "yes";
|
|
131
|
-
// scaffold dirs
|
|
132
131
|
await target.create({ recursive: true });
|
|
133
132
|
await target.join("routes").create({ recursive: true });
|
|
134
133
|
await target.join("views").create({ recursive: true });
|
|
135
|
-
if (db)
|
|
134
|
+
if (db !== undefined)
|
|
136
135
|
await target.join("stores").create({ recursive: true });
|
|
137
136
|
// files
|
|
138
137
|
await gitignore(target);
|
|
139
|
-
await tsconfig_json(target);
|
|
140
|
-
await app_config(target, {
|
|
141
|
-
if (
|
|
138
|
+
await tsconfig_json(target, { frontends });
|
|
139
|
+
await app_config(target, { frontends: frontends, backends: backends, runtime });
|
|
140
|
+
if (with_i18n)
|
|
142
141
|
await i18n_config(target);
|
|
143
142
|
if (withSessions)
|
|
144
143
|
await session_config(target);
|
|
145
144
|
if (db)
|
|
146
145
|
await database_config(target, db);
|
|
147
146
|
await package_json(target, { directory, runtime });
|
|
148
|
-
const packages = compute_packages({
|
|
149
|
-
const install =
|
|
150
|
-
outro(
|
|
151
|
-
"Done, now run",
|
|
152
|
-
`\n ${install.print}`,
|
|
153
|
-
].join("\n"));
|
|
147
|
+
const packages = compute_packages({ frontends: frontends, backends: backends, db });
|
|
148
|
+
const install = build_install_command(runtime, packages, directory);
|
|
149
|
+
outro(`${green("done, now run")} ${dim(install.print)}`);
|
|
154
150
|
process.exit();
|
|
155
151
|
}
|
|
156
152
|
async function empty(directory) {
|
|
@@ -182,29 +178,28 @@ async function gitignore(root) {
|
|
|
182
178
|
await gi.write(content);
|
|
183
179
|
}
|
|
184
180
|
async function app_config(root, c) {
|
|
185
|
-
const
|
|
186
|
-
await
|
|
187
|
-
const
|
|
188
|
-
.map((f) => `import ${
|
|
181
|
+
const config = root.join("config").join("app.ts");
|
|
182
|
+
await config.directory.create({ recursive: true });
|
|
183
|
+
const frontend_imports = c.frontends
|
|
184
|
+
.map((f) => `import ${to_ident(f)} from "@primate/${f}";`)
|
|
189
185
|
.join("\n");
|
|
190
|
-
const
|
|
191
|
-
.map((b) => `import ${
|
|
186
|
+
const backend_imports = c.backends
|
|
187
|
+
.map((b) => `import ${to_ident(b)} from "@primate/${b}";`)
|
|
192
188
|
.join("\n");
|
|
193
189
|
const modules = [
|
|
194
|
-
...c.
|
|
195
|
-
...c.
|
|
190
|
+
...c.frontends.map((f) => `${to_ident(f)}()`),
|
|
191
|
+
...c.backends.map((b) => `${to_ident(b)}()`),
|
|
196
192
|
];
|
|
197
|
-
const body =
|
|
198
|
-
${
|
|
199
|
-
${
|
|
193
|
+
const body = `import config from "primate/config";
|
|
194
|
+
${frontend_imports}
|
|
195
|
+
${backend_imports}
|
|
200
196
|
|
|
201
197
|
export default config({
|
|
202
198
|
modules: [
|
|
203
199
|
${modules.join(",\n ")}
|
|
204
200
|
],
|
|
205
|
-
})
|
|
206
|
-
|
|
207
|
-
await cfg.write(body);
|
|
201
|
+
});`;
|
|
202
|
+
await config.write(body);
|
|
208
203
|
}
|
|
209
204
|
// i18n scaffold: config + a default locale file
|
|
210
205
|
async function i18n_config(root) {
|
|
@@ -214,12 +209,10 @@ async function i18n_config(root) {
|
|
|
214
209
|
await en_us.directory.create({ recursive: true });
|
|
215
210
|
await i18i.directory.create({ recursive: true });
|
|
216
211
|
const locale = `import locale from "primate/i18n/locale";
|
|
217
|
-
|
|
218
212
|
export default locale({
|
|
219
213
|
hi: "Hello",
|
|
220
214
|
placeheld: "Hello, {name}",
|
|
221
|
-
})
|
|
222
|
-
`;
|
|
215
|
+
});`;
|
|
223
216
|
await en_us.write(locale);
|
|
224
217
|
const config = `import en from "#locale/en-US";
|
|
225
218
|
import i18n from "primate/config/i18n";
|
|
@@ -229,27 +222,22 @@ export default i18n({
|
|
|
229
222
|
locales: {
|
|
230
223
|
"en-US": en,
|
|
231
224
|
},
|
|
232
|
-
})
|
|
233
|
-
`;
|
|
225
|
+
});`;
|
|
234
226
|
await i18i.write(config);
|
|
235
227
|
}
|
|
236
228
|
async function session_config(root) {
|
|
237
229
|
const file = root.join("config").join("session.ts");
|
|
238
230
|
await file.directory.create({ recursive: true });
|
|
239
231
|
const body = `import session from "primate/config/session";
|
|
240
|
-
|
|
241
|
-
export default session({});
|
|
242
|
-
`;
|
|
232
|
+
export default session({});`;
|
|
243
233
|
await file.write(body);
|
|
244
234
|
}
|
|
245
235
|
async function database_config(root, db) {
|
|
246
236
|
const file = root.join("config").join("database").join("index.ts");
|
|
247
237
|
await file.directory.create({ recursive: true });
|
|
248
|
-
const ident =
|
|
238
|
+
const ident = to_ident(db);
|
|
249
239
|
const body = `import ${ident} from "@primate/${db}";
|
|
250
|
-
|
|
251
|
-
export default ${ident}();
|
|
252
|
-
`;
|
|
240
|
+
export default ${ident}();`;
|
|
253
241
|
await file.write(body);
|
|
254
242
|
}
|
|
255
243
|
async function package_json(root, c) {
|
|
@@ -283,78 +271,111 @@ function safe(s) {
|
|
|
283
271
|
return s.trim().toLowerCase().replace(/\s+/g, "-")
|
|
284
272
|
.replace(/[^a-z0-9._-]/g, "") || "primate-app";
|
|
285
273
|
}
|
|
286
|
-
function
|
|
274
|
+
function to_ident(token) {
|
|
287
275
|
// turn tokens like "web-components" into valid identifiers: "web_components"
|
|
288
276
|
return token.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
289
277
|
}
|
|
290
278
|
function compute_packages(args) {
|
|
291
279
|
const deps = new Set();
|
|
292
|
-
const
|
|
280
|
+
const dev_deps = new Set();
|
|
293
281
|
deps.add("primate");
|
|
294
282
|
// Always add TypeScript as dev dependency
|
|
295
|
-
|
|
283
|
+
dev_deps.add("typescript");
|
|
296
284
|
// frontends → @primate/<token> (+ peer deps)
|
|
297
|
-
for (const f of args.
|
|
285
|
+
for (const f of args.frontends) {
|
|
298
286
|
deps.add(`@primate/${f}`);
|
|
299
287
|
const extras = FRONTEND_PEER_DEPS[f] || [];
|
|
300
288
|
for (const extra of extras)
|
|
301
289
|
deps.add(extra);
|
|
302
290
|
}
|
|
291
|
+
if (args.frontends.includes("svelte")) {
|
|
292
|
+
dev_deps.add("@plsp/svelte");
|
|
293
|
+
}
|
|
303
294
|
// backends → @primate/<token>
|
|
304
|
-
for (const b of args.
|
|
295
|
+
for (const b of args.backends)
|
|
305
296
|
deps.add(`@primate/${b}`);
|
|
306
|
-
}
|
|
307
297
|
// database → @primate/<token>, if selected
|
|
308
298
|
if (args.db)
|
|
309
299
|
deps.add(`@primate/${args.db}`);
|
|
310
300
|
return {
|
|
311
301
|
dependencies: Array.from(deps),
|
|
312
|
-
|
|
302
|
+
dev_dependencies: Array.from(dev_deps),
|
|
313
303
|
};
|
|
314
304
|
}
|
|
315
|
-
function
|
|
305
|
+
function sh_quote(p) {
|
|
316
306
|
// POSIX shell-safe quoting
|
|
317
307
|
return `'${p.replace(/'/g, "'\\''")}'`;
|
|
318
308
|
}
|
|
319
|
-
function
|
|
320
|
-
const { dependencies,
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
309
|
+
function build_install_command(runtime, packages, dir) {
|
|
310
|
+
const { dependencies, dev_dependencies } = packages;
|
|
311
|
+
const all_pkgs = [...dependencies, ...dev_dependencies];
|
|
312
|
+
if (all_pkgs.length === 0) {
|
|
323
313
|
return { print: "No packages to install.", run: "" };
|
|
324
314
|
}
|
|
325
|
-
const cd = `cd ${
|
|
315
|
+
const cd = dir === "." ? "" : `cd ${sh_quote(dir)} && `;
|
|
326
316
|
if (runtime === "bun") {
|
|
327
|
-
const
|
|
317
|
+
const dep_cmd = dependencies.length > 0
|
|
328
318
|
? `bun add ${dependencies.join(" ")}`
|
|
329
319
|
: "";
|
|
330
|
-
const
|
|
331
|
-
? `bun add -d ${
|
|
320
|
+
const dev_cmd = dev_dependencies.length > 0
|
|
321
|
+
? `bun add -d ${dev_dependencies.join(" ")}`
|
|
332
322
|
: "";
|
|
333
|
-
const commands = [
|
|
323
|
+
const commands = [dep_cmd, dev_cmd].filter(Boolean);
|
|
334
324
|
return { print: cd + commands.join(" && "), run: "" };
|
|
335
325
|
}
|
|
336
326
|
if (runtime === "deno") {
|
|
337
|
-
const
|
|
327
|
+
const dep_cmd = dependencies.length > 0
|
|
338
328
|
? `deno add ${dependencies.map(d => `npm:${d}`).join(" ")}`
|
|
339
329
|
: "";
|
|
340
|
-
const
|
|
341
|
-
? `deno add -D ${
|
|
330
|
+
const dev_cmd = dev_dependencies.length > 0
|
|
331
|
+
? `deno add -D ${dev_dependencies.map(d => `npm:${d}`).join(" ")}`
|
|
342
332
|
: "";
|
|
343
|
-
const commands = [
|
|
333
|
+
const commands = [dep_cmd, dev_cmd].filter(Boolean);
|
|
344
334
|
return { print: cd + commands.join(" && "), run: "" };
|
|
345
335
|
}
|
|
346
|
-
const
|
|
336
|
+
const dep_cmd = dependencies.length > 0 ?
|
|
347
337
|
`npm install ${dependencies.join(" ")}`
|
|
348
338
|
: "";
|
|
349
|
-
const
|
|
350
|
-
? `npm install -D ${
|
|
339
|
+
const dev_cmd = dev_dependencies.length > 0
|
|
340
|
+
? `npm install -D ${dev_dependencies.join(" ")}`
|
|
351
341
|
: "";
|
|
352
|
-
const commands = [
|
|
342
|
+
const commands = [dep_cmd, dev_cmd].filter(Boolean);
|
|
353
343
|
return { print: cd + commands.join(" && "), run: "" };
|
|
354
344
|
}
|
|
355
|
-
async function tsconfig_json(root) {
|
|
356
|
-
|
|
345
|
+
async function tsconfig_json(root, opts) {
|
|
346
|
+
const is_react = opts.frontends.includes("react");
|
|
347
|
+
const is_svelte = opts.frontends.includes("svelte");
|
|
348
|
+
const tsconfig = {
|
|
357
349
|
extends: "primate/tsconfig",
|
|
358
|
-
|
|
350
|
+
compilerOptions: {
|
|
351
|
+
baseUrl: "${configDir}",
|
|
352
|
+
paths: {
|
|
353
|
+
"#config/*": ["config/*"],
|
|
354
|
+
"#session": ["config/session"],
|
|
355
|
+
"#i18n": ["config/i18n"],
|
|
356
|
+
"#view/*": ["views/*"],
|
|
357
|
+
"#component/*": ["components/*"],
|
|
358
|
+
"#store/*": ["stores/*"],
|
|
359
|
+
"#locale/*": ["locales/*"],
|
|
360
|
+
"#static/*": ["static/*"],
|
|
361
|
+
},
|
|
362
|
+
},
|
|
363
|
+
include: [
|
|
364
|
+
"config",
|
|
365
|
+
"views",
|
|
366
|
+
"components",
|
|
367
|
+
"routes",
|
|
368
|
+
"stores",
|
|
369
|
+
"locales",
|
|
370
|
+
"static",
|
|
371
|
+
"test",
|
|
372
|
+
],
|
|
373
|
+
exclude: ["node_modules"],
|
|
374
|
+
};
|
|
375
|
+
if (is_react)
|
|
376
|
+
tsconfig.compilerOptions.jsx = "react-jsx";
|
|
377
|
+
if (is_svelte)
|
|
378
|
+
tsconfig.compilerOptions.plugins = [{ name: "@plsp/svelte" }];
|
|
379
|
+
await root.join("tsconfig.json").writeJSON(tsconfig);
|
|
359
380
|
}
|
|
360
381
|
//# sourceMappingURL=init.js.map
|
package/lib/commands/serve.d.ts
CHANGED
package/lib/commands/serve.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import FileRef from "@rcompat/fs/FileRef";
|
|
2
|
-
import root from "@rcompat/
|
|
2
|
+
import root from "@rcompat/fs/project/root";
|
|
3
|
+
import get_flag from "./get-flag.js";
|
|
3
4
|
const load = async () => {
|
|
4
5
|
try {
|
|
5
6
|
return await root();
|
|
@@ -9,5 +10,8 @@ const load = async () => {
|
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
12
|
// serve from build directory
|
|
12
|
-
export default async (
|
|
13
|
+
export default async function app(flags = []) {
|
|
14
|
+
const dir = get_flag(flags, "dir") ?? "build";
|
|
15
|
+
return (await load()).join(`./${dir}/server.js`).import();
|
|
16
|
+
}
|
|
13
17
|
//# sourceMappingURL=serve.js.map
|
package/lib/commands/test.js
CHANGED
|
@@ -2,7 +2,7 @@ import { tests } from "#test";
|
|
|
2
2
|
import build from "@primate/core/build";
|
|
3
3
|
import green from "@rcompat/cli/color/green";
|
|
4
4
|
import red from "@rcompat/cli/color/red";
|
|
5
|
-
import root from "@rcompat/
|
|
5
|
+
import root from "@rcompat/fs/project/root";
|
|
6
6
|
import entries from "@rcompat/record/entries";
|
|
7
7
|
import equals from "@rcompat/test/equals";
|
|
8
8
|
import includes from "@rcompat/test/includes";
|
|
@@ -18,7 +18,7 @@ const first_error = (left, right) => {
|
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
export default async () => {
|
|
21
|
-
await build("testing"
|
|
21
|
+
await build({ mode: "testing" });
|
|
22
22
|
const app = (await serve()).default;
|
|
23
23
|
const files = await (await root()).join(directory)
|
|
24
24
|
.list(({ path }) => path.endsWith(".ts") || path.endsWith(".js"));
|
package/lib/init.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import blue from "@rcompat/cli/color/blue";
|
|
2
2
|
import bold from "@rcompat/cli/color/bold";
|
|
3
3
|
import print from "@rcompat/cli/print";
|
|
4
|
-
import
|
|
4
|
+
import pkg from "@rcompat/fs/project/package";
|
|
5
5
|
import find from "./commands/index.js";
|
|
6
6
|
export default async (...args) => {
|
|
7
7
|
const [command, ...flags] = args;
|
|
8
|
-
const { name, version, } = await (await
|
|
8
|
+
const { name, version, } = await (await pkg(import.meta.url)).json();
|
|
9
9
|
print(blue(bold(name)), blue(version), "\n");
|
|
10
10
|
find(command)(flags);
|
|
11
11
|
};
|
package/lib/public/response.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import binary from "@primate/core/response/binary";
|
|
2
2
|
import error from "@primate/core/response/error";
|
|
3
|
+
import view from "@primate/core/response/view";
|
|
3
4
|
export type { default as ViewResponse } from "@primate/core/frontend/ViewResponse";
|
|
4
5
|
export type { default as ResponseFunction } from "@primate/core/response/ResponseFunction";
|
|
5
6
|
export type { default as ServeApp } from "@primate/core/ServeApp";
|
|
@@ -15,7 +16,7 @@ declare const _default: {
|
|
|
15
16
|
}): undefined;
|
|
16
17
|
}, init?: ResponseInit) => (app: import("@primate/core/ServeApp").default) => import("@rcompat/type/MaybePromise").default<Response>;
|
|
17
18
|
text: (body: string, init?: ResponseInit) => (app: import("@primate/core/ServeApp").default) => import("@rcompat/type/MaybePromise").default<Response>;
|
|
18
|
-
view:
|
|
19
|
+
view: typeof view;
|
|
19
20
|
ws: (actions: import("@rcompat/http/Actions").default) => import("@primate/core/response/ResponseFunction").default;
|
|
20
21
|
};
|
|
21
22
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "primate",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.35.1",
|
|
4
4
|
"description": "The universal web framework",
|
|
5
5
|
"homepage": "https://primate.run",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
@@ -19,18 +19,17 @@
|
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@rcompat/record": "^0.9.1",
|
|
22
|
-
"pema": "^0.
|
|
22
|
+
"pema": "^0.4.0"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@rcompat/args": "^0.8.0",
|
|
26
26
|
"@rcompat/cli": "^0.11.3",
|
|
27
|
-
"@rcompat/fs": "^0.
|
|
28
|
-
"@rcompat/http": "~0.
|
|
29
|
-
"@rcompat/package": "^0.22.0",
|
|
27
|
+
"@rcompat/fs": "^0.22.3",
|
|
28
|
+
"@rcompat/http": "~0.16.0",
|
|
30
29
|
"@rcompat/runtime": "^0.6.0",
|
|
31
30
|
"@rcompat/string": "^0.10.0",
|
|
32
31
|
"@rcompat/test": "^0.5.0",
|
|
33
|
-
"@primate/core": "^0.
|
|
32
|
+
"@primate/core": "^0.4.4"
|
|
34
33
|
},
|
|
35
34
|
"engines": {
|
|
36
35
|
"node": ">=20"
|
package/lib/public/Loader.d.ts
DELETED
package/lib/public/Loader.js
DELETED
package/lib/public/load-text.js
DELETED