@platforma-sdk/block-tools 2.10.16 → 2.10.18
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 +13 -13
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +404 -373
- package/dist/cli.mjs.map +1 -1
- package/dist/structure/engine/api.d.ts +1 -1
- package/dist/structure/engine/builders.d.ts +9 -9
- package/dist/structure/engine/content-rules.d.ts +17 -0
- package/dist/structure/engine/registry-client.d.ts +30 -2
- package/dist/structure/engine/runner.d.ts +6 -0
- package/dist/structure/rules/root-pnpm-workspace.d.ts +13 -0
- package/package.json +5 -5
- package/src/structure/__tests__/model-package-json.snapshot.test.ts +1 -2
- package/src/structure/__tests__/tsconfig-idempotency.test.ts +94 -0
- package/src/structure/cli/run-structure.ts +12 -2
- package/src/structure/engine/__tests__/content-rules/pin-catalog-to-dependency-of.test.ts +65 -0
- package/src/structure/engine/__tests__/content-rules/when-inner.test.ts +30 -0
- package/src/structure/engine/__tests__/derived-pin-lookup.test.ts +54 -0
- package/src/structure/engine/api.ts +1 -0
- package/src/structure/engine/builders.ts +38 -23
- package/src/structure/engine/content-rules.ts +29 -0
- package/src/structure/engine/registry-client.ts +116 -2
- package/src/structure/engine/runner.ts +18 -2
- package/src/structure/init-block-constructor.ts +16 -3
- package/src/structure/rules/model-package-json.ts +35 -16
- package/src/structure/rules/model.ts +11 -35
- package/src/structure/rules/root-catalog-bump.ts +12 -1
- package/src/structure/rules/root-package-json.ts +7 -5
- package/src/structure/rules/root-pnpm-workspace.ts +24 -8
- package/src/structure/rules/ui-package-json.ts +34 -13
- package/src/structure/rules/ui.ts +10 -22
- package/src/structure/rules/workflow-package-json.ts +25 -11
- package/src/structure/rules/workflow.ts +21 -2
- package/src/structure/templates/static/model/tsconfig.node.json +7 -0
- package/src/structure/templates/static/ui/tsconfig.node.json +7 -0
|
@@ -13,9 +13,6 @@ import {
|
|
|
13
13
|
blockVars,
|
|
14
14
|
when,
|
|
15
15
|
whenFilesExist,
|
|
16
|
-
ensureField,
|
|
17
|
-
removeField,
|
|
18
|
-
pruneKeysMatching,
|
|
19
16
|
} from "../engine/api";
|
|
20
17
|
import { getActiveRunContext } from "../engine/builders";
|
|
21
18
|
import { uiPackageJsonInitial, uiPackageJsonRules } from "./ui-package-json";
|
|
@@ -23,25 +20,16 @@ import { COLOCATED_TEST_GLOB } from "./shared/colocated-tests";
|
|
|
23
20
|
|
|
24
21
|
export function uiRules(): void {
|
|
25
22
|
scope("ui", () => {
|
|
26
|
-
//
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
managed("tsconfig.json", file("ui/tsconfig.json"), () => {
|
|
37
|
-
ensureField("extends", "@milaboratories/ts-configs/block/ui");
|
|
38
|
-
removeField("compilerOptions");
|
|
39
|
-
when(whenFilesExist(COLOCATED_TEST_GLOB), () => {
|
|
40
|
-
ensureField("compilerOptions.types", ["node"]);
|
|
41
|
-
});
|
|
42
|
-
ensureField("include", ["src/**/*"]);
|
|
43
|
-
pruneKeysMatching((k) => k !== "extends" && k !== "include" && k !== "compilerOptions");
|
|
44
|
-
});
|
|
23
|
+
// Two static end states by co-located-test presence: a test-bearing ui gets
|
|
24
|
+
// node ambient types (`.node.json`) so tests' `node:*` imports type-check
|
|
25
|
+
// under vue-tsc — `@types/node` is wired alongside by the package.json rule;
|
|
26
|
+
// a test-less ui stays bare. `fixed` (engine-owned, whole-file overwrite)
|
|
27
|
+
// not `managed`, so refresh is idempotent by construction — no key-order drift.
|
|
28
|
+
when(
|
|
29
|
+
whenFilesExist(COLOCATED_TEST_GLOB),
|
|
30
|
+
() => fixed("tsconfig.json", file("ui/tsconfig.node.json")),
|
|
31
|
+
() => fixed("tsconfig.json", file("ui/tsconfig.json")),
|
|
32
|
+
);
|
|
45
33
|
fixed(".oxlintrc.json", file("ui/.oxlintrc.json"));
|
|
46
34
|
// Block-local oxfmt config — the ui is oxfmt-checked (`ts-builder check
|
|
47
35
|
// --target block-ui`).
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ensureScript,
|
|
9
9
|
ensureDep,
|
|
10
10
|
ensureDevDeps,
|
|
11
|
+
removeDep,
|
|
11
12
|
ensureWorkspaceScopeDeps,
|
|
12
13
|
enforceAlphabeticalOrder,
|
|
13
14
|
enforceFieldOrder,
|
|
@@ -44,7 +45,8 @@ export function workflowPackageJsonInitial(ctx: RunContext): Record<string, unkn
|
|
|
44
45
|
devDependencies: {
|
|
45
46
|
"@platforma-sdk/tengo-builder": "sdk:",
|
|
46
47
|
"@platforma-sdk/test": "sdk:",
|
|
47
|
-
vitest
|
|
48
|
+
// `vitest` is NOT seeded here — it's wired by the body rule only when the
|
|
49
|
+
// workflow carries co-located tests (a freshly-init'd workflow has none).
|
|
48
50
|
shx: "catalog:",
|
|
49
51
|
},
|
|
50
52
|
};
|
|
@@ -59,15 +61,28 @@ export function workflowPackageJsonRules(): void {
|
|
|
59
61
|
ensureScript("check", "pl-tengo check");
|
|
60
62
|
// Tengo source formatter (emacs batch); no-op notice when emacs is absent.
|
|
61
63
|
ensureScript("format", "/usr/bin/env emacs --script ./format.el || echo 'No emacs.'");
|
|
62
|
-
// The vitest `test` script
|
|
63
|
-
// co-located integration tests (`src/**/*.test.ts`, incl.
|
|
64
|
-
// A test-less workflow gets no `test` task
|
|
65
|
-
// (Workflow tests type-check via
|
|
66
|
-
// `types: []` — they pull their types
|
|
67
|
-
// node-types wiring is needed here,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
64
|
+
// The vitest `test` script AND the `vitest` devDep are wired ONLY when the
|
|
65
|
+
// workflow carries co-located integration tests (`src/**/*.test.ts`, incl.
|
|
66
|
+
// `src/test/`). A test-less workflow gets neither — no `test` task, no
|
|
67
|
+
// vitest dep — and stays a refresh fixpoint. (Workflow tests type-check via
|
|
68
|
+
// the standalone workflow/tsconfig with `types: []` — they pull their types
|
|
69
|
+
// from `@platforma-sdk/test` — so no node-types wiring is needed here,
|
|
70
|
+
// unlike model/ui.)
|
|
71
|
+
//
|
|
72
|
+
// Skipped entirely for sdk-internal (in-monorepo) blocks: they own their test
|
|
73
|
+
// wiring under the monorepo's shared infrastructure — see model-package-json.
|
|
74
|
+
when(
|
|
75
|
+
({ ctx }) => !ctx.isSdkInternal,
|
|
76
|
+
() =>
|
|
77
|
+
when(
|
|
78
|
+
whenFilesExist(COLOCATED_TEST_GLOB),
|
|
79
|
+
() => {
|
|
80
|
+
ensureScript("test", "vitest run --passWithNoTests");
|
|
81
|
+
ensureDevDeps({ vitest: "catalog:" });
|
|
82
|
+
},
|
|
83
|
+
() => removeDep("vitest"),
|
|
84
|
+
),
|
|
85
|
+
);
|
|
71
86
|
|
|
72
87
|
ensureDep("@platforma-sdk/workflow-tengo", "sdk:");
|
|
73
88
|
|
|
@@ -80,7 +95,6 @@ export function workflowPackageJsonRules(): void {
|
|
|
80
95
|
ensureDevDeps({
|
|
81
96
|
"@platforma-sdk/tengo-builder": "sdk:",
|
|
82
97
|
"@platforma-sdk/test": "sdk:",
|
|
83
|
-
vitest: "catalog:",
|
|
84
98
|
shx: "catalog:",
|
|
85
99
|
});
|
|
86
100
|
|
|
@@ -11,10 +11,13 @@ import {
|
|
|
11
11
|
tpl,
|
|
12
12
|
generate,
|
|
13
13
|
remove,
|
|
14
|
+
when,
|
|
15
|
+
whenFilesExist,
|
|
14
16
|
blockVars,
|
|
15
17
|
} from "../engine/api";
|
|
16
18
|
import { getActiveRunContext } from "../engine/builders";
|
|
17
19
|
import { workflowPackageJsonInitial, workflowPackageJsonRules } from "./workflow-package-json";
|
|
20
|
+
import { COLOCATED_TEST_GLOB } from "./shared/colocated-tests";
|
|
18
21
|
|
|
19
22
|
export function workflowRules(): void {
|
|
20
23
|
scope("workflow", () => {
|
|
@@ -24,8 +27,24 @@ export function workflowRules(): void {
|
|
|
24
27
|
fixed("tsconfig.json", file("workflow/tsconfig.json"));
|
|
25
28
|
// Tengo source formatter (emacs batch); the `format` script invokes it.
|
|
26
29
|
fixed("format.el", file("workflow/format.el"));
|
|
27
|
-
//
|
|
28
|
-
|
|
30
|
+
// vitest config only when the workflow carries co-located tests
|
|
31
|
+
// (`src/**/*.test.ts`, incl. `src/test/`) — paired with the conditional
|
|
32
|
+
// `vitest` devDep + `test` script in workflow-package-json. scaffold (not
|
|
33
|
+
// fixed): author-tunable when present; a test-less workflow gets none.
|
|
34
|
+
//
|
|
35
|
+
// Skipped entirely for sdk-internal (in-monorepo) blocks: they own their
|
|
36
|
+
// test config under the monorepo's shared infrastructure (e.g. a bespoke
|
|
37
|
+
// `vitest run --coverage` + `createVitestConfig`), which the structurer
|
|
38
|
+
// must neither scaffold nor remove. See workflow-package-json.
|
|
39
|
+
when(
|
|
40
|
+
({ ctx }) => !ctx.isSdkInternal,
|
|
41
|
+
() =>
|
|
42
|
+
when(
|
|
43
|
+
whenFilesExist(COLOCATED_TEST_GLOB),
|
|
44
|
+
() => scaffold("vitest.config.mts", file("workflow/vitest.config.mts")),
|
|
45
|
+
() => remove("vitest.config.mts"),
|
|
46
|
+
),
|
|
47
|
+
);
|
|
29
48
|
// No workflow facade (index.js / index.d.ts): the block loader resolves the
|
|
30
49
|
// workflow via the `block:` components dist path (workflow/dist/.../main.plj.gz),
|
|
31
50
|
// never the JS facade. It was orphaned in production — dropped. Actively
|