primate 0.33.4 → 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.
Files changed (47) hide show
  1. package/lib/app.tsconfig.json +3 -55
  2. package/lib/commands/build.d.ts +1 -2
  3. package/lib/commands/build.js +10 -6
  4. package/lib/commands/dev.d.ts +1 -1
  5. package/lib/commands/dev.js +2 -6
  6. package/lib/commands/get-flag.d.ts +2 -0
  7. package/lib/commands/get-flag.js +5 -0
  8. package/lib/commands/index.d.ts +3 -1
  9. package/lib/commands/init.js +137 -110
  10. package/lib/commands/serve.d.ts +1 -2
  11. package/lib/commands/serve.js +6 -2
  12. package/lib/commands/test.js +2 -2
  13. package/lib/init.js +2 -2
  14. package/lib/public/client/app.d.ts +1 -3
  15. package/lib/public/client/app.js +1 -2
  16. package/lib/public/database/Store.d.ts +2 -0
  17. package/lib/public/database/Store.js +2 -0
  18. package/lib/public/fs/FileRef.d.ts +2 -0
  19. package/lib/public/fs/FileRef.js +2 -0
  20. package/lib/public/pema.d.ts +2 -0
  21. package/lib/public/pema.js +2 -0
  22. package/lib/public/response.d.ts +2 -1
  23. package/package.json +5 -6
  24. package/lib/public/Loader.d.ts +0 -2
  25. package/lib/public/Loader.js +0 -2
  26. package/lib/public/load-text.d.ts +0 -4
  27. package/lib/public/load-text.js +0 -3
  28. package/lib/public/response/binary.d.ts +0 -2
  29. package/lib/public/response/binary.js +0 -2
  30. package/lib/public/response/error.d.ts +0 -2
  31. package/lib/public/response/error.js +0 -2
  32. package/lib/public/response/json.d.ts +0 -2
  33. package/lib/public/response/json.js +0 -2
  34. package/lib/public/response/redirect.d.ts +0 -2
  35. package/lib/public/response/redirect.js +0 -2
  36. package/lib/public/response/sse.d.ts +0 -2
  37. package/lib/public/response/sse.js +0 -2
  38. package/lib/public/response/text.d.ts +0 -2
  39. package/lib/public/response/text.js +0 -2
  40. package/lib/public/response/view.d.ts +0 -2
  41. package/lib/public/response/view.js +0 -2
  42. package/lib/public/response/ws.d.ts +0 -2
  43. package/lib/public/response/ws.js +0 -2
  44. package/lib/public/session/Manager.d.ts +0 -2
  45. package/lib/public/session/Manager.js +0 -2
  46. /package/lib/public/{response → http}/Status.d.ts +0 -0
  47. /package/lib/public/{response → http}/Status.js +0 -0
@@ -4,63 +4,11 @@
4
4
  "baseUrl": "${configDir}",
5
5
  "target": "esnext",
6
6
  "module": "nodenext",
7
- "moduleResolution": "nodenext",
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
- "jsx": "react-jsx",
15
- "paths": {
16
- "#route/*": ["routes/*"],
17
- "#lib/*": [
18
- "lib/*.tsx",
19
- "lib/*.jsx",
20
- "lib/*.vue",
21
- "lib/*.svelte",
22
- "lib/*.component.ts",
23
- "lib/*.ts",
24
- "lib/*.js",
25
- "lib/*"
26
- ],
27
- "#component/*": [
28
- "components/*.tsx",
29
- "components/*.jsx",
30
- "components/*.vue",
31
- "components/*.svelte",
32
- "components/*.component.ts",
33
- "components/*.ts",
34
- "components/*.js",
35
- "components/*"
36
- ],
37
- "#store/*": ["stores/*", "stores/*.ts", "stores/*.js"],
38
- "#locale/*": ["locales/*", "locales/*.ts", "locales/*.js"],
39
- "#module/*": ["modules/*", "modules/*.ts", "modules/*.js"],
40
- "#config/*": ["config/*", "config/*.ts", "config/*.js"],
41
- "#static/*": ["static/*", "static/*.ts", "static/*.js"],
42
- "#database/*": ["config/database/*.ts", "config/database/*.js"],
43
- "#app": ["config/app.ts", "config/app.js"],
44
- "#session": ["config/session.ts", "config/session.js"],
45
- "#i18n": ["config/i18n.ts", "config/i18n.js"],
46
- "#database": [
47
- "config/database/index.ts",
48
- "config/database/index.js",
49
- "config/database/default.js",
50
- "config/database/default.ts"
51
- ]
52
- }
53
- },
54
- "include": [
55
- "${configDir}/config",
56
- "${configDir}/routes",
57
- "${configDir}/components",
58
- "${configDir}/stores",
59
- "${configDir}/modules",
60
- "${configDir}/test",
61
- "${configDir}/static",
62
- "${configDir}/primate.config.js",
63
- "${configDir}/primate.config.ts"
64
- ],
65
- "exclude": ["node_modules"]
12
+ "allowImportingTsExtensions": true
13
+ }
66
14
  }
