primate 0.36.0 → 0.37.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.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ declare module "app:views" {
2
+ const views: [string, Record<string, unknown>][];
3
+ export default views;
4
+ }
5
+
6
+ declare module "$:app" {
7
+ import type AppFacade from "primate/AppFacade";
8
+ const facade: AppFacade;
9
+ export default facade;
10
+ }
package/lib/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import args from "@rcompat/args";
2
+ import runtime from "@rcompat/runtime";
3
3
  import init from "./init.js";
4
- await init(...args);
4
+ await init(...runtime.args);
5
5
  //# sourceMappingURL=bin.js.map
@@ -1,3 +1,3 @@
1
- import type Mode from "@primate/core/Mode";
2
- export default function app(flags: string[], mode?: Mode): Promise<true | undefined>;
1
+ import type { Mode } from "@primate/core";
2
+ export default function command_build(flags: string[], mode?: Mode): Promise<true | undefined>;
3
3
  //# sourceMappingURL=build.d.ts.map
@@ -1,13 +1,21 @@
1
1
  import build from "@primate/core/build";
2
+ import c from "@rcompat/cli/color";
3
+ import print from "@rcompat/cli/print";
4
+ import fs from "@rcompat/fs";
2
5
  import get_flag from "./get-flag.js";
3
- // build for production
4
- export default function app(flags, mode = "production") {
6
+ function orange(x) {
7
+ return `\x1b[38;2;255;165;0m${x}\x1b[0m`;
8
+ }
9
+ export default async function command_build(flags, mode) {
10
+ const { name, version, } = await (await fs.project.package(import.meta.dirname)).json();
11
+ print(c.bold(orange((name.toUpperCase()))), orange(version), "\n\n");
12
+ const root = await fs.project.root();
5
13
  const build_flags = {
6
- mode: mode,
14
+ mode: mode ?? "production",
7
15
  target: get_flag(flags, "target"),
8
16
  dir: get_flag(flags, "dir"),
9
17
  };
10
- return build(build_flags);
18
+ return build(root, build_flags);
11
19
  }
12
20
  ;
13
21
  //# sourceMappingURL=build.js.map
@@ -1,5 +1,5 @@
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;
4
- export default _default;
1
+ import build from "./build.js";
2
+ import migrate_create from "./migrate-create.js";
3
+ import serve from "./serve.js";
4
+ export default function run_command(command_flag?: string): typeof build | typeof serve | typeof migrate_create | (() => void);
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1,13 +1,47 @@
1
- import { default as build } from "./build.js";
2
- import { default as dev } from "./dev.js";
3
- import { default as init } from "./init.js";
4
- import { default as serve } from "./serve.js";
5
- import { default as test } from "./test.js";
6
- export default (name) => ({
1
+ import c from "@rcompat/cli/color";
2
+ import print from "@rcompat/cli/print";
3
+ import build from "./build.js";
4
+ import dev from "./dev.js";
5
+ import init from "./init.js";
6
+ import migrate_apply from "./migrate-apply.js";
7
+ import migrate_create from "./migrate-create.js";
8
+ import migrate_status from "./migrate-status.js";
9
+ import serve from "./serve.js";
10
+ import test from "./test.js";
11
+ const commands = {
7
12
  build,
8
13
  dev,
9
14
  init,
10
15
  serve,
11
16
  test,
12
- })[name] ?? dev;
17
+ migrate_apply,
18
+ migrate_create,
19
+ migrate_status,
20
+ };
21
+ function unknown(command) {
22
+ return () => {
23
+ print(`Unknown command ${c.dim(command)}\n`);
24
+ };
25
+ }
26
+ ;
27
+ function in_commands(command) {
28
+ return Object.keys(commands).find(key => key === command || key.startsWith(command)) !== undefined;
29
+ }
30
+ export default function run_command(command_flag = "") {
31
+ const [command, action = ""] = command_flag.trim().split(":");
32
+ if (command === "")
33
+ return dev;
34
+ if (in_commands(command)) {
35
+ if (action === "")
36
+ return commands[command];
37
+ else {
38
+ const subcommand = `${command}_${action}`;
39
+ if (in_commands(subcommand))
40
+ return commands[subcommand];
41
+ return unknown(subcommand.replace("_", ":"));
42
+ }
43
+ }
44
+ return unknown(command);
45
+ }
46
+ ;
13
47
  //# sourceMappingURL=index.js.map
@@ -164,13 +164,7 @@ async function gitignore(root) {
164
164
  const content = [
165
165
  "node_modules",
166
166
  "build",
167
- "dist",
168
- ".DS_Store",
169
167
  "*.log",
170
- "npm-debug.log*",
171
- "yarn-debug.log*",
172
- "yarn-error.log*",
173
- "pnpm-debug.log*",
174
168
  "",
175
169
  ].join("\n");
176
170
  await gi.write(content);
@@ -191,7 +185,6 @@ async function app_config(root, c) {
191
185
  const body = `import config from "primate/config";
192
186
  ${frontend_imports}
193
187
  ${backend_imports}
194
-
195
188
  export default config({
196
189
  modules: [
197
190
  ${modules.join(",\n ")}
@@ -0,0 +1,2 @@
1
+ export default function command_migrate_apply(): Promise<void>;
2
+ //# sourceMappingURL=migrate-apply.d.ts.map
@@ -0,0 +1,12 @@
1
+ import migrate from "@primate/core/db/migrate";
2
+ import log from "@primate/core/log";
3
+ export default async function command_migrate_apply() {
4
+ try {
5
+ await migrate.apply();
6
+ }
7
+ catch (cause) {
8
+ log.error(cause);
9
+ }
10
+ }
11
+ ;
12
+ //# sourceMappingURL=migrate-apply.js.map
@@ -0,0 +1,2 @@
1
+ export default function command_migrate_create(flags: string[]): Promise<void>;
2
+ //# sourceMappingURL=migrate-create.d.ts.map
@@ -0,0 +1,23 @@
1
+ import migrate from "@primate/core/db/migrate";
2
+ import log from "@primate/core/log";
3
+ import error from "@rcompat/error";
4
+ const n = "--name";
5
+ function create_requires_name_flag() {
6
+ return error.template `migrate:create requires a ${n} flag`;
7
+ }
8
+ const errors = error.coded({
9
+ create_requires_name_flag,
10
+ });
11
+ export default async function command_migrate_create(flags) {
12
+ const name = flags.find(f => f.startsWith(`${n}=`))?.slice(`${n}=`.length);
13
+ try {
14
+ if (name === undefined)
15
+ throw errors.create_requires_name_flag();
16
+ await migrate.create(name);
17
+ }
18
+ catch (cause) {
19
+ log.error(cause);
20
+ }
21
+ }
22
+ ;
23
+ //# sourceMappingURL=migrate-create.js.map
@@ -0,0 +1,2 @@
1
+ export default function command_migrate_status(): Promise<void>;
2
+ //# sourceMappingURL=migrate-status.d.ts.map
@@ -0,0 +1,12 @@
1
+ import migrate from "@primate/core/db/migrate";
2
+ import log from "@primate/core/log";
3
+ export default async function command_migrate_status() {
4
+ try {
5
+ await migrate.status();
6
+ }
7
+ catch (cause) {
8
+ log.error(cause);
9
+ }
10
+ }
11
+ ;
12
+ //# sourceMappingURL=migrate-status.js.map
@@ -17,7 +17,7 @@ const first_error = (left, right) => {
17
17
  }
18
18
  };
19
19
  export default async () => {
20
- await build({ mode: "testing" });
20
+ await build(await fs.project.root(), { mode: "testing" });
21
21
  const app = (await serve()).default;
22
22
  const files = await (await fs.project.root()).join(directory)
23
23
  .list({ filter: f => f.path.endsWith(".ts") || f.path.endsWith(".js") });
package/lib/index.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- declare module "app:views" {
2
- const views: [string, Record<string, unknown>][];
3
- export default views;
4
- }
1
+ import "./app.d.ts";
5
2
 
6
- declare module "$:app" {
7
- import type AppFacade from "primate/AppFacade";
8
- const facade: AppFacade;
9
- export default facade;
10
- }
3
+ export type * from "./public/index";
package/lib/init.js CHANGED
@@ -1,14 +1,9 @@
1
- import c from "@rcompat/cli/color";
2
- import print from "@rcompat/cli/print";
3
- import fs from "@rcompat/fs";
4
1
  import find from "./commands/index.js";
5
2
  function orange(x) {
6
3
  return `\x1b[38;2;255;165;0m${x}\x1b[0m`;
7
4
  }
8
5
  export default async (...args) => {
9
6
  const [command, ...flags] = args;
10
- const { name, version, } = await (await fs.project.package(import.meta.dirname)).json();
11
- print(c.bold(orange((name.toUpperCase()))), orange(version), "\n\n");
12
7
  find(command)(flags);
13
8
  };
14
9
  //# sourceMappingURL=init.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/build";
2
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "@primate/core/build";
2
+ //# sourceMappingURL=build.js.map
@@ -1,2 +1,2 @@
1
- export { default } from "@rcompat/http/Status";
1
+ export { Status as default } from "@rcompat/http";
2
2
  //# sourceMappingURL=Status.d.ts.map
@@ -1,2 +1,2 @@
1
- export { default } from "@rcompat/http/Status";
1
+ export { Status as default } from "@rcompat/http";
2
2
  //# sourceMappingURL=Status.js.map
@@ -0,0 +1,2 @@
1
+ export type { Module } from "@primate/core";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -1,4 +1,2 @@
1
- import Store from "@primate/core/orm/Store";
2
- declare const _default: typeof Store.new;
3
- export default _default;
1
+ export { default } from "@primate/core/orm/store";
4
2
  //# sourceMappingURL=store.d.ts.map
@@ -1,3 +1,2 @@
1
- import Store from "@primate/core/orm/Store";
2
- export default Store.new;
1
+ export { default } from "@primate/core/orm/store";
3
2
  //# sourceMappingURL=store.js.map
@@ -1,2 +1,2 @@
1
- export { type RequestFacade } from "@primate/core/request";
1
+ export type { RequestFacade } from "@primate/core";
2
2
  //# sourceMappingURL=request.d.ts.map
@@ -1,4 +1,4 @@
1
- export type { default as ViewResponse, } from "@primate/core/frontend/ViewResponse";
2
- export type { default as ServeApp } from "@primate/core/ServeApp";
1
+ export type { ServeApp } from "@primate/core";
2
+ export type { ViewResponse } from "@primate/core/client";
3
3
  export { default, type ResponseFunction } from "@primate/core/response";
4
4
  //# sourceMappingURL=response.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "primate",
3
- "version": "0.36.0",
3
+ "version": "0.37.0",
4
4
  "description": "The universal web framework",
5
5
  "homepage": "https://primate.run",
6
6
  "bugs": "https://github.com/primate-run/primate/issues",
@@ -20,47 +20,47 @@
20
20
  "bin": "lib/bin.js",
21
21
  "types": "lib/index.d.ts",
22
22
  "dependencies": {
23
- "@rcompat/args": "^0.11.0",
24
- "@rcompat/cli": "^0.14.0",
25
- "@rcompat/dict": "^0.3.1",
26
- "@rcompat/fs": "^0.25.2",
27
- "@rcompat/http": "~0.21.0",
28
- "@rcompat/test": "^0.8.3",
29
- "@primate/core": "^0.5.0"
23
+ "@rcompat/cli": "^0.18.1",
24
+ "@rcompat/dict": "^0.5.1",
25
+ "@rcompat/error": "^0.3.1",
26
+ "@rcompat/fs": "^0.28.1",
27
+ "@rcompat/http": "~0.25.1",
28
+ "@rcompat/runtime": "^0.11.1",
29
+ "@rcompat/test": "^0.12.2",
30
+ "@primate/core": "^0.6.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@rcompat/type": "^0.9.0"
33
+ "@rcompat/type": "^0.11.1"
33
34
  },
34
35
  "engines": {
35
- "node": ">=20"
36
+ "node": ">=24"
36
37
  },
37
38
  "imports": {
38
39
  "#*": {
39
- "apekit": "./src/private/*.ts",
40
+ "@primate/source": "./src/private/*.ts",
40
41
  "default": "./lib/private/*.js"
41
42
  }
42
43
  },
43
44
  "exports": {
44
- ".": {
45
- "types": "./lib/index.d.ts"
46
- },
47
45
  "./tsconfig": "./lib/app.tsconfig.json",
48
- "./runtime/*": {
49
- "apekit": "./src/runtime/*.ts",
50
- "default": "./lib/runtime/*.js"
51
- },
52
46
  "./http/*": {
53
- "apekit": "./src/public/http/*.ts",
47
+ "@primate/source": "./src/public/http/*.ts",
54
48
  "default": "./lib/public/http/*.js"
55
49
  },
56
50
  "./*": {
57
- "apekit": "./src/public/*.ts",
51
+ "@primate/source": "./src/public/*.ts",
58
52
  "default": "./lib/public/*.js"
53
+ },
54
+ ".": {
55
+ "types": "./lib/index.d.ts",
56
+ "@primate/source": "./src/public/index.ts",
57
+ "default": "./lib/public/index.js"
59
58
  }
60
59
  },
61
60
  "scripts": {
62
- "build": "npm run clean && tsc && cp src/{app.tsconfig.json,index.d.ts} lib",
61
+ "build": "npm run clean && tsc && cp src/app.tsconfig.json lib && cp src/types/app.d.ts lib && cp src/types/index.d.ts lib",
63
62
  "clean": "rm -rf ./lib",
64
- "lint": "eslint ."
63
+ "lint": "eslint .",
64
+ "test": "npx proby"
65
65
  }
66
66
  }
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/Module";
2
- //# sourceMappingURL=Module.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/Module";
2
- //# sourceMappingURL=Module.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/orm/wrap";
2
- //# sourceMappingURL=wrap.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "@primate/core/orm/wrap";
2
- //# sourceMappingURL=wrap.js.map
@@ -1,3 +0,0 @@
1
- declare const FileRef: typeof import("@rcompat/fs").FileRef;
2
- export { FileRef as default };
3
- //# sourceMappingURL=FileRef.d.ts.map
@@ -1,4 +0,0 @@
1
- import fs from "@rcompat/fs";
2
- const FileRef = fs.FileRef;
3
- export { FileRef as default };
4
- //# sourceMappingURL=FileRef.js.map