@diagonal-hq/cli 0.38.2 → 0.38.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.
- package/README.md +21 -5
- package/dist/check-data.json +1 -0
- package/dist/cli-assets-cli-VQBXYEIZ.mjs +386 -0
- package/dist/cli-check-data-GHZW7MSI.mjs +17893 -0
- package/dist/cli-chunk-A7Q2M4ZU.mjs +1052 -0
- package/dist/cli-chunk-F2J44UIS.mjs +39865 -0
- package/dist/cli-chunk-HWHRAOWD.mjs +24035 -0
- package/dist/cli-chunk-LRS5IEI3.mjs +48 -0
- package/dist/cli-chunk-T6442V5V.mjs +7463 -0
- package/dist/cli-chunk-U2ET6LQJ.mjs +277 -0
- package/dist/cli-chunk-WPC3DBHX.mjs +52 -0
- package/dist/cli-chunk-XMVYLKEB.mjs +359 -0
- package/dist/cli-chunk-YIPLFIKL.mjs +63 -0
- package/dist/cli-files.generated-WAU3U62D.mjs +61 -0
- package/dist/cli-sdk-files.generated-HAH7DJPZ.mjs +1429 -0
- package/dist/cli-skill-file-TEJUXCJB.mjs +262 -0
- package/dist/cli-workflows-CK5ZVNYR.mjs +462 -0
- package/dist/cli.mjs +545 -99388
- package/dist/script-sdk.json +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createRequire as __diagonalCreateRequire } from 'node:module';
|
|
2
|
+
const require = __diagonalCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
AssetVersionValue,
|
|
5
|
+
SourceError,
|
|
6
|
+
defaultExportOf,
|
|
7
|
+
expectDefineCall,
|
|
8
|
+
staticObject
|
|
9
|
+
} from "./cli-chunk-F2J44UIS.mjs";
|
|
10
|
+
|
|
11
|
+
// scripts/lib/runtime-build/assets.mjs
|
|
12
|
+
var ASSET_KEY = /^[a-z][A-Za-z0-9]*$/;
|
|
13
|
+
var MAX_ASSET_VERSIONS = 500;
|
|
14
|
+
var VERSION_REFERENCE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
15
|
+
function isAssetKey(key) {
|
|
16
|
+
return key.length <= 64 && ASSET_KEY.test(key);
|
|
17
|
+
}
|
|
18
|
+
function assetKeyMessage(key) {
|
|
19
|
+
return `Asset key "${key}" must be a camelCase name of at most 64 letters and digits that starts with a lowercase letter, such as 'hero'`;
|
|
20
|
+
}
|
|
21
|
+
function assetLibraryMessage(reference) {
|
|
22
|
+
return `Asset version "${reference}" is not in this application's asset library`;
|
|
23
|
+
}
|
|
24
|
+
function buildAssets(ast, catalog) {
|
|
25
|
+
const { declaration } = defaultExportOf(ast);
|
|
26
|
+
const [definition] = expectDefineCall(declaration, "defineAssets", 1);
|
|
27
|
+
const { value, nodes } = staticObject(definition, { assetVersions: true });
|
|
28
|
+
if (Object.keys(value).length > MAX_ASSET_VERSIONS) {
|
|
29
|
+
throw new SourceError("assets.ts can have at most 500 entries.", declaration);
|
|
30
|
+
}
|
|
31
|
+
return Object.entries(value).map(([key, version]) => {
|
|
32
|
+
if (!isAssetKey(key)) {
|
|
33
|
+
throw new SourceError(assetKeyMessage(key), nodes[key].key);
|
|
34
|
+
}
|
|
35
|
+
if (!(version instanceof AssetVersionValue)) {
|
|
36
|
+
throw new SourceError(
|
|
37
|
+
"An asset value must be asset.version('<reference>')",
|
|
38
|
+
nodes[key].value
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (!VERSION_REFERENCE.test(version.reference)) {
|
|
42
|
+
throw new SourceError("An asset version reference must be a lower-case UUID", version.node);
|
|
43
|
+
}
|
|
44
|
+
if (catalog !== null && !Object.hasOwn(catalog, version.reference)) {
|
|
45
|
+
throw new SourceError(assetLibraryMessage(version.reference), version.node);
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
key,
|
|
49
|
+
reference: version.reference,
|
|
50
|
+
line: version.node.loc.start.line,
|
|
51
|
+
column: version.node.loc.start.column + 1
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var GENERATED_ASSETS_PATH = "generated/assets.ts";
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
isAssetKey,
|
|
59
|
+
assetKeyMessage,
|
|
60
|
+
assetLibraryMessage,
|
|
61
|
+
buildAssets,
|
|
62
|
+
GENERATED_ASSETS_PATH
|
|
63
|
+
};
|