@platforma-sdk/block-tools 2.14.0 → 2.14.2
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.js +17 -13
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +780 -730
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/engine/testing.d.ts +3 -0
- package/dist/structure/rules/root-changeset-config.d.ts +8 -0
- package/dist/structure/rules/shared/initial-version.d.ts +10 -0
- package/package.json +4 -4
- package/src/structure/__tests__/facade-end-state.test.ts +68 -3
- package/src/structure/__tests__/init-catalog-completeness.test.ts +86 -0
- package/src/structure/__tests__/init-lint-clean.test.ts +84 -0
- package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -0
- package/src/structure/__tests__/root-changeset-config.test.ts +94 -0
- package/src/structure/__tests__/root-ci-workflows.test.ts +3 -0
- package/src/structure/engine/testing.ts +4 -0
- package/src/structure/rules/block-package-json.ts +2 -1
- package/src/structure/rules/kind-package-json.ts +5 -1
- package/src/structure/rules/model-package-json.ts +5 -1
- package/src/structure/rules/root-changeset-config.ts +61 -0
- package/src/structure/rules/root-package-json.ts +2 -1
- package/src/structure/rules/root-pnpm-workspace.ts +3 -0
- package/src/structure/rules/root.ts +15 -1
- package/src/structure/rules/shared/initial-version.ts +17 -0
- package/src/structure/rules/software-package-json.ts +6 -0
- package/src/structure/rules/test-package-json.ts +5 -1
- package/src/structure/rules/ui-package-json.ts +5 -1
- package/src/structure/rules/workflow-package-json.ts +5 -1
- package/src/structure/templates/text/model/src/index.tpl.ts +1 -1
- package/src/structure/templates/text/workflows/build.tpl.yaml +1 -1
- package/src/structure/templates/text/workflows/mark-stable.tpl.yaml +1 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { transformAt } from "../../engine/api";
|
|
2
|
+
|
|
3
|
+
/** Seeded at init for every module. `pnpm pack` rewrites the facade's
|
|
4
|
+
* `workspace:*` devDeps to concrete ranges, so a versionless sibling breaks
|
|
5
|
+
* `do-pack`. Changesets owns the field afterwards. */
|
|
6
|
+
export const INITIAL_MODULE_VERSION = "1.0.0";
|
|
7
|
+
|
|
8
|
+
/** Backfill `version` on a sibling that has none — a block scaffolded before
|
|
9
|
+
* the initials seeded the field keeps its versionless manifests through a
|
|
10
|
+
* `structure refresh`, and `do-pack` then dies resolving the facade's
|
|
11
|
+
* `workspace:*` deps. Never touches an existing value: past init the field
|
|
12
|
+
* belongs to changesets. */
|
|
13
|
+
export function ensureModuleVersion(): void {
|
|
14
|
+
transformAt<unknown>("version", (current) =>
|
|
15
|
+
typeof current === "string" && current.length > 0 ? current : INITIAL_MODULE_VERSION,
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
type RunContext,
|
|
21
21
|
} from "../engine/api";
|
|
22
22
|
import { canonicalPackageJsonOrder } from "./shared/key-order";
|
|
23
|
+
import { ensureModuleVersion, INITIAL_MODULE_VERSION } from "./shared/initial-version";
|
|
23
24
|
|
|
24
25
|
// The software-build build/pack commands, shared by the generator and the reconciler. block-tools
|
|
25
26
|
// bundles the build engine, so these are the only build-tool commands a software-build block runs.
|
|
@@ -56,6 +57,7 @@ export function softwarePackageJsonInitial(ctx: RunContext): Record<string, unkn
|
|
|
56
57
|
|
|
57
58
|
return {
|
|
58
59
|
name: `${v.facadeName}.software`,
|
|
60
|
+
version: INITIAL_MODULE_VERSION,
|
|
59
61
|
type: "module",
|
|
60
62
|
description: "Block Software",
|
|
61
63
|
files: ["./dist/**/*"],
|
|
@@ -80,6 +82,10 @@ export function softwarePackageJsonRules(): void {
|
|
|
80
82
|
// so a `structure refresh` heals any block that has it.
|
|
81
83
|
removeField("private");
|
|
82
84
|
|
|
85
|
+
// A software package publishes, so it must carry a `version`; backfilled when
|
|
86
|
+
// the manifest predates the seeded field, then owned by changesets.
|
|
87
|
+
ensureModuleVersion();
|
|
88
|
+
|
|
83
89
|
ensureField("type", "module");
|
|
84
90
|
ensureField("files", ["./dist/**/*"]);
|
|
85
91
|
|
|
@@ -13,12 +13,14 @@ import {
|
|
|
13
13
|
type RunContext,
|
|
14
14
|
} from "../engine/api";
|
|
15
15
|
import { canonicalPackageJsonOrder } from "./shared/key-order";
|
|
16
|
+
import { ensureModuleVersion, INITIAL_MODULE_VERSION } from "./shared/initial-version";
|
|
16
17
|
import { removeRetiredToolchainDeps } from "./shared/retired-deps";
|
|
17
18
|
|
|
18
19
|
export function testPackageJsonInitial(ctx: RunContext): Record<string, unknown> {
|
|
19
20
|
const v = ctx.blockVars;
|
|
20
21
|
return {
|
|
21
22
|
name: `${v.facadeName}.test`,
|
|
23
|
+
version: INITIAL_MODULE_VERSION,
|
|
22
24
|
private: true,
|
|
23
25
|
type: "module",
|
|
24
26
|
scripts: {
|
|
@@ -42,7 +44,9 @@ export function testPackageJsonInitial(ctx: RunContext): Record<string, unknown>
|
|
|
42
44
|
export function testPackageJsonRules(): void {
|
|
43
45
|
// Controlled sibling — workspace-only, never published. (The initial already
|
|
44
46
|
// seeds `private: true`; the body re-asserts it. The `version` is kept —
|
|
45
|
-
// changesets-owned — so the packed template's lib carries a version
|
|
47
|
+
// changesets-owned — so the packed template's lib carries a version, and
|
|
48
|
+
// backfilled when the manifest predates the seeded field.)
|
|
49
|
+
ensureModuleVersion();
|
|
46
50
|
ensureField("private", true);
|
|
47
51
|
|
|
48
52
|
ensureField("type", "module");
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
} from "../engine/api";
|
|
26
26
|
import { scopeDepMap } from "../engine/ctx";
|
|
27
27
|
import { canonicalPackageJsonOrder } from "./shared/key-order";
|
|
28
|
+
import { ensureModuleVersion, INITIAL_MODULE_VERSION } from "./shared/initial-version";
|
|
28
29
|
import { COLOCATED_TEST_GLOB } from "./shared/colocated-tests";
|
|
29
30
|
import { removeRetiredToolchainDeps } from "./shared/retired-deps";
|
|
30
31
|
|
|
@@ -32,6 +33,7 @@ export function uiPackageJsonInitial(ctx: RunContext): Record<string, unknown> {
|
|
|
32
33
|
const v = ctx.blockVars;
|
|
33
34
|
return {
|
|
34
35
|
name: `${v.facadeName}.ui`,
|
|
36
|
+
version: INITIAL_MODULE_VERSION,
|
|
35
37
|
private: true,
|
|
36
38
|
type: "module",
|
|
37
39
|
scripts: {
|
|
@@ -61,7 +63,9 @@ export function uiPackageJsonInitial(ctx: RunContext): Record<string, unknown> {
|
|
|
61
63
|
|
|
62
64
|
export function uiPackageJsonRules(): void {
|
|
63
65
|
// Controlled sibling — workspace-only, never published, but kept versioned
|
|
64
|
-
// (changesets-owned) so the packed template's lib carries a version
|
|
66
|
+
// (changesets-owned) so the packed template's lib carries a version —
|
|
67
|
+
// backfilled when the manifest predates the seeded field.
|
|
68
|
+
ensureModuleVersion();
|
|
65
69
|
ensureField("private", true);
|
|
66
70
|
|
|
67
71
|
ensureField("type", "module");
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
} from "../engine/api";
|
|
19
19
|
import { scopeDepMaps } from "../engine/ctx";
|
|
20
20
|
import { canonicalPackageJsonOrder } from "./shared/key-order";
|
|
21
|
+
import { ensureModuleVersion, INITIAL_MODULE_VERSION } from "./shared/initial-version";
|
|
21
22
|
import { COLOCATED_TEST_GLOB } from "./shared/colocated-tests";
|
|
22
23
|
import { removeRetiredToolchainDeps } from "./shared/retired-deps";
|
|
23
24
|
|
|
@@ -25,6 +26,7 @@ export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unkn
|
|
|
25
26
|
const v = ctx.blockVars;
|
|
26
27
|
return {
|
|
27
28
|
name: `${v.facadeName}.workflow`,
|
|
29
|
+
version: INITIAL_MODULE_VERSION,
|
|
28
30
|
private: true,
|
|
29
31
|
type: "module",
|
|
30
32
|
scripts: {
|
|
@@ -55,7 +57,9 @@ export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unkn
|
|
|
55
57
|
|
|
56
58
|
export function workflowPackageJsonRules(): void {
|
|
57
59
|
// Controlled sibling — workspace-only, never published, but kept versioned
|
|
58
|
-
// (changesets-owned) so the packed template's lib carries a version
|
|
60
|
+
// (changesets-owned) so the packed template's lib carries a version —
|
|
61
|
+
// backfilled when the manifest predates the seeded field.
|
|
62
|
+
ensureModuleVersion();
|
|
59
63
|
ensureField("private", true);
|
|
60
64
|
|
|
61
65
|
ensureField("type", "module");
|
|
@@ -11,7 +11,7 @@ const dataModel = new DataModelBuilder({ kind })
|
|
|
11
11
|
|
|
12
12
|
export const platforma = BlockModelV3.create({ dataModel, kind })
|
|
13
13
|
.args(() => ({}))
|
|
14
|
-
.templateParams((
|
|
14
|
+
.templateParams(() => ({}))
|
|
15
15
|
.sections(() => [{ type: "link", href: "/", label: "Main" }])
|
|
16
16
|
.done();
|
|
17
17
|
|