primate 0.34.0 → 0.35.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.
- 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 +136 -109
- 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,15 @@
|
|
|
1
1
|
import cancel from "@rcompat/cli/prompts/cancel";
|
|
2
2
|
import intro from "@rcompat/cli/prompts/intro";
|
|
3
|
-
import
|
|
3
|
+
import is_cancel from "@rcompat/cli/prompts/is-cancel";
|
|
4
4
|
import multiselect from "@rcompat/cli/prompts/multiselect";
|
|
5
5
|
import outro from "@rcompat/cli/prompts/outro";
|
|
6
6
|
import select from "@rcompat/cli/prompts/select";
|
|
7
7
|
import text from "@rcompat/cli/prompts/text";
|
|
8
8
|
import FileRef from "@rcompat/fs/FileRef";
|
|
9
9
|
import dedent from "@rcompat/string/dedent";
|
|
10
|
+
function abort() {
|
|
11
|
+
return cancel("Aborted");
|
|
12
|
+
}
|
|
10
13
|
const FRONTEND_OPTIONS = [
|
|
11
14
|
{ label: "Angular", value: "angular" },
|
|
12
15
|
{ label: "Eta", value: "eta" },
|
|
@@ -56,34 +59,33 @@ export default async function init() {
|
|
|
56
59
|
let directory;
|
|
57
60
|
let target;
|
|
58
61
|
while (true) {
|
|
59
|
-
const ans = await text({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
const ans = await text({
|
|
63
|
+
message: "Directory to create app?", initial: ".",
|
|
64
|
+
});
|
|
65
|
+
if (typeof ans === "symbol" || is_cancel(ans))
|
|
66
|
+
return abort();
|
|
62
67
|
target = new FileRef(ans);
|
|
63
68
|
if (await empty(target)) {
|
|
64
69
|
directory = ans;
|
|
65
|
-
break; //
|
|
70
|
+
break; // valid directory found, exit loop
|
|
66
71
|
}
|
|
67
|
-
//
|
|
72
|
+
// directory not empty, show error but continue loop
|
|
68
73
|
console.log("Directory not empty, choose another.");
|
|
69
74
|
}
|
|
70
|
-
|
|
71
|
-
const fronts = await multiselect({
|
|
75
|
+
const frontends = await multiselect({
|
|
72
76
|
message: "Choose frontend (press Enter to skip)",
|
|
73
77
|
options: FRONTEND_OPTIONS,
|
|
74
|
-
initial: [],
|
|
78
|
+
initial: [],
|
|
75
79
|
});
|
|
76
|
-
if (typeof
|
|
77
|
-
return
|
|
78
|
-
|
|
79
|
-
const backs = await multiselect({
|
|
80
|
+
if (typeof frontends === "symbol" || is_cancel(frontends))
|
|
81
|
+
return abort();
|
|
82
|
+
const backends = await multiselect({
|
|
80
83
|
message: "Choose backend (press Enter to skip)",
|
|
81
84
|
options: BACKEND_OPTIONS,
|
|
82
|
-
initial: [],
|
|
85
|
+
initial: [],
|
|
83
86
|
});
|
|
84
|
-
if (typeof
|
|
85
|
-
return
|
|
86
|
-
// runtime (must choose one)
|
|
87
|
+
if (typeof backends === "symbol" || is_cancel(backends))
|
|
88
|
+
return abort();
|
|
87
89
|
const runtime = await select({
|
|
88
90
|
message: "Choose runtime",
|
|
89
91
|
options: [
|
|
@@ -93,18 +95,16 @@ export default async function init() {
|
|
|
93
95
|
],
|
|
94
96
|
initial: 0,
|
|
95
97
|
});
|
|
96
|
-
if (typeof runtime === "symbol" ||
|
|
97
|
-
return
|
|
98
|
-
|
|
99
|
-
const dbChoices = await multiselect({
|
|
98
|
+
if (typeof runtime === "symbol" || is_cancel(runtime))
|
|
99
|
+
return abort();
|
|
100
|
+
const dbs = await multiselect({
|
|
100
101
|
message: "Choose a database (press Enter to skip)",
|
|
101
102
|
options: DATABASE_OPTIONS,
|
|
102
|
-
initial: [],
|
|
103
|
+
initial: [],
|
|
103
104
|
});
|
|
104
|
-
if (typeof
|
|
105
|
-
return
|
|
106
|
-
const db =
|
|
107
|
-
// i18n
|
|
105
|
+
if (typeof dbs === "symbol" || is_cancel(dbs))
|
|
106
|
+
return abort();
|
|
107
|
+
const db = dbs[0];
|
|
108
108
|
const i18n = await select({
|
|
109
109
|
message: "Enable i18n?",
|
|
110
110
|
options: [
|
|
@@ -113,10 +113,9 @@ export default async function init() {
|
|
|
113
113
|
],
|
|
114
114
|
initial: 1,
|
|
115
115
|
});
|
|
116
|
-
if (typeof i18n === "symbol" ||
|
|
117
|
-
return
|
|
118
|
-
const
|
|
119
|
-
// sessions
|
|
116
|
+
if (typeof i18n === "symbol" || is_cancel(i18n))
|
|
117
|
+
return abort();
|
|
118
|
+
const with_i18n = i18n === "yes";
|
|
120
119
|
const sessions = await select({
|
|
121
120
|
message: "Configure sessions?",
|
|
122
121
|
options: [
|
|
@@ -125,28 +124,27 @@ export default async function init() {
|
|
|
125
124
|
],
|
|
126
125
|
initial: 1,
|
|
127
126
|
});
|
|
128
|
-
if (typeof sessions === "symbol" ||
|
|
129
|
-
return
|
|
127
|
+
if (typeof sessions === "symbol" || is_cancel(sessions))
|
|
128
|
+
return abort();
|
|
130
129
|
const withSessions = sessions === "yes";
|
|
131
|
-
// scaffold dirs
|
|
132
130
|
await target.create({ recursive: true });
|
|
133
131
|
await target.join("routes").create({ recursive: true });
|
|
134
132
|
await target.join("views").create({ recursive: true });
|
|
135
|
-
if (db)
|
|
133
|
+
if (db !== undefined)
|
|
136
134
|
await target.join("stores").create({ recursive: true });
|
|
137
135
|
// files
|
|
138
136
|
await gitignore(target);
|
|
139
|
-
await tsconfig_json(target);
|
|
140
|
-
await app_config(target, {
|
|
141
|
-
if (
|
|
137
|
+
await tsconfig_json(target, { frontends });
|
|
138
|
+
await app_config(target, { frontends: frontends, backends: backends, runtime });
|
|
139
|
+
if (with_i18n)
|
|
142
140
|
await i18n_config(target);
|
|
143
141
|
if (withSessions)
|
|
144
142
|
await session_config(target);
|
|
145
143
|
if (db)
|
|
146
144
|
await database_config(target, db);
|
|
147
145
|
await package_json(target, { directory, runtime });
|
|
148
|
-
const packages = compute_packages({
|
|
149
|
-
const install =
|
|
146
|
+
const packages = compute_packages({ frontends: frontends, backends: backends, db });
|
|
147
|
+
const install = build_install_command(runtime, packages, directory);
|
|
150
148
|
outro([
|
|
151
149
|
"Done, now run",
|
|
152
150
|
`\n ${install.print}`,
|
|
@@ -182,29 +180,29 @@ async function gitignore(root) {
|
|
|
182
180
|
await gi.write(content);
|
|
183
181
|
}
|
|
184
182
|
async function app_config(root, c) {
|
|
185
|
-
const
|
|
186
|
-
await
|
|
187
|
-
const
|
|
188
|
-
.map((f) => `import ${
|
|
183
|
+
const config = root.join("config").join("app.ts");
|
|
184
|
+
await config.directory.create({ recursive: true });
|
|
185
|
+
const frontend_imports = c.frontends
|
|
186
|
+
.map((f) => `import ${to_ident(f)} from "@primate/${f}";`)
|
|
189
187
|
.join("\n");
|
|
190
|
-
const
|
|
191
|
-
.map((b) => `import ${
|
|
188
|
+
const backend_imports = c.backends
|
|
189
|
+
.map((b) => `import ${to_ident(b)} from "@primate/${b}";`)
|
|
192
190
|
.join("\n");
|
|
193
191
|
const modules = [
|
|
194
|
-
...c.
|
|
195
|
-
...c.
|
|
192
|
+
...c.frontends.map((f) => `${to_ident(f)}()`),
|
|
193
|
+
...c.backends.map((b) => `${to_ident(b)}()`),
|
|
196
194
|
];
|
|
197
195
|
const body = dedent `import config from "primate/config";
|
|
198
|
-
${
|
|
199
|
-
${
|
|
196
|
+
${frontend_imports}
|
|
197
|
+
${backend_imports}
|
|
200
198
|
|
|
201
|
-
export default config({
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
});
|
|
206
|
-
`;
|
|
207
|
-
await
|
|
199
|
+
export default config({
|
|
200
|
+
modules: [
|
|
201
|
+
${modules.join(",\n ")}
|
|
202
|
+
],
|
|
203
|
+
});
|
|
204
|
+
`;
|
|
205
|
+
await config.write(body);
|
|
208
206
|
}
|
|
209
207
|
// i18n scaffold: config + a default locale file
|
|
210
208
|
async function i18n_config(root) {
|
|
@@ -213,43 +211,40 @@ async function i18n_config(root) {
|
|
|
213
211
|
const i18i = root.join("config").join("i18n.ts");
|
|
214
212
|
await en_us.directory.create({ recursive: true });
|
|
215
213
|
await i18i.directory.create({ recursive: true });
|
|
216
|
-
const locale = `import locale from "primate/i18n/locale";
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
`;
|
|
214
|
+
const locale = dedent `import locale from "primate/i18n/locale";
|
|
215
|
+
export default locale({
|
|
216
|
+
hi: "Hello",
|
|
217
|
+
placeheld: "Hello, {name}",
|
|
218
|
+
});
|
|
219
|
+
`;
|
|
223
220
|
await en_us.write(locale);
|
|
224
|
-
const config = `import en from "#locale/en-US";
|
|
225
|
-
import i18n from "primate/config/i18n";
|
|
221
|
+
const config = dedent `import en from "#locale/en-US";
|
|
222
|
+
import i18n from "primate/config/i18n";
|
|
226
223
|
|
|
227
|
-
export default i18n({
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
});
|
|
233
|
-
`;
|
|
224
|
+
export default i18n({
|
|
225
|
+
defaultLocale: "en-US",
|
|
226
|
+
locales: {
|
|
227
|
+
"en-US": en,
|
|
228
|
+
},
|
|
229
|
+
});
|
|
230
|
+
`;
|
|
234
231
|
await i18i.write(config);
|
|
235
232
|
}
|
|
236
233
|
async function session_config(root) {
|
|
237
234
|
const file = root.join("config").join("session.ts");
|
|
238
235
|
await file.directory.create({ recursive: true });
|
|
239
|
-
const body = `import session from "primate/config/session";
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
`;
|
|
236
|
+
const body = dedent `import session from "primate/config/session";
|
|
237
|
+
export default session({});
|
|
238
|
+
`;
|
|
243
239
|
await file.write(body);
|
|
244
240
|
}
|
|
245
241
|
async function database_config(root, db) {
|
|
246
242
|
const file = root.join("config").join("database").join("index.ts");
|
|
247
243
|
await file.directory.create({ recursive: true });
|
|
248
|
-
const ident =
|
|
249
|
-
const body = `import ${ident} from "@primate/${db}";
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
`;
|
|
244
|
+
const ident = to_ident(db);
|
|
245
|
+
const body = dedent `import ${ident} from "@primate/${db}";
|
|
246
|
+
export default ${ident}();
|
|
247
|
+
`;
|
|
253
248
|
await file.write(body);
|
|
254
249
|
}
|
|
255
250
|
async function package_json(root, c) {
|
|
@@ -283,78 +278,110 @@ function safe(s) {
|
|
|
283
278
|
return s.trim().toLowerCase().replace(/\s+/g, "-")
|
|
284
279
|
.replace(/[^a-z0-9._-]/g, "") || "primate-app";
|
|
285
280
|
}
|
|
286
|
-
function
|
|
281
|
+
function to_ident(token) {
|
|
287
282
|
// turn tokens like "web-components" into valid identifiers: "web_components"
|
|
288
283
|
return token.replace(/[^a-zA-Z0-9_$]/g, "_");
|
|
289
284
|
}
|
|
290
285
|
function compute_packages(args) {
|
|
291
286
|
const deps = new Set();
|
|
292
|
-
const
|
|
287
|
+
const dev_deps = new Set();
|
|
293
288
|
deps.add("primate");
|
|
294
289
|
// Always add TypeScript as dev dependency
|
|
295
|
-
|
|
290
|
+
dev_deps.add("typescript");
|
|
296
291
|
// frontends → @primate/<token> (+ peer deps)
|
|
297
|
-
for (const f of args.
|
|
292
|
+
for (const f of args.frontends) {
|
|
298
293
|
deps.add(`@primate/${f}`);
|
|
299
294
|
const extras = FRONTEND_PEER_DEPS[f] || [];
|
|
300
295
|
for (const extra of extras)
|
|
301
296
|
deps.add(extra);
|
|
302
297
|
}
|
|
298
|
+
if (args.frontends.includes("svelte")) {
|
|
299
|
+
dev_deps.add("@plsp/svelte");
|
|
300
|
+
}
|
|
303
301
|
// backends → @primate/<token>
|
|
304
|
-
for (const b of args.
|
|
302
|
+
for (const b of args.backends)
|
|
305
303
|
deps.add(`@primate/${b}`);
|
|
306
|
-
}
|
|
307
304
|
// database → @primate/<token>, if selected
|
|
308
305
|
if (args.db)
|
|
309
306
|
deps.add(`@primate/${args.db}`);
|
|
310
307
|
return {
|
|
311
308
|
dependencies: Array.from(deps),
|
|
312
|
-
|
|
309
|
+
dev_dependencies: Array.from(dev_deps),
|
|
313
310
|
};
|
|
314
311
|
}
|
|
315
|
-
function
|
|
312
|
+
function sh_quote(p) {
|
|
316
313
|
// POSIX shell-safe quoting
|
|
317
314
|
return `'${p.replace(/'/g, "'\\''")}'`;
|
|
318
315
|
}
|
|
319
|
-
function
|
|
320
|
-
const { dependencies,
|
|
321
|
-
const
|
|
322
|
-
if (
|
|
316
|
+
function build_install_command(runtime, packages, dir) {
|
|
317
|
+
const { dependencies, dev_dependencies } = packages;
|
|
318
|
+
const all_pkgs = [...dependencies, ...dev_dependencies];
|
|
319
|
+
if (all_pkgs.length === 0) {
|
|
323
320
|
return { print: "No packages to install.", run: "" };
|
|
324
321
|
}
|
|
325
|
-
const cd = `cd ${
|
|
322
|
+
const cd = dir === "." ? "" : `cd ${sh_quote(dir)} && `;
|
|
326
323
|
if (runtime === "bun") {
|
|
327
|
-
const
|
|
324
|
+
const dep_cmd = dependencies.length > 0
|
|
328
325
|
? `bun add ${dependencies.join(" ")}`
|
|
329
326
|
: "";
|
|
330
|
-
const
|
|
331
|
-
? `bun add -d ${
|
|
327
|
+
const dev_cmd = dev_dependencies.length > 0
|
|
328
|
+
? `bun add -d ${dev_dependencies.join(" ")}`
|
|
332
329
|
: "";
|
|
333
|
-
const commands = [
|
|
330
|
+
const commands = [dep_cmd, dev_cmd].filter(Boolean);
|
|
334
331
|
return { print: cd + commands.join(" && "), run: "" };
|
|
335
332
|
}
|
|
336
333
|
if (runtime === "deno") {
|
|
337
|
-
const
|
|
334
|
+
const dep_cmd = dependencies.length > 0
|
|
338
335
|
? `deno add ${dependencies.map(d => `npm:${d}`).join(" ")}`
|
|
339
336
|
: "";
|
|
340
|
-
const
|
|
341
|
-
? `deno add -D ${
|
|
337
|
+
const dev_cmd = dev_dependencies.length > 0
|
|
338
|
+
? `deno add -D ${dev_dependencies.map(d => `npm:${d}`).join(" ")}`
|
|
342
339
|
: "";
|
|
343
|
-
const commands = [
|
|
340
|
+
const commands = [dep_cmd, dev_cmd].filter(Boolean);
|
|
344
341
|
return { print: cd + commands.join(" && "), run: "" };
|
|
345
342
|
}
|
|
346
|
-
const
|
|
343
|
+
const dep_cmd = dependencies.length > 0 ?
|
|
347
344
|
`npm install ${dependencies.join(" ")}`
|
|
348
345
|
: "";
|
|
349
|
-
const
|
|
350
|
-
? `npm install -D ${
|
|
346
|
+
const dev_cmd = dev_dependencies.length > 0
|
|
347
|
+
? `npm install -D ${dev_dependencies.join(" ")}`
|
|
351
348
|
: "";
|
|
352
|
-
const commands = [
|
|
349
|
+
const commands = [dep_cmd, dev_cmd].filter(Boolean);
|
|
353
350
|
return { print: cd + commands.join(" && "), run: "" };
|
|
354
351
|
}
|
|
355
|
-
async function tsconfig_json(root) {
|
|
356
|
-
|
|
352
|
+
async function tsconfig_json(root, opts) {
|
|
353
|
+
const is_react = opts.frontends.includes("react");
|
|
354
|
+
const is_svelte = opts.frontends.includes("svelte");
|
|
355
|
+
const tsconfig = {
|
|
357
356
|
extends: "primate/tsconfig",
|
|
358
|
-
|
|
357
|
+
compilerOptions: {
|
|
358
|
+
paths: {
|
|
359
|
+
"#config/*": ["config/*"],
|
|
360
|
+
"#session": ["config/session"],
|
|
361
|
+
"#i18n": ["config/i18n"],
|
|
362
|
+
"#view/*": ["views/*"],
|
|
363
|
+
"#component/*": ["components/*"],
|
|
364
|
+
"#store/*": ["stores/*"],
|
|
365
|
+
"#locale/*": ["locales/*"],
|
|
366
|
+
"#static/*": ["static/*"],
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
include: [
|
|
370
|
+
"config",
|
|
371
|
+
"views",
|
|
372
|
+
"components",
|
|
373
|
+
"routes",
|
|
374
|
+
"stores",
|
|
375
|
+
"locales",
|
|
376
|
+
"static",
|
|
377
|
+
"test",
|
|
378
|
+
],
|
|
379
|
+
exclude: ["node_modules"],
|
|
380
|
+
};
|
|
381
|
+
if (is_react)
|
|
382
|
+
tsconfig.compilerOptions.jsx = "react-jsx";
|
|
383
|
+
if (is_svelte)
|
|
384
|
+
tsconfig.compilerOptions.plugins = [{ name: "@plsp/svelte" }];
|
|
385
|
+
await root.join("tsconfig.json").writeJSON(tsconfig);
|
|
359
386
|
}
|
|
360
387
|
//# 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.0",
|
|
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.0"
|
|
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