@uniformdev/cli 18.19.0 → 18.20.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/cli.js +4 -1
- package/dist/index.mjs +528 -147
- package/package.json +7 -6
- package/dist/chunk-6QA6UNAY.mjs +0 -2047
- package/dist/index.d.ts +0 -9
- package/dist/index.js +0 -6476
- package/dist/sync/index.d.ts +0 -118
- package/dist/sync/index.js +0 -2035
- package/dist/sync/index.mjs +0 -36
package/dist/index.mjs
CHANGED
|
@@ -1,31 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
2
|
+
var __accessCheck = (obj, member, msg) => {
|
|
3
|
+
if (!member.has(obj))
|
|
4
|
+
throw TypeError("Cannot " + msg);
|
|
5
|
+
};
|
|
6
|
+
var __privateGet = (obj, member, getter) => {
|
|
7
|
+
__accessCheck(obj, member, "read from private field");
|
|
8
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
9
|
+
};
|
|
10
|
+
var __privateAdd = (obj, member, value) => {
|
|
11
|
+
if (member.has(obj))
|
|
12
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
13
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
14
|
+
};
|
|
15
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
16
|
+
__accessCheck(obj, member, "write to private field");
|
|
17
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
18
|
+
return value;
|
|
19
|
+
};
|
|
20
|
+
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
21
|
+
set _(value) {
|
|
22
|
+
__privateSet(obj, member, value, setter);
|
|
23
|
+
},
|
|
24
|
+
get _() {
|
|
25
|
+
return __privateGet(obj, member, getter);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
26
28
|
|
|
27
29
|
// src/index.ts
|
|
30
|
+
import * as dotenv from "dotenv";
|
|
28
31
|
import yargs17 from "yargs";
|
|
32
|
+
import { hideBin } from "yargs/helpers";
|
|
29
33
|
|
|
30
34
|
// src/commands/canvas/index.ts
|
|
31
35
|
import yargs4 from "yargs";
|
|
@@ -35,6 +39,408 @@ import yargs from "yargs";
|
|
|
35
39
|
|
|
36
40
|
// src/commands/canvas/commands/component/get.ts
|
|
37
41
|
import { UncachedCanvasClient } from "@uniformdev/canvas";
|
|
42
|
+
|
|
43
|
+
// src/sync/arraySyncEngineDataSource.ts
|
|
44
|
+
async function createArraySyncEngineDataSource({
|
|
45
|
+
objects,
|
|
46
|
+
selectIdentifier: selectIdentifier11,
|
|
47
|
+
selectDisplayName: selectDisplayName11 = selectIdentifier11,
|
|
48
|
+
onSyncComplete
|
|
49
|
+
}) {
|
|
50
|
+
const objectIndex = objects.reduce((result, current) => {
|
|
51
|
+
const identifier = selectIdentifier11(current);
|
|
52
|
+
if (result[identifier]) {
|
|
53
|
+
throw new Error(`Identifier ${identifier} was not unique.`);
|
|
54
|
+
}
|
|
55
|
+
result[identifier] = {
|
|
56
|
+
id: identifier,
|
|
57
|
+
object: current,
|
|
58
|
+
providerId: identifier,
|
|
59
|
+
displayName: selectDisplayName11(current)
|
|
60
|
+
};
|
|
61
|
+
return result;
|
|
62
|
+
}, {});
|
|
63
|
+
async function* getObjects() {
|
|
64
|
+
for (const item of Object.values(objectIndex)) {
|
|
65
|
+
yield item;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function extractCurrent() {
|
|
69
|
+
return Object.entries(objectIndex).sort((a, b) => a[0].localeCompare(b[0])).map((entry) => entry[1].object);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
objects: getObjects(),
|
|
73
|
+
deleteObject: async (providerId) => {
|
|
74
|
+
delete objectIndex[providerId];
|
|
75
|
+
},
|
|
76
|
+
writeObject: async (objectToWrite) => {
|
|
77
|
+
const id = selectIdentifier11(objectToWrite.object);
|
|
78
|
+
objectIndex[id] = objectToWrite;
|
|
79
|
+
},
|
|
80
|
+
extractCurrent,
|
|
81
|
+
onSyncComplete: onSyncComplete ? (isTarget) => onSyncComplete(isTarget, extractCurrent()) : void 0
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// src/sync/fileSyncEngineDataSource.ts
|
|
86
|
+
import chalk from "chalk";
|
|
87
|
+
import { existsSync, mkdirSync } from "fs";
|
|
88
|
+
import { readdir, unlink } from "fs/promises";
|
|
89
|
+
import { extname as extname2, join } from "path";
|
|
90
|
+
|
|
91
|
+
// src/sync/util.ts
|
|
92
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
93
|
+
import httpsProxyAgent from "https-proxy-agent";
|
|
94
|
+
import unfetch from "isomorphic-unfetch";
|
|
95
|
+
import { dump, load } from "js-yaml";
|
|
96
|
+
import { extname } from "path";
|
|
97
|
+
function withApiOptions(yargs18) {
|
|
98
|
+
return yargs18.option("apiKey", {
|
|
99
|
+
describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
|
|
100
|
+
default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
|
|
101
|
+
process.env.CANVAS_CLI_API_KEY ?? // deprecated
|
|
102
|
+
process.env.UPM_CLI_API_KEY ?? process.env.UNIFORM_API_KEY,
|
|
103
|
+
demandOption: true,
|
|
104
|
+
type: "string"
|
|
105
|
+
}).option("apiHost", {
|
|
106
|
+
describe: "Uniform host. Defaults to UNIFORM_CLI_BASE_URL env var or https://uniform.app. Supports dotenv.",
|
|
107
|
+
default: process.env.UNIFORM_CLI_BASE_URL || "https://uniform.app",
|
|
108
|
+
demandOption: true,
|
|
109
|
+
type: "string"
|
|
110
|
+
}).option("edgeApiHost", {
|
|
111
|
+
describe: "Uniform edge host. Defaults to UNIFORM_CLI_BASE_EDGE_URL env var or https://uniform.global. Supports dotenv.",
|
|
112
|
+
default: process.env.UNIFORM_CLI_BASE_EDGE_URL || "https://uniform.global",
|
|
113
|
+
demandOption: true,
|
|
114
|
+
type: "string"
|
|
115
|
+
}).option("proxy", {
|
|
116
|
+
describe: "HTTPS proxy to use for Uniform API calls. Defaults to HTTPS_PROXY, https_proxy, ALL_PROXY, or all_proxy env vars (in that order). Supports dotenv.",
|
|
117
|
+
default: process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy,
|
|
118
|
+
type: "string"
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function nodeFetchProxy(proxy) {
|
|
122
|
+
if (proxy) {
|
|
123
|
+
console.log(`\u{1F991} Using proxy ${proxy}`);
|
|
124
|
+
}
|
|
125
|
+
const wrappedFetch = (input, init) => {
|
|
126
|
+
if (proxy) {
|
|
127
|
+
const wrappedInit = {
|
|
128
|
+
...init,
|
|
129
|
+
agent: new httpsProxyAgent.HttpsProxyAgent(proxy)
|
|
130
|
+
};
|
|
131
|
+
return unfetch(input, wrappedInit);
|
|
132
|
+
}
|
|
133
|
+
return unfetch(input, init);
|
|
134
|
+
};
|
|
135
|
+
return wrappedFetch;
|
|
136
|
+
}
|
|
137
|
+
function withProjectOptions(yargs18) {
|
|
138
|
+
return yargs18.option("project", {
|
|
139
|
+
describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
|
|
140
|
+
default: process.env.UNIFORM_CLI_PROJECT_ID ?? // deprecated
|
|
141
|
+
process.env.CANVAS_CLI_PROJECT_ID ?? // deprecated
|
|
142
|
+
process.env.UPM_CLI_PROJECT_ID ?? process.env.UNIFORM_PROJECT_ID,
|
|
143
|
+
demandOption: true,
|
|
144
|
+
type: "string",
|
|
145
|
+
alias: ["p"]
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function withFormatOptions(yargs18) {
|
|
149
|
+
return yargs18.option("format", {
|
|
150
|
+
alias: ["f"],
|
|
151
|
+
describe: "Output format",
|
|
152
|
+
default: "yaml",
|
|
153
|
+
choices: ["yaml", "json"],
|
|
154
|
+
type: "string"
|
|
155
|
+
}).option("filename", {
|
|
156
|
+
alias: ["o"],
|
|
157
|
+
describe: "Output filename. If not specified, write to stdout.",
|
|
158
|
+
type: "string"
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function withDiffOptions(yargs18) {
|
|
162
|
+
return yargs18.option("diff", {
|
|
163
|
+
describe: "Whether to show diffs in stdout. off = no diffs; update = on for updates; on = updates, creates, deletes. Can be set by UNIFORM_CLI_DIFF_MODE environment variable.",
|
|
164
|
+
default: process.env.UNIFORM_CLI_DIFF_MODE ?? "off",
|
|
165
|
+
type: "string",
|
|
166
|
+
choices: ["off", "update", "on"],
|
|
167
|
+
alias: ["d"]
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
function isPathAPackageFile(path4) {
|
|
171
|
+
const extension = extname(path4);
|
|
172
|
+
return extension === ".yaml" || extension === ".yml" || extension === ".json";
|
|
173
|
+
}
|
|
174
|
+
function emitWithFormat(object, format, filename) {
|
|
175
|
+
let content;
|
|
176
|
+
if (filename && !format) {
|
|
177
|
+
const extension = extname(filename);
|
|
178
|
+
if (extension === ".yaml" || extension === ".yml") {
|
|
179
|
+
format = "yaml";
|
|
180
|
+
} else if (extension === ".json") {
|
|
181
|
+
format = "json";
|
|
182
|
+
}
|
|
183
|
+
} else if (!format) {
|
|
184
|
+
throw new Error("Format must be specified when no filename is passed");
|
|
185
|
+
}
|
|
186
|
+
switch (format) {
|
|
187
|
+
case "json":
|
|
188
|
+
content = JSON.stringify(object, null, 2);
|
|
189
|
+
break;
|
|
190
|
+
case "yaml":
|
|
191
|
+
content = dump(object);
|
|
192
|
+
break;
|
|
193
|
+
default:
|
|
194
|
+
throw new Error(`Unsupported format: ${format}`);
|
|
195
|
+
}
|
|
196
|
+
if (filename) {
|
|
197
|
+
writeFileSync(filename, content, "utf8");
|
|
198
|
+
} else {
|
|
199
|
+
console.log(content);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function readFileToObject(filename) {
|
|
203
|
+
const file = readFileSync(filename, "utf8");
|
|
204
|
+
return load(file, { filename, json: true });
|
|
205
|
+
}
|
|
206
|
+
async function* paginateAsync(fetchPage, options) {
|
|
207
|
+
const perPage = options.pageSize || 100;
|
|
208
|
+
let offset = 0;
|
|
209
|
+
let pageData = [];
|
|
210
|
+
do {
|
|
211
|
+
pageData = await fetchPage(offset, perPage);
|
|
212
|
+
for (const item of pageData) {
|
|
213
|
+
yield item;
|
|
214
|
+
}
|
|
215
|
+
offset += perPage;
|
|
216
|
+
} while (pageData.length === perPage);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// src/sync/fileSyncEngineDataSource.ts
|
|
220
|
+
async function createFileSyncEngineDataSource({
|
|
221
|
+
directory,
|
|
222
|
+
format = "yaml",
|
|
223
|
+
selectIdentifier: selectIdentifier11,
|
|
224
|
+
selectDisplayName: selectDisplayName11 = selectIdentifier11,
|
|
225
|
+
selectFilename: selectFilename2
|
|
226
|
+
}) {
|
|
227
|
+
const dirExists = existsSync(directory);
|
|
228
|
+
if (!dirExists) {
|
|
229
|
+
mkdirSync(directory, { recursive: true });
|
|
230
|
+
}
|
|
231
|
+
const rawFilenames = await readdir(directory, "utf-8");
|
|
232
|
+
const filenames = new Set(
|
|
233
|
+
rawFilenames.filter((filename) => {
|
|
234
|
+
const ext = extname2(filename);
|
|
235
|
+
return ext === `.json` || ext === `.yaml` || ext === `.yml`;
|
|
236
|
+
})
|
|
237
|
+
);
|
|
238
|
+
const getFullFilename = (id) => join(directory, `${id}.${format}`);
|
|
239
|
+
async function* getObjects() {
|
|
240
|
+
for (const filename of filenames) {
|
|
241
|
+
const fullFilename = join(directory, filename);
|
|
242
|
+
try {
|
|
243
|
+
const contents = await readFileToObject(fullFilename);
|
|
244
|
+
const object = {
|
|
245
|
+
id: selectIdentifier11(contents),
|
|
246
|
+
displayName: selectDisplayName11(contents),
|
|
247
|
+
providerId: fullFilename,
|
|
248
|
+
object: contents
|
|
249
|
+
};
|
|
250
|
+
yield object;
|
|
251
|
+
} catch (e) {
|
|
252
|
+
console.error(chalk.red(`Failed to read ${fullFilename}, data is likely invalid.
|
|
253
|
+
${e == null ? void 0 : e.message}`));
|
|
254
|
+
throw e;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
objects: getObjects(),
|
|
260
|
+
deleteObject: async (providerId) => {
|
|
261
|
+
await unlink(providerId);
|
|
262
|
+
},
|
|
263
|
+
writeObject: async (object) => {
|
|
264
|
+
if (selectFilename2) {
|
|
265
|
+
emitWithFormat(object.object, format, join(directory, `${selectFilename2(object.object)}.${format}`));
|
|
266
|
+
} else {
|
|
267
|
+
emitWithFormat(object.object, format, getFullFilename(object.id));
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/sync/package.ts
|
|
274
|
+
import fs from "fs";
|
|
275
|
+
function readUniformPackage(filename, assertExists) {
|
|
276
|
+
if (!assertExists && !fs.existsSync(filename)) {
|
|
277
|
+
return {};
|
|
278
|
+
}
|
|
279
|
+
const packageContents = readFileToObject(filename);
|
|
280
|
+
if (typeof packageContents !== "object") {
|
|
281
|
+
throw new Error(`Package ${filename} does not appear valid.`);
|
|
282
|
+
}
|
|
283
|
+
return packageContents;
|
|
284
|
+
}
|
|
285
|
+
function writeUniformPackage(filename, packageContents) {
|
|
286
|
+
emitWithFormat(packageContents, void 0, filename);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// src/sync/syncEngine.ts
|
|
290
|
+
import { diffJson, diffLines } from "diff";
|
|
291
|
+
import isEqualWith from "lodash.isequalwith";
|
|
292
|
+
async function syncEngine({
|
|
293
|
+
source,
|
|
294
|
+
target,
|
|
295
|
+
compareContents = (source2, target2) => {
|
|
296
|
+
return isEqualWith(
|
|
297
|
+
source2.object,
|
|
298
|
+
target2.object,
|
|
299
|
+
(_a, _b, key) => key === "created" || key === "modified" ? true : void 0
|
|
300
|
+
);
|
|
301
|
+
},
|
|
302
|
+
mode,
|
|
303
|
+
allowEmptySource = false,
|
|
304
|
+
whatIf = false,
|
|
305
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
306
|
+
log = () => {
|
|
307
|
+
}
|
|
308
|
+
}) {
|
|
309
|
+
var _a, _b;
|
|
310
|
+
const targetItems = /* @__PURE__ */ new Map();
|
|
311
|
+
for await (const obj of target.objects) {
|
|
312
|
+
targetItems.set(obj.id, obj);
|
|
313
|
+
}
|
|
314
|
+
const actions = [];
|
|
315
|
+
let sourceHasItems = false;
|
|
316
|
+
for await (const sourceObject of source.objects) {
|
|
317
|
+
sourceHasItems = true;
|
|
318
|
+
const id = sourceObject.id;
|
|
319
|
+
const targetObject = targetItems.get(id);
|
|
320
|
+
if (targetObject) {
|
|
321
|
+
if (!compareContents(sourceObject, targetObject)) {
|
|
322
|
+
if (mode === "createOrUpdate" || mode === "mirror") {
|
|
323
|
+
const process2 = async (sourceObject2, targetObject2) => {
|
|
324
|
+
if (!whatIf) {
|
|
325
|
+
try {
|
|
326
|
+
await target.writeObject(sourceObject2, targetObject2);
|
|
327
|
+
} catch (e) {
|
|
328
|
+
throw new SyncEngineError(e, sourceObject2);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
log({
|
|
332
|
+
action: "update",
|
|
333
|
+
id,
|
|
334
|
+
providerId: sourceObject2.providerId,
|
|
335
|
+
displayName: sourceObject2.displayName ?? sourceObject2.providerId,
|
|
336
|
+
whatIf,
|
|
337
|
+
diff: diffJson(targetObject2.object, sourceObject2.object)
|
|
338
|
+
});
|
|
339
|
+
};
|
|
340
|
+
actions.push(process2(sourceObject, targetObject));
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
targetItems.delete(id);
|
|
344
|
+
} else {
|
|
345
|
+
const process2 = async (sourceObject2, id2) => {
|
|
346
|
+
if (!whatIf) {
|
|
347
|
+
try {
|
|
348
|
+
await target.writeObject(sourceObject2);
|
|
349
|
+
} catch (e) {
|
|
350
|
+
throw new SyncEngineError(e, sourceObject2);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
log({
|
|
354
|
+
action: "create",
|
|
355
|
+
id: id2,
|
|
356
|
+
providerId: id2,
|
|
357
|
+
displayName: sourceObject2.displayName ?? sourceObject2.providerId,
|
|
358
|
+
whatIf,
|
|
359
|
+
diff: diffLines("", JSON.stringify(sourceObject2.object, null, 2))
|
|
360
|
+
});
|
|
361
|
+
};
|
|
362
|
+
actions.push(process2(sourceObject, id));
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
await Promise.all(actions);
|
|
366
|
+
if (mode === "mirror") {
|
|
367
|
+
if (!sourceHasItems && !allowEmptySource) {
|
|
368
|
+
throw new Error(
|
|
369
|
+
"Source is empty and mode is mirror. This would cause deletion of everything in the target, and most likely indicates an error in source definition."
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
const deletes = [];
|
|
373
|
+
targetItems.forEach(async (object) => {
|
|
374
|
+
const process2 = async (object2) => {
|
|
375
|
+
if (!whatIf) {
|
|
376
|
+
try {
|
|
377
|
+
await target.deleteObject(object2.providerId, object2);
|
|
378
|
+
} catch (e) {
|
|
379
|
+
throw new SyncEngineError(e, object2);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
log({
|
|
383
|
+
action: "delete",
|
|
384
|
+
id: object2.id,
|
|
385
|
+
providerId: object2.providerId,
|
|
386
|
+
displayName: object2.displayName ?? object2.providerId,
|
|
387
|
+
whatIf,
|
|
388
|
+
diff: diffLines(JSON.stringify(object2.object, null, 2), "")
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
deletes.push(process2(object));
|
|
392
|
+
});
|
|
393
|
+
await Promise.all(deletes);
|
|
394
|
+
}
|
|
395
|
+
await Promise.all([(_a = source.onSyncComplete) == null ? void 0 : _a.call(source, false), (_b = target.onSyncComplete) == null ? void 0 : _b.call(target, true)]);
|
|
396
|
+
}
|
|
397
|
+
var SyncEngineError = class extends Error {
|
|
398
|
+
constructor(innerError, sourceObject) {
|
|
399
|
+
super(
|
|
400
|
+
`Error syncing ${sourceObject.displayName ?? sourceObject.providerId} (${sourceObject.providerId})
|
|
401
|
+
${innerError}`
|
|
402
|
+
);
|
|
403
|
+
this.stack = void 0;
|
|
404
|
+
Object.setPrototypeOf(this, SyncEngineError.prototype);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
// src/sync/syncEngineConsoleLogger.ts
|
|
409
|
+
import chalk2 from "chalk";
|
|
410
|
+
function createSyncEngineConsoleLogger(options) {
|
|
411
|
+
const { diffMode = "off", indent, prefix } = options ?? {};
|
|
412
|
+
return function syncEngineConsoleLogger({ action, displayName, whatIf, diff }) {
|
|
413
|
+
let actionTag = "";
|
|
414
|
+
switch (action) {
|
|
415
|
+
case "create":
|
|
416
|
+
actionTag = chalk2.green("[A]");
|
|
417
|
+
break;
|
|
418
|
+
case "update":
|
|
419
|
+
actionTag = chalk2.white("[U]");
|
|
420
|
+
break;
|
|
421
|
+
case "delete":
|
|
422
|
+
actionTag = chalk2.yellow("[D]");
|
|
423
|
+
break;
|
|
424
|
+
}
|
|
425
|
+
let diffString = "";
|
|
426
|
+
if (diffMode === "on" || diffMode === "update" && action === "update") {
|
|
427
|
+
diffString = "\n" + diff.map((change) => {
|
|
428
|
+
if (change.added) {
|
|
429
|
+
return chalk2.green(change.value);
|
|
430
|
+
}
|
|
431
|
+
if (change.removed) {
|
|
432
|
+
return chalk2.red(change.value);
|
|
433
|
+
}
|
|
434
|
+
return change.value;
|
|
435
|
+
}).join("");
|
|
436
|
+
}
|
|
437
|
+
console.log(
|
|
438
|
+
`${indent ?? ""}${whatIf ? chalk2.gray("[WHATIF]") : ""}${actionTag}${prefix ?? ""} ${displayName}${diffString}`
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// src/commands/canvas/commands/component/get.ts
|
|
38
444
|
var ComponentGetModule = {
|
|
39
445
|
command: "get <id>",
|
|
40
446
|
describe: "Fetch a component definition",
|
|
@@ -313,7 +719,6 @@ var ComponentPullModule = {
|
|
|
313
719
|
project: projectId,
|
|
314
720
|
diff: diffMode
|
|
315
721
|
}) => {
|
|
316
|
-
var _a;
|
|
317
722
|
const fetch3 = nodeFetchProxy(proxy);
|
|
318
723
|
const client = new UncachedCanvasClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
|
|
319
724
|
const source = createComponentDefinitionEngineDataSource({ client });
|
|
@@ -322,7 +727,7 @@ var ComponentPullModule = {
|
|
|
322
727
|
if (isPackage) {
|
|
323
728
|
const packageContents = readCanvasPackage(directory, false);
|
|
324
729
|
target = await createArraySyncEngineDataSource({
|
|
325
|
-
objects:
|
|
730
|
+
objects: packageContents.components ?? [],
|
|
326
731
|
selectIdentifier,
|
|
327
732
|
selectDisplayName,
|
|
328
733
|
onSyncComplete: async (_, synced) => {
|
|
@@ -384,7 +789,6 @@ var ComponentPushModule = {
|
|
|
384
789
|
project: projectId,
|
|
385
790
|
diff: diffMode
|
|
386
791
|
}) => {
|
|
387
|
-
var _a;
|
|
388
792
|
const fetch3 = nodeFetchProxy(proxy);
|
|
389
793
|
const client = new UncachedCanvasClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
|
|
390
794
|
let source;
|
|
@@ -392,7 +796,7 @@ var ComponentPushModule = {
|
|
|
392
796
|
if (isPackage) {
|
|
393
797
|
const packageContents = readCanvasPackage(directory, true);
|
|
394
798
|
source = await createArraySyncEngineDataSource({
|
|
395
|
-
objects:
|
|
799
|
+
objects: packageContents.components ?? [],
|
|
396
800
|
selectIdentifier,
|
|
397
801
|
selectDisplayName
|
|
398
802
|
});
|
|
@@ -596,10 +1000,7 @@ import { UncachedCanvasClient as UncachedCanvasClient9 } from "@uniformdev/canva
|
|
|
596
1000
|
|
|
597
1001
|
// src/commands/canvas/commands/composition/_util.ts
|
|
598
1002
|
var selectIdentifier2 = (component) => component.composition._id;
|
|
599
|
-
var selectDisplayName2 = (component) => {
|
|
600
|
-
var _a, _b;
|
|
601
|
-
return `${(_b = (_a = component.composition._name) != null ? _a : component.composition._slug) != null ? _b : component.composition._id} (pid: ${component.composition._id})`;
|
|
602
|
-
};
|
|
1003
|
+
var selectDisplayName2 = (component) => `${component.composition._name ?? component.composition._slug ?? component.composition._id} (pid: ${component.composition._id})`;
|
|
603
1004
|
|
|
604
1005
|
// src/commands/canvas/componentInstanceEngineDataSource.ts
|
|
605
1006
|
function createComponentInstanceEngineDataSource({
|
|
@@ -750,7 +1151,6 @@ var CompositionPullModule = {
|
|
|
750
1151
|
project: projectId,
|
|
751
1152
|
diff: diffMode
|
|
752
1153
|
}) => {
|
|
753
|
-
var _a;
|
|
754
1154
|
const fetch3 = nodeFetchProxy(proxy);
|
|
755
1155
|
const client = new UncachedCanvasClient10({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
|
|
756
1156
|
const source = createComponentInstanceEngineDataSource({ client, state });
|
|
@@ -759,7 +1159,7 @@ var CompositionPullModule = {
|
|
|
759
1159
|
if (isPackage) {
|
|
760
1160
|
const packageContents = readCanvasPackage(directory, false);
|
|
761
1161
|
target = await createArraySyncEngineDataSource({
|
|
762
|
-
objects: (
|
|
1162
|
+
objects: (packageContents == null ? void 0 : packageContents.compositions) ?? [],
|
|
763
1163
|
selectIdentifier: selectIdentifier2,
|
|
764
1164
|
selectDisplayName: selectDisplayName2,
|
|
765
1165
|
onSyncComplete: async (_, synced) => {
|
|
@@ -824,7 +1224,6 @@ var CompositionPushModule = {
|
|
|
824
1224
|
project: projectId,
|
|
825
1225
|
diff: diffMode
|
|
826
1226
|
}) => {
|
|
827
|
-
var _a;
|
|
828
1227
|
const fetch3 = nodeFetchProxy(proxy);
|
|
829
1228
|
const client = new UncachedCanvasClient11({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy });
|
|
830
1229
|
let source;
|
|
@@ -832,7 +1231,7 @@ var CompositionPushModule = {
|
|
|
832
1231
|
if (isPackage) {
|
|
833
1232
|
const packageContents = readCanvasPackage(directory, true);
|
|
834
1233
|
source = await createArraySyncEngineDataSource({
|
|
835
|
-
objects:
|
|
1234
|
+
objects: packageContents.compositions ?? [],
|
|
836
1235
|
selectIdentifier: selectIdentifier2,
|
|
837
1236
|
selectDisplayName: selectDisplayName2
|
|
838
1237
|
});
|
|
@@ -1043,7 +1442,6 @@ var DataTypePullModule = {
|
|
|
1043
1442
|
project: projectId,
|
|
1044
1443
|
diff: diffMode
|
|
1045
1444
|
}) => {
|
|
1046
|
-
var _a;
|
|
1047
1445
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1048
1446
|
const client = new DataTypeClient3({
|
|
1049
1447
|
apiKey,
|
|
@@ -1059,7 +1457,7 @@ var DataTypePullModule = {
|
|
|
1059
1457
|
if (isPackage) {
|
|
1060
1458
|
const packageContents = readCanvasPackage(directory, false);
|
|
1061
1459
|
target = await createArraySyncEngineDataSource({
|
|
1062
|
-
objects:
|
|
1460
|
+
objects: packageContents.dataTypes ?? [],
|
|
1063
1461
|
selectIdentifier: selectIdentifier3,
|
|
1064
1462
|
selectDisplayName: selectDisplayName3,
|
|
1065
1463
|
onSyncComplete: async (_, synced) => {
|
|
@@ -1121,7 +1519,6 @@ var DataTypePushModule = {
|
|
|
1121
1519
|
project: projectId,
|
|
1122
1520
|
diff: diffMode
|
|
1123
1521
|
}) => {
|
|
1124
|
-
var _a;
|
|
1125
1522
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1126
1523
|
const client = new DataTypeClient4({
|
|
1127
1524
|
apiKey,
|
|
@@ -1136,7 +1533,7 @@ var DataTypePushModule = {
|
|
|
1136
1533
|
if (isPackage) {
|
|
1137
1534
|
const packageContents = readCanvasPackage(directory, true);
|
|
1138
1535
|
source = await createArraySyncEngineDataSource({
|
|
1139
|
-
objects:
|
|
1536
|
+
objects: packageContents.dataTypes ?? [],
|
|
1140
1537
|
selectIdentifier: selectIdentifier3,
|
|
1141
1538
|
selectDisplayName: selectDisplayName3
|
|
1142
1539
|
});
|
|
@@ -1361,7 +1758,6 @@ var AggregatePullModule = {
|
|
|
1361
1758
|
project: projectId,
|
|
1362
1759
|
diff: diffMode
|
|
1363
1760
|
}) => {
|
|
1364
|
-
var _a;
|
|
1365
1761
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1366
1762
|
const client = new UncachedAggregateClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
1367
1763
|
const source = createAggregateEngineDataSource({ client });
|
|
@@ -1370,7 +1766,7 @@ var AggregatePullModule = {
|
|
|
1370
1766
|
if (isPackage) {
|
|
1371
1767
|
const packageContents = readContextPackage(directory, false);
|
|
1372
1768
|
target = await createArraySyncEngineDataSource({
|
|
1373
|
-
objects:
|
|
1769
|
+
objects: packageContents.aggregates ?? [],
|
|
1374
1770
|
selectIdentifier: selectIdentifier4,
|
|
1375
1771
|
selectDisplayName: selectDisplayName4,
|
|
1376
1772
|
onSyncComplete: async (_, synced) => {
|
|
@@ -1432,7 +1828,6 @@ var AggregatePushModule = {
|
|
|
1432
1828
|
project: projectId,
|
|
1433
1829
|
diff: diffMode
|
|
1434
1830
|
}) => {
|
|
1435
|
-
var _a;
|
|
1436
1831
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1437
1832
|
const client = new UncachedAggregateClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
1438
1833
|
let source;
|
|
@@ -1440,7 +1835,7 @@ var AggregatePushModule = {
|
|
|
1440
1835
|
if (isPackage) {
|
|
1441
1836
|
const packageContents = readContextPackage(directory, true);
|
|
1442
1837
|
source = await createArraySyncEngineDataSource({
|
|
1443
|
-
objects:
|
|
1838
|
+
objects: packageContents.aggregates ?? [],
|
|
1444
1839
|
selectIdentifier: selectIdentifier4,
|
|
1445
1840
|
selectDisplayName: selectDisplayName4
|
|
1446
1841
|
});
|
|
@@ -1584,7 +1979,7 @@ function createEnrichmentEngineDataSource({
|
|
|
1584
1979
|
await client.removeCategory({ enrichmentId: providerId });
|
|
1585
1980
|
},
|
|
1586
1981
|
writeObject: async (object, existingObject) => {
|
|
1587
|
-
var _a
|
|
1982
|
+
var _a;
|
|
1588
1983
|
await client.upsertCategory({
|
|
1589
1984
|
enrichment: object.object
|
|
1590
1985
|
});
|
|
@@ -1594,7 +1989,7 @@ function createEnrichmentEngineDataSource({
|
|
|
1594
1989
|
});
|
|
1595
1990
|
const target = createEnrichmentValueEngineDataSource({
|
|
1596
1991
|
categoryId: object.id,
|
|
1597
|
-
values: (
|
|
1992
|
+
values: ((_a = existingObject == null ? void 0 : existingObject.object) == null ? void 0 : _a.values) ?? [],
|
|
1598
1993
|
client
|
|
1599
1994
|
});
|
|
1600
1995
|
await syncEngine({
|
|
@@ -1685,7 +2080,6 @@ var EnrichmentPullModule = {
|
|
|
1685
2080
|
project: projectId,
|
|
1686
2081
|
diff: diffMode
|
|
1687
2082
|
}) => {
|
|
1688
|
-
var _a;
|
|
1689
2083
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1690
2084
|
const client = new UncachedEnrichmentClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
1691
2085
|
const source = createEnrichmentEngineDataSource({ client });
|
|
@@ -1694,7 +2088,7 @@ var EnrichmentPullModule = {
|
|
|
1694
2088
|
if (isPackage) {
|
|
1695
2089
|
const packageContents = readContextPackage(directory, false);
|
|
1696
2090
|
target = await createArraySyncEngineDataSource({
|
|
1697
|
-
objects:
|
|
2091
|
+
objects: packageContents.enrichments ?? [],
|
|
1698
2092
|
selectIdentifier: selectIdentifier5,
|
|
1699
2093
|
selectDisplayName: selectDisplayName5,
|
|
1700
2094
|
onSyncComplete: async (_, synced) => {
|
|
@@ -1756,7 +2150,6 @@ var EnrichmentPushModule = {
|
|
|
1756
2150
|
project: projectId,
|
|
1757
2151
|
diff: diffMode
|
|
1758
2152
|
}) => {
|
|
1759
|
-
var _a;
|
|
1760
2153
|
const fetch3 = nodeFetchProxy(proxy);
|
|
1761
2154
|
const client = new UncachedEnrichmentClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
1762
2155
|
let source;
|
|
@@ -1764,7 +2157,7 @@ var EnrichmentPushModule = {
|
|
|
1764
2157
|
if (isPackage) {
|
|
1765
2158
|
const packageContents = readContextPackage(directory, true);
|
|
1766
2159
|
source = await createArraySyncEngineDataSource({
|
|
1767
|
-
objects:
|
|
2160
|
+
objects: packageContents.enrichments ?? [],
|
|
1768
2161
|
selectIdentifier: selectIdentifier5,
|
|
1769
2162
|
selectDisplayName: selectDisplayName5
|
|
1770
2163
|
});
|
|
@@ -1819,8 +2212,8 @@ var EnrichmentModule = {
|
|
|
1819
2212
|
import yargs7 from "yargs";
|
|
1820
2213
|
|
|
1821
2214
|
// src/commands/context/commands/manifest/get.ts
|
|
1822
|
-
var import_chalk = __toESM(require_source());
|
|
1823
2215
|
import { ApiClientError, UncachedManifestClient } from "@uniformdev/context/api";
|
|
2216
|
+
import chalk3 from "chalk";
|
|
1824
2217
|
import { writeFile } from "fs";
|
|
1825
2218
|
import { exit } from "process";
|
|
1826
2219
|
var ManifestGetModule = {
|
|
@@ -1861,7 +2254,7 @@ var ManifestGetModule = {
|
|
|
1861
2254
|
`, error);
|
|
1862
2255
|
exit(1);
|
|
1863
2256
|
}
|
|
1864
|
-
console.log(
|
|
2257
|
+
console.log(chalk3.green(`\u2705 ${output} has been updated from ${apiHost}`));
|
|
1865
2258
|
});
|
|
1866
2259
|
} else {
|
|
1867
2260
|
console.log(text);
|
|
@@ -1876,16 +2269,16 @@ var ManifestGetModule = {
|
|
|
1876
2269
|
} else {
|
|
1877
2270
|
message = e.toString();
|
|
1878
2271
|
}
|
|
1879
|
-
console.error(
|
|
1880
|
-
console.error(
|
|
2272
|
+
console.error(chalk3.red(`\u26A0 Error fetching Context manifest`));
|
|
2273
|
+
console.error(chalk3.gray(` \u2757 ${message}`));
|
|
1881
2274
|
exit(1);
|
|
1882
2275
|
}
|
|
1883
2276
|
}
|
|
1884
2277
|
};
|
|
1885
2278
|
|
|
1886
2279
|
// src/commands/context/commands/manifest/publish.ts
|
|
1887
|
-
var import_chalk2 = __toESM(require_source());
|
|
1888
2280
|
import { ApiClientError as ApiClientError2, UncachedManifestClient as UncachedManifestClient2 } from "@uniformdev/context/api";
|
|
2281
|
+
import chalk4 from "chalk";
|
|
1889
2282
|
import { exit as exit2 } from "process";
|
|
1890
2283
|
var ManifestPublishModule = {
|
|
1891
2284
|
command: "publish",
|
|
@@ -1911,8 +2304,8 @@ var ManifestPublishModule = {
|
|
|
1911
2304
|
} else {
|
|
1912
2305
|
message = e.toString();
|
|
1913
2306
|
}
|
|
1914
|
-
console.error(
|
|
1915
|
-
console.error(
|
|
2307
|
+
console.error(chalk4.red(`\u26A0 Error publishing Context manifest`));
|
|
2308
|
+
console.error(chalk4.gray(` \u2757 ${message}`));
|
|
1916
2309
|
exit2(1);
|
|
1917
2310
|
}
|
|
1918
2311
|
}
|
|
@@ -2060,7 +2453,6 @@ var QuirkPullModule = {
|
|
|
2060
2453
|
project: projectId,
|
|
2061
2454
|
diff: diffMode
|
|
2062
2455
|
}) => {
|
|
2063
|
-
var _a;
|
|
2064
2456
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2065
2457
|
const client = new UncachedQuirkClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
2066
2458
|
const source = createQuirkEngineDataSource({ client });
|
|
@@ -2069,7 +2461,7 @@ var QuirkPullModule = {
|
|
|
2069
2461
|
if (isPackage) {
|
|
2070
2462
|
const packageContents = readContextPackage(directory, false);
|
|
2071
2463
|
target = await createArraySyncEngineDataSource({
|
|
2072
|
-
objects:
|
|
2464
|
+
objects: packageContents.quirks ?? [],
|
|
2073
2465
|
selectIdentifier: selectIdentifier6,
|
|
2074
2466
|
selectDisplayName: selectDisplayName6,
|
|
2075
2467
|
onSyncComplete: async (_, synced) => {
|
|
@@ -2131,7 +2523,6 @@ var QuirkPushModule = {
|
|
|
2131
2523
|
project: projectId,
|
|
2132
2524
|
diff: diffMode
|
|
2133
2525
|
}) => {
|
|
2134
|
-
var _a;
|
|
2135
2526
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2136
2527
|
const client = new UncachedQuirkClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
2137
2528
|
let source;
|
|
@@ -2139,7 +2530,7 @@ var QuirkPushModule = {
|
|
|
2139
2530
|
if (isPackage) {
|
|
2140
2531
|
const packageContents = readContextPackage(directory, true);
|
|
2141
2532
|
source = await createArraySyncEngineDataSource({
|
|
2142
|
-
objects:
|
|
2533
|
+
objects: packageContents.quirks ?? [],
|
|
2143
2534
|
selectIdentifier: selectIdentifier6,
|
|
2144
2535
|
selectDisplayName: selectDisplayName6
|
|
2145
2536
|
});
|
|
@@ -2328,7 +2719,6 @@ var SignalPullModule = {
|
|
|
2328
2719
|
project: projectId,
|
|
2329
2720
|
diff: diffMode
|
|
2330
2721
|
}) => {
|
|
2331
|
-
var _a;
|
|
2332
2722
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2333
2723
|
const client = new UncachedSignalClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
2334
2724
|
const source = createSignalEngineDataSource({ client });
|
|
@@ -2337,7 +2727,7 @@ var SignalPullModule = {
|
|
|
2337
2727
|
if (isPackage) {
|
|
2338
2728
|
const packageContents = readContextPackage(directory, false);
|
|
2339
2729
|
target = await createArraySyncEngineDataSource({
|
|
2340
|
-
objects:
|
|
2730
|
+
objects: packageContents.signals ?? [],
|
|
2341
2731
|
selectIdentifier: selectIdentifier7,
|
|
2342
2732
|
selectDisplayName: selectDisplayName7,
|
|
2343
2733
|
onSyncComplete: async (_, synced) => {
|
|
@@ -2399,7 +2789,6 @@ var SignalPushModule = {
|
|
|
2399
2789
|
project: projectId,
|
|
2400
2790
|
diff: diffMode
|
|
2401
2791
|
}) => {
|
|
2402
|
-
var _a;
|
|
2403
2792
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2404
2793
|
const client = new UncachedSignalClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
2405
2794
|
let source;
|
|
@@ -2407,7 +2796,7 @@ var SignalPushModule = {
|
|
|
2407
2796
|
if (isPackage) {
|
|
2408
2797
|
const packageContents = readContextPackage(directory, true);
|
|
2409
2798
|
source = await createArraySyncEngineDataSource({
|
|
2410
|
-
objects:
|
|
2799
|
+
objects: packageContents.signals ?? [],
|
|
2411
2800
|
selectIdentifier: selectIdentifier7,
|
|
2412
2801
|
selectDisplayName: selectDisplayName7
|
|
2413
2802
|
});
|
|
@@ -2596,7 +2985,6 @@ var TestPullModule = {
|
|
|
2596
2985
|
project: projectId,
|
|
2597
2986
|
diff: diffMode
|
|
2598
2987
|
}) => {
|
|
2599
|
-
var _a;
|
|
2600
2988
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2601
2989
|
const client = new UncachedTestClient3({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
2602
2990
|
const source = createTestEngineDataSource({ client });
|
|
@@ -2605,7 +2993,7 @@ var TestPullModule = {
|
|
|
2605
2993
|
if (isPackage) {
|
|
2606
2994
|
const packageContents = readContextPackage(directory, false);
|
|
2607
2995
|
target = await createArraySyncEngineDataSource({
|
|
2608
|
-
objects:
|
|
2996
|
+
objects: packageContents.tests ?? [],
|
|
2609
2997
|
selectIdentifier: selectIdentifier8,
|
|
2610
2998
|
selectDisplayName: selectDisplayName8,
|
|
2611
2999
|
onSyncComplete: async (_, synced) => {
|
|
@@ -2667,7 +3055,6 @@ var TestPushModule = {
|
|
|
2667
3055
|
project: projectId,
|
|
2668
3056
|
diff: diffMode
|
|
2669
3057
|
}) => {
|
|
2670
|
-
var _a;
|
|
2671
3058
|
const fetch3 = nodeFetchProxy(proxy);
|
|
2672
3059
|
const client = new UncachedTestClient4({ apiKey, apiHost, fetch: fetch3, projectId, limitPolicy: limitPolicy2 });
|
|
2673
3060
|
let source;
|
|
@@ -2675,7 +3062,7 @@ var TestPushModule = {
|
|
|
2675
3062
|
if (isPackage) {
|
|
2676
3063
|
const packageContents = readContextPackage(directory, true);
|
|
2677
3064
|
source = await createArraySyncEngineDataSource({
|
|
2678
|
-
objects:
|
|
3065
|
+
objects: packageContents.tests ?? [],
|
|
2679
3066
|
selectIdentifier: selectIdentifier8,
|
|
2680
3067
|
selectDisplayName: selectDisplayName8
|
|
2681
3068
|
});
|
|
@@ -2752,11 +3139,12 @@ var ContextCommand = {
|
|
|
2752
3139
|
};
|
|
2753
3140
|
|
|
2754
3141
|
// src/spinner.ts
|
|
3142
|
+
import ora from "ora";
|
|
2755
3143
|
var makeSpinner = () => {
|
|
2756
3144
|
const spinners = [];
|
|
2757
3145
|
const stopAllSpinners = () => spinners.forEach((spinner) => spinner.stop());
|
|
2758
3146
|
const spin = async (text) => {
|
|
2759
|
-
const spinner =
|
|
3147
|
+
const spinner = ora(text).start();
|
|
2760
3148
|
spinners.push(spinner);
|
|
2761
3149
|
const minWait = new Promise((resolve) => setTimeout(resolve, 500));
|
|
2762
3150
|
return async () => {
|
|
@@ -2774,7 +3162,7 @@ import { PostHog } from "posthog-node";
|
|
|
2774
3162
|
// package.json
|
|
2775
3163
|
var package_default = {
|
|
2776
3164
|
name: "@uniformdev/cli",
|
|
2777
|
-
version: "18.
|
|
3165
|
+
version: "18.20.0",
|
|
2778
3166
|
description: "Uniform command line interface tool",
|
|
2779
3167
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
2780
3168
|
main: "./cli.js",
|
|
@@ -2793,6 +3181,7 @@ var package_default = {
|
|
|
2793
3181
|
"@uniformdev/canvas": "workspace:*",
|
|
2794
3182
|
"@uniformdev/context": "workspace:*",
|
|
2795
3183
|
"@uniformdev/project-map": "workspace:*",
|
|
3184
|
+
chalk: "^5.2.0",
|
|
2796
3185
|
diff: "^5.0.0",
|
|
2797
3186
|
dotenv: "^16.0.3",
|
|
2798
3187
|
execa: "5.1.1",
|
|
@@ -2811,7 +3200,7 @@ var package_default = {
|
|
|
2811
3200
|
"posthog-node": "2.5.3",
|
|
2812
3201
|
slugify: "1.6.5",
|
|
2813
3202
|
yargs: "^17.6.2",
|
|
2814
|
-
zod: "3.
|
|
3203
|
+
zod: "3.21.0"
|
|
2815
3204
|
},
|
|
2816
3205
|
devDependencies: {
|
|
2817
3206
|
"@types/diff": "5.0.2",
|
|
@@ -3131,7 +3520,7 @@ var runNpm = async (workDir, args, { inherit, env } = {}) => {
|
|
|
3131
3520
|
try {
|
|
3132
3521
|
result = await execa("npm", args, {
|
|
3133
3522
|
cwd: workDir,
|
|
3134
|
-
env: env
|
|
3523
|
+
env: env ?? {},
|
|
3135
3524
|
...inherit ? { stdout: "inherit", stderr: "inherit" } : {}
|
|
3136
3525
|
});
|
|
3137
3526
|
} catch (err) {
|
|
@@ -3146,10 +3535,10 @@ ${err.message}`);
|
|
|
3146
3535
|
|
|
3147
3536
|
// src/projects/cloneStarter.ts
|
|
3148
3537
|
import crypto2 from "crypto";
|
|
3149
|
-
import
|
|
3150
|
-
import
|
|
3538
|
+
import fs2 from "fs";
|
|
3539
|
+
import fsj from "fs-jetpack";
|
|
3151
3540
|
import * as git from "isomorphic-git";
|
|
3152
|
-
import * as http from "isomorphic-git/http/node";
|
|
3541
|
+
import * as http from "isomorphic-git/http/node/index.js";
|
|
3153
3542
|
import os from "os";
|
|
3154
3543
|
import path from "path";
|
|
3155
3544
|
async function cloneStarter({
|
|
@@ -3163,7 +3552,7 @@ async function cloneStarter({
|
|
|
3163
3552
|
const [user, repo, ...pathSegments] = githubPath.split("/");
|
|
3164
3553
|
try {
|
|
3165
3554
|
await git.clone({
|
|
3166
|
-
fs,
|
|
3555
|
+
fs: fs2,
|
|
3167
3556
|
http,
|
|
3168
3557
|
url: `https://github.com/${user}/${repo}`,
|
|
3169
3558
|
dir: cloneDir,
|
|
@@ -3174,13 +3563,13 @@ async function cloneStarter({
|
|
|
3174
3563
|
throw new Error(`Failed to fetch starter code: ${err.message}`);
|
|
3175
3564
|
}
|
|
3176
3565
|
await done();
|
|
3177
|
-
if (
|
|
3566
|
+
if (fs2.existsSync(targetDir) && fs2.readdirSync(targetDir).length > 0) {
|
|
3178
3567
|
throw new Error(`"${targetDir}" is not empty`);
|
|
3179
3568
|
}
|
|
3180
3569
|
const starterDir = path.join(cloneDir, ...pathSegments);
|
|
3181
|
-
copy(starterDir, targetDir, { overwrite: true });
|
|
3570
|
+
fsj.copy(starterDir, targetDir, { overwrite: true });
|
|
3182
3571
|
if (dotEnvFile) {
|
|
3183
|
-
|
|
3572
|
+
fs2.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
|
|
3184
3573
|
}
|
|
3185
3574
|
console.log(`
|
|
3186
3575
|
Your project now lives in ${targetDir} \u2728`);
|
|
@@ -3196,7 +3585,7 @@ Installing project dependencies...
|
|
|
3196
3585
|
}
|
|
3197
3586
|
|
|
3198
3587
|
// src/projects/getOrCreateProject.ts
|
|
3199
|
-
import
|
|
3588
|
+
import fs3, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
3200
3589
|
import inquirer2 from "inquirer";
|
|
3201
3590
|
import path2 from "path";
|
|
3202
3591
|
import slugify from "slugify";
|
|
@@ -3293,8 +3682,8 @@ async function chooseExistingProject({
|
|
|
3293
3682
|
teamId,
|
|
3294
3683
|
user
|
|
3295
3684
|
}) {
|
|
3296
|
-
var _a, _b
|
|
3297
|
-
const projects = ((
|
|
3685
|
+
var _a, _b;
|
|
3686
|
+
const projects = (((_a = user.teams.find((t) => t.team.id === teamId)) == null ? void 0 : _a.team.sites) ?? []).map((t) => ({
|
|
3298
3687
|
name: t.name,
|
|
3299
3688
|
value: t.id
|
|
3300
3689
|
}));
|
|
@@ -3309,7 +3698,7 @@ async function chooseExistingProject({
|
|
|
3309
3698
|
]);
|
|
3310
3699
|
return {
|
|
3311
3700
|
projectId: result.projectId,
|
|
3312
|
-
projectName: (
|
|
3701
|
+
projectName: (_b = projects.find((p) => p.value === result.projectId)) == null ? void 0 : _b.name
|
|
3313
3702
|
};
|
|
3314
3703
|
}
|
|
3315
3704
|
function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
|
|
@@ -3319,13 +3708,13 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
|
|
|
3319
3708
|
throw new Error("Project name cannot be shorter than 3 characters.");
|
|
3320
3709
|
}
|
|
3321
3710
|
if (checkTargetDir) {
|
|
3322
|
-
let targetDir = explicitTargetDir
|
|
3323
|
-
if (!
|
|
3324
|
-
|
|
3711
|
+
let targetDir = explicitTargetDir ?? process.cwd();
|
|
3712
|
+
if (!existsSync2(targetDir)) {
|
|
3713
|
+
mkdirSync2(targetDir, { recursive: true });
|
|
3325
3714
|
}
|
|
3326
|
-
if (
|
|
3715
|
+
if (fs3.readdirSync(targetDir).length > 0) {
|
|
3327
3716
|
targetDir = path2.resolve(targetDir, projectNameSlug);
|
|
3328
|
-
if (
|
|
3717
|
+
if (fs3.existsSync(targetDir)) {
|
|
3329
3718
|
throw new Error(`${targetDir} already exists, choose a different name.`);
|
|
3330
3719
|
}
|
|
3331
3720
|
}
|
|
@@ -3548,7 +3937,7 @@ npm run dev
|
|
|
3548
3937
|
}
|
|
3549
3938
|
|
|
3550
3939
|
// src/commands/new/commands/new-mesh-integration.ts
|
|
3551
|
-
import { existsSync as
|
|
3940
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
3552
3941
|
import inquirer5 from "inquirer";
|
|
3553
3942
|
import path3 from "path";
|
|
3554
3943
|
import slugify2 from "slugify";
|
|
@@ -3592,18 +3981,18 @@ async function newMeshIntegrationHandler({
|
|
|
3592
3981
|
});
|
|
3593
3982
|
let done = await spin("Registering integration to team...");
|
|
3594
3983
|
const pathToManifest = path3.resolve(targetDir, "mesh-manifest.json");
|
|
3595
|
-
if (!
|
|
3984
|
+
if (!existsSync3(pathToManifest)) {
|
|
3596
3985
|
throw new Error("Invalid integration starter cloned: missing `mesh-manifest.json`");
|
|
3597
3986
|
}
|
|
3598
|
-
const manifestContents =
|
|
3987
|
+
const manifestContents = readFileSync2(pathToManifest, "utf-8");
|
|
3599
3988
|
const manifestJson = JSON.parse(manifestContents);
|
|
3600
3989
|
manifestJson.type = typeSlug;
|
|
3601
3990
|
manifestJson.displayName = name;
|
|
3602
|
-
|
|
3991
|
+
writeFileSync2(pathToManifest, JSON.stringify(manifestJson, null, 2), "utf-8");
|
|
3603
3992
|
const packageJsonPath = path3.resolve(targetDir, "package.json");
|
|
3604
|
-
const packageJson = JSON.parse(
|
|
3993
|
+
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
3605
3994
|
packageJson.name = typeSlug;
|
|
3606
|
-
|
|
3995
|
+
writeFileSync2(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
3607
3996
|
const fullMeshAppKey = await uniformClient.registerMeshIntegration({ teamId, manifest: manifestJson });
|
|
3608
3997
|
await done();
|
|
3609
3998
|
await runNpmInstall();
|
|
@@ -3645,13 +4034,13 @@ function validateIntegrationName(integrationName, explicitOutputPath) {
|
|
|
3645
4034
|
if (integrationName.length < 6 || typeSlug.length < 6) {
|
|
3646
4035
|
throw new Error("Integration name cannot be shorter than 6 characters.");
|
|
3647
4036
|
}
|
|
3648
|
-
let targetDir = explicitOutputPath
|
|
3649
|
-
if (!
|
|
3650
|
-
|
|
4037
|
+
let targetDir = explicitOutputPath ?? process.cwd();
|
|
4038
|
+
if (!existsSync3(targetDir)) {
|
|
4039
|
+
mkdirSync3(targetDir, { recursive: true });
|
|
3651
4040
|
}
|
|
3652
4041
|
if (readdirSync(targetDir).length > 0) {
|
|
3653
4042
|
targetDir = path3.resolve(targetDir, typeSlug);
|
|
3654
|
-
if (
|
|
4043
|
+
if (existsSync3(targetDir)) {
|
|
3655
4044
|
throw new Error(`${targetDir} directory already exists, choose a different name.`);
|
|
3656
4045
|
}
|
|
3657
4046
|
}
|
|
@@ -3745,7 +4134,7 @@ import yargs13 from "yargs";
|
|
|
3745
4134
|
import yargs12 from "yargs";
|
|
3746
4135
|
|
|
3747
4136
|
// src/commands/optimize/manifest/download.ts
|
|
3748
|
-
|
|
4137
|
+
import chalk5 from "chalk";
|
|
3749
4138
|
import { writeFile as writeFile2 } from "fs";
|
|
3750
4139
|
import fetch2 from "isomorphic-unfetch";
|
|
3751
4140
|
import { exit as exit3 } from "process";
|
|
@@ -3757,43 +4146,40 @@ var UniformBaseUrl = "https://uniform.app";
|
|
|
3757
4146
|
var module = {
|
|
3758
4147
|
command: "download [output]",
|
|
3759
4148
|
describe: "Download intent manifest",
|
|
3760
|
-
builder: (yargs18) => {
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set."
|
|
3783
|
-
});
|
|
3784
|
-
},
|
|
4149
|
+
builder: (yargs18) => yargs18.option("apiKey", {
|
|
4150
|
+
alias: "k",
|
|
4151
|
+
demandOption: true,
|
|
4152
|
+
string: true,
|
|
4153
|
+
default: process.env.UNIFORM_API_KEY,
|
|
4154
|
+
describe: "Uniform API key to use. Defaults to UNIFORM_API_KEY env if set."
|
|
4155
|
+
}).option("project", {
|
|
4156
|
+
describe: "Uniform project ID. Defaults to UOPT_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
|
|
4157
|
+
default: process.env.UOPT_CLI_PROJECT_ID ?? process.env.UNIFORM_PROJECT_ID,
|
|
4158
|
+
type: "string",
|
|
4159
|
+
alias: ["p"]
|
|
4160
|
+
}).option("preview", {
|
|
4161
|
+
describe: "If set, fetches the unpublished preview manifest (assuming your API key has permission)",
|
|
4162
|
+
default: false,
|
|
4163
|
+
type: "boolean",
|
|
4164
|
+
alias: ["d"]
|
|
4165
|
+
}).option("output", {
|
|
4166
|
+
string: true,
|
|
4167
|
+
alias: "o",
|
|
4168
|
+
default: process.env.UNIFORM_MANIFEST_PATH,
|
|
4169
|
+
describe: "Path to write manifest to. Defaults to UNIFORM_MANIFEST_PATH env if set."
|
|
4170
|
+
}),
|
|
3785
4171
|
handler: async ({ apiKey, output, project, preview }) => {
|
|
3786
4172
|
const isLegacyApiKey = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i.test(
|
|
3787
4173
|
apiKey
|
|
3788
4174
|
);
|
|
3789
4175
|
if (isLegacyApiKey) {
|
|
3790
4176
|
console.error(
|
|
3791
|
-
|
|
4177
|
+
chalk5.yellow(
|
|
3792
4178
|
"WARNING: you appear to be using a deprecated type of API key. Keys like this will stop working soon; please create new keys on uniform.app."
|
|
3793
4179
|
)
|
|
3794
4180
|
);
|
|
3795
4181
|
} else if (!project) {
|
|
3796
|
-
console.error(
|
|
4182
|
+
console.error(chalk5.red("You must specify the project ID"));
|
|
3797
4183
|
exit3(1);
|
|
3798
4184
|
}
|
|
3799
4185
|
const baseUrl = resolveBaseUrl();
|
|
@@ -3819,16 +4205,16 @@ var module = {
|
|
|
3819
4205
|
throw `${fetchResponse.status} ${fetchResponse.statusText}, content ${await fetchResponse.text()}`;
|
|
3820
4206
|
}
|
|
3821
4207
|
} catch (e) {
|
|
3822
|
-
console.error(
|
|
3823
|
-
console.error(
|
|
4208
|
+
console.error(chalk5.red(`\u26A0 Error fetching intent manifest ${manifestUrl}`));
|
|
4209
|
+
console.error(chalk5.gray(` \u2757 ${e}`));
|
|
3824
4210
|
exit3(1);
|
|
3825
4211
|
}
|
|
3826
4212
|
let json;
|
|
3827
4213
|
try {
|
|
3828
4214
|
json = await fetchResponse.json();
|
|
3829
4215
|
} catch (e) {
|
|
3830
|
-
console.error(
|
|
3831
|
-
console.error(
|
|
4216
|
+
console.error(chalk5.red(chalk5.red(`\u26A0 Error parsing intent manifest ${manifestUrl}`)));
|
|
4217
|
+
console.error(chalk5.gray(` \u2757 ${e}`));
|
|
3832
4218
|
console.error(`Response: ${await fetchResponse.text()}`);
|
|
3833
4219
|
exit3(1);
|
|
3834
4220
|
}
|
|
@@ -3840,7 +4226,7 @@ var module = {
|
|
|
3840
4226
|
`, error);
|
|
3841
4227
|
exit3(1);
|
|
3842
4228
|
}
|
|
3843
|
-
console.log(
|
|
4229
|
+
console.log(chalk5.green(`\u2705 ${output} has been updated from ${manifestUrl}`));
|
|
3844
4230
|
});
|
|
3845
4231
|
} else {
|
|
3846
4232
|
console.log(text);
|
|
@@ -4014,7 +4400,6 @@ var ProjectMapDefinitionPullModule = {
|
|
|
4014
4400
|
project: projectId,
|
|
4015
4401
|
diff: diffMode
|
|
4016
4402
|
}) => {
|
|
4017
|
-
var _a;
|
|
4018
4403
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4019
4404
|
const client = new UncachedProjectMapClient3({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
4020
4405
|
const source = createProjectMapDefinitionEngineDataSource({ client });
|
|
@@ -4023,7 +4408,7 @@ var ProjectMapDefinitionPullModule = {
|
|
|
4023
4408
|
if (isPackage) {
|
|
4024
4409
|
const packageContents = readContextPackage2(directory, false);
|
|
4025
4410
|
target = await createArraySyncEngineDataSource({
|
|
4026
|
-
objects:
|
|
4411
|
+
objects: packageContents.projectMaps ?? [],
|
|
4027
4412
|
selectIdentifier: selectIdentifier9,
|
|
4028
4413
|
selectDisplayName: selectDisplayName9,
|
|
4029
4414
|
onSyncComplete: async (_, synced) => {
|
|
@@ -4085,7 +4470,6 @@ var ProjectMapDefinitionPushModule = {
|
|
|
4085
4470
|
project: projectId,
|
|
4086
4471
|
diff: diffMode
|
|
4087
4472
|
}) => {
|
|
4088
|
-
var _a;
|
|
4089
4473
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4090
4474
|
const client = new UncachedProjectMapClient4({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
4091
4475
|
let source;
|
|
@@ -4093,7 +4477,7 @@ var ProjectMapDefinitionPushModule = {
|
|
|
4093
4477
|
if (isPackage) {
|
|
4094
4478
|
const packageContents = readContextPackage2(directory, true);
|
|
4095
4479
|
source = await createArraySyncEngineDataSource({
|
|
4096
|
-
objects:
|
|
4480
|
+
objects: packageContents.projectMaps ?? [],
|
|
4097
4481
|
selectIdentifier: selectIdentifier9,
|
|
4098
4482
|
selectDisplayName: selectDisplayName9
|
|
4099
4483
|
});
|
|
@@ -4176,7 +4560,7 @@ var ProjectMapNodeGetModule = {
|
|
|
4176
4560
|
)
|
|
4177
4561
|
),
|
|
4178
4562
|
handler: async ({ apiHost, apiKey, proxy, id, projectMapId, format, project: projectId, filename }) => {
|
|
4179
|
-
var _a
|
|
4563
|
+
var _a;
|
|
4180
4564
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4181
4565
|
const client = new UncachedProjectMapClient7({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
4182
4566
|
console.log("Debugging params for node get", { projectMapId, id, projectId });
|
|
@@ -4185,7 +4569,7 @@ var ProjectMapNodeGetModule = {
|
|
|
4185
4569
|
console.error("Project map node does not exist");
|
|
4186
4570
|
process.exit(1);
|
|
4187
4571
|
} else {
|
|
4188
|
-
emitWithFormat({ nodes:
|
|
4572
|
+
emitWithFormat({ nodes: res.nodes ?? [], projectMapId }, format, filename);
|
|
4189
4573
|
}
|
|
4190
4574
|
}
|
|
4191
4575
|
};
|
|
@@ -4204,11 +4588,10 @@ var ProjectMapNodeListModule = {
|
|
|
4204
4588
|
)
|
|
4205
4589
|
),
|
|
4206
4590
|
handler: async ({ apiHost, apiKey, proxy, projectMapId, format, filename, project: projectId }) => {
|
|
4207
|
-
var _a;
|
|
4208
4591
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4209
4592
|
const client = new UncachedProjectMapClient8({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
4210
4593
|
const res = await client.getNodes({ projectMapId });
|
|
4211
|
-
emitWithFormat({ nodes:
|
|
4594
|
+
emitWithFormat({ nodes: res.nodes ?? [], projectMapId }, format, filename);
|
|
4212
4595
|
}
|
|
4213
4596
|
};
|
|
4214
4597
|
|
|
@@ -4229,7 +4612,7 @@ function createProjectMapNodeEngineDataSource({
|
|
|
4229
4612
|
const projectMaps = (await client.getProjectMapDefinitions()).projectMaps;
|
|
4230
4613
|
for (const projectMap of projectMaps) {
|
|
4231
4614
|
const nodes = (await client.getNodes({ projectMapId: projectMap.id })).nodes;
|
|
4232
|
-
for await (const def of nodes
|
|
4615
|
+
for await (const def of nodes ?? []) {
|
|
4233
4616
|
if (def) {
|
|
4234
4617
|
const result = {
|
|
4235
4618
|
id: selectIdentifier10({ ...def, projectMapId: projectMap.id }, projectId),
|
|
@@ -4302,7 +4685,6 @@ var ProjectMapNodePullModule = {
|
|
|
4302
4685
|
project: projectId,
|
|
4303
4686
|
diff: diffMode
|
|
4304
4687
|
}) => {
|
|
4305
|
-
var _a;
|
|
4306
4688
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4307
4689
|
const client = new UncachedProjectMapClient9({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
4308
4690
|
const source = createProjectMapNodeEngineDataSource({ client, projectId });
|
|
@@ -4314,7 +4696,7 @@ var ProjectMapNodePullModule = {
|
|
|
4314
4696
|
if (isPackage) {
|
|
4315
4697
|
const packageContents = readContextPackage2(directory, false);
|
|
4316
4698
|
target = await createArraySyncEngineDataSource({
|
|
4317
|
-
objects:
|
|
4699
|
+
objects: packageContents.projectMapNodes ?? [],
|
|
4318
4700
|
selectIdentifier: expandedSelectIdentifier,
|
|
4319
4701
|
selectDisplayName: selectDisplayName10,
|
|
4320
4702
|
onSyncComplete: async (_, synced) => {
|
|
@@ -4377,7 +4759,6 @@ var ProjectMapNodePushModule = {
|
|
|
4377
4759
|
project: projectId,
|
|
4378
4760
|
diff: diffMode
|
|
4379
4761
|
}) => {
|
|
4380
|
-
var _a;
|
|
4381
4762
|
const fetch3 = nodeFetchProxy(proxy);
|
|
4382
4763
|
const client = new UncachedProjectMapClient10({
|
|
4383
4764
|
apiKey,
|
|
@@ -4393,7 +4774,7 @@ var ProjectMapNodePushModule = {
|
|
|
4393
4774
|
if (isPackage) {
|
|
4394
4775
|
const packageContents = readContextPackage2(directory, true);
|
|
4395
4776
|
source = await createArraySyncEngineDataSource({
|
|
4396
|
-
objects:
|
|
4777
|
+
objects: packageContents.projectMapNodes ?? [],
|
|
4397
4778
|
selectIdentifier: expandedSelectIdentifier,
|
|
4398
4779
|
selectDisplayName: selectDisplayName10
|
|
4399
4780
|
});
|
|
@@ -4475,6 +4856,6 @@ var ProjectMapCommand = {
|
|
|
4475
4856
|
};
|
|
4476
4857
|
|
|
4477
4858
|
// src/index.ts
|
|
4478
|
-
|
|
4479
|
-
var yarggery = yargs17.
|
|
4859
|
+
dotenv.config();
|
|
4860
|
+
var yarggery = yargs17(hideBin(process.argv));
|
|
4480
4861
|
yarggery.command(CanvasCommand).command(ContextCommand).command(ProjectMapCommand).command(NewCmd).command(NewMeshCmd).command(OptimizeCommand).demandCommand(1, "").strict().help().argv;
|