@platforma-sdk/block-tools 2.15.2 → 2.16.0
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 +3 -3
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +5 -5
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/engine/version.d.ts +1 -1
- package/package.json +8 -8
- package/src/structure/__tests__/workflow-imports-check.test.ts +74 -0
- package/src/structure/engine/version.ts +1 -1
- package/src/structure/rules/workflow-package-json.ts +6 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FileSystem } from './fs/api';
|
|
2
|
-
export declare const STRUCTURE_VERSION =
|
|
2
|
+
export declare const STRUCTURE_VERSION = 3;
|
|
3
3
|
export declare const STRUCTURE_MIN_SUPPORTED = 0;
|
|
4
4
|
/** Block-relative path of the structurer metadata file. */
|
|
5
5
|
export declare const STRUCTURE_META_FILE = ".structure";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/block-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.16.0",
|
|
4
4
|
"description": "Utility to manipulate Platforma Blocks and Block Registry",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"bin": {
|
|
@@ -34,14 +34,14 @@
|
|
|
34
34
|
"undici": "~7.16.0",
|
|
35
35
|
"yaml": "^2.8.0",
|
|
36
36
|
"zod": "~3.25.76",
|
|
37
|
-
"@milaboratories/pl-model-
|
|
37
|
+
"@milaboratories/pl-model-backend": "1.4.26",
|
|
38
|
+
"@milaboratories/pl-http": "1.2.4",
|
|
38
39
|
"@milaboratories/pl-model-middle-layer": "1.32.1",
|
|
39
|
-
"@platforma-sdk/blocks-deps-updater": "2.2.0",
|
|
40
|
-
"@milaboratories/ts-helpers": "1.8.6",
|
|
41
40
|
"@milaboratories/resolve-helper": "1.1.3",
|
|
42
41
|
"@platforma-sdk/package-builder-lib": "1.4.0",
|
|
43
|
-
"@milaboratories/
|
|
44
|
-
"@
|
|
42
|
+
"@milaboratories/ts-helpers": "1.8.6",
|
|
43
|
+
"@platforma-sdk/blocks-deps-updater": "2.2.0",
|
|
44
|
+
"@milaboratories/pl-model-common": "1.49.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"vite": "^8.0.6",
|
|
57
57
|
"vite-plugin-dts": "^5.0.3",
|
|
58
58
|
"vitest": "^4.1.3",
|
|
59
|
-
"@milaboratories/
|
|
59
|
+
"@milaboratories/build-configs": "2.0.1",
|
|
60
60
|
"@milaboratories/ts-configs": "1.4.0",
|
|
61
|
-
"@milaboratories/
|
|
61
|
+
"@milaboratories/ts-builder": "1.7.2"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "vite build",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// End-to-end (real STRUCTURE): the workflow `check` script drops the unused
|
|
2
|
+
// tengo imports before it checks the sources, an existing block converges on
|
|
3
|
+
// that script, and a second refresh changes nothing.
|
|
4
|
+
//
|
|
5
|
+
// `imports` belongs to `check` and not to `build`: the build task declares
|
|
6
|
+
// every tracked file as its input, so a command that rewrites sources inside
|
|
7
|
+
// it would change the inputs turbo has already hashed.
|
|
8
|
+
|
|
9
|
+
import { describe, test, expect } from "vitest";
|
|
10
|
+
import { simulateInit, defaultTemplateProvider } from "../engine/testing";
|
|
11
|
+
import { run as engineRun } from "../engine/runner";
|
|
12
|
+
import { discoverRunContext } from "../engine/discovery-fs";
|
|
13
|
+
import { STRUCTURE } from "../structure-definition";
|
|
14
|
+
import { SDK_CATALOG_PACKAGES } from "../rules/root-pnpm-workspace";
|
|
15
|
+
import type { BlockVars } from "../engine/api";
|
|
16
|
+
|
|
17
|
+
const VARS: BlockVars = {
|
|
18
|
+
facadeName: "@platforma-open/test-org.demo",
|
|
19
|
+
baseName: "test-org.demo",
|
|
20
|
+
npmOrg: "@platforma-open",
|
|
21
|
+
orgScope: "test-org",
|
|
22
|
+
shortName: "demo",
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const CHECK_SCRIPT = "pl-tengo imports && pl-tengo check";
|
|
26
|
+
const BUILD_SCRIPT = "shx rm -rf dist && pl-tengo build";
|
|
27
|
+
|
|
28
|
+
const mockLookup = (name: string): string | undefined =>
|
|
29
|
+
SDK_CATALOG_PACKAGES.includes(name) ? "9.9.9" : undefined;
|
|
30
|
+
|
|
31
|
+
type Pkg = { scripts?: Record<string, string> };
|
|
32
|
+
|
|
33
|
+
function refresh(fs: ReturnType<typeof simulateInit>["fs"]) {
|
|
34
|
+
const ctx = discoverRunContext({ fs, isSdkInternal: false });
|
|
35
|
+
engineRun(STRUCTURE, fs, ctx, {
|
|
36
|
+
templates: defaultTemplateProvider(),
|
|
37
|
+
rediscover: () => discoverRunContext({ fs, isSdkInternal: false, dryRun: true }),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const workflowScripts = (fs: ReturnType<typeof simulateInit>["fs"]): Record<string, string> =>
|
|
42
|
+
(JSON.parse(fs.read("workflow/package.json")) as Pkg).scripts ?? {};
|
|
43
|
+
|
|
44
|
+
describe("workflow imports check (real STRUCTURE)", () => {
|
|
45
|
+
test("init writes the check script, and leaves build without it", () => {
|
|
46
|
+
const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
|
|
47
|
+
|
|
48
|
+
const scripts = workflowScripts(fs);
|
|
49
|
+
expect(scripts.check).toBe(CHECK_SCRIPT);
|
|
50
|
+
expect(scripts.build).toBe(BUILD_SCRIPT);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test("a block with the old check script converges on the new one", () => {
|
|
54
|
+
const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
|
|
55
|
+
|
|
56
|
+
// A block made before the command existed.
|
|
57
|
+
const pkg = JSON.parse(fs.read("workflow/package.json")) as Pkg;
|
|
58
|
+
pkg.scripts = { ...pkg.scripts, check: "pl-tengo check" };
|
|
59
|
+
fs.write("workflow/package.json", JSON.stringify(pkg, null, 2) + "\n");
|
|
60
|
+
|
|
61
|
+
refresh(fs);
|
|
62
|
+
|
|
63
|
+
expect(workflowScripts(fs).check).toBe(CHECK_SCRIPT);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test("refresh of a canonical block changes nothing", () => {
|
|
67
|
+
const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
|
|
68
|
+
const before = fs.read("workflow/package.json");
|
|
69
|
+
|
|
70
|
+
refresh(fs);
|
|
71
|
+
|
|
72
|
+
expect(fs.read("workflow/package.json")).toBe(before);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
import type { FileSystem } from "./fs/api";
|
|
12
12
|
|
|
13
|
-
export const STRUCTURE_VERSION =
|
|
13
|
+
export const STRUCTURE_VERSION = 3;
|
|
14
14
|
export const STRUCTURE_MIN_SUPPORTED = 0;
|
|
15
15
|
/** Block-relative path of the structurer metadata file. */
|
|
16
16
|
export const STRUCTURE_META_FILE = ".structure";
|
|
@@ -33,7 +33,11 @@ export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unkn
|
|
|
33
33
|
// No `fmt`: the workflow is Tengo, not TS — nothing for oxlint/oxfmt
|
|
34
34
|
// to process. Tengo is built and checked by pl-tengo.
|
|
35
35
|
build: "shx rm -rf dist && pl-tengo build",
|
|
36
|
-
|
|
36
|
+
// `imports` drops the imports the tengo sources do not use. It belongs
|
|
37
|
+
// to `check`, not `build`: the build task declares every tracked file as
|
|
38
|
+
// its input, so a command that rewrites sources inside it would change
|
|
39
|
+
// the inputs turbo has already hashed.
|
|
40
|
+
check: "pl-tengo imports && pl-tengo check",
|
|
37
41
|
// No `test`: the vitest `test` script is wired by the body rule ONLY
|
|
38
42
|
// when co-located test files exist (a freshly-init'd workflow has none).
|
|
39
43
|
// Tengo source formatter (emacs batch). Falls back to a notice when
|
|
@@ -67,7 +71,7 @@ export function workflowPackageJsonRules(): void {
|
|
|
67
71
|
// No `fmt` script: the workflow is Tengo, not TS — build + check run via
|
|
68
72
|
// pl-tengo; `format` runs the emacs-batch Tengo formatter (no-op when absent).
|
|
69
73
|
ensureScript("build", "shx rm -rf dist && pl-tengo build");
|
|
70
|
-
ensureScript("check", "pl-tengo check");
|
|
74
|
+
ensureScript("check", "pl-tengo imports && pl-tengo check");
|
|
71
75
|
ensureScript("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'");
|
|
72
76
|
// The vitest `test` script AND the `vitest` devDep are wired ONLY when the
|
|
73
77
|
// workflow carries co-located integration tests (`src/**/*.test.ts`, incl.
|