@@ -1,4 +1,3 @@
1
1
  import type Mode from "@primate/core/Mode";
2
- declare const _default: (flags: string[], mode?: Mode) => Promise<true | undefined>;
3
- export default _default;
2
+ export default function app(flags: string[], mode?: Mode): Promise<true | undefined>;
4
3
  //# sourceMappingURL=build.d.ts.map
@@ -1,9 +1,13 @@
1
1
  import build from "@primate/core/build";
2
- const T_FLAG = "--target=";
2
+ import get_flag from "./get-flag.js";
3
3
  // build for production
4
- export default (flags, mode = "production") => {
5
- const target = flags.find(f => f.startsWith(T_FLAG))?.slice(T_FLAG.length)
6
- ?? "web";
7
- return build(mode, target);
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
@@ -1,3 +1,3 @@
1
- declare const _default: () => Promise<void>;
1
+ declare const _default: () => Promise<true | undefined>;
2
2
  export default _default;
3
3
  //# sourceMappingURL=dev.d.ts.map
@@ -1,8 +1,4 @@
1
1
  import build from "./build.js";
2
- import serve from "./serve.js";
3
- // build for development and serve
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
@@ -0,0 +1,2 @@
1
+ export default function get_flag(flags: string[], option: string): string | undefined;
2
+ //# sourceMappingURL=get-flag.d.ts.map
@@ -0,0 +1,5 @@
1
+ export default function get_flag(flags, option) {
2
+ const flag = `--${option}=`;
3
+ return flags.find(f => f.startsWith(flag))?.slice(flag.length);
4
+ }
5
+ //# sourceMappingURL=get-flag.js.map
@@ -1,3 +1,5 @@
1
- declare const _default: (name: string) => ((flags: string[], mode?: import("@primate/core/Mode").default) => Promise<true | undefined>) | (() => Promise<any>);
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
@@ -1,12 +1,15 @@
1
1
  import cancel from "@rcompat/cli/prompts/cancel";
2
2
  import intro from "@rcompat/cli/prompts/intro";
3
- import isCancel from "@rcompat/cli/prompts/is-cancel";
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({ message: "Directory to create app?", initial: "." });
60
- if (typeof ans === "symbol" || isCancel(ans))
61
- return cancel("Aborted.");
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; // Valid directory found, exit loop
70
+ break; // valid directory found, exit loop
66
71
  }
67
- // Directory not empty, show error but continue loop
72
+ // directory not empty, show error but continue loop
68
73
  console.log("Directory not empty, choose another.");
69
74
  }
70
- // frontends — Enter = skip (none)
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: [], // indices
78
+ initial: [],
75
79
  });
76
- if (typeof fronts === "symbol" || isCancel(fronts))
77
- return cancel("Aborted.");
78
- // backends — Enter = skip (none)
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: [], // indices
85
+ initial: [],
83
86
  });
84
- if (typeof backs === "symbol" || isCancel(backs))
85
- return cancel("Aborted.");
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" || isCancel(runtime))
97
- return cancel("Aborted.");
98
- // database — Enter = skip (none); if multiple chosen, take the first
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: [], // indices
103
+ initial: [],
103
104
  });
