@platforma-sdk/block-tools 2.21.0 → 2.22.1

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.
@@ -49,7 +49,8 @@ export type RunContext = {
49
49
  /** True for `check` mode and the post-run recheck. */
50
50
  dryRun: boolean;
51
51
  /** `ownNpmRegistry` from `.structure`: the block publishes `@platforma-open`
52
- * to npm.platforma.bio (shared-CI opt-in). False when absent. */
52
+ * to npm.platforma.bio (shared CI `npm-own-registry-scopes`). True when
53
+ * absent; false only for a block that opted out. */
53
54
  ownNpmRegistry: boolean;
54
55
  };
55
56
  export type { ContentForm, ManagedBody, RunMode, Structure, TriggerFn };
@@ -5,9 +5,9 @@ export declare const STRUCTURE_MIN_SUPPORTED = 0;
5
5
  export declare const STRUCTURE_META_FILE = ".structure";
6
6
  export type StructureMeta = {
7
7
  version: number;
8
- /** The block publishes `@platforma-open` to npm.platforma.bio instead of
9
- * npmjs (the shared CI's `npm-own-registry-scopes` opt-in). Set by hand in
10
- * `.structure` while blocks move; absent = npmjs, as before. */
8
+ /** Whether the block publishes `@platforma-open` to npm.platforma.bio
9
+ * (the shared CI's `npm-own-registry-scopes`). Absent = yes, the default.
10
+ * `false` keeps the block on npmjs (opt-out, set by hand). */
11
11
  ownNpmRegistry?: boolean;
12
12
  };
13
13
  /** Read `.structure`. Missing file or invalid payload → version 0. */
@@ -19,6 +19,8 @@ export declare class StructureVersionFloorError extends Error {
19
19
  readonly floor: number;
20
20
  constructor(version: number, floor: number);
21
21
  }
22
- /** Write `.structure`. Writes a fresh payload rather than merging; an unset
23
- * `ownNpmRegistry` is left out, so a block without it keeps `{"version":N}`. */
22
+ /** Write `.structure`. Writes a fresh payload rather than merging. Only the
23
+ * opt-out (`ownNpmRegistry: false`) is written: `true` is the default, so a
24
+ * block on the default keeps `{"version":N}` (an explicit `true` from the
25
+ * opt-in period is dropped). */
24
26
  export declare function writeStructureMeta(fs: FileSystem, meta: StructureMeta): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/block-tools",
3
- "version": "2.21.0",
3
+ "version": "2.22.1",
4
4
  "description": "Utility to manipulate Platforma Blocks and Block Registry",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -26,9 +26,9 @@
26
26
  "@aws-sdk/client-ecr-public": "3.1157.0",
27
27
  "@inquirer/prompts": "^7.0.1",
28
28
  "@milaboratories/pl-http": "1.2.7",
29
- "@milaboratories/pl-model-backend": "1.4.53",
30
- "@milaboratories/pl-model-common": "1.56.0",
31
- "@milaboratories/pl-model-middle-layer": "1.41.0",
29
+ "@milaboratories/pl-model-backend": "1.4.54",
30
+ "@milaboratories/pl-model-common": "1.57.0",
31
+ "@milaboratories/pl-model-middle-layer": "1.41.1",
32
32
  "@milaboratories/resolve-helper": "1.1.3",
33
33
  "@milaboratories/ts-helpers": "1.9.1",
34
34
  "@platforma-sdk/blocks-deps-updater": "2.2.2",
@@ -73,29 +73,31 @@ describe("root CI workflows (fixed, generated)", () => {
73
73
  expect(ciChanges).toEqual([]);
74
74
  });
75
75
 
