@kizunajs/cli 2.0.0-beta.15 → 2.0.0-beta.17
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/dist/cli.cjs +48 -3
- package/dist/cli.mjs +48 -3
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.mts +4 -1
- package/dist/index.mjs +1 -1
- package/dist/{route-map-Bt94ERSi.mjs → route-map-BPi-Oj1o.mjs} +4 -3
- package/dist/{route-map-CTy0nJPu.cjs → route-map-C0CF82bw.cjs} +4 -3
- package/package.json +5 -5
package/dist/cli.cjs
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_route_map = require("./route-map-
|
|
2
|
+
const require_route_map = require("./route-map-C0CF82bw.cjs");
|
|
3
|
+
let kizunajs_generator = require("kizunajs/generator");
|
|
3
4
|
let node_path = require("node:path");
|
|
4
5
|
let node_fs = require("node:fs");
|
|
5
6
|
let node_util = require("node:util");
|
|
7
|
+
//#region src/group-check.ts
|
|
8
|
+
const within = (path, group) => path === group || path.startsWith(`${group}.`);
|
|
9
|
+
/**
|
|
10
|
+
* Every group problem in an api. Hidden and plugin routes are skipped.
|
|
11
|
+
*/
|
|
12
|
+
const checkGroups = (api) => {
|
|
13
|
+
const declared = api.groups?.groups;
|
|
14
|
+
if (declared === void 0 || declared.size === 0) return [];
|
|
15
|
+
const problems = [];
|
|
16
|
+
const filed = [];
|
|
17
|
+
(0, kizunajs_generator.walkApi)(api, {
|
|
18
|
+
processRoute({ routeKey, routeGroups, hidden, plugin }) {
|
|
19
|
+
if (plugin !== void 0 || hidden) return;
|
|
20
|
+
if (routeGroups[0] === void 0) {
|
|
21
|
+
problems.push({
|
|
22
|
+
kind: "ungrouped",
|
|
23
|
+
message: `${routeKey} is in no group. Declare it with k.routes.<group>(...).`
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
filed.push(...routeGroups);
|
|
28
|
+
},
|
|
29
|
+
finalize: () => void 0
|
|
30
|
+
});
|
|
31
|
+
for (const group of declared.values()) {
|
|
32
|
+
if (filed.some((path) => within(path, group.path))) continue;
|
|
33
|
+
problems.push({
|
|
34
|
+
kind: "empty",
|
|
35
|
+
message: `The group ${group.path} holds no routes. Remove it, or file a route in it.`
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return problems;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The problems, for the terminal.
|
|
42
|
+
*/
|
|
43
|
+
const formatGroupProblems = (problems) => [`${problems.length} group ${problems.length === 1 ? "problem" : "problems"}:`, ...problems.map((problem) => ` ${problem.message}`)].join("\n");
|
|
44
|
+
//#endregion
|
|
6
45
|
//#region src/cli.ts
|
|
7
46
|
const usage = `Usage: kizuna <command> [options]
|
|
8
47
|
|
|
9
48
|
Commands:
|
|
10
49
|
generate Write kizuna.types.ts and every client the config declares.
|
|
11
|
-
routes Print every route the config serves.
|
|
50
|
+
routes Print every route the config serves. Exits 1 when a route is in
|
|
51
|
+
no group while others are, or a group holds no routes.
|
|
12
52
|
diff Compare the config against the same config at a git ref.
|
|
13
53
|
|
|
14
54
|
Options:
|
|
@@ -98,8 +138,13 @@ const runGenerate = async (values) => {
|
|
|
98
138
|
process.stdout.write(changed.length > 0 ? `Wrote:\n${changed.map((file) => ` ${file}`).join("\n")}\n` : "Everything was already up to date.\n");
|
|
99
139
|
};
|
|
100
140
|
const runRoutes = async (values) => {
|
|
101
|
-
const
|
|
141
|
+
const config = await loadOrDie(configPathFrom(values.config));
|
|
142
|
+
const entries = require_route_map.routeMap(config.api, {});
|
|
143
|
+
const problems = checkGroups(config.api);
|
|
102
144
|
process.stdout.write(values.json ? `${JSON.stringify(entries, null, 2)}\n` : `${require_route_map.formatRoutes(entries)}\n`);
|
|
145
|
+
if (problems.length === 0) return;
|
|
146
|
+
process.stderr.write(`\n${formatGroupProblems(problems)}\n`);
|
|
147
|
+
process.exit(1);
|
|
103
148
|
};
|
|
104
149
|
const runDiff = async (values) => {
|
|
105
150
|
let changes;
|
package/dist/cli.mjs
CHANGED
|
@@ -1,14 +1,54 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, d as diffSnapshots, f as formatChange, h as snapshotTarget, i as readSnapshot, l as writeFiles, m as snapshotPathFor, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes } from "./route-map-
|
|
2
|
+
import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, d as diffSnapshots, f as formatChange, h as snapshotTarget, i as readSnapshot, l as writeFiles, m as snapshotPathFor, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes } from "./route-map-BPi-Oj1o.mjs";
|
|
3
|
+
import { walkApi } from "kizunajs/generator";
|
|
3
4
|
import { dirname, relative, resolve } from "node:path";
|
|
4
5
|
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
5
6
|
import { parseArgs } from "node:util";
|
|
7
|
+
//#region src/group-check.ts
|
|
8
|
+
const within = (path, group) => path === group || path.startsWith(`${group}.`);
|
|
9
|
+
/**
|
|
10
|
+
* Every group problem in an api. Hidden and plugin routes are skipped.
|
|
11
|
+
*/
|
|
12
|
+
const checkGroups = (api) => {
|
|
13
|
+
const declared = api.groups?.groups;
|
|
14
|
+
if (declared === void 0 || declared.size === 0) return [];
|
|
15
|
+
const problems = [];
|
|
16
|
+
const filed = [];
|
|
17
|
+
walkApi(api, {
|
|
18
|
+
processRoute({ routeKey, routeGroups, hidden, plugin }) {
|
|
19
|
+
if (plugin !== void 0 || hidden) return;
|
|
20
|
+
if (routeGroups[0] === void 0) {
|
|
21
|
+
problems.push({
|
|
22
|
+
kind: "ungrouped",
|
|
23
|
+
message: `${routeKey} is in no group. Declare it with k.routes.<group>(...).`
|
|
24
|
+
});
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
filed.push(...routeGroups);
|
|
28
|
+
},
|
|
29
|
+
finalize: () => void 0
|
|
30
|
+
});
|
|
31
|
+
for (const group of declared.values()) {
|
|
32
|
+
if (filed.some((path) => within(path, group.path))) continue;
|
|
33
|
+
problems.push({
|
|
34
|
+
kind: "empty",
|
|
35
|
+
message: `The group ${group.path} holds no routes. Remove it, or file a route in it.`
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return problems;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The problems, for the terminal.
|
|
42
|
+
*/
|
|
43
|
+
const formatGroupProblems = (problems) => [`${problems.length} group ${problems.length === 1 ? "problem" : "problems"}:`, ...problems.map((problem) => ` ${problem.message}`)].join("\n");
|
|
44
|
+
//#endregion
|
|
6
45
|
//#region src/cli.ts
|
|
7
46
|
const usage = `Usage: kizuna <command> [options]
|
|
8
47
|
|
|
9
48
|
Commands:
|
|
10
49
|
generate Write kizuna.types.ts and every client the config declares.
|
|
11
|
-
routes Print every route the config serves.
|
|
50
|
+
routes Print every route the config serves. Exits 1 when a route is in
|
|
51
|
+
no group while others are, or a group holds no routes.
|
|
12
52
|
diff Compare the config against the same config at a git ref.
|
|
13
53
|
|
|
14
54
|
Options:
|
|
@@ -98,8 +138,13 @@ const runGenerate = async (values) => {
|
|
|
98
138
|
process.stdout.write(changed.length > 0 ? `Wrote:\n${changed.map((file) => ` ${file}`).join("\n")}\n` : "Everything was already up to date.\n");
|
|
99
139
|
};
|
|
100
140
|
const runRoutes = async (values) => {
|
|
101
|
-
const
|
|
141
|
+
const config = await loadOrDie(configPathFrom(values.config));
|
|
142
|
+
const entries = routeMap(config.api, {});
|
|
143
|
+
const problems = checkGroups(config.api);
|
|
102
144
|
process.stdout.write(values.json ? `${JSON.stringify(entries, null, 2)}\n` : `${formatRoutes(entries)}\n`);
|
|
145
|
+
if (problems.length === 0) return;
|
|
146
|
+
process.stderr.write(`\n${formatGroupProblems(problems)}\n`);
|
|
147
|
+
process.exit(1);
|
|
103
148
|
};
|
|
104
149
|
const runDiff = async (values) => {
|
|
105
150
|
let changes;
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_route_map = require("./route-map-
|
|
2
|
+
const require_route_map = require("./route-map-C0CF82bw.cjs");
|
|
3
3
|
let kizunajs_generator = require("kizunajs/generator");
|
|
4
4
|
//#region src/api-notices.ts
|
|
5
5
|
const readSunset = (route) => {
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, f as formatChange, g as diffSchemas, l as writeFiles, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes, u as diffApis } from "./route-map-
|
|
1
|
+
import { _ as loadConfig, a as ConfigSyntaxError, c as formatStale, f as formatChange, g as diffSchemas, l as writeFiles, n as routeMap, o as generateConfigTypes, p as hasBreakingChange, r as diffAgainst, s as checkFiles, t as formatRoutes, u as diffApis } from "./route-map-BPi-Oj1o.mjs";
|
|
2
2
|
import { walkApi } from "kizunajs/generator";
|
|
3
3
|
//#region src/api-notices.ts
|
|
4
4
|
const readSunset = (route) => {
|
|
@@ -502,7 +502,7 @@ const formatStale = (stale, command = "kizuna generate") => {
|
|
|
502
502
|
*/
|
|
503
503
|
const CONFIG_KEYS = [
|
|
504
504
|
"adapter",
|
|
505
|
-
"
|
|
505
|
+
"groups",
|
|
506
506
|
"auth",
|
|
507
507
|
"requestContext",
|
|
508
508
|
"validation",
|
|
@@ -823,7 +823,7 @@ const routeMap = (api, _options = {}) => {
|
|
|
823
823
|
const entries = [];
|
|
824
824
|
const toolKeys = [];
|
|
825
825
|
return walkApi(api, {
|
|
826
|
-
processRoute({ routeKey, route,
|
|
826
|
+
processRoute({ routeKey, route, routeGroups, deprecated, deprecationMessage, hidden }) {
|
|
827
827
|
if (route.tool) toolKeys.push({
|
|
828
828
|
key: routeKey,
|
|
829
829
|
origin: "route"
|
|
@@ -833,7 +833,7 @@ const routeMap = (api, _options = {}) => {
|
|
|
833
833
|
method: route.method,
|
|
834
834
|
path: route.path,
|
|
835
835
|
auth: describeAuth(route.auth),
|
|
836
|
-
|
|
836
|
+
groups: routeGroups,
|
|
837
837
|
deprecated: deprecated ? deprecationMessage ?? "" : void 0,
|
|
838
838
|
sunset: describeSunset(route.sunset),
|
|
839
839
|
...hidden ? { hidden: true } : {}
|
|
@@ -860,6 +860,7 @@ const formatRoutes = (entries) => {
|
|
|
860
860
|
return entries.map((entry) => {
|
|
861
861
|
const notes = [
|
|
862
862
|
`auth: ${entry.auth}`,
|
|
863
|
+
entry.groups.length > 0 && `group: ${entry.groups.join(", ")}`,
|
|
863
864
|
entry.tool && `tool: ${entry.tool}`,
|
|
864
865
|
entry.deprecated !== void 0 && `deprecated${entry.deprecated ? `, ${entry.deprecated}` : ""}`,
|
|
865
866
|
entry.sunset && `sunset ${entry.sunset}`,
|
|
@@ -525,7 +525,7 @@ const formatStale = (stale, command = "kizuna generate") => {
|
|
|
525
525
|
*/
|
|
526
526
|
const CONFIG_KEYS = [
|
|
527
527
|
"adapter",
|
|
528
|
-
"
|
|
528
|
+
"groups",
|
|
529
529
|
"auth",
|
|
530
530
|
"requestContext",
|
|
531
531
|
"validation",
|
|
@@ -846,7 +846,7 @@ const routeMap = (api, _options = {}) => {
|
|
|
846
846
|
const entries = [];
|
|
847
847
|
const toolKeys = [];
|
|
848
848
|
return (0, kizunajs_generator.walkApi)(api, {
|
|
849
|
-
processRoute({ routeKey, route,
|
|
849
|
+
processRoute({ routeKey, route, routeGroups, deprecated, deprecationMessage, hidden }) {
|
|
850
850
|
if (route.tool) toolKeys.push({
|
|
851
851
|
key: routeKey,
|
|
852
852
|
origin: "route"
|
|
@@ -856,7 +856,7 @@ const routeMap = (api, _options = {}) => {
|
|
|
856
856
|
method: route.method,
|
|
857
857
|
path: route.path,
|
|
858
858
|
auth: describeAuth(route.auth),
|
|
859
|
-
|
|
859
|
+
groups: routeGroups,
|
|
860
860
|
deprecated: deprecated ? deprecationMessage ?? "" : void 0,
|
|
861
861
|
sunset: describeSunset(route.sunset),
|
|
862
862
|
...hidden ? { hidden: true } : {}
|
|
@@ -883,6 +883,7 @@ const formatRoutes = (entries) => {
|
|
|
883
883
|
return entries.map((entry) => {
|
|
884
884
|
const notes = [
|
|
885
885
|
`auth: ${entry.auth}`,
|
|
886
|
+
entry.groups.length > 0 && `group: ${entry.groups.join(", ")}`,
|
|
886
887
|
entry.tool && `tool: ${entry.tool}`,
|
|
887
888
|
entry.deprecated !== void 0 && `deprecated${entry.deprecated ? `, ${entry.deprecated}` : ""}`,
|
|
888
889
|
entry.sunset && `sunset ${entry.sunset}`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kizunajs/cli",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.17",
|
|
4
4
|
"description": "Command line tooling for Kizuna.js",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"kizunajs",
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"yaml": "^2.8.4"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
|
-
"
|
|
65
|
-
"
|
|
64
|
+
"kizunajs": "2.0.0-beta.17",
|
|
65
|
+
"zod": "^4.0.0"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
+
"kizunajs": "2.0.0-beta.17",
|
|
68
69
|
"@types/node": "^24",
|
|
69
70
|
"@types/react": "^19.2.18",
|
|
70
71
|
"tsdown": "^0.21.0",
|
|
71
|
-
"zod": "^4.0.0"
|
|
72
|
-
"kizunajs": "2.0.0-beta.15"
|
|
72
|
+
"zod": "^4.0.0"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
75
|
"build": "tsdown src/index.ts src/cli.ts --format esm,cjs --dts --clean --external kizunajs --external zod --external jiti --external typescript",
|