@platforma-sdk/block-tools 2.12.2 → 2.12.4

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.
@@ -0,0 +1,2 @@
1
+ export declare function rootTurboJsonInitial(): Record<string, unknown>;
2
+ export declare function rootTurboJsonRules(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platforma-sdk/block-tools",
3
- "version": "2.12.2",
3
+ "version": "2.12.4",
4
4
  "description": "Utility to manipulate Platforma Blocks and Block Registry",
5
5
  "license": "UNLICENSED",
6
6
  "bin": {
@@ -35,13 +35,13 @@
35
35
  "yaml": "^2.8.0",
36
36
  "zod": "~3.25.76",
37
37
  "@milaboratories/pl-http": "1.2.4",
38
- "@milaboratories/pl-model-middle-layer": "1.30.11",
38
+ "@milaboratories/pl-model-backend": "1.4.14",
39
39
  "@milaboratories/pl-model-common": "1.46.4",
40
+ "@milaboratories/pl-model-middle-layer": "1.30.11",
40
41
  "@milaboratories/resolve-helper": "1.1.3",
41
- "@platforma-sdk/blocks-deps-updater": "2.2.0",
42
- "@milaboratories/pl-model-backend": "1.4.13",
42
+ "@milaboratories/ts-helpers": "1.8.4",
43
43
  "@platforma-sdk/package-builder-lib": "1.2.0",
44
- "@milaboratories/ts-helpers": "1.8.4"
44
+ "@platforma-sdk/blocks-deps-updater": "2.2.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": "^4.5.3",
58
58
  "vitest": "^4.1.3",
59
- "@milaboratories/ts-builder": "1.6.0",
60
59
  "@milaboratories/build-configs": "2.0.0",
61
- "@milaboratories/ts-configs": "1.3.0"
60
+ "@milaboratories/ts-configs": "1.3.0",
61
+ "@milaboratories/ts-builder": "1.6.0"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "vite build",
@@ -1,14 +1,10 @@
1
1
  import { describe, it, expect } from "vitest";
2
- import { readFileSync } from "node:fs";
3
- import { fileURLToPath } from "node:url";
4
2
  import { softwareBuildCacheEnv } from "./env";
3
+ import { rootTurboJsonInitial } from "../../structure/rules/root-turbo-json";
5
4
 
6
5
  // The block's turbo build task must cache-key on every software-build env var, declared once in the
7
- // structurer template. This guards against the template drifting from softwareBuildCacheEnv.
8
- const turboPath = fileURLToPath(
9
- new URL("../../structure/templates/static/root/turbo.json", import.meta.url),
10
- );
11
- const buildEnv: string[] = JSON.parse(readFileSync(turboPath, "utf8")).tasks.build.env;
6
+ // structurer's turbo.json rule. This guards against the rule drifting from softwareBuildCacheEnv.
7
+ const buildEnv = (rootTurboJsonInitial().tasks as { build: { env: string[] } }).build.env;
12
8
 
13
9
  describe("block turbo build cache env", () => {
14
10
  it("declares every software-build cache var", () => {
@@ -0,0 +1,41 @@
1
+ // turbo.json is `managed`, not `fixed`: the engine re-asserts its own tasks
2
+ // but must leave author-added tasks (notably `software:reqs`, which a
3
+ // Python-block `requirements-sync` CI job runs via `turbo run software:reqs`)
4
+ // untouched. These guard that contract.
5
+
6
+ import { describe, test, expect } from "vitest";
7
+ import { runRulesAgainst } from "../engine/testing";
8
+ import { rootTurboJsonInitial, rootTurboJsonRules } from "../rules/root-turbo-json";
9
+
10
+ describe("root turbo.json rules", () => {
11
+ test("corrects a drifted engine task and preserves an author task", () => {
12
+ const drifted = {
13
+ $schema: "https://turbo.build/schema.json",
14
+ tasks: {
15
+ build: { env: ["ONLY_ONE"] }, // engine task, drifted
16
+ "build:dev": { dependsOn: ["build"], outputs: ["./dist/**"] }, // legacy, must go
17
+ "software:reqs": { cache: false, outputs: ["./src/requirements.txt"] }, // author task
18
+ },
19
+ };
20
+
21
+ const out = runRulesAgainst(drifted, () => rootTurboJsonRules());
22
+ const tasks = out.tasks as Record<string, { env?: string[]; outputs?: string[] }>;
23
+
24
+ // Engine task re-asserted to canonical.
25
+ expect(tasks.build.env).toContain("PL_BUILD_CHANNEL");
26
+ expect(tasks.build.outputs).toEqual(["./dist/**", "./block-pack/**", "./pkg-*.tgz"]);
27
+ // Legacy task pruned.
28
+ expect(tasks["build:dev"]).toBeUndefined();
29
+ // Author task left exactly as it was.
30
+ expect(tasks["software:reqs"]).toEqual({ cache: false, outputs: ["./src/requirements.txt"] });
31
+ expect(out.globalDependencies).toEqual(["tsconfig.json"]);
32
+ });
33
+
34
+ test("initial owns the engine tasks but not software:reqs or legacy build:dev", () => {
35
+ const keys = Object.keys(rootTurboJsonInitial().tasks as Record<string, unknown>);
36
+ expect(keys).toContain("build");
37
+ expect(keys).toContain("test");
38
+ expect(keys).not.toContain("software:reqs");
39
+ expect(keys).not.toContain("build:dev");
40
+ });
41
+ });
@@ -0,0 +1,71 @@
1
+ // Root `turbo.json`: the initial generator and the drift-correcting body
2
+ // rules, co-located. Managed (not fixed) so the engine OWNS its own task
3
+ // graph but LEAVES author-added tasks alone — `ensureFieldEntries("tasks", …)`
4
+ // merges the canonical engine tasks over whatever is there, preserving any
5
+ // other key under `tasks`.
6
+ //
7
+ // Why this matters: blocks with a Python software package carry a
8
+ // `software:reqs` task (a `requirements-sync` CI job runs `turbo run
9
+ // software:reqs`). When turbo.json was `fixed`, every `upgrade-sdk` wiped that
10
+ // task and CI failed with "Could not find task software:reqs". `software:reqs`
11
+ // is deliberately NOT in the engine-owned set below — it (and any custom task)
12
+ // is author-owned and survives refresh via the merge.
13
+
14
+ import { ensureField, ensureFieldEntries, removeField, enforceFieldOrder } from "../engine/api";
15
+
16
+ const SCHEMA = "https://turbo.build/schema.json";
17
+ const GLOBAL_DEPENDENCIES = ["tsconfig.json"];
18
+
19
+ // The tasks the engine owns. Re-asserted on every refresh; author tasks
20
+ // (e.g. `software:reqs`) are merged around these, never clobbered.
21
+ const ENGINE_TASKS: Record<string, unknown> = {
22
+ fmt: { cache: false },
23
+ check: { dependsOn: ["^build"], outputs: [] },
24
+ build: {
25
+ dependsOn: ["^build", "check"],
26
+ inputs: ["$TURBO_DEFAULT$"],
27
+ env: [
28
+ "PL_DOCKER_REGISTRY_PUSH_TO",
29
+ "PL_BUILD_CHANNEL",
30
+ "PL_BUILD_VARIANT",
31
+ "PL_BUILD_LOCATION",
32
+ "PL_BUILD_USE_PUBLISHED",
33
+ "PL_DEV_DOCKER_PUSH_URL",
34
+ "PL_DEV_DOCKER_PULL_URL",
35
+ "PL_DEV_BINARY_UPLOAD_URL",
36
+ "PL_RELEASE_DOCKER_PUSH_URL",
37
+ "PL_RELEASE_DOCKER_PULL_URL",
38
+ "PL_RELEASE_BINARY_UPLOAD_URL",
39
+ "PL_REGISTRY_PLATFORMA_OPEN_UPLOAD_URL",
40
+ ],
41
+ passThroughEnv: ["AWS_*", "PL_AWS_*"],
42
+ outputs: ["./dist/**", "./block-pack/**", "./pkg-*.tgz"],
43
+ },
44
+ "do-pack": { dependsOn: ["build"], outputs: ["package.tgz"] },
45
+ test: {
46
+ dependsOn: ["build", "check"],
47
+ passThroughEnv: ["PL_ADDRESS", "PL_TEST_PASSWORD", "PL_TEST_USER", "PL_TEST_PROXY", "DEBUG"],
48
+ },
49
+ "mark-stable": { passThroughEnv: ["PL_REGISTRY", "AWS_*"], cache: false },
50
+ };
51
+
52
+ export function rootTurboJsonInitial(): Record<string, unknown> {
53
+ return {
54
+ $schema: SCHEMA,
55
+ globalDependencies: GLOBAL_DEPENDENCIES,
56
+ tasks: { ...ENGINE_TASKS },
57
+ };
58
+ }
59
+
60
+ export function rootTurboJsonRules(): void {
61
+ ensureField("$schema", SCHEMA);
62
+ ensureField("globalDependencies", GLOBAL_DEPENDENCIES);
63
+ // Merge the engine tasks, preserving any author task (software:reqs, …).
64
+ ensureFieldEntries("tasks", ENGINE_TASKS);
65
+ // Legacy single-dev-build task, superseded by the env-parameterised `build`
66
+ // task + `build:dev-*` package scripts (software-build spec). The
67
+ // root package.json rule likewise drops the `build:dev` script; drop the
68
+ // matching turbo task so migrated blocks converge.
69
+ removeField("tasks.build:dev");
70
+ enforceFieldOrder(["$schema", "globalDependencies", "tasks"]);
71
+ }
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { scope, when, fixed, managed, file, generate } from "../engine/api";
7
7
  import { rootPackageJsonInitial, rootPackageJsonRules } from "./root-package-json";
8
+ import { rootTurboJsonInitial, rootTurboJsonRules } from "./root-turbo-json";
8
9
  import { rootPnpmWorkspaceInitial, rootPnpmWorkspaceRules } from "./root-pnpm-workspace";
9
10
  import { rootGitignoreRules } from "./root-gitignore";
10
11
 
@@ -13,7 +14,13 @@ export function rootRules(): void {
13
14
  when(
14
15
  ({ ctx }) => !ctx.isSdkInternal,
15
16
  () => {
16
- fixed("turbo.json", file("root/turbo.json"));
17
+ managed(
18
+ "turbo.json",
19
+ generate(() => rootTurboJsonInitial()),
20
+ () => {
21
+ rootTurboJsonRules();
22
+ },
23
+ );
17
24
  fixed(".vscode/settings.json", file("root/.vscode/settings.json"));
18
25
 
19
26
  managed(
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "extends": ["node_modules/@milaboratories/ts-builder/configs/oxfmt.json"],
3
- "ignorePatterns": ["dist", "coverage", "CHANGELOG.md"]
3
+ "ignorePatterns": ["dist", "coverage", "CHANGELOG.md", ".test_auth.json"]
4
4
  }
@@ -1,49 +0,0 @@
1
- {
2
- "$schema": "https://turbo.build/schema.json",
3
- "globalDependencies": ["tsconfig.json"],
4
- "tasks": {
5
- "fmt": {
6
- "cache": false
7
- },
8
- "check": {
9
- "dependsOn": ["^build"],
10
- "outputs": []
11
- },
12
- "build": {
13
- "dependsOn": ["^build", "check"],
14
- "inputs": ["$TURBO_DEFAULT$"],
15
- "env": [
16
- "PL_DOCKER_REGISTRY_PUSH_TO",
17
- "PL_BUILD_CHANNEL",
18
- "PL_BUILD_VARIANT",
19
- "PL_BUILD_LOCATION",
20
- "PL_BUILD_USE_PUBLISHED",
21
- "PL_DEV_DOCKER_PUSH_URL",
22
- "PL_DEV_DOCKER_PULL_URL",
23
- "PL_DEV_BINARY_UPLOAD_URL",
24
- "PL_RELEASE_DOCKER_PUSH_URL",
25
- "PL_RELEASE_DOCKER_PULL_URL",
26
- "PL_RELEASE_BINARY_UPLOAD_URL",
27
- "PL_REGISTRY_PLATFORMA_OPEN_UPLOAD_URL"
28
- ],
29
- "passThroughEnv": ["AWS_*", "PL_AWS_*"],
30
- "outputs": ["./dist/**", "./block-pack/**", "./pkg-*.tgz"]
31
- },
32
- "build:dev": {
33
- "dependsOn": ["build"],
34
- "outputs": ["./dist/**"]
35
- },
36
- "do-pack": {
37
- "dependsOn": ["build"],
38
- "outputs": ["package.tgz"]
39
- },
40
- "test": {
41
- "dependsOn": ["build", "check"],
42
- "passThroughEnv": ["PL_ADDRESS", "PL_TEST_PASSWORD", "PL_TEST_USER", "PL_TEST_PROXY", "DEBUG"]
43
- },
44
- "mark-stable": {
45
- "passThroughEnv": ["PL_REGISTRY", "AWS_*"],
46
- "cache": false
47
- }
48
- }
49
- }