@platforma-sdk/block-tools 2.17.1 → 2.17.2
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 +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/package.json +1 -1
- package/src/structure/__tests__/templates-packed.test.ts +45 -0
- package/src/structure/rules/root-gitignore.ts +1 -1
- package/src/structure/rules/root.ts +3 -1
- package/src/structure/templates/static/root/gitignore +13 -0
package/package.json
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// `structure init` and `structure refresh` read their templates from the
|
|
2
|
+
// installed package. `pnpm pack` (pnpm 11+) follows npm's pack rules and
|
|
3
|
+
// leaves some files out, `.gitignore` among them: block-tools 2.17.0 shipped
|
|
4
|
+
// without `templates/static/root/.gitignore`, so `structure init` failed with
|
|
5
|
+
// ENOENT. This test packs the package with the pnpm that the release uses and
|
|
6
|
+
// checks that every template file in git is in the package.
|
|
7
|
+
|
|
8
|
+
import { spawnSync } from "node:child_process";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { describe, expect, test } from "vitest";
|
|
11
|
+
|
|
12
|
+
/** The block-tools package directory. */
|
|
13
|
+
const PACKAGE_ROOT = fileURLToPath(new URL("../../..", import.meta.url));
|
|
14
|
+
|
|
15
|
+
/** The template tree that the structure commands read, relative to PACKAGE_ROOT. */
|
|
16
|
+
const TEMPLATES_DIR = "src/structure/templates";
|
|
17
|
+
|
|
18
|
+
/** Runs a command in PACKAGE_ROOT and returns its stdout. Throws when it fails. */
|
|
19
|
+
function run(command: string, args: string[]): string {
|
|
20
|
+
const result = spawnSync(command, args, { cwd: PACKAGE_ROOT, encoding: "utf-8" });
|
|
21
|
+
if (result.status !== 0) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`\`${command} ${args.join(" ")}\` failed: ${result.error?.message ?? result.stderr}`,
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
return result.stdout;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
describe("published package", () => {
|
|
30
|
+
test("contains every template file", () => {
|
|
31
|
+
const templates = run("git", ["ls-files", "-z", "--", TEMPLATES_DIR])
|
|
32
|
+
.split("\0")
|
|
33
|
+
.filter((file) => file !== "");
|
|
34
|
+
const packResult: { files: { path: string }[] } = JSON.parse(
|
|
35
|
+
run("pnpm", ["pack", "--dry-run", "--json"]),
|
|
36
|
+
);
|
|
37
|
+
const packed = new Set(packResult.files.map((file) => file.path));
|
|
38
|
+
|
|
39
|
+
expect(templates.length).toBeGreaterThan(0);
|
|
40
|
+
expect(
|
|
41
|
+
templates.filter((file) => !packed.has(file)),
|
|
42
|
+
"template files that `pnpm pack` leaves out of the package",
|
|
43
|
+
).toEqual([]);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Root `.gitignore` content rules.
|
|
2
|
-
// The static template under templates/static/root
|
|
2
|
+
// The static template under templates/static/root/gitignore carries the
|
|
3
3
|
// canonical line set; the body re-asserts the same set via
|
|
4
4
|
// `ensureGitignoreEntries` so any future edit that drops a required line
|
|
5
5
|
// is restored.
|
|
@@ -44,7 +44,9 @@ export function rootRules(): void {
|
|
|
44
44
|
},
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
// The template has no dot: `pnpm pack` (pnpm 11+) leaves every
|
|
48
|
+
// `.gitignore` out of the published package.
|
|
49
|
+
managed(".gitignore", file("root/gitignore"), () => {
|
|
48
50
|
rootGitignoreRules();
|
|
49
51
|
});
|
|
50
52
|
|