@platforma-sdk/block-tools 2.16.10 → 2.16.12

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,4 @@
1
1
  /** Glob (module-relative) for co-located unit tests in a scope's `src/`. */
2
2
  export declare const COLOCATED_TEST_GLOB = "src/**/*.test.ts";
3
+ /** Glob (module-relative) for Tengo unit tests, run by `pl-tengo test`. */
4
+ export declare const TENGO_TEST_GLOB = "src/**/*.test.tengo";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/block-tools",
3
- "version": "2.16.10",
3
+ "version": "2.16.12",
4
4
  "description": "Utility to manipulate Platforma Blocks and Block Registry",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -34,10 +34,10 @@
34
34
  "undici": "~7.16.0",
35
35
  "yaml": "^2.8.0",
36
36
  "zod": "~3.25.76",
37
+ "@milaboratories/pl-model-backend": "1.4.36",
38
+ "@milaboratories/pl-model-middle-layer": "1.34.2",
37
39
  "@milaboratories/pl-http": "1.2.4",
38
- "@milaboratories/pl-model-backend": "1.4.35",
39
- "@milaboratories/pl-model-middle-layer": "1.34.1",
40
- "@milaboratories/pl-model-common": "1.52.0",
40
+ "@milaboratories/pl-model-common": "1.53.0",
41
41
  "@milaboratories/resolve-helper": "1.1.3",
42
42
  "@milaboratories/ts-helpers": "1.8.6",
43
43
  "@platforma-sdk/package-builder-lib": "1.4.0",
@@ -56,8 +56,8 @@
56
56
  "vite": "^8.0.6",
57
57
  "vite-plugin-dts": "^5.0.3",
58
58
  "vitest": "^4.1.3",
59
- "@milaboratories/build-configs": "2.0.2",
60
59
  "@milaboratories/ts-builder": "1.7.2",
60
+ "@milaboratories/build-configs": "2.0.2",
61
61
  "@milaboratories/ts-configs": "1.4.0"
62
62
  },
63
63
  "scripts": {
@@ -104,4 +104,63 @@ describe("co-located test wiring (real STRUCTURE)", () => {
104
104
  // (workflow tsconfig is JSON, but parseYaml reads JSON too; types:[] unchanged)
105
105
  expect(wfTs.types).toEqual([]);
106
106
  });
107
+
108
+ test("a workflow Tengo test wires `pl-tengo test` without vitest", async () => {
109
+ const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
110
+ fs.write("workflow/src/lib.test.tengo", `test := import(":test")\n`);
111
+
112
+ await refresh(fs);
113
+
114
+ const workflow = JSON.parse(fs.read("workflow/package.json")) as Pkg;
115
+ expect(workflow.scripts?.test).toBe("pl-tengo test");
116
+ expect(workflow.devDependencies?.vitest).toBeUndefined();
117
+
118
+ const after = fs.read("workflow/package.json");
119
+ await refresh(fs);
120
+ expect(fs.read("workflow/package.json")).toBe(after);
121
+ });
122
+
123
+ test("a Tengo-only workflow replaces a stale vitest script and drops the vitest devDep", async () => {
124
+ const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
125
+ fs.write("workflow/src/sub/deep/lib.test.tengo", `test := import(":test")\n`);
126
+ const stale = JSON.parse(fs.read("workflow/package.json")) as Pkg;
127
+ stale.scripts = { ...stale.scripts, test: "vitest run --passWithNoTests" };
128
+ stale.devDependencies = { ...stale.devDependencies, vitest: "catalog:" };
129
+ fs.write("workflow/package.json", JSON.stringify(stale, null, 2) + "\n");
130
+
131
+ await refresh(fs);
132
+
133
+ const workflow = JSON.parse(fs.read("workflow/package.json")) as Pkg;
134
+ expect(workflow.scripts?.test).toBe("pl-tengo test");
135
+ expect(workflow.devDependencies?.vitest).toBeUndefined();
136
+ });
137
+
138
+ test("Tengo and vitest workflow tests wire both runners and restore a drifted script", async () => {
139
+ const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
140
+ fs.write("workflow/src/lib.test.tengo", `test := import(":test")\n`);
141
+ fs.write("workflow/src/wf.test.ts", `import { test } from "vitest";\ntest("x", () => {});\n`);
142
+ const drifted = JSON.parse(fs.read("workflow/package.json")) as Pkg;
143
+ drifted.scripts = { ...drifted.scripts, test: "vitest run --passWithNoTests" };
144
+ fs.write("workflow/package.json", JSON.stringify(drifted, null, 2) + "\n");
145
+
146
+ await refresh(fs);
147
+
148
+ const workflow = JSON.parse(fs.read("workflow/package.json")) as Pkg;
149
+ expect(workflow.scripts?.test).toBe("pl-tengo test && vitest run --passWithNoTests");
150
+ expect(workflow.devDependencies?.vitest).toBe("catalog:");
151
+
152
+ const after = fs.read("workflow/package.json");
153
+ await refresh(fs);
154
+ expect(fs.read("workflow/package.json")).toBe(after);
155
+ });
156
+
157
+ test("a Tengo test template for vitest (`*.test.tpl.tengo`) does not wire `pl-tengo test`", async () => {
158
+ const { fs } = simulateInit({ vars: VARS, registryLookup: mockLookup });
159
+ fs.write("workflow/src/test/run.test.tpl.tengo", `self := import(":tpl")\n`);
160
+
161
+ await refresh(fs);
162
+
163
+ const workflow = JSON.parse(fs.read("workflow/package.json")) as Pkg;
164
+ expect(workflow.scripts?.test).toBeUndefined();
165
+ });
107
166
  });