104
- if (typeof dbChoices === "symbol" || isCancel(dbChoices))
105
- return cancel("Aborted.");
106
- const db = dbChoices[0];
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" || isCancel(i18n))
117
- return cancel("Aborted.");
118
- const withI18n = i18n === "yes";
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" || isCancel(sessions))
129
- return cancel("Aborted.");
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
- await target.join("components").create({ recursive: true });
135
- if (db)
132
+ await target.join("views").create({ recursive: true });
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, { fronts, backs, runtime });
141
- if (withI18n)
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({ fronts, backs, db });
149
- const install = buildInstallCommand(runtime, packages, directory);
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 cfg = root.join("config").join("app.ts");
186
- await cfg.directory.create({ recursive: true });
187
- const frontendImports = c.fronts
188
- .map((f) => `import ${toIdent(f)} from "@primate/${f}";`)
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 backendImports = c.backs
191
- .map((b) => `import ${toIdent(b)} from "@primate/${b}";`)
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.fronts.map((f) => `${toIdent(f)}()`),
195
- ...c.backs.map((b) => `${toIdent(b)}()`),
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
- ${frontendImports}
199
- ${backendImports}
196
+ ${frontend_imports}
197
+ ${backend_imports}
200
198
 
201
- export default config({
202
- modules: [
203
- ${modules.join(",\n ")}
204
- ],
205
- });
206
- `;
207
- await cfg.write(body);
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
- export default locale({
219
- hi: "Hello",
220
- placeheld: "Hello, {name}",
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
- defaultLocale: "en-US",
229
- locales: {
230
- "en-US": en,
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
- export default session({});
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 = toIdent(db);
249
- const body = `import ${ident} from "@primate/${db}";
250
-
251
- export default ${ident}();
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 toIdent(token) {
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 devDeps = new Set();
287
+ const dev_deps = new Set();
293
288
  deps.add("primate");
294
289
  // Always add TypeScript as dev dependency
295
- devDeps.add("typescript");
290
+ dev_deps.add("typescript");
296
291
  // frontends → @primate/<token> (+ peer deps)
297
- for (const f of args.fronts) {
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.backs) {
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
- devDependencies: Array.from(devDeps),
309
+ dev_dependencies: Array.from(dev_deps),
313
310
  };
314
311
  }
