@pbuilder/sdk 0.13.0 → 0.14.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.
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"manifestVersion": 1,
|
|
3
3
|
"algorithm": "sha256",
|
|
4
4
|
"entry": "dist/bin/pbuilder-runner.js",
|
|
5
|
-
"packageVersion": "0.
|
|
5
|
+
"packageVersion": "0.14.0",
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"path": "dist/bin/pbuilder-runner.js",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
"path": "package.json",
|
|
101
|
-
"sha256": "
|
|
101
|
+
"sha256": "c02a0fe03d363197f2490851657b0dd76aa3907ea5103d28218b7383fcf4d378"
|
|
102
102
|
}
|
|
103
103
|
]
|
|
104
104
|
}
|
|
@@ -31,7 +31,7 @@ import { invalidInput } from "../core/authoring-error.js";
|
|
|
31
31
|
import { forceEntry } from "../core/directive-factory.js";
|
|
32
32
|
import { EMIT_BATCH_BUDGET_BYTES, serializedBatchSize } from "../core/wire.js";
|
|
33
33
|
import { walkFolder } from "./walk.js";
|
|
34
|
-
import { runFilenamePipeline, isIncluded, detectDestinationCollisions, translateTokens } from "./filename-pipeline.js";
|
|
34
|
+
import { runFilenamePipeline, isIncluded, detectDestinationCollisions, translateTokens, checkSourceNames, } from "./filename-pipeline.js";
|
|
35
35
|
import { classifyTransport } from "./classify-transport.js";
|
|
36
36
|
import { validateDestinationLexical, validateSourceLexical } from "./path-guards.js";
|
|
37
37
|
function noResolutionAnchorMessage() {
|
|
@@ -143,6 +143,9 @@ export function runScaffold(args) {
|
|
|
143
143
|
if (walked.length === 0) {
|
|
144
144
|
return; // REQ-FSC-04.1: a truly-empty source folder is a silent no-op.
|
|
145
145
|
}
|
|
146
|
+
// A-17 covers every name under the source folder, excluded ones included: an excluded
|
|
147
|
+
// `con.ts` still cannot be checked out on Windows.
|
|
148
|
+
checkSourceNames(walked.map((entry) => entry.relPath));
|
|
146
149
|
const filtered = walked.filter((entry) => isIncluded(entry.relPath, args.include, args.exclude));
|
|
147
150
|
if (filtered.length === 0) {
|
|
148
151
|
throw invalidInput(filtersEliminatedEverythingMessage(args.include, args.exclude));
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Architecture A-17: rejects a source-relative path, as written on disk, when any of its
|
|
3
|
+
* components holds `{=` or `=}` or is a name Windows refuses — on every OS. A well-formed
|
|
4
|
+
* token holds only letters, digits, `_` and `@`, so it never trips this check.
|
|
5
|
+
*/
|
|
6
|
+
export declare function checkSourceName(relPath: string): void;
|
|
1
7
|
/**
|
|
2
8
|
* Translates on-disk filename tokens to the wire `pathTemplate` syntax the ENGINE
|
|
3
9
|
* substitutes (obs #915 ruling 4) — the SDK never renders these itself, only rewrites the
|
|
@@ -28,6 +34,8 @@ export interface PipelineResult {
|
|
|
28
34
|
* (the marker must survive translation to be recognized).
|
|
29
35
|
*/
|
|
30
36
|
export declare function runFilenamePipeline(relPath: string, rename: Record<string, string> | undefined): PipelineResult;
|
|
37
|
+
/** Checks every path, reporting the first bad one in byte-wise order, as the engine does. */
|
|
38
|
+
export declare function checkSourceNames(relPaths: readonly string[]): void;
|
|
31
39
|
/**
|
|
32
40
|
* REQ-FSC-03: include/exclude filtering — `exclude` WINS on overlap with `include`.
|
|
33
41
|
* Default `include` matches everything (`["**"]`); default `exclude` matches nothing.
|
|
@@ -9,7 +9,61 @@ import { posix } from "node:path";
|
|
|
9
9
|
import { invalidInput } from "../core/authoring-error.js";
|
|
10
10
|
const TEMPLATE_SUFFIX = ".template";
|
|
11
11
|
const TOKEN_MARKER = "__";
|
|
12
|
-
|
|
12
|
+
// A key starts with a letter, so an opening `__` inside a longer underscore run is its last
|
|
13
|
+
// two underscores (A-17); a filter name may start with `_`.
|
|
14
|
+
const TOKEN_INNER = /^[A-Za-z][A-Za-z0-9_]*(?:@[A-Za-z_][A-Za-z0-9_]*)*$/;
|
|
15
|
+
const FORBIDDEN_CHARACTER_NAMES = {
|
|
16
|
+
"|": "vertical bar",
|
|
17
|
+
'"': "double quote",
|
|
18
|
+
"<": "less-than sign",
|
|
19
|
+
">": "greater-than sign",
|
|
20
|
+
":": "colon",
|
|
21
|
+
"?": "question mark",
|
|
22
|
+
"*": "asterisk",
|
|
23
|
+
"\\": "backslash",
|
|
24
|
+
};
|
|
25
|
+
const RESERVED_DEVICE_NAMES = new Set([
|
|
26
|
+
"CON",
|
|
27
|
+
"PRN",
|
|
28
|
+
"AUX",
|
|
29
|
+
"NUL",
|
|
30
|
+
...["COM", "LPT"].flatMap((prefix) => [..."0123456789¹²³"].map((digit) => prefix + digit)),
|
|
31
|
+
]);
|
|
32
|
+
// The first A-17 rule `name` breaks, in the engine's `CheckPortableName` order and vocabulary
|
|
33
|
+
// (characters first, then reserved device names, then a trailing dot or space).
|
|
34
|
+
function portableNameViolation(name) {
|
|
35
|
+
for (const ch of name) {
|
|
36
|
+
const code = ch.charCodeAt(0);
|
|
37
|
+
if (code < 0x20) {
|
|
38
|
+
return { rule: "forbidden character", character: `control character 0x${code.toString(16).toUpperCase().padStart(2, "0")}` };
|
|
39
|
+
}
|
|
40
|
+
const character = FORBIDDEN_CHARACTER_NAMES[ch];
|
|
41
|
+
if (character !== undefined)
|
|
42
|
+
return { rule: "forbidden character", character };
|
|
43
|
+
}
|
|
44
|
+
const stem = name.split(".", 1)[0];
|
|
45
|
+
if (RESERVED_DEVICE_NAMES.has(stem.replace(/ +$/, "").toUpperCase()))
|
|
46
|
+
return { rule: "reserved device name" };
|
|
47
|
+
if (name.endsWith("."))
|
|
48
|
+
return { rule: "trailing dot" };
|
|
49
|
+
if (name.endsWith(" "))
|
|
50
|
+
return { rule: "trailing space" };
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Architecture A-17: rejects a source-relative path, as written on disk, when any of its
|
|
55
|
+
* components holds `{=` or `=}` or is a name Windows refuses — on every OS. A well-formed
|
|
56
|
+
* token holds only letters, digits, `_` and `@`, so it never trips this check.
|
|
57
|
+
*/
|
|
58
|
+
export function checkSourceName(relPath) {
|
|
59
|
+
for (const name of relPath.split("/")) {
|
|
60
|
+
const violation = name.includes("{=") || name.includes("=}") ? { rule: "template syntax" } : portableNameViolation(name);
|
|
61
|
+
if (violation === undefined)
|
|
62
|
+
continue;
|
|
63
|
+
const suffix = violation.character === undefined ? "" : ` (${violation.character})`;
|
|
64
|
+
throw invalidInput(`invalid input: scaffold file name "${relPath}": the name "${name}" breaks the rule "${violation.rule}"${suffix}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
13
67
|
/**
|
|
14
68
|
* Translates on-disk filename tokens to the wire `pathTemplate` syntax the ENGINE
|
|
15
69
|
* substitutes (obs #915 ruling 4) — the SDK never renders these itself, only rewrites the
|
|
@@ -77,6 +131,23 @@ export function runFilenamePipeline(relPath, rename) {
|
|
|
77
131
|
const { stripped, wasTemplate } = stripTemplateSuffix(translated);
|
|
78
132
|
return { sourceRelPath: relPath, destRelPath: stripped, isTemplateMarked: wasTemplate };
|
|
79
133
|
}
|
|
134
|
+
// UTF-8 byte order is code-point order; the default sort compares UTF-16 code units, which
|
|
135
|
+
// puts astral characters before U+E000-U+FFFF.
|
|
136
|
+
function compareCodePoints(a, b) {
|
|
137
|
+
const x = [...a];
|
|
138
|
+
const y = [...b];
|
|
139
|
+
for (let i = 0; i < x.length && i < y.length; i++) {
|
|
140
|
+
const diff = x[i].codePointAt(0) - y[i].codePointAt(0);
|
|
141
|
+
if (diff !== 0)
|
|
142
|
+
return diff;
|
|
143
|
+
}
|
|
144
|
+
return x.length - y.length;
|
|
145
|
+
}
|
|
146
|
+
/** Checks every path, reporting the first bad one in byte-wise order, as the engine does. */
|
|
147
|
+
export function checkSourceNames(relPaths) {
|
|
148
|
+
for (const relPath of [...relPaths].sort(compareCodePoints))
|
|
149
|
+
checkSourceName(relPath);
|
|
150
|
+
}
|
|
80
151
|
function escapeRegexChar(ch) {
|
|
81
152
|
return /[.+^${}()|[\]\\]/.test(ch) ? `\\${ch}` : ch;
|
|
82
153
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pbuilder/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "The public TypeScript/Bun authoring layer for Project Builder schematics. Authors file mutations (create, replaceContent, remove, rename, move, copy, copyIn), lowers them to IR, and talks to the Project Builder engine over framed stdio (see docs/engine-sdk-wire-spec.md).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|