@@ -9,3 +9,6 @@
9
9
 
10
10
  /** Glob (module-relative) for co-located unit tests in a scope's `src/`. */
11
11
  export const COLOCATED_TEST_GLOB = "src/**/*.test.ts";
12
+
13
+ /** Glob (module-relative) for Tengo unit tests, run by `pl-tengo test`. */
14
+ export const TENGO_TEST_GLOB = "src/**/*.test.tengo";
@@ -19,7 +19,7 @@ import {
19
19
  import { scopeDepMaps } from "../engine/ctx";
20
20
  import { canonicalPackageJsonOrder } from "./shared/key-order";
21
21
  import { ensureModuleVersion, INITIAL_MODULE_VERSION } from "./shared/initial-version";
22
- import { COLOCATED_TEST_GLOB } from "./shared/colocated-tests";
22
+ import { COLOCATED_TEST_GLOB, TENGO_TEST_GLOB } from "./shared/colocated-tests";
23
23
  import { removeRetiredToolchainDeps } from "./shared/retired-deps";
24
24
 
25
25
  export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unknown> {
@@ -38,8 +38,8 @@ export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unkn
38
38
  // its input, so a command that rewrites sources inside it would change
39
39
  // the inputs turbo has already hashed.
40
40
  check: "pl-tengo imports && pl-tengo check",
41
- // No `test`: the vitest `test` script is wired by the body rule ONLY
42
- // when co-located test files exist (a freshly-init'd workflow has none).
41
+ // No `test`: the body rule wires it ONLY when Tengo or vitest test files
42
+ // exist (a freshly-init'd workflow has none).
43
43
  // Tengo source formatter (emacs batch). Falls back to a notice when
44
44
  // emacs is absent, so the script never hard-fails the environment.
45
45
  format: "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'",
@@ -53,7 +53,7 @@ export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unkn
53
53
  "@platforma-sdk/tengo-builder": "sdk:",
54
54
  "@platforma-sdk/test": "sdk:",
55
55
  // `vitest` is NOT seeded here — it's wired by the body rule only when the
56
- // workflow carries co-located tests (a freshly-init'd workflow has none).
56
+ // workflow carries `*.test.ts` tests (a freshly-init'd workflow has none).
57
57
  shx: "catalog:",
58
58
  },
59
59
  };
@@ -73,13 +73,14 @@ export function workflowPackageJsonRules(): void {
73
73
  ensureScript("build", "shx rm -rf dist && pl-tengo build");
74
74
  ensureScript("check", "pl-tengo imports && pl-tengo check");
75
75
  ensureScript("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'");
76
- // The vitest `test` script AND the `vitest` devDep are wired ONLY when the
77
- // workflow carries co-located integration tests (`src/**/*.test.ts`, incl.
78
- // `src/test/`). A test-less workflow gets neither — no `test` task, no
79
- // vitest dep — and stays a refresh fixpoint. (Workflow tests type-check via
80
- // the standalone workflow/tsconfig with `types: []` — they pull their types
81
- // from `@platforma-sdk/test` — so no node-types wiring is needed here,
82
- // unlike model/ui.)
76
+ // The `test` script runs `pl-tengo test` when the workflow carries Tengo unit
77
+ // tests (`src/**/*.test.tengo`) and vitest when it carries co-located
78
+ // integration tests (`src/**/*.test.ts`, incl. `src/test/`); both when it
79
+ // carries both. The `vitest` devDep follows the vitest tests. A test-less
80
+ // workflow gets no vitest dep, and an existing `test` script is left as is.
81
+ // (Workflow tests type-check via the standalone workflow/tsconfig with
82
+ // `types: []` — they pull their types from `@platforma-sdk/test` — so no
83
+ // node-types wiring is needed here, unlike model/ui.)
83
84
  //
84
85
  // Skipped entirely for sdk-internal (in-monorepo) blocks: they own their test
85
86
  // wiring under the monorepo's shared infrastructure — see model-package-json.
@@ -89,10 +90,17 @@ export function workflowPackageJsonRules(): void {
89
90
  when(
90
91
  whenFilesExist(COLOCATED_TEST_GLOB),
91
92
  () => {
92
- ensureScript("test", "vitest run --passWithNoTests");
93
+ when(
94
+ whenFilesExist(TENGO_TEST_GLOB),
95
+ () => ensureScript("test", "pl-tengo test && vitest run --passWithNoTests"),
96
+ () => ensureScript("test", "vitest run --passWithNoTests"),
97
+ );
93
98
  ensureDevDeps({ vitest: "catalog:" });
94
99
  },
95
- () => removeDep("vitest"),
100
+ () => {
101
+ when(whenFilesExist(TENGO_TEST_GLOB), () => ensureScript("test", "pl-tengo test"));
102
+ removeDep("vitest");
103
+ },
96
104
  ),
97
105
  );
98
106