@homepages/concrete 13.0.1 → 14.1.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.
- package/CHANGELOG.md +46 -0
- package/README.md +4 -5
- package/codemods/manifest.json +11 -0
- package/dist/artifact/playground/client/assets/index-DZbV6Ucf.js +1338 -0
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +22 -22
- package/dist/cli/build/esbuild.js +42 -3
- package/dist/cli/build/manifest.js +1 -1
- package/dist/cli/build/record.js +5 -4
- package/dist/cli/build/sections.js +13 -6
- package/dist/cli/build/template-build.js +19 -9
- package/dist/cli/check/load-workspace.js +3 -6
- package/dist/cli/commands.js +63 -15
- package/dist/cli/media/deriver-plugin.js +36 -5
- package/dist/cli/publish/artifact.js +18 -40
- package/dist/cli/publish/fixtures.js +1 -1
- package/dist/cli/publish/index.js +90 -115
- package/dist/cli/publish/report.js +36 -56
- package/dist/cli/publish/send.js +142 -0
- package/dist/cli/publish/target.js +33 -31
- package/dist/cli/publish/verdict.js +65 -0
- package/dist/cli/release/client.js +69 -0
- package/dist/cli/release/index.js +143 -0
- package/dist/cli/release/report.js +73 -0
- package/dist/cli/upgrade/fixture-modules.js +3 -5
- package/dist/cli.js +1 -0
- package/dist/css/graph.js +29 -40
- package/dist/css/inline.js +2 -3
- package/dist/fixtures/media-plugin.js +7 -25
- package/dist/fixtures/package-stylesheets.js +12 -48
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/download-files/dist/capture-origin.js +5 -5
- package/dist/packages/internal/media-resolution/dist/image.js +43 -4
- package/dist/packages/internal/media-resolution/dist/list.js +4 -4
- package/dist/packages/internal/media-resolution/dist/media.js +2 -2
- package/dist/packages/internal/media-resolution/dist/slot.js +2 -2
- package/dist/packages/internal/playground/dist/fixture-formats.js +5 -1
- package/dist/packages/internal/playground/dist/host/built.js +4 -12
- package/dist/packages/internal/playground/dist/host/catalog-fixture.js +0 -1
- package/dist/packages/internal/playground/dist/host/download.js +1 -8
- package/dist/packages/internal/playground/dist/host/fixture-addresses.js +3 -4
- package/dist/packages/internal/playground/dist/host/program.js +1 -2
- package/dist/packages/internal/playground/dist/host/serve.js +4 -30
- package/dist/packages/internal/playground/dist/host/stored-fixtures.js +2 -9
- package/dist/packages/internal/playground/dist/layout.js +5 -5
- package/dist/packages/internal/playground/dist/send-wire.js +9 -0
- package/dist/packages/internal/playground/dist/server/changes.js +0 -1
- package/dist/packages/internal/playground/dist/server/listen.js +2 -19
- package/dist/packages/internal/playground/dist/server/playground-server.js +2 -3
- package/dist/packages/internal/property-facts/dist/registry-facts.js +0 -7
- package/dist/packages/internal/site-files/dist/site.js +4 -6
- package/dist/packages/internal/static-assets-binding/dist/index.js +2 -1
- package/dist/packages/internal/static-assets-binding/dist/section-asset-url.js +16 -4
- package/dist/packages/internal/template-artifact/dist/framework-floor.js +33 -0
- package/dist/packages/internal/template-artifact/dist/index.js +3 -3
- package/dist/packages/internal/template-artifact/dist/layout.js +7 -39
- package/dist/packages/internal/template-artifact/dist/manifest.js +1 -1
- package/dist/packages/internal/template-artifact/dist/verify.js +14 -57
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +8 -1
- package/dist/packages/internal/template-contracts/dist/tour-value.d.ts +1 -1
- package/dist/packages/internal/template-contracts/dist/video-value.d.ts +1 -1
- package/dist/template/logic-build.js +38 -19
- package/guide/reference/cli/INDEX.md +5 -4
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/install.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +17 -16
- package/guide/reference/cli/release.md +57 -0
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +1 -1
- package/package.json +6 -4
- package/dist/artifact/playground/client/assets/index-Bmvcss4B.js +0 -1338
- package/dist/cli/publish/captures.js +0 -61
- package/dist/cli/publish/client.js +0 -118
- package/dist/cli/publish/pack.js +0 -77
- package/dist/cli/publish/playground.js +0 -27
- package/dist/cli/publish/wire.js +0 -23
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { CAPTURE_FILES, capturePath } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
2
|
-
import "../../packages/internal/template-artifact/dist/index.js";
|
|
3
|
-
import { folderFiles } from "../dev/folder-files.js";
|
|
4
|
-
import { ROUTES } from "../../packages/internal/playground/dist/wire.js";
|
|
5
|
-
import { freeDevPort } from "../../packages/internal/playground/dist/server/listen.js";
|
|
6
|
-
import { startPlaygroundServer } from "../dev/playground-server.js";
|
|
7
|
-
import { Writable } from "node:stream";
|
|
8
|
-
|
|
9
|
-
//#region src/cli/publish/captures.ts
|
|
10
|
-
const silent = new Writable({ write: (_chunk, _encoding, done) => done() });
|
|
11
|
-
const DOWNLOAD_PATIENCE_MS = 10 * 6e4;
|
|
12
|
-
async function downloaded(url, what, optional) {
|
|
13
|
-
const deadline = Date.now() + DOWNLOAD_PATIENCE_MS;
|
|
14
|
-
for (;;) {
|
|
15
|
-
const answer = await fetch(url);
|
|
16
|
-
if (answer.status === 202 && Date.now() < deadline) continue;
|
|
17
|
-
if (optional && answer.status === 404) return null;
|
|
18
|
-
if (!answer.ok) throw new Error(`publish: downloading ${what} failed (${String(answer.status)}): ${await answer.text()}`);
|
|
19
|
-
return new Uint8Array(await answer.arrayBuffer());
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
async function captureFiles(options) {
|
|
23
|
-
const files = /* @__PURE__ */ new Map();
|
|
24
|
-
if (options.output === "website") return files;
|
|
25
|
-
const server = await startPlaygroundServer({
|
|
26
|
-
root: options.root,
|
|
27
|
-
port: await freeDevPort(),
|
|
28
|
-
log: silent,
|
|
29
|
-
files: folderFiles({
|
|
30
|
-
root: options.root,
|
|
31
|
-
build: { output: options.build }
|
|
32
|
-
}),
|
|
33
|
-
...options.browser === void 0 ? {} : { browser: options.browser }
|
|
34
|
-
});
|
|
35
|
-
try {
|
|
36
|
-
const catalog = await (await fetch(new URL(ROUTES.catalog, server.url))).json();
|
|
37
|
-
if (catalog.error !== void 0) throw new Error(`publish: the playground did not open over the build for capture:\n${catalog.error}`);
|
|
38
|
-
for (const property of catalog.properties) for (const fixture of property.content) for (const format of catalog.template.formats) {
|
|
39
|
-
const of = `of fixture "${fixture.name}" at ${format.id}`;
|
|
40
|
-
const take = async (page, file, optional = false) => {
|
|
41
|
-
const bytes = await downloaded(new URL(ROUTES.download(property.name, fixture.name, {
|
|
42
|
-
format: format.id,
|
|
43
|
-
page
|
|
44
|
-
}), server.url), `${file} ${of}`, optional);
|
|
45
|
-
if (bytes !== null) files.set(capturePath(fixture.name, format.id, file), bytes);
|
|
46
|
-
};
|
|
47
|
-
if (catalog.template.output === "document") {
|
|
48
|
-
await take(null, CAPTURE_FILES.document);
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
for (const page of catalog.template.pages) await take(page.id, `${page.id}.png`, true);
|
|
52
|
-
if (catalog.template.pages.filter((page) => !(fixture.pagesOff ?? []).includes(page.id)).length > 1) await take(null, CAPTURE_FILES.bundle);
|
|
53
|
-
}
|
|
54
|
-
} finally {
|
|
55
|
-
await server.close();
|
|
56
|
-
}
|
|
57
|
-
return files;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
export { captureFiles };
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import { asProblem, isCreateResponse, isPublicationRecord, isSubmitResponse } from "./wire.js";
|
|
2
|
-
import { createReadStream } from "node:fs";
|
|
3
|
-
import { request } from "node:http";
|
|
4
|
-
import { request as request$1 } from "node:https";
|
|
5
|
-
|
|
6
|
-
//#region src/cli/publish/client.ts
|
|
7
|
-
const IDLE_TIMEOUT_MS = 6e4;
|
|
8
|
-
function send(url, method, headers, body) {
|
|
9
|
-
const request$2 = url.protocol === "https:" ? request$1 : request;
|
|
10
|
-
return new Promise((resolve, reject) => {
|
|
11
|
-
const payload = body !== null && "json" in body ? Buffer.from(JSON.stringify(body.json), "utf8") : null;
|
|
12
|
-
const req = request$2(url, {
|
|
13
|
-
method,
|
|
14
|
-
headers: payload === null ? headers : {
|
|
15
|
-
...headers,
|
|
16
|
-
"content-type": "application/json",
|
|
17
|
-
"content-length": String(payload.length)
|
|
18
|
-
},
|
|
19
|
-
timeout: IDLE_TIMEOUT_MS
|
|
20
|
-
}, (res) => {
|
|
21
|
-
const chunks = [];
|
|
22
|
-
res.on("data", (chunk) => chunks.push(chunk));
|
|
23
|
-
res.on("end", () => resolve({
|
|
24
|
-
status: res.statusCode ?? 0,
|
|
25
|
-
body: Buffer.concat(chunks).toString("utf8")
|
|
26
|
-
}));
|
|
27
|
-
res.on("error", reject);
|
|
28
|
-
});
|
|
29
|
-
req.on("timeout", () => req.destroy(/* @__PURE__ */ new Error(`no response in ${String(IDLE_TIMEOUT_MS / 1e3)}s`)));
|
|
30
|
-
req.on("error", reject);
|
|
31
|
-
if (payload !== null) req.end(payload);
|
|
32
|
-
else if (body !== null && "file" in body) {
|
|
33
|
-
const stream = createReadStream(body.file);
|
|
34
|
-
stream.on("error", (cause) => req.destroy(cause));
|
|
35
|
-
stream.pipe(req);
|
|
36
|
-
} else req.end();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function reasonOf(cause) {
|
|
40
|
-
if (cause instanceof Error) {
|
|
41
|
-
const code = cause.code;
|
|
42
|
-
return code === void 0 ? cause.message : `${code}: ${cause.message}`;
|
|
43
|
-
}
|
|
44
|
-
return String(cause);
|
|
45
|
-
}
|
|
46
|
-
function parseJson(text) {
|
|
47
|
-
try {
|
|
48
|
-
return JSON.parse(text);
|
|
49
|
-
} catch {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
async function exchange(url, method, headers, body, expected, accept) {
|
|
54
|
-
let raw;
|
|
55
|
-
try {
|
|
56
|
-
raw = await send(url, method, headers, body);
|
|
57
|
-
} catch (cause) {
|
|
58
|
-
return {
|
|
59
|
-
kind: "unreachable",
|
|
60
|
-
reason: reasonOf(cause)
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
const parsed = parseJson(raw.body);
|
|
64
|
-
if (expected.includes(raw.status)) return accept(parsed) ? {
|
|
65
|
-
kind: "ok",
|
|
66
|
-
value: parsed
|
|
67
|
-
} : {
|
|
68
|
-
kind: "unexpected",
|
|
69
|
-
status: raw.status,
|
|
70
|
-
reason: "the body is not the shape this route answers with"
|
|
71
|
-
};
|
|
72
|
-
if (raw.status >= 400 && raw.status < 600) return {
|
|
73
|
-
kind: "refused",
|
|
74
|
-
status: raw.status,
|
|
75
|
-
problem: asProblem(parsed)
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
kind: "unexpected",
|
|
79
|
-
status: raw.status,
|
|
80
|
-
reason: `HTTP ${String(raw.status)}`
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function publicationClient(endpoint, token) {
|
|
84
|
-
const auth = {
|
|
85
|
-
authorization: `Bearer ${token}`,
|
|
86
|
-
accept: "application/json"
|
|
87
|
-
};
|
|
88
|
-
const route = (path) => new URL(`${endpoint}${path}`);
|
|
89
|
-
return {
|
|
90
|
-
create: (body) => exchange(route("/catalog/publications"), "POST", auth, { json: body }, [201], isCreateResponse),
|
|
91
|
-
upload: async (upload, file) => {
|
|
92
|
-
let raw;
|
|
93
|
-
try {
|
|
94
|
-
raw = await send(new URL(upload.url), upload.method, upload.headers, { file });
|
|
95
|
-
} catch (cause) {
|
|
96
|
-
return {
|
|
97
|
-
kind: "unreachable",
|
|
98
|
-
reason: reasonOf(cause)
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
if (raw.status >= 200 && raw.status < 300) return {
|
|
102
|
-
kind: "ok",
|
|
103
|
-
value: null
|
|
104
|
-
};
|
|
105
|
-
const message = /<Message>([^<]*)<\/Message>/.exec(raw.body)?.[1];
|
|
106
|
-
return {
|
|
107
|
-
kind: "refused",
|
|
108
|
-
status: raw.status,
|
|
109
|
-
problem: { detail: message ?? `HTTP ${String(raw.status)}` }
|
|
110
|
-
};
|
|
111
|
-
},
|
|
112
|
-
submit: (id, body) => exchange(route(`/catalog/publications/${encodeURIComponent(id)}/submit`), "POST", auth, body === null ? null : { json: body }, [202], isSubmitResponse),
|
|
113
|
-
read: (id) => exchange(route(`/catalog/publications/${encodeURIComponent(id)}`), "GET", auth, null, [200], isPublicationRecord)
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
//#endregion
|
|
118
|
-
export { publicationClient };
|
package/dist/cli/publish/pack.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { byCodeUnit } from "../../platform/order.js";
|
|
2
|
-
import { listDir } from "../../platform/fs.js";
|
|
3
|
-
import { createWriteStream } from "node:fs";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { lstat, readFile } from "node:fs/promises";
|
|
6
|
-
import { createGzip } from "node:zlib";
|
|
7
|
-
import { Readable } from "node:stream";
|
|
8
|
-
import { pipeline } from "node:stream/promises";
|
|
9
|
-
|
|
10
|
-
//#region src/cli/publish/pack.ts
|
|
11
|
-
const BLOCK = 512;
|
|
12
|
-
const NAME_FIELD = 100;
|
|
13
|
-
async function listFiles(dir) {
|
|
14
|
-
const out = [];
|
|
15
|
-
const visit = async (relative) => {
|
|
16
|
-
for (const entry of await listDir(join(dir, relative))) {
|
|
17
|
-
const path = relative === "" ? entry.name : `${relative}/${entry.name}`;
|
|
18
|
-
if (entry.isDirectory()) await visit(path);
|
|
19
|
-
else if (entry.isFile()) out.push(path);
|
|
20
|
-
else throw new Error(`The artifact holds ${path}, which is not a regular file; run \`concrete publish --rebuild\` to write a clean artifact.`);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
if (!(await lstat(dir)).isDirectory()) throw new Error(`${dir} is not a directory.`);
|
|
24
|
-
await visit("");
|
|
25
|
-
return out.sort(byCodeUnit);
|
|
26
|
-
}
|
|
27
|
-
function octal(value, width) {
|
|
28
|
-
return `${value.toString(8).padStart(width - 1, "0")}\0`;
|
|
29
|
-
}
|
|
30
|
-
function header(name, size, type) {
|
|
31
|
-
const block = Buffer.alloc(BLOCK);
|
|
32
|
-
block.write(name, 0, NAME_FIELD, "utf8");
|
|
33
|
-
block.write(octal(420, 8), 100, "ascii");
|
|
34
|
-
block.write(octal(0, 8), 108, "ascii");
|
|
35
|
-
block.write(octal(0, 8), 116, "ascii");
|
|
36
|
-
block.write(octal(size, 12), 124, "ascii");
|
|
37
|
-
block.write(octal(0, 12), 136, "ascii");
|
|
38
|
-
block.write(" ", 148, "ascii");
|
|
39
|
-
block.write(type, 156, "ascii");
|
|
40
|
-
block.write("ustar\0", 257, "ascii");
|
|
41
|
-
block.write("00", 263, "ascii");
|
|
42
|
-
let sum = 0;
|
|
43
|
-
for (const byte of block) sum += byte;
|
|
44
|
-
block.write(`${sum.toString(8).padStart(6, "0")}\0 `, 148, "ascii");
|
|
45
|
-
return block;
|
|
46
|
-
}
|
|
47
|
-
const padding = (size) => Buffer.alloc((BLOCK - size % BLOCK) % BLOCK);
|
|
48
|
-
function paxRecord(path) {
|
|
49
|
-
const body = ` path=${path}\n`;
|
|
50
|
-
const bodyBytes = Buffer.byteLength(body, "utf8");
|
|
51
|
-
let length = bodyBytes + 1;
|
|
52
|
-
while (String(length).length + bodyBytes !== length) length = String(length).length + bodyBytes;
|
|
53
|
-
return Buffer.from(`${String(length)}${body}`, "utf8");
|
|
54
|
-
}
|
|
55
|
-
async function* entries(dir, paths) {
|
|
56
|
-
for (const path of paths) {
|
|
57
|
-
const body = await readFile(join(dir, ...path.split("/")));
|
|
58
|
-
if (Buffer.byteLength(path, "utf8") > NAME_FIELD) {
|
|
59
|
-
const record = paxRecord(path);
|
|
60
|
-
yield header("PaxHeader", record.length, "x");
|
|
61
|
-
yield record;
|
|
62
|
-
yield padding(record.length);
|
|
63
|
-
}
|
|
64
|
-
yield header(Buffer.from(path, "utf8").subarray(0, NAME_FIELD).toString("utf8"), body.length, "0");
|
|
65
|
-
yield body;
|
|
66
|
-
yield padding(body.length);
|
|
67
|
-
}
|
|
68
|
-
yield Buffer.alloc(BLOCK * 2);
|
|
69
|
-
}
|
|
70
|
-
async function packArtifact(dir, file) {
|
|
71
|
-
const paths = await listFiles(dir);
|
|
72
|
-
await pipeline(Readable.from(entries(dir, paths)), createGzip(), createWriteStream(file));
|
|
73
|
-
return { files: paths.length };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
export { packArtifact };
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { packageRoot, workspacePath } from "../../platform/paths.js";
|
|
2
|
-
import { byCodeUnit } from "../../platform/order.js";
|
|
3
|
-
import { PLAYGROUND_FILES, playgroundPath } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
4
|
-
import "../../packages/internal/template-artifact/dist/index.js";
|
|
5
|
-
import { playgroundDistDir } from "../../packages/internal/playground/dist/layout.js";
|
|
6
|
-
import { existsSync } from "node:fs";
|
|
7
|
-
import { join } from "node:path";
|
|
8
|
-
import { readFile, readdir } from "node:fs/promises";
|
|
9
|
-
|
|
10
|
-
//#region src/cli/publish/playground.ts
|
|
11
|
-
async function listFiles(dir) {
|
|
12
|
-
return (await readdir(dir, {
|
|
13
|
-
withFileTypes: true,
|
|
14
|
-
recursive: true
|
|
15
|
-
})).filter((entry) => entry.isFile()).map((entry) => join(entry.parentPath, entry.name));
|
|
16
|
-
}
|
|
17
|
-
async function playgroundFiles(root = packageRoot()) {
|
|
18
|
-
const dir = playgroundDistDir(root);
|
|
19
|
-
for (const file of Object.values(PLAYGROUND_FILES)) if (!existsSync(join(dir, file))) throw new Error(`The framework's playground is not built (${join(dir, file)} is missing). Reinstall @homepages/concrete, or build the package from its checkout.`);
|
|
20
|
-
const out = /* @__PURE__ */ new Map();
|
|
21
|
-
const paths = (await listFiles(dir)).map((file) => workspacePath(dir, file)).sort(byCodeUnit);
|
|
22
|
-
for (const path of paths) out.set(playgroundPath(path), new Uint8Array(await readFile(join(dir, ...path.split("/")))));
|
|
23
|
-
return out;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
export { playgroundFiles };
|
package/dist/cli/publish/wire.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
//#region src/cli/publish/wire.ts
|
|
2
|
-
const TERMINAL_STATES = [
|
|
3
|
-
"published",
|
|
4
|
-
"refused",
|
|
5
|
-
"failed",
|
|
6
|
-
"dry_run"
|
|
7
|
-
];
|
|
8
|
-
const isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
-
function isPublicationRecord(value) {
|
|
10
|
-
return isObject(value) && typeof value.id === "string" && typeof value.state === "string" && typeof value.template_key === "string" && isObject(value.publisher) && typeof value.publisher.name === "string";
|
|
11
|
-
}
|
|
12
|
-
function isCreateResponse(value) {
|
|
13
|
-
return isObject(value) && isPublicationRecord(value.publication) && isObject(value.upload) && typeof value.upload.url === "string" && isObject(value.upload.headers);
|
|
14
|
-
}
|
|
15
|
-
function isSubmitResponse(value) {
|
|
16
|
-
return isObject(value) && isPublicationRecord(value.publication);
|
|
17
|
-
}
|
|
18
|
-
function asProblem(value) {
|
|
19
|
-
return isObject(value) && (typeof value.detail === "string" || typeof value.code === "string") ? value : null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
//#endregion
|
|
23
|
-
export { TERMINAL_STATES, asProblem, isCreateResponse, isPublicationRecord, isSubmitResponse };
|