@diagonal-hq/cli 0.41.5 → 0.41.6
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 -2
- package/dist/check-data.json +1 -1
- package/dist/{cli-assets-cli-FMLE5XEF.mjs → cli-assets-cli-WEGERBBR.mjs} +8 -134
- package/dist/{cli-check-data-PIXADUF2.mjs → cli-check-data-7TKAM34J.mjs} +152 -2259
- package/dist/cli-chunk-25JQRNTW.mjs +24138 -0
- package/dist/{cli-chunk-U2ET6LQJ.mjs → cli-chunk-3SEADNVJ.mjs} +153 -1
- package/dist/{cli-chunk-TEV2VFGB.mjs → cli-chunk-77DCVFIZ.mjs} +7 -23955
- package/dist/{cli-chunk-4FQYK2WG.mjs → cli-chunk-ES45EAOO.mjs} +4 -1
- package/dist/{cli-skill-file-26B4RRZZ.mjs → cli-chunk-KZOQCV4Y.mjs} +7 -8
- package/dist/{cli-chunk-2YX3ABIW.mjs → cli-chunk-NEXRHJ3X.mjs} +1500 -44
- package/dist/{cli-chunk-XMVYLKEB.mjs → cli-chunk-TDGR3ENO.mjs} +278 -1
- package/dist/cli-chunk-XO3FRXQ4.mjs +3200 -0
- package/dist/{cli-chunk-GCF6XYTF.mjs → cli-chunk-XQQBHS6I.mjs} +18 -2
- package/dist/cli-skill-file-XEFKCU5Y.mjs +27 -0
- package/dist/{cli-workflows-YLHANSO2.mjs → cli-workflows-VFKTQW7H.mjs} +14 -18
- package/dist/cli.mjs +10361 -99
- package/dist/index.d.ts +18 -0
- package/dist/sdk-contract.d.ts +4 -1
- package/package.json +4 -4
- package/dist/cli-chunk-C3LVTOK3.mjs +0 -1054
- package/dist/cli-chunk-WPC3DBHX.mjs +0 -52
|
@@ -7,151 +7,25 @@ import {
|
|
|
7
7
|
errorText,
|
|
8
8
|
formatDiagnostic,
|
|
9
9
|
parseFlags,
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
readAssetEntries,
|
|
11
|
+
request,
|
|
12
|
+
writeAssetEntry
|
|
13
|
+
} from "./cli-chunk-TDGR3ENO.mjs";
|
|
12
14
|
import {
|
|
13
15
|
assetKeyMessage,
|
|
14
16
|
assetLibraryMessage,
|
|
15
|
-
buildAssets,
|
|
16
17
|
isAssetKey
|
|
17
|
-
} from "./cli-chunk-
|
|
18
|
+
} from "./cli-chunk-XQQBHS6I.mjs";
|
|
18
19
|
import {
|
|
19
20
|
SourceError,
|
|
20
|
-
|
|
21
|
-
diagnosticFromError
|
|
22
|
-
|
|
23
|
-
parseSource,
|
|
24
|
-
staticObject,
|
|
25
|
-
traverse
|
|
26
|
-
} from "./cli-chunk-2YX3ABIW.mjs";
|
|
27
|
-
import {
|
|
28
|
-
diagnostic
|
|
29
|
-
} from "./cli-chunk-C3LVTOK3.mjs";
|
|
21
|
+
diagnostic,
|
|
22
|
+
diagnosticFromError
|
|
23
|
+
} from "./cli-chunk-NEXRHJ3X.mjs";
|
|
30
24
|
import "./cli-chunk-LRS5IEI3.mjs";
|
|
31
25
|
|
|
32
26
|
// scripts/lib/runtime-build/assets-cli.mjs
|
|
33
27
|
import { readFileSync, statSync, writeFileSync } from "node:fs";
|
|
34
28
|
import { basename, join, resolve } from "node:path";
|
|
35
|
-
|
|
36
|
-
// scripts/lib/runtime-build/assets-file.mjs
|
|
37
|
-
var traverse2 = traverse.default ?? traverse;
|
|
38
|
-
function readAssetEntries(source) {
|
|
39
|
-
return source === null ? [] : buildAssets(parseSource(source, { jsx: false }), null);
|
|
40
|
-
}
|
|
41
|
-
function applyEdits(source, edits) {
|
|
42
|
-
for (const { start, end = start, text } of edits.sort((a, b) => b.start - a.start)) {
|
|
43
|
-
source = source.slice(0, start) + text + source.slice(end);
|
|
44
|
-
}
|
|
45
|
-
return source;
|
|
46
|
-
}
|
|
47
|
-
function addAssetImport(ast, source, edits) {
|
|
48
|
-
const imports = ast.program.body.filter(
|
|
49
|
-
(node) => node.type === "ImportDeclaration" && node.source.value === "@diagonal-hq/cli"
|
|
50
|
-
);
|
|
51
|
-
const hasAsset = imports.some(
|
|
52
|
-
(node) => node.importKind !== "type" && node.specifiers.some(
|
|
53
|
-
(specifier) => specifier.type === "ImportSpecifier" && specifier.importKind !== "type" && specifier.imported.name === "asset" && specifier.local.name === "asset"
|
|
54
|
-
)
|
|
55
|
-
);
|
|
56
|
-
if (hasAsset) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const namedImport = imports.find(
|
|
60
|
-
(node) => node.importKind !== "type" && node.specifiers.some((specifier) => specifier.type === "ImportSpecifier")
|
|
61
|
-
);
|
|
62
|
-
if (namedImport) {
|
|
63
|
-
const brace = source.indexOf("{", namedImport.start);
|
|
64
|
-
edits.push({ start: brace + 1, text: " asset," });
|
|
65
|
-
} else {
|
|
66
|
-
edits.push({
|
|
67
|
-
start: ast.program.interpreter?.end ?? 0,
|
|
68
|
-
text: "\nimport { asset } from '@diagonal-hq/cli';\n"
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
function writeAssetEntry(source, key, reference) {
|
|
73
|
-
if (!isAssetKey(key)) {
|
|
74
|
-
throw new SourceError(assetKeyMessage(key));
|
|
75
|
-
}
|
|
76
|
-
const entries = readAssetEntries(source);
|
|
77
|
-
let output;
|
|
78
|
-
if (source === null) {
|
|
79
|
-
output = `import { defineAssets, asset } from '@diagonal-hq/cli';
|
|
80
|
-
|
|
81
|
-
export default defineAssets({
|
|
82
|
-
${key}: asset.version('${reference}')
|
|
83
|
-
});
|
|
84
|
-
`;
|
|
85
|
-
} else {
|
|
86
|
-
const ast = parseSource(source, { jsx: false });
|
|
87
|
-
const { declaration } = defaultExportOf(ast);
|
|
88
|
-
const [argument] = expectDefineCall(declaration, "defineAssets", 1);
|
|
89
|
-
const definition = ["TSAsExpression", "TSSatisfiesExpression"].includes(argument.type) ? argument.expression : argument;
|
|
90
|
-
const { value } = staticObject(definition, { assetVersions: true });
|
|
91
|
-
const edits = [];
|
|
92
|
-
const existing = entries.find((entry) => entry.key === key);
|
|
93
|
-
if (existing) {
|
|
94
|
-
const node = value[key].node;
|
|
95
|
-
const quote = source[node.start];
|
|
96
|
-
edits.push({ start: node.start, end: node.end, text: `${quote}${reference}${quote}` });
|
|
97
|
-
} else {
|
|
98
|
-
const last = definition.properties.at(-1);
|
|
99
|
-
const property = `${key}: asset.version('${reference}')`;
|
|
100
|
-
const newline = source.includes("\r\n") ? "\r\n" : "\n";
|
|
101
|
-
if (!last) {
|
|
102
|
-
edits.push({ start: definition.start + 1, text: `${newline} ${property}${newline}` });
|
|
103
|
-
} else {
|
|
104
|
-
let between = source.slice(last.end, definition.end - 1);
|
|
105
|
-
for (const comment of ast.comments) {
|
|
106
|
-
if (comment.start >= last.end && comment.end < definition.end) {
|
|
107
|
-
const start = comment.start - last.end;
|
|
108
|
-
between = between.slice(0, start) + " ".repeat(comment.end - comment.start) + between.slice(comment.end - last.end);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
const comma = between.indexOf(",");
|
|
112
|
-
const trailingComma = comma !== -1;
|
|
113
|
-
let lineEnd = source.indexOf("\n", last.end);
|
|
114
|
-
for (const comment of ast.comments) {
|
|
115
|
-
if (comment.start >= last.end && comment.start < lineEnd && comment.end > lineEnd) {
|
|
116
|
-
lineEnd = source.indexOf("\n", comment.end);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
const multiline = last.loc.end.line < definition.loc.end.line;
|
|
120
|
-
if (multiline) {
|
|
121
|
-
const lineStart = source.lastIndexOf("\n", last.start - 1) + 1;
|
|
122
|
-
const indent = source.slice(lineStart, last.start).match(/^[\t ]*/)[0];
|
|
123
|
-
if (!trailingComma) {
|
|
124
|
-
edits.push({ start: last.end, text: "," });
|
|
125
|
-
}
|
|
126
|
-
const insertBeforeBrace = lineEnd === -1 || lineEnd >= definition.end;
|
|
127
|
-
edits.push({
|
|
128
|
-
start: insertBeforeBrace ? definition.end - 1 : lineEnd + 1,
|
|
129
|
-
text: `${insertBeforeBrace ? newline : ""}${indent}${property}${trailingComma ? "," : ""}${newline}`
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
edits.push({
|
|
133
|
-
start: trailingComma ? last.end + comma + 1 : last.end,
|
|
134
|
-
text: `${trailingComma ? "" : ","} ${property}${trailingComma ? "," : ""}`
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
addAssetImport(ast, source, edits);
|
|
140
|
-
output = applyEdits(source, edits);
|
|
141
|
-
}
|
|
142
|
-
const result = readAssetEntries(output);
|
|
143
|
-
const expected = new Map(entries.map((entry) => [entry.key, entry.reference]));
|
|
144
|
-
expected.set(key, reference);
|
|
145
|
-
if (result.length !== expected.size || result.some((entry) => expected.get(entry.key) !== entry.reference)) {
|
|
146
|
-
throw new SourceError("The assets.ts edit did not preserve the asset entries.");
|
|
147
|
-
}
|
|
148
|
-
return output;
|
|
149
|
-
}
|
|
150
|
-
var REFERENCE_MEMBERS = Object.freeze({ url: ".url", asset: "", key: ".key" });
|
|
151
|
-
var CSS_FORM = "css";
|
|
152
|
-
var ASSET_REFERENCE_FORMS = Object.freeze([...Object.keys(REFERENCE_MEMBERS), CSS_FORM]);
|
|
153
|
-
|
|
154
|
-
// scripts/lib/runtime-build/assets-cli.mjs
|
|
155
29
|
var NIL_REFERENCE = "00000000-0000-0000-0000-000000000000";
|
|
156
30
|
var MISSING_VERSION = "This version is not in the Application Asset library.";
|
|
157
31
|
function readManifest(path) {
|