315
- function shQuote(p) {
312
+ function sh_quote(p) {
316
313
  // POSIX shell-safe quoting
317
314
  return `'${p.replace(/'/g, "'\\''")}'`;
318
315
  }
319
- function buildInstallCommand(runtime, packages, dir) {
320
- const { dependencies, devDependencies } = packages;
321
- const allPkgs = [...dependencies, ...devDependencies];
322
- if (allPkgs.length === 0) {
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 ${shQuote(dir)} && `;
322
+ const cd = dir === "." ? "" : `cd ${sh_quote(dir)} && `;
326
323
  if (runtime === "bun") {
327
- const depCmd = dependencies.length > 0
324
+ const dep_cmd = dependencies.length > 0
328
325
  ? `bun add ${dependencies.join(" ")}`
329
326
  : "";
330
- const devCmd = devDependencies.length > 0
331
- ? `bun add -d ${devDependencies.join(" ")}`
327
+ const dev_cmd = dev_dependencies.length > 0
328
+ ? `bun add -d ${dev_dependencies.join(" ")}`
332
329
  : "";
333
- const commands = [depCmd, devCmd].filter(Boolean);
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 depCmd = dependencies.length > 0
334
+ const dep_cmd = dependencies.length > 0
338
335
  ? `deno add ${dependencies.map(d => `npm:${d}`).join(" ")}`
339
336
  : "";
340
- const devCmd = devDependencies.length > 0
341
- ? `deno add -D ${devDependencies.map(d => `npm:${d}`).join(" ")}`
337
+ const dev_cmd = dev_dependencies.length > 0
338
+ ? `deno add -D ${dev_dependencies.map(d => `npm:${d}`).join(" ")}`
342
339
  : "";
343
- const commands = [depCmd, devCmd].filter(Boolean);
340
+ const commands = [dep_cmd, dev_cmd].filter(Boolean);
344
341
  return { print: cd + commands.join(" && "), run: "" };
345
342
  }
346
- const depCmd = dependencies.length > 0 ?
343
+ const dep_cmd = dependencies.length > 0 ?
347
344
  `npm install ${dependencies.join(" ")}`
348
345
  : "";
349
- const devCmd = devDependencies.length > 0
350
- ? `npm install -D ${devDependencies.join(" ")}`
346
+ const dev_cmd = dev_dependencies.length > 0
347
+ ? `npm install -D ${dev_dependencies.join(" ")}`
351
348
  : "";
352
- const commands = [depCmd, devCmd].filter(Boolean);
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
- await root.join("tsconfig.json").writeJSON({
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
@@ -1,3 +1,2 @@
1
- declare const _default: () => Promise<any>;
2
- export default _default;
1
+ export default function app(flags?: string[]): Promise<any>;
3
2
  //# sourceMappingURL=serve.d.ts.map
@@ -1,5 +1,6 @@
1
1
  import FileRef from "@rcompat/fs/FileRef";
2
- import root from "@rcompat/package/root";
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 () => (await load()).join("./build/serve.js").import();
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
@@ -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/package/root";
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", "web");
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 json from "@rcompat/package/json";
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 json(import.meta.url)).json();
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
  };
@@ -1,4 +1,2 @@
1
- import App from "@primate/core/client/App";
2
- declare const _default: App;
3
- export default _default;
1
+ import "@primate/core/client/app";
4
2
  //# sourceMappingURL=app.d.ts.map
@@ -1,3 +1,2 @@
1
- import App from "@primate/core/client/App";
2
- export default new App();
1
+ import "@primate/core/client/app";
3
2
  //# sourceMappingURL=app.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/database/Store";
2
+ //# sourceMappingURL=Store.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/database/Store";
2
+ //# sourceMappingURL=Store.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@rcompat/fs/FileRef";
2
+ //# sourceMappingURL=FileRef.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@rcompat/fs/FileRef";
2
+ //# sourceMappingURL=FileRef.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "pema";
2
+ //# sourceMappingURL=pema.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "pema";
2
+ //# sourceMappingURL=pema.js.map
@@ -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: import("@primate/core/frontend/ViewResponse").default;
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.33.4",
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.2.1"
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.21.1",
28
- "@rcompat/http": "~0.15.1",
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.2.4"
32
+ "@primate/core": "^0.4.0"
34
33
  },
35
34
  "engines": {
36
35
  "node": ">=20"
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/Loader";
2
- //# sourceMappingURL=Loader.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/Loader";
2
- //# sourceMappingURL=Loader.js.map
@@ -1,4 +0,0 @@
1
- import type Path from "@rcompat/fs/Path";
2
- declare const _default: (path: Path, ...paths: Path[]) => Promise<string>;
3
- export default _default;
4
- //# sourceMappingURL=load-text.d.ts.map
@@ -1,3 +0,0 @@
1
- import FileRef from "@rcompat/fs/FileRef";
2
- export default (path, ...paths) => FileRef.join(path, ...paths).text();
3
- //# sourceMappingURL=load-text.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/binary";
2
- //# sourceMappingURL=binary.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/binary";
2
- //# sourceMappingURL=binary.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/error";
2
- //# sourceMappingURL=error.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/error";
2
- //# sourceMappingURL=error.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/json";
2
- //# sourceMappingURL=json.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/json";
2
- //# sourceMappingURL=json.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/redirect";
2
- //# sourceMappingURL=redirect.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/redirect";
2
- //# sourceMappingURL=redirect.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/sse";
2
- //# sourceMappingURL=sse.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/sse";
2
- //# sourceMappingURL=sse.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/text";
2
- //# sourceMappingURL=text.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/text";
2
- //# sourceMappingURL=text.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/view";
2
- //# sourceMappingURL=view.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/view";
2
- //# sourceMappingURL=view.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/ws";
2
- //# sourceMappingURL=ws.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/response/ws";
2
- //# sourceMappingURL=ws.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/session/Manager";
2
- //# sourceMappingURL=Manager.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/session/Manager";
2
- //# sourceMappingURL=Manager.js.map
File without changes
File without changes