@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
|
@@ -39,17 +39,56 @@ function bundledFrameworkPlugin() {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
function workspaceLoaders(root) {
|
|
42
|
+
function workspaceLoaders(root, addresses) {
|
|
43
43
|
return {
|
|
44
44
|
loader: {
|
|
45
45
|
".css": "empty",
|
|
46
46
|
...MEDIA_LOADERS
|
|
47
47
|
},
|
|
48
|
-
publicPath: ASSET_PUBLIC_PATH,
|
|
48
|
+
publicPath: addresses === "fixed" ? ASSET_PUBLIC_PATH : "",
|
|
49
49
|
assetNames: ASSET_NAMES,
|
|
50
50
|
outdir: join(root, ".concrete", "cache", "build")
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
+
const RELATIVE_ASSET_NAMESPACE = "concrete-relative-asset";
|
|
54
|
+
const RELATIVE_ASSET_INNER = Symbol("concrete-relative-asset:inner");
|
|
55
|
+
const ASSET_IMPORT_KINDS = /* @__PURE__ */ new Set([
|
|
56
|
+
"import-statement",
|
|
57
|
+
"require-call",
|
|
58
|
+
"dynamic-import"
|
|
59
|
+
]);
|
|
60
|
+
const MEDIA_FILTER = new RegExp(`\\.(?:${Object.keys(MEDIA_LOADERS).map((ext) => [...ext.slice(1)].map((c) => `[${c.toLowerCase()}${c.toUpperCase()}]`).join("")).join("|")})$`);
|
|
61
|
+
function relativeAssetPlugin() {
|
|
62
|
+
return {
|
|
63
|
+
name: RELATIVE_ASSET_NAMESPACE,
|
|
64
|
+
setup(build) {
|
|
65
|
+
build.onResolve({ filter: MEDIA_FILTER }, async (args) => {
|
|
66
|
+
if (args.pluginData === RELATIVE_ASSET_INNER || !ASSET_IMPORT_KINDS.has(args.kind)) return null;
|
|
67
|
+
const resolved = await build.resolve(args.path, {
|
|
68
|
+
importer: args.importer,
|
|
69
|
+
namespace: args.namespace,
|
|
70
|
+
resolveDir: args.resolveDir,
|
|
71
|
+
kind: args.kind,
|
|
72
|
+
pluginData: RELATIVE_ASSET_INNER
|
|
73
|
+
});
|
|
74
|
+
if (resolved.errors.length > 0 || resolved.path === "" || resolved.external === true) return null;
|
|
75
|
+
return {
|
|
76
|
+
path: resolved.path,
|
|
77
|
+
namespace: RELATIVE_ASSET_NAMESPACE
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
build.onLoad({
|
|
81
|
+
filter: /.*/,
|
|
82
|
+
namespace: RELATIVE_ASSET_NAMESPACE
|
|
83
|
+
}, (args) => ({
|
|
84
|
+
contents: `import file from ${JSON.stringify(args.path)};\nexport default new URL(file, import.meta.url).pathname;`,
|
|
85
|
+
loader: "js",
|
|
86
|
+
resolveDir: dirname(args.path),
|
|
87
|
+
pluginData: RELATIVE_ASSET_INNER
|
|
88
|
+
}));
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
53
92
|
function emittedAssets(outputs) {
|
|
54
93
|
const byName = /* @__PURE__ */ new Map();
|
|
55
94
|
for (const file of outputs) {
|
|
@@ -83,4 +122,4 @@ async function runPass(what, pass) {
|
|
|
83
122
|
}
|
|
84
123
|
|
|
85
124
|
//#endregion
|
|
86
|
-
export { ASSET_NAMES, ASSET_PUBLIC_PATH, assetContentType, bundledFrameworkPlugin, emittedAssets, javascriptOutput, runPass, workspaceLoaders };
|
|
125
|
+
export { ASSET_NAMES, ASSET_PUBLIC_PATH, RELATIVE_ASSET_NAMESPACE, assetContentType, bundledFrameworkPlugin, emittedAssets, javascriptOutput, relativeAssetPlugin, runPass, workspaceLoaders };
|
|
@@ -19,7 +19,7 @@ function fixtureListOf(template) {
|
|
|
19
19
|
async function buildManifest(input) {
|
|
20
20
|
const { template } = input;
|
|
21
21
|
const fields = {
|
|
22
|
-
artifact_schema:
|
|
22
|
+
artifact_schema: 6,
|
|
23
23
|
framework_version: CONCRETE_CLI_VERSION,
|
|
24
24
|
key: template.key,
|
|
25
25
|
display_name: template.name,
|
package/dist/cli/build/record.js
CHANGED
|
@@ -10,13 +10,14 @@ const LEGACY_BUILD_RECORD_FILE = "build.json";
|
|
|
10
10
|
function buildRecordPath(out) {
|
|
11
11
|
return join(dirname(out), `${basename(out)}.json`);
|
|
12
12
|
}
|
|
13
|
-
const BUILD_RECORD_SCHEMA =
|
|
13
|
+
const BUILD_RECORD_SCHEMA = 3;
|
|
14
14
|
const IslandRecord = z.object({
|
|
15
15
|
island_key: z.string(),
|
|
16
16
|
filename: z.string(),
|
|
17
17
|
content_hash: z.string(),
|
|
18
18
|
file: z.string(),
|
|
19
|
-
frameless: z.boolean()
|
|
19
|
+
frameless: z.boolean(),
|
|
20
|
+
assets: z.array(z.string())
|
|
20
21
|
});
|
|
21
22
|
const SourceRecord = z.object({
|
|
22
23
|
file: z.string(),
|
|
@@ -37,7 +38,7 @@ const SectionRecord = z.object({
|
|
|
37
38
|
files: z.array(z.string())
|
|
38
39
|
});
|
|
39
40
|
const BuildRecord = z.object({
|
|
40
|
-
build_schema: z.literal(
|
|
41
|
+
build_schema: z.literal(3),
|
|
41
42
|
framework_version: z.string(),
|
|
42
43
|
key: z.string(),
|
|
43
44
|
template: z.object({ content_hash: z.string() }),
|
|
@@ -98,7 +99,7 @@ async function stampTree(dir, hash) {
|
|
|
98
99
|
}
|
|
99
100
|
entries.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
100
101
|
for (const entry of entries) {
|
|
101
|
-
if (entry.name
|
|
102
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules") continue;
|
|
102
103
|
const path = join(at, entry.name);
|
|
103
104
|
if (entry.isDirectory()) await visit(path);
|
|
104
105
|
else if (entry.isFile()) hash.update(`${path}\0${await stampOf(path)}\n`);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isWorkspaceFile, toPosix, workspacePath } from "../../platform/paths.js";
|
|
2
|
-
import { bundledFrameworkPlugin, emittedAssets, javascriptOutput, runPass, workspaceLoaders } from "./esbuild.js";
|
|
2
|
+
import { bundledFrameworkPlugin, emittedAssets, javascriptOutput, relativeAssetPlugin, runPass, workspaceLoaders } from "./esbuild.js";
|
|
3
3
|
import { ISLAND_REACT_EXTERNALS } from "../../packages/internal/static-assets-binding/dist/index.js";
|
|
4
4
|
import { declaresNoServerFrame, stubClientModule, wrapClientModule } from "../../islands/wrap.js";
|
|
5
5
|
import { mediaCacheDir } from "../media/cache.js";
|
|
@@ -95,7 +95,7 @@ async function rendererPass(input, deriver, found, stubFrameless) {
|
|
|
95
95
|
"react/jsx-runtime"
|
|
96
96
|
],
|
|
97
97
|
absWorkingDir: root,
|
|
98
|
-
...workspaceLoaders(root),
|
|
98
|
+
...workspaceLoaders(root, "fixed"),
|
|
99
99
|
plugins: [
|
|
100
100
|
bundledFrameworkPlugin(),
|
|
101
101
|
serverIslandsPlugin(root, key, found, stubFrameless),
|
|
@@ -166,7 +166,11 @@ async function buildSection(input) {
|
|
|
166
166
|
collect(rendererDeriver, rendered.outputFiles, rendered.metafile);
|
|
167
167
|
const islands = [];
|
|
168
168
|
for (const [islandKey, file] of [...found].sort(([a], [b]) => a < b ? -1 : 1)) {
|
|
169
|
-
const deriver = createMediaDeriver(
|
|
169
|
+
const deriver = createMediaDeriver({
|
|
170
|
+
...deriverOptions,
|
|
171
|
+
addresses: "relative"
|
|
172
|
+
});
|
|
173
|
+
let named = [];
|
|
170
174
|
const bytes = await runPass(`The island chunk ${islandKey}`, async () => {
|
|
171
175
|
const result = await build({
|
|
172
176
|
entryPoints: [file],
|
|
@@ -179,16 +183,18 @@ async function buildSection(input) {
|
|
|
179
183
|
jsx: "automatic",
|
|
180
184
|
external: [...ISLAND_REACT_EXTERNALS],
|
|
181
185
|
absWorkingDir: root,
|
|
182
|
-
...workspaceLoaders(root),
|
|
186
|
+
...workspaceLoaders(root, "relative"),
|
|
183
187
|
plugins: [
|
|
184
188
|
bundledFrameworkPlugin(),
|
|
185
189
|
nestedIslandsPlugin(root, key, file),
|
|
186
|
-
deriver.plugin
|
|
190
|
+
deriver.plugin,
|
|
191
|
+
relativeAssetPlugin()
|
|
187
192
|
],
|
|
188
193
|
metafile: true,
|
|
189
194
|
logLevel: "silent"
|
|
190
195
|
});
|
|
191
196
|
collect(deriver, result.outputFiles, result.metafile);
|
|
197
|
+
named = [.../* @__PURE__ */ new Set([...emittedAssets(result.outputFiles).map((asset) => asset.filename), ...deriver.named])].sort();
|
|
192
198
|
return javascriptOutput(result.outputFiles, `island ${islandKey}`);
|
|
193
199
|
});
|
|
194
200
|
const contentHash = sha256(bytes);
|
|
@@ -199,7 +205,8 @@ async function buildSection(input) {
|
|
|
199
205
|
contentHash,
|
|
200
206
|
bytes,
|
|
201
207
|
file,
|
|
202
|
-
frameless
|
|
208
|
+
frameless,
|
|
209
|
+
assets: named
|
|
203
210
|
});
|
|
204
211
|
}
|
|
205
212
|
return {
|
|
@@ -120,7 +120,8 @@ async function produceSection(root, out, task, site, context) {
|
|
|
120
120
|
contentHash: island.content_hash,
|
|
121
121
|
bytes: islandBytes[index],
|
|
122
122
|
file: island.file,
|
|
123
|
-
frameless: island.frameless
|
|
123
|
+
frameless: island.frameless,
|
|
124
|
+
assets: island.assets
|
|
124
125
|
}));
|
|
125
126
|
return {
|
|
126
127
|
logic: {
|
|
@@ -194,7 +195,8 @@ async function produceSection(root, out, task, site, context) {
|
|
|
194
195
|
filename: island.filename,
|
|
195
196
|
content_hash: island.contentHash,
|
|
196
197
|
file: island.file,
|
|
197
|
-
frameless: island.frameless
|
|
198
|
+
frameless: island.frameless,
|
|
199
|
+
assets: [...island.assets]
|
|
198
200
|
})),
|
|
199
201
|
sources: [...built.sources],
|
|
200
202
|
masters: Object.fromEntries(byKey(built.masters)),
|
|
@@ -447,6 +449,7 @@ async function assemble(root, out, workspace, composition, css, results, shared)
|
|
|
447
449
|
const sectionRecords = [];
|
|
448
450
|
const islands = {};
|
|
449
451
|
const masters = [];
|
|
452
|
+
const relativeAssets = /* @__PURE__ */ new Set();
|
|
450
453
|
for (const result of [...results].sort((a, b) => a.build.key < b.build.key ? -1 : a.build.key > b.build.key ? 1 : 0)) {
|
|
451
454
|
const { build, record } = result;
|
|
452
455
|
if (!isSectionKey(build.key)) throw new LayoutRefusal({
|
|
@@ -479,10 +482,13 @@ async function assemble(root, out, workspace, composition, css, results, shared)
|
|
|
479
482
|
output.keep(path, sha);
|
|
480
483
|
}
|
|
481
484
|
}
|
|
482
|
-
for (const island of bundles.islands)
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
485
|
+
for (const island of bundles.islands) {
|
|
486
|
+
islands[island.islandKey] = {
|
|
487
|
+
filename: island.filename,
|
|
488
|
+
content_hash: island.contentHash
|
|
489
|
+
};
|
|
490
|
+
for (const asset of island.assets) relativeAssets.add(asset);
|
|
491
|
+
}
|
|
486
492
|
masters.push(...bundles.masters);
|
|
487
493
|
const contentHash = output.digestUnder(sectionDir(build.key));
|
|
488
494
|
sectionRecords.push({
|
|
@@ -512,7 +518,10 @@ async function assemble(root, out, workspace, composition, css, results, shared)
|
|
|
512
518
|
output.put(templatePath(TEMPLATE_FILES.composition), json(compositionColumn));
|
|
513
519
|
output.put(templatePath(TEMPLATE_FILES.preview), json(manifest.preview ?? null));
|
|
514
520
|
output.put(templatePath(TEMPLATE_FILES.stylesheet), css.bytes);
|
|
515
|
-
for (const asset of css.assets)
|
|
521
|
+
for (const asset of css.assets) {
|
|
522
|
+
output.asset(asset);
|
|
523
|
+
relativeAssets.add(asset.filename);
|
|
524
|
+
}
|
|
516
525
|
const { icons } = shared;
|
|
517
526
|
if (icons === null) throw new LayoutRefusal({
|
|
518
527
|
rule: "workspace/template-invalid",
|
|
@@ -541,7 +550,8 @@ async function assemble(root, out, workspace, composition, css, results, shared)
|
|
|
541
550
|
react_vendor_core: vendor === null ? null : putStatic(vendor.core),
|
|
542
551
|
analytics: shared.analytics === null ? null : putStatic(shared.analytics),
|
|
543
552
|
masters: Object.fromEntries(byKey(masters)),
|
|
544
|
-
icons: icons.icons
|
|
553
|
+
icons: icons.icons,
|
|
554
|
+
relative_assets: [...relativeAssets].sort()
|
|
545
555
|
};
|
|
546
556
|
output.put(templatePath(TEMPLATE_FILES.staticAssets), json(binding));
|
|
547
557
|
const clashes = browserFileClashes(binding, output.hashes.keys());
|
|
@@ -574,7 +584,7 @@ async function assemble(root, out, workspace, composition, css, results, shared)
|
|
|
574
584
|
message: `The build would not write the same files on Windows and macOS:\n` + unportable.map((found) => ` ${found.paths.join(" and ")}: ${found.reason}`).join("\n") + "\nRename the source files these names come from."
|
|
575
585
|
});
|
|
576
586
|
const record = {
|
|
577
|
-
build_schema:
|
|
587
|
+
build_schema: 3,
|
|
578
588
|
framework_version: CONCRETE_CLI_VERSION,
|
|
579
589
|
key: template.key,
|
|
580
590
|
template: { content_hash: templateHash },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isTemplate } from "../../template/define-template.js";
|
|
2
2
|
import { workspacePath } from "../../platform/paths.js";
|
|
3
3
|
import { MEDIA_LOADERS, createFixtureMediaPlugin, externalOutsideWorkspace } from "../../fixtures/media-plugin.js";
|
|
4
|
-
import {
|
|
4
|
+
import { emptyPackageStylesheets } from "../../fixtures/package-stylesheets.js";
|
|
5
5
|
import { runningCopyPlugin } from "../../template/running-copy.js";
|
|
6
6
|
import { listModules } from "../../section/discovery.js";
|
|
7
7
|
import { claimLoadOutdir } from "./load-outdir.js";
|
|
@@ -31,7 +31,7 @@ async function loadWorkspace(root) {
|
|
|
31
31
|
};
|
|
32
32
|
const files = listModules(root);
|
|
33
33
|
const media = createFixtureMediaPlugin(root);
|
|
34
|
-
|
|
34
|
+
emptyPackageStylesheets();
|
|
35
35
|
const outdir = await claimLoadOutdir(root);
|
|
36
36
|
let result;
|
|
37
37
|
try {
|
|
@@ -54,8 +54,7 @@ async function loadWorkspace(root) {
|
|
|
54
54
|
plugins: [
|
|
55
55
|
runningCopyPlugin(),
|
|
56
56
|
externalOutsideWorkspace(root),
|
|
57
|
-
media.plugin
|
|
58
|
-
stylesheets.plugin
|
|
57
|
+
media.plugin
|
|
59
58
|
],
|
|
60
59
|
sourcemap: "inline",
|
|
61
60
|
metafile: true,
|
|
@@ -77,8 +76,6 @@ async function loadWorkspace(root) {
|
|
|
77
76
|
message: m.text
|
|
78
77
|
}))
|
|
79
78
|
};
|
|
80
|
-
} finally {
|
|
81
|
-
await stylesheets.dispose();
|
|
82
79
|
}
|
|
83
80
|
process.setSourceMapsEnabled(true);
|
|
84
81
|
const outputByInput = /* @__PURE__ */ new Map();
|
package/dist/cli/commands.js
CHANGED
|
@@ -183,50 +183,98 @@ const DECLARED_COMMANDS = [
|
|
|
183
183
|
},
|
|
184
184
|
{
|
|
185
185
|
name: "publish",
|
|
186
|
-
summary: "
|
|
186
|
+
summary: "Send the template to the development console",
|
|
187
|
+
flags: [{
|
|
188
|
+
name: "json",
|
|
189
|
+
type: "boolean",
|
|
190
|
+
default: false,
|
|
191
|
+
summary: "Print the version, its playground link, the merge and the verdict on stdout instead of the summary"
|
|
192
|
+
}, {
|
|
193
|
+
name: "env-file",
|
|
194
|
+
type: "string",
|
|
195
|
+
valueLabel: "<path>",
|
|
196
|
+
summary: "Read `CONCRETE_CONSOLE_KEY` and `CONCRETE_CONSOLE_URL` from this dotenv file instead of the workspace's `.env`"
|
|
197
|
+
}],
|
|
198
|
+
exits: [
|
|
199
|
+
{
|
|
200
|
+
code: 0,
|
|
201
|
+
when: "the template was sent and the platform loads and renders the version's build"
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
code: 1,
|
|
205
|
+
when: "`check` is not green, the console refuses the send, or the version's build fails verification"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
code: 2,
|
|
209
|
+
when: "no console key is set, the key is malformed or not accepted, the console cannot be reached or gives no verdict, or it runs outside a workspace"
|
|
210
|
+
}
|
|
211
|
+
],
|
|
212
|
+
constraints: [
|
|
213
|
+
"The key is the environment: `CONCRETE_CONSOLE_KEY`, the team's console key, names production, staging or dev in its prefix (`cck_prod_…`), and publish sends to that environment's console. There is no environment flag.",
|
|
214
|
+
"Reads `CONCRETE_CONSOLE_KEY` from the environment, then from the workspace's `.env`, and refuses before anything is built or sent when it is missing. `CONCRETE_CONSOLE_URL` replaces the console the key's prefix names.",
|
|
215
|
+
"`--env-file <path>` names the key file instead, relative to the current directory: its values win over the environment and the workspace's `.env` is not read. It is how a library holding one key file per environment picks one, in any shell.",
|
|
216
|
+
"Builds and checks on every run, then sends the template — the build and the authored fixtures — to the development console, which merges it with the work already there as a new version and serves its playground. Nothing is reused.",
|
|
217
|
+
"Then asks the console for the version's verdict: whether the platform loads and renders its build. A failing verdict prints its problems and exits 1; the version stays on the console, and its playground shows the build.",
|
|
218
|
+
"Asks nothing of HomePages: a sent version reaches customers only when `concrete release` hands it over. The last line names the `concrete release --version <n>` that does.",
|
|
219
|
+
"Prints the version, the playground's link and every fixture where the console's work was replaced or kept, and warns when the build's @homepages/concrete is older than the console's.",
|
|
220
|
+
"Prints one line per stage on stderr as it settles: console, build, send, verify.",
|
|
221
|
+
"Has no dry run: `concrete release --dry-run` is the run that asks without changing anything.",
|
|
222
|
+
"Under `--json` the outcome is the only thing written to stdout; every stage line goes to stderr.",
|
|
223
|
+
"Never prompts, in any environment."
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "release",
|
|
228
|
+
summary: "Hand a version on the development console to HomePages",
|
|
187
229
|
flags: [
|
|
230
|
+
{
|
|
231
|
+
name: "version",
|
|
232
|
+
type: "string",
|
|
233
|
+
valueLabel: "<n>",
|
|
234
|
+
summary: "Release this version instead of the template's current one"
|
|
235
|
+
},
|
|
188
236
|
{
|
|
189
237
|
name: "dry-run",
|
|
190
238
|
type: "boolean",
|
|
191
239
|
default: false,
|
|
192
|
-
summary: "
|
|
240
|
+
summary: "Report what releasing would change, and change nothing in HomePages"
|
|
193
241
|
},
|
|
194
242
|
{
|
|
195
243
|
name: "json",
|
|
196
244
|
type: "boolean",
|
|
197
245
|
default: false,
|
|
198
|
-
summary: "Print the
|
|
246
|
+
summary: "Print the release's outcome on stdout instead of the summary"
|
|
199
247
|
},
|
|
200
248
|
{
|
|
201
249
|
name: "env-file",
|
|
202
250
|
type: "string",
|
|
203
251
|
valueLabel: "<path>",
|
|
204
|
-
summary: "Read `
|
|
252
|
+
summary: "Read `CONCRETE_CONSOLE_KEY` and `CONCRETE_CONSOLE_URL` from this dotenv file instead of the workspace's `.env`"
|
|
205
253
|
}
|
|
206
254
|
],
|
|
207
255
|
exits: [
|
|
208
256
|
{
|
|
209
257
|
code: 0,
|
|
210
|
-
when: "the
|
|
258
|
+
when: "the version was released, HomePages already held its build, or a dry run found it would release"
|
|
211
259
|
},
|
|
212
260
|
{
|
|
213
261
|
code: 1,
|
|
214
|
-
when: "
|
|
262
|
+
when: "the console or HomePages refuses the release: the build failed verification, its audience is outside the team's, it drops a format deliverables still hold, or the console holds no such version"
|
|
215
263
|
},
|
|
216
264
|
{
|
|
217
265
|
code: 2,
|
|
218
|
-
when: "no
|
|
266
|
+
when: "no console key is set, the key is malformed or not accepted, the console cannot be reached, HomePages could not take the release, or it runs outside a workspace"
|
|
219
267
|
}
|
|
220
268
|
],
|
|
221
269
|
constraints: [
|
|
222
|
-
"The key is the environment: `
|
|
223
|
-
"Reads `
|
|
224
|
-
"
|
|
225
|
-
"
|
|
226
|
-
"
|
|
227
|
-
"
|
|
228
|
-
"
|
|
229
|
-
"Under `--json` the
|
|
270
|
+
"The key is the environment: `CONCRETE_CONSOLE_KEY`, the team's console key, names production, staging or dev in its prefix (`cck_prod_…`), and release asks that environment's console. There is no environment flag.",
|
|
271
|
+
"Reads `CONCRETE_CONSOLE_KEY` from the environment, then from the workspace's `.env`; `--env-file <path>` names the key file instead. `CONCRETE_CONSOLE_URL` replaces the console the key's prefix names.",
|
|
272
|
+
"Builds and sends nothing: the console holds every version a send made, its build and its verdict. The template is the one the workspace's `template.ts` declares.",
|
|
273
|
+
"Without `--version` the template's current version is released, and the first line names it, with when and with which key its build was sent.",
|
|
274
|
+
"Prints the audience, what changed, and how many deliverables are adopting the build. A refusal prints its problems.",
|
|
275
|
+
"While the console is still verifying the build or delivering it, release asks again on its own.",
|
|
276
|
+
"When HomePages could not take the release it says why and exits 2: nothing says the build is unfit, and the same command can be run again.",
|
|
277
|
+
"Under `--json` the outcome is the only thing written to stdout; every other line goes to stderr.",
|
|
230
278
|
"Never prompts, in any environment."
|
|
231
279
|
]
|
|
232
280
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { isFileSpecifier } from "../../platform/paths.js";
|
|
2
|
+
import { ASSET_PUBLIC_PATH, RELATIVE_ASSET_NAMESPACE } from "../build/esbuild.js";
|
|
1
3
|
import { DERIVABLE_EXTENSIONS, cachedAuthorImage, deriveAuthorImage, masterOnlyDerivation } from "./derive.js";
|
|
2
|
-
import {
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { extname, resolve } from "node:path";
|
|
3
6
|
import { readFile } from "node:fs/promises";
|
|
4
7
|
|
|
5
8
|
//#region src/cli/media/deriver-plugin.ts
|
|
@@ -12,14 +15,22 @@ function createMediaDeriver(opts = {}) {
|
|
|
12
15
|
const passthrough = /* @__PURE__ */ new Set();
|
|
13
16
|
const pending = /* @__PURE__ */ new Set();
|
|
14
17
|
const sources = /* @__PURE__ */ new Map();
|
|
18
|
+
const named = /* @__PURE__ */ new Set();
|
|
15
19
|
return {
|
|
16
20
|
plugin: {
|
|
17
21
|
name: NAMESPACE,
|
|
18
22
|
setup(build) {
|
|
19
23
|
build.onResolve({ filter: RASTER_FILTER }, async (args) => {
|
|
20
24
|
if (args.pluginData === RESOLVING) return null;
|
|
21
|
-
if (args.kind !== "import-statement") return null;
|
|
25
|
+
if (args.kind !== "import-statement" || args.namespace === "concrete-relative-asset") return null;
|
|
22
26
|
if (!DERIVABLE_EXTENSIONS.has(extname(args.path).toLowerCase())) return null;
|
|
27
|
+
if (isFileSpecifier(args.path)) {
|
|
28
|
+
const written = resolve(args.resolveDir, args.path);
|
|
29
|
+
if (existsSync(written)) return {
|
|
30
|
+
path: written,
|
|
31
|
+
namespace: NAMESPACE
|
|
32
|
+
};
|
|
33
|
+
}
|
|
23
34
|
const resolved = await build.resolve(args.path, {
|
|
24
35
|
importer: args.importer,
|
|
25
36
|
namespace: args.namespace,
|
|
@@ -64,8 +75,9 @@ function createMediaDeriver(opts = {}) {
|
|
|
64
75
|
masterBytes: masterBytes.byteLength,
|
|
65
76
|
derivatives: derivation.derivatives
|
|
66
77
|
});
|
|
78
|
+
for (const address of imageAddresses(derivation.image)) named.add(address.slice(FIXED_PREFIX.length));
|
|
67
79
|
return {
|
|
68
|
-
contents:
|
|
80
|
+
contents: authorImageModule(derivation.image, opts.addresses ?? "fixed"),
|
|
69
81
|
loader: "js",
|
|
70
82
|
watchFiles: [args.path]
|
|
71
83
|
};
|
|
@@ -76,9 +88,28 @@ function createMediaDeriver(opts = {}) {
|
|
|
76
88
|
masters,
|
|
77
89
|
passthrough,
|
|
78
90
|
pending,
|
|
79
|
-
sources
|
|
91
|
+
sources,
|
|
92
|
+
named
|
|
80
93
|
};
|
|
81
94
|
}
|
|
95
|
+
const FIXED_PREFIX = `${ASSET_PUBLIC_PATH}/`;
|
|
96
|
+
function imageAddresses(image) {
|
|
97
|
+
const candidates = (image.responsive?.sources ?? []).flatMap((source) => source.srcset.split(", ").map((candidate) => candidate.split(" ")[0]));
|
|
98
|
+
return [image.url, ...candidates];
|
|
99
|
+
}
|
|
100
|
+
function relativeAddress(address) {
|
|
101
|
+
if (!address.startsWith(FIXED_PREFIX)) throw new Error(`derive: an image address outside ${FIXED_PREFIX}: ${address}`);
|
|
102
|
+
return `d+${JSON.stringify(address.slice(FIXED_PREFIX.length))}`;
|
|
103
|
+
}
|
|
104
|
+
function authorImageModule(image, addresses) {
|
|
105
|
+
if (addresses === "fixed") return `export default ${JSON.stringify(image)};`;
|
|
106
|
+
const srcset = (list) => list.split(", ").map((candidate) => {
|
|
107
|
+
const space = candidate.indexOf(" ");
|
|
108
|
+
return space < 0 ? relativeAddress(candidate) : `${relativeAddress(candidate.slice(0, space))}+${JSON.stringify(candidate.slice(space))}`;
|
|
109
|
+
}).join(`+", "+`);
|
|
110
|
+
const responsive = image.responsive === null ? "null" : `{sources:[${image.responsive.sources.map((source) => `{type:${JSON.stringify(source.type)},srcset:${srcset(source.srcset)}}`).join(",")}],width:${String(image.responsive.width)},height:${String(image.responsive.height)}}`;
|
|
111
|
+
return [`const d = new URL("./", import.meta.url).pathname;`, `export default {url:${relativeAddress(image.url)},responsive:${responsive},width:${String(image.width)},height:${String(image.height)}};`].join("\n");
|
|
112
|
+
}
|
|
82
113
|
|
|
83
114
|
//#endregion
|
|
84
|
-
export { createMediaDeriver };
|
|
115
|
+
export { authorImageModule, createMediaDeriver };
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { qualify } from "../../rules/registry.js";
|
|
2
|
-
import { MANIFEST_FILE,
|
|
2
|
+
import { MANIFEST_FILE, builtTreePath } from "../../packages/internal/template-artifact/dist/layout.js";
|
|
3
3
|
import { ArtifactManifest } from "../../packages/internal/template-artifact/dist/manifest.js";
|
|
4
|
-
import {
|
|
4
|
+
import { verifyBuild } from "../../packages/internal/template-artifact/dist/verify.js";
|
|
5
5
|
import "../../packages/internal/template-artifact/dist/index.js";
|
|
6
6
|
import { unportablePaths } from "../../platform/names.js";
|
|
7
7
|
import { readBuiltFiles } from "../build/template-build.js";
|
|
8
8
|
import { analyzeWorkspace } from "../check/analyze.js";
|
|
9
|
-
import { captureFiles } from "./captures.js";
|
|
10
9
|
import { fixtureFiles } from "./fixtures.js";
|
|
11
|
-
import {
|
|
12
|
-
import { dirname, join, relative } from "node:path";
|
|
13
|
-
import { mkdir, writeFile } from "node:fs/promises";
|
|
10
|
+
import { relative } from "node:path";
|
|
14
11
|
|
|
15
12
|
//#region src/cli/publish/artifact.ts
|
|
16
13
|
async function gather(options) {
|
|
@@ -25,8 +22,7 @@ async function gather(options) {
|
|
|
25
22
|
report
|
|
26
23
|
};
|
|
27
24
|
const { build, fixtureFiles: fixtureSet } = context;
|
|
28
|
-
|
|
29
|
-
if (build.output === null || template === null || fixtureSet === void 0) throw new Error("publish: check passed without a written build and the fixtures an artifact carries.");
|
|
25
|
+
if (build.output === null || build.workspace.template === null || fixtureSet === void 0) throw new Error("publish: check passed without a written build and the fixtures a send carries.");
|
|
30
26
|
const passthrough = build.sections.flatMap((section) => section.bundles?.ok === true ? [...section.bundles.value.passthrough] : []);
|
|
31
27
|
if (passthrough.length > 0) throw new Error(`The template imports images that could not be derived because \`sharp\` did not load: ${passthrough.map((p) => relative(root, p)).join(", ")}. An artifact carries every image's responsive ladder; reinstall so sharp's native binary lands, then publish again.`);
|
|
32
28
|
const built = await readBuiltFiles(build.output);
|
|
@@ -34,55 +30,37 @@ async function gather(options) {
|
|
|
34
30
|
if (written === void 0) throw new Error(`publish: the build wrote no ${MANIFEST_FILE}.`);
|
|
35
31
|
const manifest = ArtifactManifest.parse(JSON.parse(new TextDecoder().decode(written)));
|
|
36
32
|
if (manifest.fixture_list !== fixtureSet.list) throw new Error(`publish: the build's ${MANIFEST_FILE} names the fixture list ${manifest.fixture_list}; check read ${fixtureSet.list}.`);
|
|
33
|
+
const fixtures = await fixtureFiles({
|
|
34
|
+
root,
|
|
35
|
+
files: fixtureSet.files
|
|
36
|
+
});
|
|
37
|
+
const unportable = unportablePaths(fixtures.keys());
|
|
38
|
+
if (unportable.length > 0) throw new Error(`the fixtures would not write the same files on Windows and macOS (${qualify("workspace/unportable-name")}):\n` + unportable.map((found) => ` ${found.paths.join(" and ")}: ${found.reason}`).join("\n") + "\nRename the source files these names come from.");
|
|
37
39
|
return {
|
|
38
40
|
ok: true,
|
|
39
41
|
report,
|
|
40
42
|
manifest,
|
|
41
43
|
built,
|
|
42
|
-
fixtures
|
|
43
|
-
root,
|
|
44
|
-
files: fixtureSet.files
|
|
45
|
-
}),
|
|
46
|
-
captureInput: {
|
|
47
|
-
root,
|
|
48
|
-
output: template.output,
|
|
49
|
-
build: build.output
|
|
50
|
-
}
|
|
44
|
+
fixtures
|
|
51
45
|
};
|
|
52
46
|
}
|
|
53
47
|
const byPath = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0;
|
|
48
|
+
function sendableOf(gathered) {
|
|
49
|
+
const files = [...gathered.fixtures, ...[...gathered.built].map(([path, bytes]) => [builtTreePath(path), bytes])];
|
|
50
|
+
return new Map(files.sort(byPath));
|
|
51
|
+
}
|
|
54
52
|
async function assembleArtifact(options) {
|
|
55
53
|
const gathered = await gather(options);
|
|
56
54
|
if (!gathered.ok) return gathered;
|
|
57
55
|
const { report, manifest } = gathered;
|
|
58
|
-
const
|
|
59
|
-
const put = (path, bytes) => {
|
|
60
|
-
const prior = files.get(path);
|
|
61
|
-
if (prior !== void 0 && Buffer.compare(prior, bytes) !== 0) throw new Error(`Two different files would be written as ${path}. Content-addressed names cannot collide; rename one of the sources.`);
|
|
62
|
-
files.set(path, bytes);
|
|
63
|
-
};
|
|
64
|
-
for (const [path, bytes] of gathered.fixtures) put(fixturePath(path), bytes);
|
|
65
|
-
for (const [path, bytes] of await playgroundFiles()) put(path, bytes);
|
|
66
|
-
const captures = await captureFiles({
|
|
67
|
-
...gathered.captureInput,
|
|
68
|
-
...options.browser === void 0 ? {} : { browser: options.browser }
|
|
69
|
-
});
|
|
70
|
-
for (const [path, bytes] of captures) put(path, bytes);
|
|
71
|
-
const verdict = verifyArtifact(files);
|
|
56
|
+
const verdict = verifyBuild(gathered.built);
|
|
72
57
|
if (verdict.problems.length > 0) throw new Error(`publish: the artifact failed its own verification:\n${verdict.problems.map((p) => ` ${p.path}: ${p.message}`).join("\n")}`);
|
|
73
|
-
const unportable = unportablePaths(files.keys());
|
|
74
|
-
if (unportable.length > 0) throw new Error(`the artifact would not write the same files on Windows and macOS (${qualify("workspace/unportable-name")}):\n` + unportable.map((found) => ` ${found.paths.join(" and ")}: ${found.reason}`).join("\n") + "\nRename the source files these names come from.");
|
|
75
|
-
const sorted = [...files].sort(byPath);
|
|
76
|
-
for (const [path, bytes] of sorted) {
|
|
77
|
-
const target = join(options.out, ...path.split("/"));
|
|
78
|
-
await mkdir(dirname(target), { recursive: true });
|
|
79
|
-
await writeFile(target, bytes);
|
|
80
|
-
}
|
|
81
58
|
return {
|
|
82
59
|
ok: true,
|
|
83
60
|
report,
|
|
84
61
|
manifest,
|
|
85
|
-
|
|
62
|
+
sendable: sendableOf(gathered),
|
|
63
|
+
files: new Map([...gathered.built].sort(byPath))
|
|
86
64
|
};
|
|
87
65
|
}
|
|
88
66
|
|
|
@@ -7,7 +7,7 @@ import { readFile } from "node:fs/promises";
|
|
|
7
7
|
async function fixtureFiles(input) {
|
|
8
8
|
const out = /* @__PURE__ */ new Map();
|
|
9
9
|
for (const path of [...input.files].sort()) {
|
|
10
|
-
if (!isFixtureFilePath(path)) throw new Error(`The fixture file ${path} cannot
|
|
10
|
+
if (!isFixtureFilePath(path)) throw new Error(`The fixture file ${path} cannot be sent: a sent fixture file's path is segments of letters, digits, ".", "_" and "-". Rename it.`);
|
|
11
11
|
out.set(path, new Uint8Array(await readFile(join(input.root, ...path.split("/")))));
|
|
12
12
|
}
|
|
13
13
|
return out;
|