@platforma-sdk/block-tools 2.17.8 → 2.17.9

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.
@@ -1,2 +1,3 @@
1
1
  export declare function rootPackageJsonInitial(): Record<string, unknown>;
2
+ export declare function rootPackageJsonToolchainRules(): void;
2
3
  export declare function rootPackageJsonRules(): void;
@@ -31,4 +31,5 @@ export declare const DERIVED_CATALOG_PINS: readonly DerivedCatalogPin[];
31
31
  export declare const RUNENV_PYTHON = "@platforma-open/milaboratories.runenv-python-3";
32
32
  export declare const RUNENV_PYTHON_VERSION = "1.8.2";
33
33
  export declare function rootPnpmWorkspaceInitial(ctx: RunContext): Record<string, unknown>;
34
+ export declare function rootPnpmWorkspaceToolchainRules(): void;
34
35
  export declare function rootPnpmWorkspaceRules(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/block-tools",
3
- "version": "2.17.8",
3
+ "version": "2.17.9",
4
4
  "description": "Utility to manipulate Platforma Blocks and Block Registry",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -31,14 +31,14 @@ export async function runRefresh(opts: {
31
31
 
32
32
  export function structureRefreshCommand(packageRoot: string): Command {
33
33
  const cmd = new Command("refresh").description(
34
- "Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only fires only catalog-bump rules (network).",
34
+ "Bring block(s) up to date with the canonical structure. Applies rules, writes files, bumps .structure version. Default mode is offline; --update-deps-only updates the catalog versions and the pnpm and Node toolchain (network).",
35
35
  );
36
36
 
37
37
  cmd.argument("[paths...]", "block path(s); defaults to the current directory");
38
38
  cmd.option("--sdk-internal", "block(s) live inside the SDK monorepo; skip root-scope rules");
39
39
  cmd.option(
40
40
  "--update-deps-only",
41
- "fire ONLY catalog-bump rules (npm network). Follow with `pnpm install` then a plain refresh.",
41
+ "update ONLY the catalog versions and the pnpm and Node toolchain (npm network). Follow with `pnpm install` then a plain refresh.",
42
42
  );
43
43
 
44
44
  cmd.action(async (argv: string[], flags) => {
@@ -31,11 +31,18 @@ const VARS: BlockVars = {
31
31
  const readMonorepoFile = (relativePath: string) =>
32
32
  readFileSync(new URL(`../../../../../${relativePath}`, import.meta.url), "utf-8");
33
33
 
34
- function refresh(fs: MemoryFileSystem) {
35
- return engineRun(STRUCTURE, fs, discoverRunContext({ fs, isSdkInternal: false }), {
36
- templates: defaultTemplateProvider(),
37
- rediscover: () => discoverRunContext({ fs, isSdkInternal: false, dryRun: true }),
38
- });
34
+ const REFRESH_MODES = ["default", "update-deps-only"] as const;
35
+
36
+ function refresh(fs: MemoryFileSystem, mode: (typeof REFRESH_MODES)[number] = "default") {
37
+ return engineRun(
38
+ STRUCTURE,
39
+ fs,
40
+ discoverRunContext({ fs, isSdkInternal: false, updateDepsOnly: mode === "update-deps-only" }),
41
+ {
42
+ templates: defaultTemplateProvider(),
43
+ rediscover: () => discoverRunContext({ fs, isSdkInternal: false, dryRun: true }),
44
+ },
45
+ );
39
46
  }
40
47
 
41
48
  function editJson(fs: MemoryFileSystem, edit: (json: Record<string, unknown>) => void) {
@@ -67,7 +74,7 @@ describe("block toolchain", () => {
67
74
  expect(workspace.allowBuilds).toMatchObject({ ...REQUIRED_BUILDS, ...SKIPPED_BUILDS });
68
75
  });
69
76
 
70
- test("refresh moves an old block to the SDK pnpm and Node", () => {
77
+ test.each(REFRESH_MODES)("refresh (%s) moves an old block to the SDK pnpm and Node", (mode) => {
71
78
  const { fs } = simulateInit({ vars: VARS });
72
79
  editJson(fs, (json) => {
73
80
  json.packageManager = "pnpm@9.12.0";
@@ -80,7 +87,7 @@ describe("block toolchain", () => {
80
87
  doc.setIn(["catalog", "turbo"], "~2.8.11");
81
88
  });
82
89
 
83
- refresh(fs);
90
+ refresh(fs, mode);
84
91
 
85
92
  const pkg = JSON.parse(fs.read("package.json"));
86
93
  expect(pkg.packageManager).toBe(PACKAGE_MANAGER);
@@ -146,11 +153,14 @@ describe("block toolchain", () => {
146
153
  expect(workspace.allowBuilds).toEqual({ ...SKIPPED_BUILDS, ...REQUIRED_BUILDS });
147
154
  });
148
155
 
149
- test("refresh refuses a package.json pnpm field with settings", () => {
150
- const { fs } = simulateInit({ vars: VARS });
151
- editJson(fs, (json) => {
152
- json.pnpm = { overrides: { zod: "~3.25.76" } };
153
- });
154
- expect(() => refresh(fs)).toThrow(/pnpm-workspace\.yaml/);
155
- });
156
+ test.each(REFRESH_MODES)(
157
+ "refresh (%s) refuses a package.json pnpm field with settings",
158
+ (mode) => {
159
+ const { fs } = simulateInit({ vars: VARS });
160
+ editJson(fs, (json) => {
161
+ json.pnpm = { overrides: { zod: "~3.25.76" } };
162
+ });
163
+ expect(() => refresh(fs, mode)).toThrow(/pnpm-workspace\.yaml/);
164
+ },
165
+ );
156
166
  });
@@ -14,6 +14,10 @@
14
14
  // migrated block that never carried `@milaboratories/ts-builder` etc. now
15
15
  // gets them ADDED on `--update-deps-only`, no manual catalog seed required.
16
16
  //
17
+ // The same frame also applies the toolchain rules (SDK pnpm and Node, pnpm 12
18
+ // workspace settings), so `upgrade-sdk` runs its first `pnpm i` on the SDK
19
+ // pnpm with its release-age check.
20
+ //
17
21
  // Wrapped in the same root-scope `when(!isSdkInternal)` guard as the rest of
18
22
  // the root rules — internal blocks get their catalog from the parent
19
23
  // monorepo, so catalog resolution never applies there.
@@ -27,9 +31,13 @@ import {
27
31
  ensureCatalogLatest,
28
32
  ensureCatalogVersion,
29
33
  pinCatalogToDependencyOf,
34
+ enforceFieldOrder,
30
35
  } from "../engine/api";
36
+ import { rootPackageJsonInitial, rootPackageJsonToolchainRules } from "./root-package-json";
37
+ import { canonicalPackageJsonOrder } from "./shared/key-order";
31
38
  import {
32
39
  rootPnpmWorkspaceInitial,
40
+ rootPnpmWorkspaceToolchainRules,
33
41
  SDK_CATALOG_PACKAGES,
34
42
  DERIVED_CATALOG_PINS,
35
43
  RUNENV_PYTHON,
@@ -42,6 +50,14 @@ export function rootCatalogBumpRules(): void {
42
50
  when(
43
51
  ({ ctx }) => !ctx.isSdkInternal,
44
52
  () => {
53
+ managed(
54
+ "package.json",
55
+ generate(() => rootPackageJsonInitial()),
56
+ () => {
57
+ rootPackageJsonToolchainRules();
58
+ enforceFieldOrder([...canonicalPackageJsonOrder]);
59
+ },
60
+ );
45
61
  // On init, the default root rules create pnpm-workspace.yaml from
46
62
  // this same generator (the curated SDK placeholders + infra
47
63
  // floor); this leaf then overwrites the SDK entries with npm
@@ -77,6 +93,7 @@ export function rootCatalogBumpRules(): void {
77
93
  if (ctx.modules.some((m) => m.scope === "software")) {
78
94
  ensureCatalogVersion(RUNENV_PYTHON, RUNENV_PYTHON_VERSION);
79
95
  }
96
+ rootPnpmWorkspaceToolchainRules();
80
97
  },
81
98
  );
82
99
  },
@@ -80,7 +80,7 @@ export function rootPackageJsonInitial(): Record<string, unknown> {
80
80
  };
81
81
  }
82
82
 
83
- export function rootPackageJsonRules(): void {
83
+ export function rootPackageJsonToolchainRules(): void {
84
84
  ensureField("packageManager", PACKAGE_MANAGER);
85
85
  ensureField("devEngines.runtime", NODE_RUNTIME);
86
86
  removeField(
@@ -96,6 +96,10 @@ export function rootPackageJsonRules(): void {
96
96
  "pnpm",
97
97
  'pnpm 11+ ignores the "pnpm" field in package.json. Move its settings to pnpm-workspace.yaml: overrides as is, onlyBuiltDependencies as allowBuilds true, neverBuiltDependencies as allowBuilds false.',
98
98
  );
99
+ }
100
+
101
+ export function rootPackageJsonRules(): void {
102
+ rootPackageJsonToolchainRules();
99
103
 
100
104
  // Root is never published — it carries no `name`; delete any stray one.
101
105
  removeField("name");
@@ -134,8 +134,7 @@ export function rootPnpmWorkspaceInitial(ctx: RunContext): Record<string, unknow
134
134
  };
135
135
  }
136
136
 
137
- export function rootPnpmWorkspaceRules(): void {
138
- ensureWorkspaceModulePaths();
137
+ export function rootPnpmWorkspaceToolchainRules(): void {
139
138
  ensureWorkspaceListItems("minimumReleaseAgeExclude", MINIMUM_RELEASE_AGE_EXCLUDE);
140
139
  ensureWorkspaceMapEntries("allowBuilds", SKIPPED_BUILDS, { keepExisting: true });
141
140
  ensureWorkspaceMapEntries("allowBuilds", REQUIRED_BUILDS);
@@ -151,6 +150,11 @@ export function rootPnpmWorkspaceRules(): void {
151
150
  ensureCatalogVersion(name, version);
152
151
  }
153
152
  ensureCatalogAtLeast("turbo", TURBO_VERSION);
153
+ }
154
+
155
+ export function rootPnpmWorkspaceRules(): void {
156
+ ensureWorkspaceModulePaths();
157
+ rootPnpmWorkspaceToolchainRules();
154
158
  // Catalog side of the retired-dep cleanup — the per-package side sheds the
155
159
  // matching `catalog:` references.
156
160
  for (const name of RETIRED_TOOLCHAIN_DEPS) ensureCatalogAbsent(name);
@@ -28,8 +28,6 @@ export const REQUIRED_BUILDS: Record<string, boolean> = {
28
28
  /** Install scripts in the SDK tree that only clean up, print, or build optional native code. */
29
29
  export const SKIPPED_BUILDS: Record<string, boolean> = {
30
30
  "@milaboratories/tengo-tester": false,
31
- "cpu-features": false,
32
31
  esbuild: false,
33
32
  protobufjs: false,
34
- ssh2: false,
35
33
  };