76
- test("without ownNpmRegistry the workflow has no own-registry input", () => {
76
+ test("by default the workflow publishes to the own registry", () => {
77
77
  const { fs, ctx } = simulateInit({ vars: VARS });
78
- expect(ctx.ownNpmRegistry).toBe(false);
78
+ expect(ctx.ownNpmRegistry).toBe(true);
79
79
  const build = fs.read(BUILD);
80
- expect(build).not.toContain("npm-own-registry-scopes");
81
- // The placeholder expands to nothing: the next line follows directly.
82
- expect(build).toContain("require-package-path-bump: true\n\n npmrc-config: |");
80
+ expect(build.match(/npm-own-registry-scopes: '@platforma-open'/g)).toHaveLength(1);
81
+ // The default is not written: a block on it keeps {"version":N}.
83
82
  expect(fs.read(STRUCTURE_META_FILE)).not.toContain("ownNpmRegistry");
83
+ expect(discoverRunContext({ fs, isSdkInternal: false }).ownNpmRegistry).toBe(true);
84
84
  });
85
85
 
86
- test("ownNpmRegistry in .structure adds the opt-in input, and refresh keeps both", () => {
86
+ test("ownNpmRegistry: false opts out, and refresh keeps the opt-out", () => {
87
87
  const { fs } = simulateInit({ vars: VARS });
88
88
  const meta = readStructureMeta(fs);
89
- fs.write(STRUCTURE_META_FILE, JSON.stringify({ ...meta, ownNpmRegistry: true }));
89
+ fs.write(STRUCTURE_META_FILE, JSON.stringify({ ...meta, ownNpmRegistry: false }));
90
90
 
91
91
  const ctx = discoverRunContext({ fs, isSdkInternal: false });
92
- expect(ctx.ownNpmRegistry).toBe(true);
92
+ expect(ctx.ownNpmRegistry).toBe(false);
93
93
  engineRun(STRUCTURE, fs, ctx, { templates: TEMPLATES });
94
94
 
95
95
  const build = fs.read(BUILD);
96
- expect(build.match(/npm-own-registry-scopes: '@platforma-open'/g)).toHaveLength(1);
97
- // Refresh rewrote .structure and kept the setting.
98
- expect(readStructureMeta(fs).ownNpmRegistry).toBe(true);
96
+ expect(build).not.toContain("npm-own-registry-scopes");
97
+ // The placeholder expands to nothing: the next line follows directly.
98
+ expect(build).toContain("require-package-path-bump: true\n\n npmrc-config: |");
99
+ // Refresh rewrote .structure and kept the opt-out.
100
+ expect(readStructureMeta(fs).ownNpmRegistry).toBe(false);
99
101
 
100
102
  // Fixpoint: a check right after changes nothing in the workflow files.
101
103
  const checkCtx: RunContext = {
@@ -106,20 +108,31 @@ describe("root CI workflows (fixed, generated)", () => {
106
108
  expect(result.changes.filter((c) => c.path === BUILD || c.path === MARK_STABLE)).toEqual([]);
107
109
  });
108
110
 
109
- test("removing ownNpmRegistry from .structure removes the input on refresh", () => {
111
+ test("removing the opt-out brings the input back on refresh", () => {
110
112
  const { fs } = simulateInit({ vars: VARS });
111
113
  const meta = readStructureMeta(fs);
112
- fs.write(STRUCTURE_META_FILE, JSON.stringify({ ...meta, ownNpmRegistry: true }));
114
+ fs.write(STRUCTURE_META_FILE, JSON.stringify({ ...meta, ownNpmRegistry: false }));
113
115
  engineRun(STRUCTURE, fs, discoverRunContext({ fs, isSdkInternal: false }), {
114
116
  templates: TEMPLATES,
115
117
  });
116
- expect(fs.read(BUILD)).toContain("npm-own-registry-scopes");
118
+ expect(fs.read(BUILD)).not.toContain("npm-own-registry-scopes");
117
119
 
118
120
  fs.write(STRUCTURE_META_FILE, JSON.stringify({ version: meta.version }));
119
121
  engineRun(STRUCTURE, fs, discoverRunContext({ fs, isSdkInternal: false }), {
120
122
  templates: TEMPLATES,
121
123
  });
122
- expect(fs.read(BUILD)).not.toContain("npm-own-registry-scopes");
124
+ expect(fs.read(BUILD)).toContain("npm-own-registry-scopes");
125
+ });
126
+
127
+ test("an explicit ownNpmRegistry: true (opt-in period) is kept on and dropped from .structure", () => {
128
+ const { fs } = simulateInit({ vars: VARS });
129
+ const meta = readStructureMeta(fs);
130
+ fs.write(STRUCTURE_META_FILE, JSON.stringify({ ...meta, ownNpmRegistry: true }));
131
+ engineRun(STRUCTURE, fs, discoverRunContext({ fs, isSdkInternal: false }), {
132
+ templates: TEMPLATES,
133
+ });
134
+ expect(fs.read(BUILD).match(/npm-own-registry-scopes: '@platforma-open'/g)).toHaveLength(1);
135
+ expect(fs.read(STRUCTURE_META_FILE)).toBe(JSON.stringify({ version: meta.version }));
123
136
  });
124
137
 
125
138
  test("sdk-internal blocks get neither workflow file", () => {
@@ -63,7 +63,8 @@ export type RunContext = {
63
63
  /** True for `check` mode and the post-run recheck. */
64
64
  dryRun: boolean;
65
65
  /** `ownNpmRegistry` from `.structure`: the block publishes `@platforma-open`
66
- * to npm.platforma.bio (shared-CI opt-in). False when absent. */
66
+ * to npm.platforma.bio (shared CI `npm-own-registry-scopes`). True when
67
+ * absent; false only for a block that opted out. */
67
68
  ownNpmRegistry: boolean;
68
69
  };
69
70
 
@@ -92,6 +92,6 @@ export function createRunContext(input: CreateRunContextInput): RunContext {
92
92
  blockVars: input.blockVars,
93
93
  version: input.version ?? 0,
94
94
  dryRun: input.dryRun ?? false,
95
- ownNpmRegistry: input.ownNpmRegistry ?? false,
95
+ ownNpmRegistry: input.ownNpmRegistry ?? true,
96
96
  };
97
97
  }
@@ -217,6 +217,6 @@ export function discoverRunContext(input: DiscoverInput): RunContext {
217
217
  blockVars,
218
218
  version: meta.version,
219
219
  dryRun: input.dryRun ?? false,
220
- ownNpmRegistry: meta.ownNpmRegistry === true,
220
+ ownNpmRegistry: meta.ownNpmRegistry !== false,
221
221
  });
222
222
  }
@@ -17,9 +17,9 @@ export const STRUCTURE_META_FILE = ".structure";
17
17
 
18
18
  export type StructureMeta = {
19
19
  version: number;
20
- /** The block publishes `@platforma-open` to npm.platforma.bio instead of
21
- * npmjs (the shared CI's `npm-own-registry-scopes` opt-in). Set by hand in
22
- * `.structure` while blocks move; absent = npmjs, as before. */
20
+ /** Whether the block publishes `@platforma-open` to npm.platforma.bio
21
+ * (the shared CI's `npm-own-registry-scopes`). Absent = yes, the default.
22
+ * `false` keeps the block on npmjs (opt-out, set by hand). */
23
23
  ownNpmRegistry?: boolean;
24
24
  };
25
25
 
@@ -31,7 +31,7 @@ export function readStructureMeta(fs: FileSystem): StructureMeta {
31
31
  const meta: StructureMeta = {
32
32
  version: typeof parsed?.version === "number" ? parsed.version : 0,
33
33
  };
34
- if (parsed?.ownNpmRegistry === true) meta.ownNpmRegistry = true;
34
+ if (typeof parsed?.ownNpmRegistry === "boolean") meta.ownNpmRegistry = parsed.ownNpmRegistry;
35
35
  return meta;
36
36
  } catch {
37
37
  return { version: 0 };
@@ -61,11 +61,13 @@ export class StructureVersionFloorError extends Error {
61
61
  }
62
62
  }
63
63
 
64
- /** Write `.structure`. Writes a fresh payload rather than merging; an unset
65
- * `ownNpmRegistry` is left out, so a block without it keeps `{"version":N}`. */
64
+ /** Write `.structure`. Writes a fresh payload rather than merging. Only the
65
+ * opt-out (`ownNpmRegistry: false`) is written: `true` is the default, so a
66
+ * block on the default keeps `{"version":N}` (an explicit `true` from the
67
+ * opt-in period is dropped). */
66
68
  export function writeStructureMeta(fs: FileSystem, meta: StructureMeta): void {
67
69
  const payload: StructureMeta = { version: meta.version };
68
- if (meta.ownNpmRegistry === true) payload.ownNpmRegistry = true;
70
+ if (meta.ownNpmRegistry === false) payload.ownNpmRegistry = false;
69
71
  // Compact, single-line — this is a tiny machine file, no pretty-print.
70
72
  fs.write(STRUCTURE_META_FILE, JSON.stringify(payload));
71
73
  }
@@ -29,13 +29,13 @@ function humanizeShortName(shortName: string): string {
29
29
  .join(" ");
30
30
  }
31
31
 
32
- /** Appended after `require-package-path-bump` when `.structure` has
33
- * `ownNpmRegistry: true`: the shared CI then installs and publishes
34
- * `@platforma-open` through npm.platforma.bio. Empty otherwise, so a block
35
- * without the setting gets the same file byte for byte. */
32
+ /** Appended after `require-package-path-bump` unless `.structure` has
33
+ * `ownNpmRegistry: false`: the shared CI then installs and publishes
34
+ * `@platforma-open` through npm.platforma.bio. Empty for an opted-out block,
35
+ * which keeps publishing to npmjs. */
36
36
  const OWN_NPM_REGISTRY_INPUT = `
37
37
 
38
- # .structure "ownNpmRegistry": publish @platforma-open to npm.platforma.bio.
38
+ # Publish @platforma-open to npm.platforma.bio (opt out: .structure "ownNpmRegistry": false).
39
39
  npm-own-registry-scopes: '@platforma-open'`;
40
40
 
41
41
  export function rootCiRules(): void {