@uniformdev/cli 19.156.0 → 19.157.1-alpha.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/dist/chunk-2TESILZJ.mjs +267 -0
- package/dist/defaultConfig.d.mts +46 -0
- package/dist/defaultConfig.mjs +51 -0
- package/dist/index-CwNHvz9G.d.mts +48 -0
- package/dist/index.d.mts +1 -47
- package/dist/index.mjs +106 -349
- package/package.json +19 -9
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import {
|
|
3
|
+
__require,
|
|
4
|
+
applyDefaultSyncConfiguration,
|
|
5
|
+
emitWithFormat,
|
|
6
|
+
getDirectoryOrFilename,
|
|
7
|
+
getEntityOption,
|
|
8
|
+
isPathAPackageFile,
|
|
9
|
+
nodeFetchProxy,
|
|
10
|
+
paginateAsync,
|
|
11
|
+
readFileToObject,
|
|
12
|
+
withApiOptions,
|
|
13
|
+
withConfiguration,
|
|
14
|
+
withDiffOptions,
|
|
15
|
+
withFormatOptions,
|
|
16
|
+
withProjectOptions,
|
|
17
|
+
withTeamOptions
|
|
18
|
+
} from "./chunk-2TESILZJ.mjs";
|
|
16
19
|
|
|
17
20
|
// src/index.ts
|
|
18
21
|
import * as dotenv from "dotenv";
|
|
@@ -90,9 +93,9 @@ async function createArraySyncEngineDataSource({
|
|
|
90
93
|
|
|
91
94
|
// src/sync/fileSyncEngineDataSource.ts
|
|
92
95
|
import { red } from "colorette";
|
|
93
|
-
import { existsSync, mkdirSync
|
|
96
|
+
import { existsSync, mkdirSync } from "fs";
|
|
94
97
|
import { readdir, unlink } from "fs/promises";
|
|
95
|
-
import { extname
|
|
98
|
+
import { extname, join } from "path";
|
|
96
99
|
|
|
97
100
|
// src/util.ts
|
|
98
101
|
import { cosmiconfigSync } from "cosmiconfig";
|
|
@@ -121,254 +124,16 @@ var loadConfig = (configPath) => {
|
|
|
121
124
|
throw new Error(`Invalid configuration file path: ${configPath}. File does not exist.`);
|
|
122
125
|
}
|
|
123
126
|
const configFile = syncCosmicExplorer.load(configPath);
|
|
124
|
-
if (!
|
|
127
|
+
if (!configFile?.config.serialization) {
|
|
125
128
|
throw new Error(
|
|
126
129
|
`Invalid configuration file: ${configPath}. Missing config.serialization configuration.`
|
|
127
130
|
);
|
|
128
131
|
}
|
|
129
|
-
return applyDefaultSyncConfiguration(
|
|
132
|
+
return applyDefaultSyncConfiguration(configFile?.config ?? {});
|
|
130
133
|
} else {
|
|
131
134
|
const searchedForm = syncCosmicExplorer.search();
|
|
132
|
-
return applyDefaultSyncConfiguration(
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
// src/sync/util.ts
|
|
137
|
-
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
138
|
-
import { dump, load } from "js-yaml";
|
|
139
|
-
import { dirname, extname, isAbsolute, resolve, sep } from "path";
|
|
140
|
-
import { fetch as undiciFetch, ProxyAgent } from "undici";
|
|
141
|
-
function withConfiguration(yargs34) {
|
|
142
|
-
return yargs34.option("serialization", {
|
|
143
|
-
skipValidation: true,
|
|
144
|
-
hidden: true
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
function withApiOptions(yargs34) {
|
|
148
|
-
return yargs34.option("apiKey", {
|
|
149
|
-
describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
|
|
150
|
-
default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
|
|
151
|
-
process.env.CANVAS_CLI_API_KEY ?? // deprecated
|
|
152
|
-
process.env.UPM_CLI_API_KEY ?? process.env.UNIFORM_API_KEY,
|
|
153
|
-
demandOption: true,
|
|
154
|
-
type: "string"
|
|
155
|
-
}).option("apiHost", {
|
|
156
|
-
describe: "Uniform host. Defaults to UNIFORM_CLI_BASE_URL env var or https://uniform.app. Supports dotenv.",
|
|
157
|
-
default: process.env.UNIFORM_CLI_BASE_URL || "https://uniform.app",
|
|
158
|
-
demandOption: true,
|
|
159
|
-
type: "string"
|
|
160
|
-
}).option("edgeApiHost", {
|
|
161
|
-
describe: "Uniform edge host. Defaults to UNIFORM_CLI_BASE_EDGE_URL env var or https://uniform.global. Supports dotenv.",
|
|
162
|
-
default: process.env.UNIFORM_CLI_BASE_EDGE_URL || "https://uniform.global",
|
|
163
|
-
demandOption: true,
|
|
164
|
-
type: "string"
|
|
165
|
-
}).option("proxy", {
|
|
166
|
-
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.",
|
|
167
|
-
default: process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy,
|
|
168
|
-
type: "string"
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
function nodeFetchProxy(proxy) {
|
|
172
|
-
if (proxy) {
|
|
173
|
-
console.log(`\u{1F991} Using proxy ${proxy}`);
|
|
174
|
-
}
|
|
175
|
-
const wrappedFetch = (input, init) => {
|
|
176
|
-
if (proxy) {
|
|
177
|
-
const wrappedInit = {
|
|
178
|
-
...init,
|
|
179
|
-
dispatcher: new ProxyAgent(proxy)
|
|
180
|
-
};
|
|
181
|
-
return undiciFetch(input, wrappedInit);
|
|
182
|
-
}
|
|
183
|
-
return undiciFetch(input, init);
|
|
184
|
-
};
|
|
185
|
-
return wrappedFetch;
|
|
186
|
-
}
|
|
187
|
-
function withProjectOptions(yargs34) {
|
|
188
|
-
return yargs34.option("project", {
|
|
189
|
-
describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
|
|
190
|
-
default: process.env.UNIFORM_CLI_PROJECT_ID ?? // deprecated
|
|
191
|
-
process.env.CANVAS_CLI_PROJECT_ID ?? // deprecated
|
|
192
|
-
process.env.UPM_CLI_PROJECT_ID ?? process.env.UNIFORM_PROJECT_ID,
|
|
193
|
-
demandOption: true,
|
|
194
|
-
type: "string",
|
|
195
|
-
alias: ["p"]
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
function withTeamOptions(yargs34) {
|
|
199
|
-
return yargs34.option("team", {
|
|
200
|
-
describe: "Uniform team ID. Defaults to UNIFORM_CLI_TEAM_ID or UNIFORM_TEAM_ID env. Supports dotenv.",
|
|
201
|
-
default: process.env.UNIFORM_CLI_TEAM_ID ?? process.env.UNIFORM_TEAM_ID,
|
|
202
|
-
demandOption: true,
|
|
203
|
-
type: "string",
|
|
204
|
-
alias: ["p"]
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
function withFormatOptions(yargs34) {
|
|
208
|
-
return yargs34.option("format", {
|
|
209
|
-
alias: ["f"],
|
|
210
|
-
describe: "Output format",
|
|
211
|
-
default: "yaml",
|
|
212
|
-
choices: ["yaml", "json"],
|
|
213
|
-
type: "string"
|
|
214
|
-
}).option("filename", {
|
|
215
|
-
alias: ["o"],
|
|
216
|
-
describe: "Output filename. If not specified, write to stdout.",
|
|
217
|
-
type: "string"
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
function withDiffOptions(yargs34) {
|
|
221
|
-
return yargs34.option("diff", {
|
|
222
|
-
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.",
|
|
223
|
-
default: process.env.UNIFORM_CLI_DIFF_MODE ?? "off",
|
|
224
|
-
type: "string",
|
|
225
|
-
choices: ["off", "update", "on"],
|
|
226
|
-
alias: ["d"]
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
function isPathAPackageFile(path5) {
|
|
230
|
-
const extension = extname(path5);
|
|
231
|
-
return extension === ".yaml" || extension === ".yml" || extension === ".json";
|
|
232
|
-
}
|
|
233
|
-
function emitWithFormat(object, format, filename) {
|
|
234
|
-
let content;
|
|
235
|
-
if (filename && !format) {
|
|
236
|
-
const extension = extname(filename);
|
|
237
|
-
if (extension === ".yaml" || extension === ".yml") {
|
|
238
|
-
format = "yaml";
|
|
239
|
-
} else if (extension === ".json") {
|
|
240
|
-
format = "json";
|
|
241
|
-
}
|
|
242
|
-
} else if (!format) {
|
|
243
|
-
throw new Error("Format must be specified when no filename is passed");
|
|
244
|
-
}
|
|
245
|
-
switch (format) {
|
|
246
|
-
case "json":
|
|
247
|
-
content = JSON.stringify(object, null, 2);
|
|
248
|
-
break;
|
|
249
|
-
case "yaml":
|
|
250
|
-
content = dump(object);
|
|
251
|
-
if ("$schema" in object) {
|
|
252
|
-
content = `# yaml-language-server: $schema=<${object["$schema"]}>
|
|
253
|
-
${content}`;
|
|
254
|
-
}
|
|
255
|
-
break;
|
|
256
|
-
default:
|
|
257
|
-
throw new Error(`Unsupported format: ${format}`);
|
|
258
|
-
}
|
|
259
|
-
if (filename) {
|
|
260
|
-
const directory = dirname(filename);
|
|
261
|
-
mkDirByPathSync(directory);
|
|
262
|
-
writeFileSync(filename, content, "utf8");
|
|
263
|
-
} else {
|
|
264
|
-
console.log(content);
|
|
135
|
+
return applyDefaultSyncConfiguration(searchedForm?.config ?? {});
|
|
265
136
|
}
|
|
266
|
-
}
|
|
267
|
-
function mkDirByPathSync(targetDir, { isRelativeToScript = false } = {}) {
|
|
268
|
-
const initDir = isAbsolute(targetDir) ? sep : "";
|
|
269
|
-
const baseDir = isRelativeToScript ? __dirname : ".";
|
|
270
|
-
return targetDir.split(sep).reduce((parentDir, childDir) => {
|
|
271
|
-
const curDir = resolve(baseDir, parentDir, childDir);
|
|
272
|
-
try {
|
|
273
|
-
mkdirSync(curDir);
|
|
274
|
-
} catch (err) {
|
|
275
|
-
if (err.code === "EEXIST") {
|
|
276
|
-
return curDir;
|
|
277
|
-
}
|
|
278
|
-
if (err.code === "ENOENT") {
|
|
279
|
-
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
|
280
|
-
}
|
|
281
|
-
const caughtErr = ["EACCES", "EPERM", "EISDIR"].indexOf(err.code) > -1;
|
|
282
|
-
if (!caughtErr || caughtErr && curDir === resolve(targetDir)) {
|
|
283
|
-
throw err;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return curDir;
|
|
287
|
-
}, initDir);
|
|
288
|
-
}
|
|
289
|
-
function readFileToObject(filename) {
|
|
290
|
-
const file = readFileSync(filename, "utf8");
|
|
291
|
-
return load(file, { filename, json: true });
|
|
292
|
-
}
|
|
293
|
-
async function* paginateAsync(fetchPage, options) {
|
|
294
|
-
const perPage = options.pageSize || 100;
|
|
295
|
-
let offset = 0;
|
|
296
|
-
let pageData = [];
|
|
297
|
-
do {
|
|
298
|
-
pageData = await fetchPage(offset, perPage);
|
|
299
|
-
for (const item of pageData) {
|
|
300
|
-
yield item;
|
|
301
|
-
}
|
|
302
|
-
offset += perPage;
|
|
303
|
-
} while (pageData.length === perPage);
|
|
304
|
-
}
|
|
305
|
-
var defaultSyncConfiguration = {
|
|
306
|
-
entitiesConfig: {},
|
|
307
|
-
directory: "uniform-data",
|
|
308
|
-
allowEmptySource: false,
|
|
309
|
-
format: "yaml",
|
|
310
|
-
mode: "mirror"
|
|
311
|
-
};
|
|
312
|
-
var applyDefaultSyncConfiguration = (config2) => {
|
|
313
|
-
var _a;
|
|
314
|
-
const mergedConfig = {
|
|
315
|
-
serialization: {
|
|
316
|
-
...defaultSyncConfiguration,
|
|
317
|
-
...(config2 == null ? void 0 : config2.serialization) ?? {},
|
|
318
|
-
entitiesConfig: {
|
|
319
|
-
...defaultSyncConfiguration.entitiesConfig,
|
|
320
|
-
...((_a = config2 == null ? void 0 : config2.serialization) == null ? void 0 : _a.entitiesConfig) ?? {}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
};
|
|
324
|
-
for (const entityType in mergedConfig.serialization.entitiesConfig) {
|
|
325
|
-
const entityTypeCasted = entityType;
|
|
326
|
-
const entityConfig = mergedConfig.serialization.entitiesConfig[entityTypeCasted];
|
|
327
|
-
if (Object.keys(entityConfig).length === 0) {
|
|
328
|
-
const separator = mergedConfig.serialization.directory[mergedConfig.serialization.directory.length - 1] === "/" ? "" : "/";
|
|
329
|
-
mergedConfig.serialization.entitiesConfig[entityTypeCasted].directory = isPathAPackageFile(
|
|
330
|
-
mergedConfig.serialization.directory
|
|
331
|
-
) ? mergedConfig.serialization.directory : `${mergedConfig.serialization.directory}${separator}${entityTypeCasted}`;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
return mergedConfig;
|
|
335
|
-
};
|
|
336
|
-
var getEntityOption = ({
|
|
337
|
-
optionName,
|
|
338
|
-
config: config2,
|
|
339
|
-
entityType,
|
|
340
|
-
operation
|
|
341
|
-
}) => {
|
|
342
|
-
var _a, _b, _c, _d, _e, _f;
|
|
343
|
-
if ((_b = (_a = config2.entitiesConfig[entityType]) == null ? void 0 : _a[operation]) == null ? void 0 : _b[optionName]) {
|
|
344
|
-
return (_d = (_c = config2.entitiesConfig[entityType]) == null ? void 0 : _c[operation]) == null ? void 0 : _d[optionName];
|
|
345
|
-
}
|
|
346
|
-
if ((_e = config2.entitiesConfig[entityType]) == null ? void 0 : _e[optionName]) {
|
|
347
|
-
return (_f = config2.entitiesConfig[entityType]) == null ? void 0 : _f[optionName];
|
|
348
|
-
}
|
|
349
|
-
if (config2[optionName]) {
|
|
350
|
-
return config2[optionName];
|
|
351
|
-
}
|
|
352
|
-
throw `No ${optionName} option specified for ${entityType} ${operation}`;
|
|
353
|
-
};
|
|
354
|
-
var getDirectoryOrFilename = ({
|
|
355
|
-
config: config2,
|
|
356
|
-
entityType,
|
|
357
|
-
operation,
|
|
358
|
-
defaultEntityFolderName = entityType
|
|
359
|
-
}) => {
|
|
360
|
-
var _a, _b, _c, _d, _e, _f;
|
|
361
|
-
if ((_b = (_a = config2.entitiesConfig[entityType]) == null ? void 0 : _a[operation]) == null ? void 0 : _b.directory) {
|
|
362
|
-
return (_d = (_c = config2.entitiesConfig[entityType]) == null ? void 0 : _c[operation]) == null ? void 0 : _d.directory;
|
|
363
|
-
}
|
|
364
|
-
if ((_e = config2.entitiesConfig[entityType]) == null ? void 0 : _e.directory) {
|
|
365
|
-
return (_f = config2.entitiesConfig[entityType]) == null ? void 0 : _f.directory;
|
|
366
|
-
}
|
|
367
|
-
const isPackage = isPathAPackageFile(config2.directory);
|
|
368
|
-
if (isPackage) {
|
|
369
|
-
return config2.directory;
|
|
370
|
-
}
|
|
371
|
-
return `${config2.directory}/${defaultEntityFolderName}`;
|
|
372
137
|
};
|
|
373
138
|
|
|
374
139
|
// src/sync/fileSyncEngineDataSource.ts
|
|
@@ -383,12 +148,12 @@ async function createFileSyncEngineDataSource({
|
|
|
383
148
|
}) {
|
|
384
149
|
const dirExists = existsSync(directory);
|
|
385
150
|
if (!dirExists) {
|
|
386
|
-
|
|
151
|
+
mkdirSync(directory, { recursive: true });
|
|
387
152
|
}
|
|
388
153
|
const rawFilenames = await readdir(directory, "utf-8");
|
|
389
154
|
const filenames = new Set(
|
|
390
155
|
rawFilenames.filter((filename) => {
|
|
391
|
-
const ext =
|
|
156
|
+
const ext = extname(filename);
|
|
392
157
|
return ext === `.json` || ext === `.yaml` || ext === `.yml`;
|
|
393
158
|
})
|
|
394
159
|
);
|
|
@@ -408,7 +173,7 @@ async function createFileSyncEngineDataSource({
|
|
|
408
173
|
yield object;
|
|
409
174
|
} catch (e) {
|
|
410
175
|
console.error(red(`Failed to read ${fullFilename}, data is likely invalid.
|
|
411
|
-
${e
|
|
176
|
+
${e?.message}`));
|
|
412
177
|
throw e;
|
|
413
178
|
}
|
|
414
179
|
}
|
|
@@ -474,7 +239,6 @@ async function syncEngine({
|
|
|
474
239
|
onBeforeCompareObjects,
|
|
475
240
|
onBeforeWriteObject
|
|
476
241
|
}) {
|
|
477
|
-
var _a, _b;
|
|
478
242
|
const targetItems = /* @__PURE__ */ new Map();
|
|
479
243
|
const deleteTracker = /* @__PURE__ */ new Set();
|
|
480
244
|
const processDelete = async (object) => {
|
|
@@ -510,7 +274,7 @@ async function syncEngine({
|
|
|
510
274
|
sourceHasItems = true;
|
|
511
275
|
const ids = Array.isArray(sourceObject.id) ? sourceObject.id : [sourceObject.id];
|
|
512
276
|
const targetObject = targetItems.get(ids[0]);
|
|
513
|
-
const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) =>
|
|
277
|
+
const invalidTargetObjects = ids.map((i) => targetItems.get(i)).filter((o) => o?.object !== targetObject?.object);
|
|
514
278
|
if (targetObject && invalidTargetObjects.length == 0) {
|
|
515
279
|
sourceObject = onBeforeCompareObjects ? await onBeforeCompareObjects(sourceObject, targetObject) : sourceObject;
|
|
516
280
|
if (!compareContents(sourceObject, targetObject)) {
|
|
@@ -558,8 +322,7 @@ async function syncEngine({
|
|
|
558
322
|
};
|
|
559
323
|
if (invalidTargetObjects.length > 0) {
|
|
560
324
|
[...invalidTargetObjects, targetObject].forEach((o) => {
|
|
561
|
-
|
|
562
|
-
(_a2 = Array.isArray(o == null ? void 0 : o.id) ? o == null ? void 0 : o.id : [o == null ? void 0 : o.id]) == null ? void 0 : _a2.forEach((i) => i && targetItems.delete(i));
|
|
325
|
+
(Array.isArray(o?.id) ? o?.id : [o?.id])?.forEach((i) => i && targetItems.delete(i));
|
|
563
326
|
});
|
|
564
327
|
const deletes = invalidTargetObjects.filter((io) => typeof io !== "undefined").map(async (io) => {
|
|
565
328
|
await processDelete(io);
|
|
@@ -586,7 +349,7 @@ async function syncEngine({
|
|
|
586
349
|
});
|
|
587
350
|
await Promise.all(deletes);
|
|
588
351
|
}
|
|
589
|
-
await Promise.all([
|
|
352
|
+
await Promise.all([source.onSyncComplete?.(false), target.onSyncComplete?.(true)]);
|
|
590
353
|
}
|
|
591
354
|
var SyncEngineError = class _SyncEngineError extends Error {
|
|
592
355
|
constructor(innerError, sourceObject) {
|
|
@@ -691,7 +454,7 @@ import { createHash } from "crypto";
|
|
|
691
454
|
import fsj from "fs-jetpack";
|
|
692
455
|
import sizeOf from "image-size";
|
|
693
456
|
import PQueue from "p-queue";
|
|
694
|
-
import { dirname
|
|
457
|
+
import { dirname, join as join2 } from "path";
|
|
695
458
|
var FILES_DIRECTORY_NAME = "files";
|
|
696
459
|
var escapeRegExp = (string) => {
|
|
697
460
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -735,7 +498,7 @@ var urlToFileName = (url, hash) => {
|
|
|
735
498
|
};
|
|
736
499
|
var getFilesDirectory = (directory) => {
|
|
737
500
|
const isPackage = isPathAPackageFile(directory);
|
|
738
|
-
return isPackage ?
|
|
501
|
+
return isPackage ? dirname(directory) : (
|
|
739
502
|
// If we are syncing to a directory, we want to write all files into a
|
|
740
503
|
// top-lvl folder. That way any entities that contain files will sync to the
|
|
741
504
|
// same directory, so there is no duplication
|
|
@@ -809,7 +572,7 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
|
|
|
809
572
|
const uniformFileUrlMatches = getUniformFileUrlMatches(objectAsString);
|
|
810
573
|
const writeDirectory = getFilesDirectory(options.directory);
|
|
811
574
|
const isPackage = isPathAPackageFile(options.directory);
|
|
812
|
-
const legacyWriteDirectory = isPackage ?
|
|
575
|
+
const legacyWriteDirectory = isPackage ? dirname(options.directory) : options.directory;
|
|
813
576
|
if (uniformFileUrlMatches) {
|
|
814
577
|
const fileUploadQueue = new PQueue({ concurrency: 3 });
|
|
815
578
|
for (const match of uniformFileUrlMatches) {
|
|
@@ -886,7 +649,7 @@ var extractAndUploadUniformFilesForObject = async (object, options) => {
|
|
|
886
649
|
}
|
|
887
650
|
const file2 = await options.fileClient.get({ id });
|
|
888
651
|
if (!file2 || file2.state !== FILE_READY_STATE || !file2.url) {
|
|
889
|
-
await new Promise((
|
|
652
|
+
await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
890
653
|
return checkForFile();
|
|
891
654
|
}
|
|
892
655
|
return file2.url;
|
|
@@ -975,11 +738,10 @@ var replaceRemoteUrlsWithLocalReferences = async (sourceObject, targetObject, op
|
|
|
975
738
|
return JSON.parse(sourceObjectAsString);
|
|
976
739
|
};
|
|
977
740
|
var updateAssetFileIdBasedOnUrl = async (asset, options) => {
|
|
978
|
-
var _a;
|
|
979
741
|
if (!asset.asset.fields) {
|
|
980
742
|
return asset;
|
|
981
743
|
}
|
|
982
|
-
const fileUrl =
|
|
744
|
+
const fileUrl = asset.asset.fields.url?.value;
|
|
983
745
|
if (!fileUrl) {
|
|
984
746
|
return asset;
|
|
985
747
|
}
|
|
@@ -1009,10 +771,7 @@ import { convertAssetToPutAsset } from "@uniformdev/assets";
|
|
|
1009
771
|
|
|
1010
772
|
// src/commands/canvas/commands/asset/_util.ts
|
|
1011
773
|
var selectAssetIdentifier = (e) => e.asset._id;
|
|
1012
|
-
var selectAssetDisplayName = (e) => {
|
|
1013
|
-
var _a, _b;
|
|
1014
|
-
return `${((_b = (_a = e.asset.fields) == null ? void 0 : _a.title) == null ? void 0 : _b.value) ?? "Untitled"} (pid: ${selectAssetIdentifier(e)})`;
|
|
1015
|
-
};
|
|
774
|
+
var selectAssetDisplayName = (e) => `${e.asset.fields?.title?.value ?? "Untitled"} (pid: ${selectAssetIdentifier(e)})`;
|
|
1016
775
|
|
|
1017
776
|
// src/commands/canvas/util.ts
|
|
1018
777
|
import {
|
|
@@ -1148,9 +907,8 @@ var AssetPullModule = {
|
|
|
1148
907
|
let target;
|
|
1149
908
|
const isPackage = isPathAPackageFile(directory);
|
|
1150
909
|
const onBeforeDeleteObject = async (id, object) => {
|
|
1151
|
-
var _a, _b;
|
|
1152
910
|
const asset = object.object;
|
|
1153
|
-
if (!
|
|
911
|
+
if (!asset.asset.fields?.url?.value) {
|
|
1154
912
|
return;
|
|
1155
913
|
}
|
|
1156
914
|
await deleteDownloadedFileByUrl(asset.asset.fields.url.value, {
|
|
@@ -1187,7 +945,6 @@ var AssetPullModule = {
|
|
|
1187
945
|
allowEmptySource: allowEmptySource ?? true,
|
|
1188
946
|
log: createSyncEngineConsoleLogger({ diffMode }),
|
|
1189
947
|
onBeforeCompareObjects: async (sourceObject, targetObject) => {
|
|
1190
|
-
var _a, _b;
|
|
1191
948
|
delete sourceObject.object.asset._author;
|
|
1192
949
|
const sourceObjectWithPotentiallySwappedUrl = await replaceRemoteUrlsWithLocalReferences(
|
|
1193
950
|
sourceObject,
|
|
@@ -1197,7 +954,7 @@ var AssetPullModule = {
|
|
|
1197
954
|
fileClient
|
|
1198
955
|
}
|
|
1199
956
|
);
|
|
1200
|
-
if (
|
|
957
|
+
if (sourceObjectWithPotentiallySwappedUrl.object.asset.fields?.url && targetObject.object.asset.fields?.url && sourceObjectWithPotentiallySwappedUrl.object.asset.fields.url.value === targetObject.object.asset.fields.url.value) {
|
|
1201
958
|
targetObject.object.asset.fields.file = sourceObjectWithPotentiallySwappedUrl.object.asset.fields.file;
|
|
1202
959
|
}
|
|
1203
960
|
return sourceObjectWithPotentiallySwappedUrl;
|
|
@@ -2417,7 +2174,7 @@ var CompositionPullModule = {
|
|
|
2417
2174
|
const packageContents = readCanvasPackage(directory, false);
|
|
2418
2175
|
target = await createArraySyncEngineDataSource({
|
|
2419
2176
|
name: `Package file ${directory}`,
|
|
2420
|
-
objects:
|
|
2177
|
+
objects: packageContents?.compositions ?? [],
|
|
2421
2178
|
selectIdentifier: selectIdentifier3,
|
|
2422
2179
|
selectDisplayName: selectDisplayName3,
|
|
2423
2180
|
onSyncComplete: async (_, synced) => {
|
|
@@ -5551,10 +5308,9 @@ var EnrichmentGetModule = {
|
|
|
5551
5308
|
)
|
|
5552
5309
|
),
|
|
5553
5310
|
handler: async ({ apiHost, apiKey, proxy, id, format, project: projectId, filename }) => {
|
|
5554
|
-
var _a, _b;
|
|
5555
5311
|
const fetch3 = nodeFetchProxy(proxy);
|
|
5556
5312
|
const client = new UncachedEnrichmentClient({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
5557
|
-
const res = (
|
|
5313
|
+
const res = (await client.get())?.enrichments?.filter((enr) => enr.id === id);
|
|
5558
5314
|
if (res.length === 0) {
|
|
5559
5315
|
console.error("Enrichment did not exist");
|
|
5560
5316
|
process.exit(1);
|
|
@@ -5609,7 +5365,6 @@ function createEnrichmentEngineDataSource({
|
|
|
5609
5365
|
await client.removeCategory({ enrichmentId: providerId });
|
|
5610
5366
|
},
|
|
5611
5367
|
writeObject: async (object, existingObject) => {
|
|
5612
|
-
var _a;
|
|
5613
5368
|
await client.upsertCategory({
|
|
5614
5369
|
enrichment: object.object
|
|
5615
5370
|
});
|
|
@@ -5619,7 +5374,7 @@ function createEnrichmentEngineDataSource({
|
|
|
5619
5374
|
});
|
|
5620
5375
|
const target = createEnrichmentValueEngineDataSource({
|
|
5621
5376
|
categoryId: object.object.id,
|
|
5622
|
-
values:
|
|
5377
|
+
values: existingObject?.object?.values ?? [],
|
|
5623
5378
|
client
|
|
5624
5379
|
});
|
|
5625
5380
|
await syncEngine({
|
|
@@ -6852,7 +6607,7 @@ import yargs23 from "yargs";
|
|
|
6852
6607
|
import yargs22 from "yargs";
|
|
6853
6608
|
|
|
6854
6609
|
// src/commands/integration/commands/definition/edgehancer/deploy.ts
|
|
6855
|
-
import { readFileSync
|
|
6610
|
+
import { readFileSync } from "fs";
|
|
6856
6611
|
|
|
6857
6612
|
// src/commands/integration/commands/definition/edgehancer/EdgehancerClient.ts
|
|
6858
6613
|
import { createLimitPolicy } from "@uniformdev/canvas";
|
|
@@ -6923,7 +6678,7 @@ var IntegrationEdgehancerDeployModule = {
|
|
|
6923
6678
|
handler: async ({ apiHost, apiKey, proxy, filename, team: teamId, archetype, connectorType, hook }) => {
|
|
6924
6679
|
const fetch3 = nodeFetchProxy(proxy);
|
|
6925
6680
|
const client = new EdgehancerClient({ apiKey, apiHost, fetch: fetch3, teamId });
|
|
6926
|
-
const code =
|
|
6681
|
+
const code = readFileSync(filename, "utf8");
|
|
6927
6682
|
await client.deploy({ archetype, code, connectorType, hook });
|
|
6928
6683
|
}
|
|
6929
6684
|
};
|
|
@@ -7131,7 +6886,7 @@ var makeSpinner = () => {
|
|
|
7131
6886
|
const spin = async (text) => {
|
|
7132
6887
|
const spinner = ora(text).start();
|
|
7133
6888
|
spinners.push(spinner);
|
|
7134
|
-
const minWait = new Promise((
|
|
6889
|
+
const minWait = new Promise((resolve) => setTimeout(resolve, 500));
|
|
7135
6890
|
return async () => {
|
|
7136
6891
|
await minWait;
|
|
7137
6892
|
spinner.stop();
|
|
@@ -7147,10 +6902,20 @@ import { PostHog } from "posthog-node";
|
|
|
7147
6902
|
// package.json
|
|
7148
6903
|
var package_default = {
|
|
7149
6904
|
name: "@uniformdev/cli",
|
|
7150
|
-
version: "19.
|
|
6905
|
+
version: "19.157.0",
|
|
7151
6906
|
description: "Uniform command line interface tool",
|
|
7152
6907
|
license: "SEE LICENSE IN LICENSE.txt",
|
|
7153
6908
|
main: "./cli.js",
|
|
6909
|
+
exports: {
|
|
6910
|
+
".": {
|
|
6911
|
+
types: "./dist/index.d.mts",
|
|
6912
|
+
default: "./cli.js"
|
|
6913
|
+
},
|
|
6914
|
+
"./config": {
|
|
6915
|
+
types: "./dist/defaultConfig.d.mts",
|
|
6916
|
+
default: "./dist/defaultConfig.mjs"
|
|
6917
|
+
}
|
|
6918
|
+
},
|
|
7154
6919
|
types: "./dist/index.d.mts",
|
|
7155
6920
|
sideEffects: false,
|
|
7156
6921
|
scripts: {
|
|
@@ -7172,7 +6937,7 @@ var package_default = {
|
|
|
7172
6937
|
"@uniformdev/redirect": "workspace:*",
|
|
7173
6938
|
"call-bind": "^1.0.2",
|
|
7174
6939
|
colorette: "2.0.20",
|
|
7175
|
-
cosmiconfig: "
|
|
6940
|
+
cosmiconfig: "9.0.0",
|
|
7176
6941
|
"cosmiconfig-typescript-loader": "5.0.0",
|
|
7177
6942
|
diff: "^5.0.0",
|
|
7178
6943
|
dotenv: "^16.0.3",
|
|
@@ -7249,8 +7014,7 @@ var Telemetry = class {
|
|
|
7249
7014
|
this.send("logged in");
|
|
7250
7015
|
}
|
|
7251
7016
|
send(event, properties = {}) {
|
|
7252
|
-
|
|
7253
|
-
(_a = this.posthog) == null ? void 0 : _a.capture({
|
|
7017
|
+
this.posthog?.capture({
|
|
7254
7018
|
distinctId: this.distinctId,
|
|
7255
7019
|
event: [this.prefix, event].join(" "),
|
|
7256
7020
|
properties: {
|
|
@@ -7260,9 +7024,8 @@ var Telemetry = class {
|
|
|
7260
7024
|
});
|
|
7261
7025
|
}
|
|
7262
7026
|
shutdown() {
|
|
7263
|
-
var _a;
|
|
7264
7027
|
this.send("exited", { exitCode: process.exitCode });
|
|
7265
|
-
return
|
|
7028
|
+
return this.posthog?.shutdown();
|
|
7266
7029
|
}
|
|
7267
7030
|
};
|
|
7268
7031
|
|
|
@@ -7275,7 +7038,7 @@ import jwt from "jsonwebtoken";
|
|
|
7275
7038
|
import open from "open";
|
|
7276
7039
|
|
|
7277
7040
|
// src/url.ts
|
|
7278
|
-
var makeUrl = (baseUrl,
|
|
7041
|
+
var makeUrl = (baseUrl, path4) => [baseUrl.trim().replace(/\/+$/, ""), path4.trim().replace(/^\/+/, "")].join("/");
|
|
7279
7042
|
|
|
7280
7043
|
// src/auth/getBearerToken.ts
|
|
7281
7044
|
async function getBearerToken(baseUrl) {
|
|
@@ -7380,8 +7143,8 @@ var getLimitsSchema = z.object({
|
|
|
7380
7143
|
})
|
|
7381
7144
|
});
|
|
7382
7145
|
var createClient = (baseUrl, authToken) => {
|
|
7383
|
-
const request2 = async (
|
|
7384
|
-
const res = await fetch(makeUrl(baseUrl,
|
|
7146
|
+
const request2 = async (path4, opts, allowedNon2xxStatusCodes = []) => {
|
|
7147
|
+
const res = await fetch(makeUrl(baseUrl, path4), {
|
|
7385
7148
|
...opts,
|
|
7386
7149
|
headers: { Authorization: `Bearer ${authToken}` }
|
|
7387
7150
|
});
|
|
@@ -7389,18 +7152,18 @@ var createClient = (baseUrl, authToken) => {
|
|
|
7389
7152
|
return res;
|
|
7390
7153
|
} else {
|
|
7391
7154
|
throw new Error(
|
|
7392
|
-
`Non-2xx API response: ${opts.method} ${
|
|
7155
|
+
`Non-2xx API response: ${opts.method} ${path4} responded with ${res.status} ${res.statusText}`
|
|
7393
7156
|
);
|
|
7394
7157
|
}
|
|
7395
7158
|
};
|
|
7396
|
-
const requestJson = async (
|
|
7397
|
-
const res = await request2(
|
|
7159
|
+
const requestJson = async (path4, opts, schema2, allowedNon2xxStatusCodes = []) => {
|
|
7160
|
+
const res = await request2(path4, opts, allowedNon2xxStatusCodes);
|
|
7398
7161
|
const data = await res.json();
|
|
7399
7162
|
const parseResult = schema2.safeParse(data);
|
|
7400
7163
|
if (parseResult.success) {
|
|
7401
7164
|
return parseResult.data;
|
|
7402
7165
|
} else {
|
|
7403
|
-
throw new Error(`Invalid ${opts.method} ${
|
|
7166
|
+
throw new Error(`Invalid ${opts.method} ${path4} response: ${parseResult.error.message}`);
|
|
7404
7167
|
}
|
|
7405
7168
|
};
|
|
7406
7169
|
return {
|
|
@@ -7522,7 +7285,7 @@ var runNpm = async (workDir, args, { inherit, env } = {}) => {
|
|
|
7522
7285
|
${err.message}`);
|
|
7523
7286
|
}
|
|
7524
7287
|
if (result.exitCode !== 0) {
|
|
7525
|
-
throw new Error(`Command npm ${args.join(" ")} exitted with code ${result
|
|
7288
|
+
throw new Error(`Command npm ${args.join(" ")} exitted with code ${result?.exitCode}}: ${result.stderr}`);
|
|
7526
7289
|
}
|
|
7527
7290
|
return result.stdout;
|
|
7528
7291
|
};
|
|
@@ -7534,7 +7297,7 @@ import fsj2 from "fs-jetpack";
|
|
|
7534
7297
|
import * as git from "isomorphic-git";
|
|
7535
7298
|
import * as http from "isomorphic-git/http/node/index.js";
|
|
7536
7299
|
import os from "os";
|
|
7537
|
-
import
|
|
7300
|
+
import path from "path";
|
|
7538
7301
|
async function cloneStarter({
|
|
7539
7302
|
spin,
|
|
7540
7303
|
githubPath,
|
|
@@ -7542,7 +7305,7 @@ async function cloneStarter({
|
|
|
7542
7305
|
dotEnvFile
|
|
7543
7306
|
}) {
|
|
7544
7307
|
const done = await spin("Fetching starter code...");
|
|
7545
|
-
const cloneDir =
|
|
7308
|
+
const cloneDir = path.join(os.tmpdir(), `uniform-new-${crypto2.randomBytes(20).toString("hex")}`);
|
|
7546
7309
|
const [user, repo, ...pathSegments] = githubPath.split("/");
|
|
7547
7310
|
try {
|
|
7548
7311
|
await git.clone({
|
|
@@ -7560,10 +7323,10 @@ async function cloneStarter({
|
|
|
7560
7323
|
if (fs3.existsSync(targetDir) && fs3.readdirSync(targetDir).length > 0) {
|
|
7561
7324
|
throw new Error(`"${targetDir}" is not empty`);
|
|
7562
7325
|
}
|
|
7563
|
-
const starterDir =
|
|
7326
|
+
const starterDir = path.join(cloneDir, ...pathSegments);
|
|
7564
7327
|
fsj2.copy(starterDir, targetDir, { overwrite: true });
|
|
7565
7328
|
if (dotEnvFile) {
|
|
7566
|
-
fs3.writeFileSync(
|
|
7329
|
+
fs3.writeFileSync(path.resolve(targetDir, ".env"), dotEnvFile, "utf-8");
|
|
7567
7330
|
}
|
|
7568
7331
|
console.log(`
|
|
7569
7332
|
Your project now lives in ${targetDir} \u2728`);
|
|
@@ -7579,9 +7342,9 @@ Installing project dependencies...
|
|
|
7579
7342
|
}
|
|
7580
7343
|
|
|
7581
7344
|
// src/projects/getOrCreateProject.ts
|
|
7582
|
-
import fs4, { existsSync as existsSync2, mkdirSync as
|
|
7345
|
+
import fs4, { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
7583
7346
|
import inquirer2 from "inquirer";
|
|
7584
|
-
import
|
|
7347
|
+
import path2 from "path";
|
|
7585
7348
|
import slugify from "slugify";
|
|
7586
7349
|
var newProjectId = "$new";
|
|
7587
7350
|
async function getOrCreateProject({
|
|
@@ -7676,8 +7439,7 @@ async function chooseExistingProject({
|
|
|
7676
7439
|
teamId,
|
|
7677
7440
|
user
|
|
7678
7441
|
}) {
|
|
7679
|
-
|
|
7680
|
-
const projects = (((_a = user.teams.find((t) => t.team.id === teamId)) == null ? void 0 : _a.team.sites) ?? []).map((t) => ({
|
|
7442
|
+
const projects = (user.teams.find((t) => t.team.id === teamId)?.team.sites ?? []).map((t) => ({
|
|
7681
7443
|
name: t.name,
|
|
7682
7444
|
value: t.id
|
|
7683
7445
|
}));
|
|
@@ -7692,7 +7454,7 @@ async function chooseExistingProject({
|
|
|
7692
7454
|
]);
|
|
7693
7455
|
return {
|
|
7694
7456
|
projectId: result.projectId,
|
|
7695
|
-
projectName:
|
|
7457
|
+
projectName: projects.find((p) => p.value === result.projectId)?.name
|
|
7696
7458
|
};
|
|
7697
7459
|
}
|
|
7698
7460
|
function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
|
|
@@ -7704,10 +7466,10 @@ function validateProjectName(projectName, checkTargetDir, explicitTargetDir) {
|
|
|
7704
7466
|
if (checkTargetDir) {
|
|
7705
7467
|
let targetDir = explicitTargetDir ?? process.cwd();
|
|
7706
7468
|
if (!existsSync2(targetDir)) {
|
|
7707
|
-
|
|
7469
|
+
mkdirSync2(targetDir, { recursive: true });
|
|
7708
7470
|
}
|
|
7709
7471
|
if (fs4.readdirSync(targetDir).length > 0) {
|
|
7710
|
-
targetDir =
|
|
7472
|
+
targetDir = path2.resolve(targetDir, projectNameSlug);
|
|
7711
7473
|
if (fs4.existsSync(targetDir)) {
|
|
7712
7474
|
throw new Error(`${targetDir} already exists, choose a different name.`);
|
|
7713
7475
|
}
|
|
@@ -7961,9 +7723,9 @@ npm run dev
|
|
|
7961
7723
|
}
|
|
7962
7724
|
|
|
7963
7725
|
// src/commands/new/commands/new-mesh-integration.ts
|
|
7964
|
-
import { existsSync as existsSync3, mkdirSync as
|
|
7726
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
7965
7727
|
import inquirer5 from "inquirer";
|
|
7966
|
-
import
|
|
7728
|
+
import path3 from "path";
|
|
7967
7729
|
import slugify2 from "slugify";
|
|
7968
7730
|
async function newMeshIntegrationHandler({
|
|
7969
7731
|
spin,
|
|
@@ -8004,19 +7766,19 @@ async function newMeshIntegrationHandler({
|
|
|
8004
7766
|
targetDir
|
|
8005
7767
|
});
|
|
8006
7768
|
let done = await spin("Registering integration to team...");
|
|
8007
|
-
const pathToManifest =
|
|
7769
|
+
const pathToManifest = path3.resolve(targetDir, "mesh-manifest.json");
|
|
8008
7770
|
if (!existsSync3(pathToManifest)) {
|
|
8009
7771
|
throw new Error("Invalid integration starter cloned: missing `mesh-manifest.json`");
|
|
8010
7772
|
}
|
|
8011
|
-
const manifestContents =
|
|
7773
|
+
const manifestContents = readFileSync2(pathToManifest, "utf-8");
|
|
8012
7774
|
const manifestJson = JSON.parse(manifestContents);
|
|
8013
7775
|
manifestJson.type = typeSlug;
|
|
8014
7776
|
manifestJson.displayName = name;
|
|
8015
|
-
|
|
8016
|
-
const packageJsonPath =
|
|
8017
|
-
const packageJson = JSON.parse(
|
|
7777
|
+
writeFileSync(pathToManifest, JSON.stringify(manifestJson, null, 2), "utf-8");
|
|
7778
|
+
const packageJsonPath = path3.resolve(targetDir, "package.json");
|
|
7779
|
+
const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
|
|
8018
7780
|
packageJson.name = typeSlug;
|
|
8019
|
-
|
|
7781
|
+
writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
8020
7782
|
const fullMeshAppKey = await uniformClient.registerMeshIntegration({ teamId, manifest: manifestJson });
|
|
8021
7783
|
await done();
|
|
8022
7784
|
await runNpmInstall();
|
|
@@ -8060,10 +7822,10 @@ function validateIntegrationName(integrationName, explicitOutputPath) {
|
|
|
8060
7822
|
}
|
|
8061
7823
|
let targetDir = explicitOutputPath ?? process.cwd();
|
|
8062
7824
|
if (!existsSync3(targetDir)) {
|
|
8063
|
-
|
|
7825
|
+
mkdirSync3(targetDir, { recursive: true });
|
|
8064
7826
|
}
|
|
8065
7827
|
if (readdirSync(targetDir).length > 0) {
|
|
8066
|
-
targetDir =
|
|
7828
|
+
targetDir = path3.resolve(targetDir, typeSlug);
|
|
8067
7829
|
if (existsSync3(targetDir)) {
|
|
8068
7830
|
throw new Error(`${targetDir} directory already exists, choose a different name.`);
|
|
8069
7831
|
}
|
|
@@ -8607,12 +8369,11 @@ var ProjectMapNodeGetModule = {
|
|
|
8607
8369
|
)
|
|
8608
8370
|
),
|
|
8609
8371
|
handler: async ({ apiHost, apiKey, proxy, id, projectMapId, format, project: projectId, filename }) => {
|
|
8610
|
-
var _a;
|
|
8611
8372
|
const fetch3 = nodeFetchProxy(proxy);
|
|
8612
8373
|
const client = new UncachedProjectMapClient7({ apiKey, apiHost, fetch: fetch3, projectId });
|
|
8613
8374
|
console.log("Debugging params for node get", { projectMapId, id, projectId });
|
|
8614
8375
|
const res = await client.getNodes({ projectMapId, id });
|
|
8615
|
-
if (
|
|
8376
|
+
if (res.nodes?.length === 0) {
|
|
8616
8377
|
console.error("Project map node does not exist");
|
|
8617
8378
|
process.exit(1);
|
|
8618
8379
|
} else {
|
|
@@ -9317,12 +9078,11 @@ var SyncPullModule = {
|
|
|
9317
9078
|
)
|
|
9318
9079
|
),
|
|
9319
9080
|
handler: async ({ serialization, ...otherParams }) => {
|
|
9320
|
-
var _a, _b;
|
|
9321
9081
|
const config2 = serialization;
|
|
9322
9082
|
let isUsingDeprecatedPatternConfig = false;
|
|
9323
9083
|
if (config2.entitiesConfig.pattern) {
|
|
9324
9084
|
isUsingDeprecatedPatternConfig = true;
|
|
9325
|
-
|
|
9085
|
+
config2.entitiesConfig.componentPattern ??= config2.entitiesConfig.pattern;
|
|
9326
9086
|
}
|
|
9327
9087
|
const enabledEntities = Object.entries({
|
|
9328
9088
|
locale: LocalePullModule,
|
|
@@ -9347,8 +9107,7 @@ var SyncPullModule = {
|
|
|
9347
9107
|
contentType: ContentTypePullModule
|
|
9348
9108
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9349
9109
|
}).filter(([entityType]) => {
|
|
9350
|
-
|
|
9351
|
-
return Boolean((_a2 = config2.entitiesConfig) == null ? void 0 : _a2[entityType]) && ((_c = (_b2 = config2.entitiesConfig) == null ? void 0 : _b2[entityType]) == null ? void 0 : _c.disabled) !== true && ((_f = (_e = (_d = config2.entitiesConfig) == null ? void 0 : _d[entityType]) == null ? void 0 : _e.pull) == null ? void 0 : _f.disabled) !== true;
|
|
9110
|
+
return Boolean(config2.entitiesConfig?.[entityType]) && config2.entitiesConfig?.[entityType]?.disabled !== true && config2.entitiesConfig?.[entityType]?.pull?.disabled !== true;
|
|
9352
9111
|
});
|
|
9353
9112
|
if (enabledEntities.length === 0) {
|
|
9354
9113
|
throw new Error(
|
|
@@ -9359,7 +9118,7 @@ var SyncPullModule = {
|
|
|
9359
9118
|
const entityConfigSupportsPullState = (entityConfig2) => {
|
|
9360
9119
|
return entityConfig2 !== void 0 && "state" in entityConfig2;
|
|
9361
9120
|
};
|
|
9362
|
-
const entityConfig =
|
|
9121
|
+
const entityConfig = config2.entitiesConfig?.[entityType];
|
|
9363
9122
|
try {
|
|
9364
9123
|
await spinPromise(
|
|
9365
9124
|
module3.handler({
|
|
@@ -9378,7 +9137,7 @@ var SyncPullModule = {
|
|
|
9378
9137
|
failText(error) {
|
|
9379
9138
|
return `${entityType}
|
|
9380
9139
|
|
|
9381
|
-
${error.stack}`;
|
|
9140
|
+
${error.stack ?? error.message}`;
|
|
9382
9141
|
}
|
|
9383
9142
|
}
|
|
9384
9143
|
);
|
|
@@ -9433,12 +9192,11 @@ var SyncPushModule = {
|
|
|
9433
9192
|
)
|
|
9434
9193
|
),
|
|
9435
9194
|
handler: async ({ serialization, ...otherParams }) => {
|
|
9436
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
9437
9195
|
const config2 = serialization;
|
|
9438
9196
|
let isUsingDeprecatedPatternConfig = false;
|
|
9439
9197
|
if (config2.entitiesConfig.pattern) {
|
|
9440
9198
|
isUsingDeprecatedPatternConfig = true;
|
|
9441
|
-
|
|
9199
|
+
config2.entitiesConfig.componentPattern ??= config2.entitiesConfig.pattern;
|
|
9442
9200
|
}
|
|
9443
9201
|
const enabledEntities = Object.entries({
|
|
9444
9202
|
locale: LocalePushModule,
|
|
@@ -9463,8 +9221,7 @@ var SyncPushModule = {
|
|
|
9463
9221
|
entryPattern: EntryPatternPushModule
|
|
9464
9222
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9465
9223
|
}).filter(([entityType]) => {
|
|
9466
|
-
|
|
9467
|
-
return Boolean((_a2 = config2.entitiesConfig) == null ? void 0 : _a2[entityType]) && ((_c2 = (_b2 = config2.entitiesConfig) == null ? void 0 : _b2[entityType]) == null ? void 0 : _c2.disabled) !== true && ((_f2 = (_e2 = (_d2 = config2.entitiesConfig) == null ? void 0 : _d2[entityType]) == null ? void 0 : _e2.push) == null ? void 0 : _f2.disabled) !== true;
|
|
9224
|
+
return Boolean(config2.entitiesConfig?.[entityType]) && config2.entitiesConfig?.[entityType]?.disabled !== true && config2.entitiesConfig?.[entityType]?.push?.disabled !== true;
|
|
9468
9225
|
});
|
|
9469
9226
|
if (enabledEntities.length === 0) {
|
|
9470
9227
|
throw new Error(
|
|
@@ -9490,7 +9247,7 @@ var SyncPushModule = {
|
|
|
9490
9247
|
failText(error) {
|
|
9491
9248
|
return `${entityType}
|
|
9492
9249
|
|
|
9493
|
-
${error.stack}`;
|
|
9250
|
+
${error.stack ?? error.message}`;
|
|
9494
9251
|
}
|
|
9495
9252
|
}
|
|
9496
9253
|
);
|
|
@@ -9498,16 +9255,16 @@ var SyncPushModule = {
|
|
|
9498
9255
|
process.exit(1);
|
|
9499
9256
|
}
|
|
9500
9257
|
}
|
|
9501
|
-
if (
|
|
9258
|
+
if (config2.entitiesConfig?.componentPattern && config2.entitiesConfig?.componentPattern?.push?.disabled !== true && config2.entitiesConfig?.componentPattern?.publish) {
|
|
9502
9259
|
await ComponentPatternPublishModule.handler({ ...otherParams, all: true });
|
|
9503
9260
|
}
|
|
9504
|
-
if (
|
|
9261
|
+
if (config2.entitiesConfig?.composition && config2.entitiesConfig?.composition?.push?.disabled !== true && config2.entitiesConfig?.composition?.publish) {
|
|
9505
9262
|
await CompositionPublishModule.handler({ ...otherParams, all: true });
|
|
9506
9263
|
}
|
|
9507
|
-
if (
|
|
9264
|
+
if (config2.entitiesConfig?.entry && config2.entitiesConfig?.entry?.push?.disabled !== true && config2.entitiesConfig?.entry?.publish) {
|
|
9508
9265
|
await EntryPublishModule.handler({ ...otherParams, all: true });
|
|
9509
9266
|
}
|
|
9510
|
-
if (
|
|
9267
|
+
if (config2.entitiesConfig?.entryPattern && config2.entitiesConfig?.entryPattern?.push?.disabled !== true && config2.entitiesConfig?.entryPattern?.publish) {
|
|
9511
9268
|
await EntryPatternPublishModule.handler({ ...otherParams, all: true });
|
|
9512
9269
|
}
|
|
9513
9270
|
}
|
|
@@ -9617,7 +9374,7 @@ var updateCache = async (file, latest, lastUpdate) => {
|
|
|
9617
9374
|
});
|
|
9618
9375
|
await fs5.writeFile(file, content, "utf8");
|
|
9619
9376
|
};
|
|
9620
|
-
var loadPackage = ({ url, timeout }, authInfo) => new Promise((
|
|
9377
|
+
var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve, reject) => {
|
|
9621
9378
|
const options = {
|
|
9622
9379
|
host: url.hostname,
|
|
9623
9380
|
path: url.pathname,
|
|
@@ -9648,7 +9405,7 @@ var loadPackage = ({ url, timeout }, authInfo) => new Promise((resolve2, reject)
|
|
|
9648
9405
|
response.on("end", () => {
|
|
9649
9406
|
try {
|
|
9650
9407
|
const parsedData = JSON.parse(rawData);
|
|
9651
|
-
|
|
9408
|
+
resolve(parsedData);
|
|
9652
9409
|
} catch (e) {
|
|
9653
9410
|
reject(e);
|
|
9654
9411
|
}
|
|
@@ -9662,7 +9419,7 @@ var getMostRecent = async ({ full, scope }, distTag, timeout) => {
|
|
|
9662
9419
|
try {
|
|
9663
9420
|
spec = await loadPackage({ url, timeout });
|
|
9664
9421
|
} catch (err) {
|
|
9665
|
-
if (
|
|
9422
|
+
if (err?.code && String(err.code).startsWith("4")) {
|
|
9666
9423
|
const registryAuthToken = __require("registry-auth-token");
|
|
9667
9424
|
const authInfo = registryAuthToken(regURL, { recursive: true });
|
|
9668
9425
|
spec = await loadPackage({ url, timeout }, authInfo);
|
|
@@ -9743,14 +9500,14 @@ import { join as join4 } from "path";
|
|
|
9743
9500
|
|
|
9744
9501
|
// src/fs.ts
|
|
9745
9502
|
import { promises as fs6 } from "fs";
|
|
9746
|
-
async function readJSON(
|
|
9747
|
-
const fileContents = await fs6.readFile(
|
|
9503
|
+
async function readJSON(path4) {
|
|
9504
|
+
const fileContents = await fs6.readFile(path4, "utf-8");
|
|
9748
9505
|
return JSON.parse(fileContents);
|
|
9749
9506
|
}
|
|
9750
|
-
async function tryReadJSON(
|
|
9507
|
+
async function tryReadJSON(path4, missingValue = null) {
|
|
9751
9508
|
try {
|
|
9752
|
-
const stat = await fs6.stat(
|
|
9753
|
-
return stat.isFile() ? await readJSON(
|
|
9509
|
+
const stat = await fs6.stat(path4);
|
|
9510
|
+
return stat.isFile() ? await readJSON(path4) : missingValue;
|
|
9754
9511
|
} catch (e) {
|
|
9755
9512
|
return missingValue;
|
|
9756
9513
|
}
|
|
@@ -9783,8 +9540,8 @@ var checkLocalDepsVersions = async (args) => {
|
|
|
9783
9540
|
return;
|
|
9784
9541
|
let firstVersion;
|
|
9785
9542
|
const allDependencies = {
|
|
9786
|
-
...
|
|
9787
|
-
...
|
|
9543
|
+
...localPackages?.dependencies ?? {},
|
|
9544
|
+
...localPackages?.devDependencies ?? {}
|
|
9788
9545
|
};
|
|
9789
9546
|
for (const [p, version] of Object.entries(allDependencies)) {
|
|
9790
9547
|
if (uniformStrictVersions.includes(p)) {
|