@platforma-sdk/block-tools 2.14.1 → 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.
Files changed (30) hide show
  1. package/dist/cli.js +17 -13
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +779 -730
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/structure/engine/testing.d.ts +3 -0
  6. package/dist/structure/rules/root-changeset-config.d.ts +8 -0
  7. package/dist/structure/rules/shared/initial-version.d.ts +10 -0
  8. package/package.json +8 -8
  9. package/src/structure/__tests__/facade-end-state.test.ts +68 -3
  10. package/src/structure/__tests__/init-catalog-completeness.test.ts +86 -0
  11. package/src/structure/__tests__/init-lint-clean.test.ts +84 -0
  12. package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -0
  13. package/src/structure/__tests__/root-changeset-config.test.ts +94 -0
  14. package/src/structure/__tests__/root-ci-workflows.test.ts +3 -0
  15. package/src/structure/engine/testing.ts +4 -0
  16. package/src/structure/rules/block-package-json.ts +2 -1
  17. package/src/structure/rules/kind-package-json.ts +5 -1
  18. package/src/structure/rules/model-package-json.ts +5 -1
  19. package/src/structure/rules/root-changeset-config.ts +61 -0
  20. package/src/structure/rules/root-package-json.ts +2 -1
  21. package/src/structure/rules/root-pnpm-workspace.ts +2 -0
  22. package/src/structure/rules/root.ts +15 -1
  23. package/src/structure/rules/shared/initial-version.ts +17 -0
  24. package/src/structure/rules/software-package-json.ts +6 -0
  25. package/src/structure/rules/test-package-json.ts +5 -1
  26. package/src/structure/rules/ui-package-json.ts +5 -1
  27. package/src/structure/rules/workflow-package-json.ts +5 -1
  28. package/src/structure/templates/text/model/src/index.tpl.ts +1 -1
  29. package/src/structure/templates/text/workflows/build.tpl.yaml +1 -1
  30. package/src/structure/templates/text/workflows/mark-stable.tpl.yaml +1 -1
@@ -3,11 +3,16 @@
3
3
  // skip this whole scope: the parent monorepo owns root files. Hence the
4
4
  // `when(({ ctx }) => !ctx.isSdkInternal, ...)` wrapper.
5
5
 
6
- import { scope, when, fixed, managed, file, generate } from "../engine/api";
6
+ import { scope, when, fixed, managed, seed, file, text, generate } from "../engine/api";
7
7
  import { rootPackageJsonInitial, rootPackageJsonRules } from "./root-package-json";
8
8
  import { rootTurboJsonInitial, rootTurboJsonRules } from "./root-turbo-json";
9
9
  import { rootPnpmWorkspaceInitial, rootPnpmWorkspaceRules } from "./root-pnpm-workspace";
10
10
  import { rootGitignoreRules } from "./root-gitignore";
11
+ import {
12
+ rootChangesetConfigInitial,
13
+ rootChangesetConfigRules,
14
+ EMPTY_CHANGESET_SEED,
15
+ } from "./root-changeset-config";
11
16
 
12
17
  export function rootRules(): void {
13
18
  scope("root", () => {
@@ -42,6 +47,15 @@ export function rootRules(): void {
42
47
  managed(".gitignore", file("root/.gitignore"), () => {
43
48
  rootGitignoreRules();
44
49
  });
50
+
51
+ managed(
52
+ ".changeset/config.json",
53
+ generate(() => rootChangesetConfigInitial()),
54
+ () => {
55
+ rootChangesetConfigRules();
56
+ },
57
+ );
58
+ seed(".changeset/scaffold.md", text(EMPTY_CHANGESET_SEED));
45
59
  },
46
60
  );
47
61
  });
@@ -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((data) => ({}))
14
+ .templateParams(() => ({}))
15
15
  .sections(() => [{ type: "link", href: "/", label: "Main" }])
16
16
  .done();
17
17
 
@@ -24,7 +24,7 @@ jobs:
24
24
  with:
25
25
  app-name: '${appName}'
26
26
  app-name-slug: '${appNameSlug}'
27
- node-version: '20.x'
27
+ node-version: '22.x'
28
28
  gha-runner-label: hz-ubuntu-dind
29
29
  build-script-name: 'build:dev-local'
30
30
  build-before-publish-script-name: 'build:release'
@@ -15,7 +15,7 @@ jobs:
15
15
  uses: milaboratory/github-ci/.github/workflows/block-mark-stable.yaml@v4
16
16
  with:
17
17
  app-name: '${appName}'
18
- node-version: '20.x'
18
+ node-version: '22.x'
19
19
  npmrc-config: |
20
20
  {
21
21
  "registries": {