@uniformdev/cli 20.49.2 → 20.49.3-alpha.47
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.
|
@@ -5,9 +5,9 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/tsup@8.
|
|
9
|
-
import { fileURLToPath } from "url";
|
|
8
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.58.9_@types+node@26.0.0__jiti@2.7.0_postcss@8.5.1_7017c7d2ba4cec51f3116591eb787c26/node_modules/tsup/assets/esm_shims.js
|
|
10
9
|
import path from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
11
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
12
12
|
var getDirname = () => path.dirname(getFilename());
|
|
13
13
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
@@ -17,7 +17,93 @@ import { ApiClientError } from "@uniformdev/canvas";
|
|
|
17
17
|
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
18
18
|
import { dump, load } from "js-yaml";
|
|
19
19
|
import { dirname, extname, isAbsolute, resolve, sep } from "path";
|
|
20
|
-
|
|
20
|
+
|
|
21
|
+
// package.json
|
|
22
|
+
var package_default = {
|
|
23
|
+
name: "@uniformdev/cli",
|
|
24
|
+
version: "20.74.3",
|
|
25
|
+
description: "Uniform command line interface tool",
|
|
26
|
+
license: "SEE LICENSE IN LICENSE.txt",
|
|
27
|
+
main: "./cli.js",
|
|
28
|
+
exports: {
|
|
29
|
+
".": {
|
|
30
|
+
types: "./dist/index.d.mts",
|
|
31
|
+
default: "./cli.js"
|
|
32
|
+
},
|
|
33
|
+
"./config": {
|
|
34
|
+
types: "./dist/defaultConfig.d.mts",
|
|
35
|
+
default: "./dist/defaultConfig.mjs"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
types: "./dist/index.d.mts",
|
|
39
|
+
sideEffects: false,
|
|
40
|
+
scripts: {
|
|
41
|
+
uniform: "node ./cli.js",
|
|
42
|
+
build: "tsc --noEmit && tsup",
|
|
43
|
+
dev: "tsup --watch",
|
|
44
|
+
clean: "rimraf dist",
|
|
45
|
+
test: "vitest run",
|
|
46
|
+
format: 'prettier --write "src/**/*.{js,ts,tsx}"'
|
|
47
|
+
},
|
|
48
|
+
dependencies: {
|
|
49
|
+
"@inquirer/prompts": "^8.5.2",
|
|
50
|
+
"@thi.ng/mime": "^2.2.23",
|
|
51
|
+
"@uniformdev/assets": "workspace:*",
|
|
52
|
+
"@uniformdev/canvas": "workspace:*",
|
|
53
|
+
"@uniformdev/context": "workspace:*",
|
|
54
|
+
"@uniformdev/files": "workspace:*",
|
|
55
|
+
"@uniformdev/project-map": "workspace:*",
|
|
56
|
+
"@uniformdev/redirect": "workspace:*",
|
|
57
|
+
"@uniformdev/richtext": "workspace:*",
|
|
58
|
+
"call-bind": "^1.0.2",
|
|
59
|
+
colorette: "2.0.20",
|
|
60
|
+
cosmiconfig: "9.0.2",
|
|
61
|
+
"cosmiconfig-typescript-loader": "5.0.0",
|
|
62
|
+
diff: "^9.0.0",
|
|
63
|
+
dotenv: "^17.4.2",
|
|
64
|
+
esbuild: "0.28.1",
|
|
65
|
+
execa: "5.1.1",
|
|
66
|
+
"file-type": "^22.0.1",
|
|
67
|
+
"fs-jetpack": "5.1.0",
|
|
68
|
+
graphql: "17.0.1",
|
|
69
|
+
"graphql-request": "7.4.0",
|
|
70
|
+
"image-size": "2.0.2",
|
|
71
|
+
"isomorphic-git": "1.38.5",
|
|
72
|
+
"js-yaml": "^4.2.0",
|
|
73
|
+
jsonwebtoken: "9.0.3",
|
|
74
|
+
mitt: "^3.0.1",
|
|
75
|
+
"normalize-newline": "^4.1.0",
|
|
76
|
+
open: "11.0.0",
|
|
77
|
+
ora: "9.4.0",
|
|
78
|
+
"p-queue": "7.3.4",
|
|
79
|
+
"posthog-node": "5.38.2",
|
|
80
|
+
"registry-auth-token": "^5.0.0",
|
|
81
|
+
"registry-url": "^6.0.0",
|
|
82
|
+
slugify: "1.6.9",
|
|
83
|
+
svix: "^1.96.0",
|
|
84
|
+
undici: "^7.28.0",
|
|
85
|
+
yargs: "^18.0.0",
|
|
86
|
+
zod: "4.4.3"
|
|
87
|
+
},
|
|
88
|
+
devDependencies: {
|
|
89
|
+
"@types/js-yaml": "4.0.9",
|
|
90
|
+
"@types/jsonwebtoken": "9.0.10",
|
|
91
|
+
"@types/node": "26.0.0",
|
|
92
|
+
"@types/yargs": "17.0.35"
|
|
93
|
+
},
|
|
94
|
+
bin: {
|
|
95
|
+
uniform: "./cli.js"
|
|
96
|
+
},
|
|
97
|
+
files: [
|
|
98
|
+
"/dist"
|
|
99
|
+
],
|
|
100
|
+
publishConfig: {
|
|
101
|
+
access: "public"
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// src/constants.ts
|
|
106
|
+
var CLI_USER_AGENT = `uniform-cli/${package_default.version}`;
|
|
21
107
|
|
|
22
108
|
// src/sync/windowsRetry.ts
|
|
23
109
|
var RETRIABLE_ERRORS = [
|
|
@@ -112,11 +198,23 @@ function withDebugOptions(yargs) {
|
|
|
112
198
|
});
|
|
113
199
|
}
|
|
114
200
|
var fetchIndex = 0;
|
|
201
|
+
var undiciModulePromise;
|
|
202
|
+
function loadUndici() {
|
|
203
|
+
if (!undiciModulePromise) {
|
|
204
|
+
undiciModulePromise = import("undici");
|
|
205
|
+
}
|
|
206
|
+
return undiciModulePromise;
|
|
207
|
+
}
|
|
115
208
|
function nodeFetchProxy(proxy, verbose) {
|
|
116
209
|
if (proxy) {
|
|
117
210
|
console.log(`\u{1F991} Using proxy ${proxy}`);
|
|
118
211
|
}
|
|
119
212
|
const baseFetch = (input, init) => {
|
|
213
|
+
const initWithUserAgent = {
|
|
214
|
+
...init,
|
|
215
|
+
headers: { "User-Agent": CLI_USER_AGENT, ...init?.headers }
|
|
216
|
+
};
|
|
217
|
+
init = initWithUserAgent;
|
|
120
218
|
const handleFetchError = (e) => {
|
|
121
219
|
if (e instanceof Error) {
|
|
122
220
|
e.message = `Error fetching ${input.toString()}
|
|
@@ -132,15 +230,15 @@ ${e.message}`;
|
|
|
132
230
|
throw e;
|
|
133
231
|
};
|
|
134
232
|
if (proxy) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
233
|
+
return loadUndici().then(({ fetch: undiciFetch, ProxyAgent }) => {
|
|
234
|
+
const wrappedInit = {
|
|
235
|
+
...init,
|
|
236
|
+
dispatcher: new ProxyAgent(proxy)
|
|
237
|
+
};
|
|
238
|
+
return undiciFetch(input, wrappedInit).catch(handleFetchError);
|
|
239
|
+
});
|
|
140
240
|
}
|
|
141
|
-
return
|
|
142
|
-
handleFetchError
|
|
143
|
-
);
|
|
241
|
+
return globalThis.fetch(input, init).catch(handleFetchError);
|
|
144
242
|
};
|
|
145
243
|
const wrappedFetch = createFetchWithRetry(baseFetch, verbose);
|
|
146
244
|
if (verbose) {
|
|
@@ -291,16 +389,84 @@ function readFileToObject(filename) {
|
|
|
291
389
|
return load(file, { filename, json: true });
|
|
292
390
|
}
|
|
293
391
|
async function* paginateAsync(fetchPage, options) {
|
|
294
|
-
const
|
|
392
|
+
const pageSize = options.pageSize ?? 100;
|
|
393
|
+
if (pageSize < 1) {
|
|
394
|
+
throw new Error(`pageSize must be at least 1, got ${pageSize}`);
|
|
395
|
+
}
|
|
295
396
|
let offset = 0;
|
|
296
397
|
let pageData = [];
|
|
297
398
|
do {
|
|
298
|
-
|
|
399
|
+
if (options.verbose) {
|
|
400
|
+
console.log(`Fetching ${options.entityName ?? "items"} batch: offset=${offset}, pageSize=${pageSize}`);
|
|
401
|
+
}
|
|
402
|
+
pageData = await fetchPage(offset, pageSize);
|
|
299
403
|
for (const item of pageData) {
|
|
300
404
|
yield item;
|
|
301
405
|
}
|
|
302
|
-
offset +=
|
|
303
|
-
} while (pageData.length ===
|
|
406
|
+
offset += pageSize;
|
|
407
|
+
} while (pageData.length === pageSize);
|
|
408
|
+
}
|
|
409
|
+
var entityBatchSizeDefaults = {
|
|
410
|
+
composition: 100,
|
|
411
|
+
compositionPattern: 100,
|
|
412
|
+
componentPattern: 100,
|
|
413
|
+
entry: 100,
|
|
414
|
+
entryPattern: 100,
|
|
415
|
+
component: 200,
|
|
416
|
+
label: 100,
|
|
417
|
+
asset: 50,
|
|
418
|
+
contentType: 100,
|
|
419
|
+
workflow: 100
|
|
420
|
+
};
|
|
421
|
+
var paginatedEntityTypes = /* @__PURE__ */ new Set([
|
|
422
|
+
"composition",
|
|
423
|
+
"compositionPattern",
|
|
424
|
+
"componentPattern",
|
|
425
|
+
"entry",
|
|
426
|
+
"entryPattern",
|
|
427
|
+
"component",
|
|
428
|
+
"asset",
|
|
429
|
+
"label",
|
|
430
|
+
"contentType",
|
|
431
|
+
"workflow"
|
|
432
|
+
]);
|
|
433
|
+
function isPaginatedSyncEntity(entityType) {
|
|
434
|
+
return paginatedEntityTypes.has(entityType);
|
|
435
|
+
}
|
|
436
|
+
function getEntityBatchSize(entityType, config) {
|
|
437
|
+
const fromConfig = config.entitiesConfig?.[entityType]?.batchSize;
|
|
438
|
+
if (fromConfig !== void 0) {
|
|
439
|
+
return fromConfig;
|
|
440
|
+
}
|
|
441
|
+
return entityBatchSizeDefaults[entityType];
|
|
442
|
+
}
|
|
443
|
+
function resolveEntityBatchSize({
|
|
444
|
+
entityType,
|
|
445
|
+
cliBatchSize,
|
|
446
|
+
config
|
|
447
|
+
}) {
|
|
448
|
+
if (cliBatchSize !== void 0) {
|
|
449
|
+
return cliBatchSize;
|
|
450
|
+
}
|
|
451
|
+
if (config) {
|
|
452
|
+
return getEntityBatchSize(entityType, config);
|
|
453
|
+
}
|
|
454
|
+
return void 0;
|
|
455
|
+
}
|
|
456
|
+
function withBatchSizeOptions(yargs, entityType) {
|
|
457
|
+
return yargs.option("batchSize", {
|
|
458
|
+
alias: ["b"],
|
|
459
|
+
describe: "Number of items to fetch per API request when reading from Uniform",
|
|
460
|
+
type: "number"
|
|
461
|
+
}).middleware((argv) => {
|
|
462
|
+
const rawSerialization = argv.serialization;
|
|
463
|
+
const config = rawSerialization ? applyDefaultSyncConfiguration({ serialization: rawSerialization }).serialization : void 0;
|
|
464
|
+
argv.resolvedBatchSize = resolveEntityBatchSize({
|
|
465
|
+
entityType,
|
|
466
|
+
cliBatchSize: argv.batchSize,
|
|
467
|
+
config
|
|
468
|
+
});
|
|
469
|
+
});
|
|
304
470
|
}
|
|
305
471
|
var defaultSyncConfiguration = {
|
|
306
472
|
entitiesConfig: {},
|
|
@@ -370,6 +536,8 @@ var getDirectoryOrFilename = ({
|
|
|
370
536
|
|
|
371
537
|
export {
|
|
372
538
|
__require,
|
|
539
|
+
package_default,
|
|
540
|
+
CLI_USER_AGENT,
|
|
373
541
|
withConfiguration,
|
|
374
542
|
withApiOptions,
|
|
375
543
|
withDebugOptions,
|
|
@@ -382,6 +550,9 @@ export {
|
|
|
382
550
|
emitWithFormat,
|
|
383
551
|
readFileToObject,
|
|
384
552
|
paginateAsync,
|
|
553
|
+
isPaginatedSyncEntity,
|
|
554
|
+
getEntityBatchSize,
|
|
555
|
+
withBatchSizeOptions,
|
|
385
556
|
applyDefaultSyncConfiguration,
|
|
386
557
|
getEntityOption,
|
|
387
558
|
getDirectoryOrFilename
|
package/dist/defaultConfig.d.mts
CHANGED
package/dist/defaultConfig.mjs
CHANGED
|
@@ -4,7 +4,7 @@ type StateArgs = {
|
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
type SyncMode = 'mirror' | 'createOrUpdate' | 'create';
|
|
7
|
-
type EntityTypes = 'aggregate' | 'asset' | 'category' | 'workflow' | 'webhook' | 'component' | 'composition' | 'contentType' | 'dataType' | 'enrichment' | 'entry' | 'entryPattern' | 'locale' | 'componentPattern' | 'compositionPattern' | 'policyDocument' | 'projectMapDefinition' | 'projectMapNode' | 'previewUrl' | 'previewViewport' | 'prompt' | 'quirk' | 'redirect' | 'signal' | 'test';
|
|
7
|
+
type EntityTypes = 'aggregate' | 'asset' | 'category' | 'workflow' | 'webhook' | 'component' | 'composition' | 'contentType' | 'dataType' | 'enrichment' | 'entry' | 'entryPattern' | 'label' | 'locale' | 'componentPattern' | 'compositionPattern' | 'policyDocument' | 'projectMapDefinition' | 'projectMapNode' | 'previewUrl' | 'previewViewport' | 'prompt' | 'quirk' | 'redirect' | 'signal' | 'test';
|
|
8
8
|
type SyncFileFormat = 'yaml' | 'json';
|
|
9
9
|
type EntityConfiguration = {
|
|
10
10
|
mode?: SyncMode;
|
|
@@ -15,10 +15,12 @@ type EntityConfiguration = {
|
|
|
15
15
|
type EntityWithStateConfiguration = EntityConfiguration & Partial<StateArgs>;
|
|
16
16
|
type PublishableEntitiesConfiguration = EntityWithStateConfiguration & {
|
|
17
17
|
publish?: boolean;
|
|
18
|
+
batchSize?: number;
|
|
18
19
|
};
|
|
19
20
|
type SerializationEntitiesConfiguration = Record<EntityTypes, {
|
|
20
21
|
pull?: EntityConfiguration;
|
|
21
22
|
push?: EntityConfiguration;
|
|
23
|
+
batchSize?: number;
|
|
22
24
|
} & EntityConfiguration> & {
|
|
23
25
|
composition?: PublishableEntitiesConfiguration;
|
|
24
26
|
componentPattern?: PublishableEntitiesConfiguration;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { C as CLIConfiguration } from './index-
|
|
2
|
+
export { C as CLIConfiguration } from './index-DeoTNXj-.mjs';
|