@oj-module/cli 0.2.30 → 0.2.43
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/devkit/manual.md +5 -5
- package/devkit/module-dev-and-cdn-playground.md +1 -1
- package/package.json +2 -2
- package/shell-dist/assets/runtime.js +2 -2
- package/shell-dist/index.html +2 -2
- package/shell-dist/versions.json +3 -3
- package/src/__tests__/cli.test.ts +23 -14
- package/src/__tests__/list.test.ts +176 -0
- package/src/__tests__/registry-cli.test.ts +522 -0
- package/src/__tests__/registry-export.test.ts +319 -0
- package/src/__tests__/registry-import.test.ts +336 -0
- package/src/__tests__/registry-sign.test.ts +352 -0
- package/src/cli-output.ts +81 -0
- package/src/cli.ts +298 -39
- package/src/config-cmd.ts +100 -0
- package/src/contract/__tests__/handler-scan.test.ts +74 -2
- package/src/contract/handler-scan.ts +27 -2
- package/src/enable.ts +1 -1
- package/src/exit-codes.ts +33 -0
- package/src/index.ts +5 -9
- package/src/install.ts +120 -38
- package/src/lifecycle/__tests__/authoring.test.ts +6 -5
- package/src/lifecycle/__tests__/fixtures/sig/demo-solution-0.2.0.tgz.bad.sig +3 -2
- package/src/lifecycle/__tests__/fixtures/sig/demo-solution-0.2.0.tgz.sig +3 -2
- package/src/lifecycle/__tests__/fixtures/sig/demo-solution-0.2.0.tgz.unknown.sig +3 -2
- package/src/lifecycle/__tests__/fixtures/sig/gen-signed-fixtures.d.mts +5 -4
- package/src/lifecycle/__tests__/fixtures/sig/gen-signed-fixtures.mjs +9 -6
- package/src/lifecycle/__tests__/helpers.ts +10 -6
- package/src/lifecycle/__tests__/install.test.ts +72 -15
- package/src/lifecycle/__tests__/manifest-contract.test.ts +40 -1
- package/src/lifecycle/__tests__/publish.test.ts +174 -33
- package/src/lifecycle/__tests__/sig-fixtures.test.ts +9 -6
- package/src/lifecycle/__tests__/sign.test.ts +9 -8
- package/src/lifecycle/__tests__/smoke.test.ts +1 -1
- package/src/lifecycle/__tests__/uninstall.test.ts +4 -4
- package/src/lifecycle/sign.ts +8 -7
- package/src/list.ts +146 -0
- package/src/manifest-contract.ts +11 -5
- package/src/market/__tests__/bootstrap.test.ts +4 -1
- package/src/market/__tests__/build-index.test.ts +529 -42
- package/src/market/__tests__/fixture.test.ts +17 -1
- package/src/market/__tests__/publish.test.ts +8 -7
- package/src/market/__tests__/setup.test.ts +4 -4
- package/src/market/__tests__/sharding.test.ts +90 -0
- package/src/market/__tests__/verify.test.ts +237 -13
- package/src/market/__tests__/yank-ledger.test.ts +60 -0
- package/src/market/bootstrap.ts +8 -3
- package/src/market/build-index.ts +407 -40
- package/src/market/cdn-layout.ts +3 -2
- package/src/market/command.ts +40 -6
- package/src/market/failure-playbook.ts +1 -1
- package/src/market/fixture.ts +20 -3
- package/src/market/index-builder.ts +120 -47
- package/src/market/publish.ts +3 -1
- package/src/market/setup.ts +3 -3
- package/src/market/sharding.ts +94 -0
- package/src/market/trial.ts +1 -1
- package/src/market/verify.ts +220 -53
- package/src/market/walkthrough.ts +7 -6
- package/src/market/yank-ledger.ts +91 -0
- package/src/publish.ts +250 -38
- package/src/registry-export.ts +405 -0
- package/src/registry-import.ts +410 -0
- package/src/registry-sidecar.ts +84 -0
- package/src/registry-sign.ts +322 -0
- package/src/registry-source.ts +192 -0
- package/src/sign.ts +13 -10
- package/src/site.ts +4 -4
- package/src/trust.ts +1 -1
- package/src/uninstall.ts +14 -2
- package/src/usage.ts +130 -25
- package/src/view.ts +94 -0
- package/templates/cdn/README.md +35 -5
- package/templates/config.yaml +46 -96
- package/templates/init.include.yaml +1 -1
- package/templates/src/_platform/api/_lifecycle/atomic.ts +3 -0
- package/templates/src/_platform/api/_lifecycle/installer.ts +44 -7
- package/templates/src/_platform/api/_lifecycle/limits.ts +21 -0
- package/templates/src/_platform/api/_lifecycle/source-seq.ts +88 -0
- package/templates/src/_platform/api/_lifecycle/steps/download.ts +15 -0
- package/templates/src/_platform/api/_lifecycle/steps/extract.ts +61 -2
- package/templates/src/_platform/api/_lifecycle/steps/preflight.ts +55 -6
- package/templates/src/_platform/api/_lifecycle/steps/register.ts +2 -1
- package/templates/src/_platform/api/_lifecycle/steps/verify.ts +22 -8
- package/templates/src/_platform/api/_lifecycle/tgz-guard.ts +96 -0
- package/templates/src/_platform/api/_lifecycle/types.ts +6 -3
- package/templates/src/_platform/api/_lifecycle/verify-checks.ts +8 -0
- package/templates/src/_platform/api/_shared/service/domain/solution-perms.ts +9 -1
- package/templates/src/_platform/api/_shared/site-facade.ts +62 -11
- package/templates/src/_platform/api/manifest.yaml +1 -0
- package/templates/src/_platform/api/market/api.ts +362 -99
- package/templates/src/_platform/api/market/index-source.ts +112 -0
- package/templates/src/_platform/api/migrations/0014__reg_source_seq.mysql.sql +9 -0
- package/templates/src/_platform/api/migrations/0014__reg_source_seq.pg.sql +7 -0
- package/templates/src/_platform/api/migrations/0014__reg_source_seq.sql +8 -0
- package/templates/src/_platform/api/schema.yaml +8 -0
- package/templates/src/_platform/api/solutions/api.ts +8 -3
- package/templates/src/oj-market/web/__tests__/CardGrid.test.tsx +13 -0
- package/templates/src/oj-market/web/__tests__/InstallDialog.test.tsx +38 -0
- package/templates/src/oj-market/web/components/CardItem.tsx +10 -0
- package/templates/src/oj-market/web/components/InstallDialog.tsx +18 -0
- package/templates/src/oj-market/web/locales/en-US.json +1 -0
- package/templates/src/oj-market/web/locales/zh-CN.json +1 -0
- package/templates/src/oj-market/web/types.ts +3 -1
- package/templates/tests/lifecycle/installer.spec.ts +24 -0
- package/templates/tests/lifecycle/market-api.spec.ts +641 -85
- package/templates/tests/lifecycle/preflight.spec.ts +52 -0
- package/templates/tests/lifecycle/sig-fixtures.spec.ts +7 -4
- package/templates/tests/lifecycle/source-seq.spec.ts +55 -0
- package/templates/tests/lifecycle/steps-fs.spec.ts +166 -7
- package/templates/tests/lifecycle/tgz-guard.spec.ts +133 -1
- package/templates/tests/lifecycle/verify-checks.spec.ts +27 -13
- package/templates/tests/lifecycle/verify-report.spec.ts +3 -1
- package/templates/tests/rbac-solution-perms.spec.ts +41 -0
- package/vendor/host-versions.json +3 -3
package/src/manifest-contract.ts
CHANGED
|
@@ -32,8 +32,13 @@ export function assertValidSolutionName(name: string, where: string): void {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/** §4.2 保留名清单(C2-01/13/14 共用;market 经 R9
|
|
36
|
-
export const RESERVED_NAMES = new Set(["_platform", "system", "auth", "market", "framework", "health", "plugins", "_system"]);
|
|
35
|
+
/** §4.2 保留名清单(C2-01/13/14 共用;market 经 R9 恢复保留)。REG-CS7 扩项:oj/ojm/registry 一并保留 */
|
|
36
|
+
export const RESERVED_NAMES = new Set(["_platform", "system", "auth", "market", "framework", "health", "plugins", "_system", "oj", "ojm", "registry"]);
|
|
37
|
+
|
|
38
|
+
/** 保留名替代建议(REG-CS7:给可落地的 kebab-case 候选,而非只说「非法」;两候选恒非保留名) */
|
|
39
|
+
export function reservedNameSuggestions(name: string): [string, string] {
|
|
40
|
+
return [`${name}-app`, `meta-${name}`];
|
|
41
|
+
}
|
|
37
42
|
|
|
38
43
|
/** C2-02 字符集:[0-9A-Za-z.-](禁 +——oj validate_version 拒装,附录 B-1;禁 _——契约收紧) */
|
|
39
44
|
const VERSION_CHARS_RE = /^[0-9A-Z.-]+$/i;
|
|
@@ -201,7 +206,8 @@ export function validateContract(m: unknown): string[] {
|
|
|
201
206
|
v0.push(v("C2-01", `name「${String(m.name)}」不匹配 ^[a-z][a-z0-9-]{0,63}$(小写字母开头,仅小写字母/数字/连字符)`));
|
|
202
207
|
}
|
|
203
208
|
if (RESERVED_NAMES.has(name)) {
|
|
204
|
-
|
|
209
|
+
const [a1, a2] = reservedNameSuggestions(name);
|
|
210
|
+
v0.push(v("C2-01", `name「${name}」为保留名(§4.2:${[...RESERVED_NAMES].join("/")}),禁用于方案(R9);替代名建议:${a1} / ${a2}`));
|
|
205
211
|
}
|
|
206
212
|
|
|
207
213
|
// ── C2-02 version:字符集 + oj 相容排除 ──
|
|
@@ -285,7 +291,7 @@ export function validateContract(m: unknown): string[] {
|
|
|
285
291
|
else {
|
|
286
292
|
apiSeg = p.slice("/api/".length);
|
|
287
293
|
if (RESERVED_NAMES.has(apiSeg)) {
|
|
288
|
-
v0.push(v("C2-13", `api.prefix 模块段「${apiSeg}
|
|
294
|
+
v0.push(v("C2-13", `api.prefix 模块段「${apiSeg}」为保留名(§4.2:${[...RESERVED_NAMES].join("/")}),禁用;替代名建议:${reservedNameSuggestions(apiSeg)[0]} / ${reservedNameSuggestions(apiSeg)[1]}`));
|
|
289
295
|
}
|
|
290
296
|
}
|
|
291
297
|
}
|
|
@@ -352,7 +358,7 @@ export function validateContract(m: unknown): string[] {
|
|
|
352
358
|
v0.push(v("C2-14", `web.route_prefix「${String(rp)}」必须匹配 ^/[a-z][a-z0-9-]{0,63}$(缺省 /<name>)`));
|
|
353
359
|
}
|
|
354
360
|
else if (RESERVED_NAMES.has(rp.slice(1))) {
|
|
355
|
-
v0.push(v("C2-14", `web.route_prefix 首段「${rp.slice(1)}
|
|
361
|
+
v0.push(v("C2-14", `web.route_prefix 首段「${rp.slice(1)}」为保留名(§4.2:${[...RESERVED_NAMES].join("/")}),禁用;替代名建议:${reservedNameSuggestions(rp.slice(1))[0]} / ${reservedNameSuggestions(rp.slice(1))[1]}`));
|
|
356
362
|
}
|
|
357
363
|
}
|
|
358
364
|
const base = `modules/${escapeRe(name)}/${escapeRe(version)}/[a-z0-9._/-]+`;
|
|
@@ -132,7 +132,10 @@ describe("given 一个装了 oj 二进制的源工程 When 自举隔离站点",
|
|
|
132
132
|
|
|
133
133
|
expect(site.cdnDir.startsWith(site.root)).toBe(true);
|
|
134
134
|
expect(existsSync(join(site.cdnDir, "demo-solution-0.1.0.tgz"))).toBe(true);
|
|
135
|
-
|
|
135
|
+
// REG-CS5 三级索引:catalog.yaml(提交点)+ shards/<n>.yaml(版本明细)及其 .sig
|
|
136
|
+
expect(existsSync(join(site.cdnDir, "catalog.yaml"))).toBe(true);
|
|
137
|
+
expect(existsSync(join(site.cdnDir, "catalog.yaml.sig"))).toBe(true);
|
|
138
|
+
expect(readdirSync(join(site.cdnDir, "shards")).some(f => /^1\.yaml$/.test(f))).toBe(true);
|
|
136
139
|
expect(site.cdnBaseUrl).toBe(`${site.baseUrl}/cdn`);
|
|
137
140
|
await site.cleanup();
|
|
138
141
|
});
|