@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.
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/engine/api.d.ts +2 -1
- package/dist/structure/engine/version.d.ts +7 -5
- package/package.json +4 -4
- package/src/structure/__tests__/root-ci-workflows.test.ts +28 -15
- package/src/structure/engine/api.ts +2 -1
- package/src/structure/engine/ctx.ts +1 -1
- package/src/structure/engine/discovery-fs.ts +1 -1
- package/src/structure/engine/version.ts +9 -7
- package/src/structure/rules/root-ci.ts +5 -5
|
@@ -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
|
|
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
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
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
|
|
23
|
-
* `ownNpmRegistry` is
|
|
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.
|
|
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.
|
|
30
|
-
"@milaboratories/pl-model-common": "1.
|
|
31
|
-
"@milaboratories/pl-model-middle-layer": "1.41.
|
|
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("
|
|
76
|
+
test("by default the workflow publishes to the own registry", () => {
|
|
77
77
|
const { fs, ctx } = simulateInit({ vars: VARS });
|
|
78
|
-
expect(ctx.ownNpmRegistry).toBe(
|
|
78
|
+
expect(ctx.ownNpmRegistry).toBe(true);
|
|
79
79
|
const build = fs.read(BUILD);
|
|
80
|
-
expect(build
|
|
81
|
-
// The
|
|
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
|
|
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:
|
|
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(
|
|
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.
|
|
97
|
-
//
|
|
98
|
-
expect(
|
|
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
|
|
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:
|
|
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)).
|
|
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
|
|
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 ??
|
|
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
|
|
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
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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 ===
|
|
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
|
|
65
|
-
* `ownNpmRegistry` is
|
|
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 ===
|
|
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`
|
|
33
|
-
* `ownNpmRegistry:
|
|
34
|
-
* `@platforma-open` through npm.platforma.bio. Empty
|
|
35
|
-
*
|
|
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
|
-
#
|
|
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 {
|