@uniformdev/cli 20.50.2-alpha.1 → 20.50.2-alpha.117

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.
@@ -19,6 +19,94 @@ import { dump, load } from "js-yaml";
19
19
  import { dirname, extname, isAbsolute, resolve, sep } from "path";
20
20
  import { fetch as undiciFetch, ProxyAgent } from "undici";
21
21
 
22
+ // package.json
23
+ var package_default = {
24
+ name: "@uniformdev/cli",
25
+ version: "20.66.6",
26
+ description: "Uniform command line interface tool",
27
+ license: "SEE LICENSE IN LICENSE.txt",
28
+ main: "./cli.js",
29
+ exports: {
30
+ ".": {
31
+ types: "./dist/index.d.mts",
32
+ default: "./cli.js"
33
+ },
34
+ "./config": {
35
+ types: "./dist/defaultConfig.d.mts",
36
+ default: "./dist/defaultConfig.mjs"
37
+ }
38
+ },
39
+ types: "./dist/index.d.mts",
40
+ sideEffects: false,
41
+ scripts: {
42
+ uniform: "node ./cli.js",
43
+ build: "tsc --noEmit && tsup",
44
+ dev: "tsup --watch",
45
+ clean: "rimraf dist",
46
+ test: "vitest run",
47
+ format: 'prettier --write "src/**/*.{js,ts,tsx}"'
48
+ },
49
+ dependencies: {
50
+ "@inquirer/prompts": "^7.10.1",
51
+ "@thi.ng/mime": "^2.2.23",
52
+ "@uniformdev/assets": "workspace:*",
53
+ "@uniformdev/canvas": "workspace:*",
54
+ "@uniformdev/context": "workspace:*",
55
+ "@uniformdev/files": "workspace:*",
56
+ "@uniformdev/project-map": "workspace:*",
57
+ "@uniformdev/redirect": "workspace:*",
58
+ "@uniformdev/richtext": "workspace:*",
59
+ "call-bind": "^1.0.2",
60
+ colorette: "2.0.20",
61
+ cosmiconfig: "9.0.0",
62
+ "cosmiconfig-typescript-loader": "5.0.0",
63
+ diff: "^8.0.3",
64
+ dotenv: "^16.4.7",
65
+ esbuild: "0.25.0",
66
+ execa: "5.1.1",
67
+ "file-type": "^21.3.2",
68
+ "fs-jetpack": "5.1.0",
69
+ graphql: "16.9.0",
70
+ "graphql-request": "6.1.0",
71
+ "image-size": "2.0.2",
72
+ "isomorphic-git": "1.35.0",
73
+ "js-yaml": "^4.1.0",
74
+ jsonwebtoken: "9.0.3",
75
+ mitt: "^3.0.1",
76
+ "normalize-newline": "^4.1.0",
77
+ open: "10.2.0",
78
+ ora: "8.0.1",
79
+ "p-queue": "7.3.4",
80
+ "posthog-node": "5.28.5",
81
+ "registry-auth-token": "^5.0.0",
82
+ "registry-url": "^6.0.0",
83
+ slugify: "1.6.6",
84
+ svix: "^1.71.0",
85
+ undici: "^7.24.0",
86
+ yargs: "^17.6.2",
87
+ zod: "4.3.6"
88
+ },
89
+ devDependencies: {
90
+ "@types/diff": "^8.0.0",
91
+ "@types/js-yaml": "4.0.9",
92
+ "@types/jsonwebtoken": "9.0.5",
93
+ "@types/node": "24.3.1",
94
+ "@types/yargs": "17.0.32"
95
+ },
96
+ bin: {
97
+ uniform: "./cli.js"
98
+ },
99
+ files: [
100
+ "/dist"
101
+ ],
102
+ publishConfig: {
103
+ access: "public"
104
+ }
105
+ };
106
+
107
+ // src/constants.ts
108
+ var CLI_USER_AGENT = `uniform-cli/${package_default.version}`;
109
+
22
110
  // src/sync/windowsRetry.ts
23
111
  var RETRIABLE_ERRORS = [
24
112
  "ECONNRESET",
@@ -117,6 +205,11 @@ function nodeFetchProxy(proxy, verbose) {
117
205
  console.log(`\u{1F991} Using proxy ${proxy}`);
118
206
  }
119
207
  const baseFetch = (input, init) => {
208
+ const initWithUserAgent = {
209
+ ...init,
210
+ headers: { "User-Agent": CLI_USER_AGENT, ...init?.headers }
211
+ };
212
+ init = initWithUserAgent;
120
213
  const handleFetchError = (e) => {
121
214
  if (e instanceof Error) {
122
215
  e.message = `Error fetching ${input.toString()}
@@ -291,16 +384,84 @@ function readFileToObject(filename) {
291
384
  return load(file, { filename, json: true });
292
385
  }
293
386
  async function* paginateAsync(fetchPage, options) {
294
- const perPage = options.pageSize || 100;
387
+ const pageSize = options.pageSize ?? 100;
388
+ if (pageSize < 1) {
389
+ throw new Error(`pageSize must be at least 1, got ${pageSize}`);
390
+ }
295
391
  let offset = 0;
296
392
  let pageData = [];
297
393
  do {
298
- pageData = await fetchPage(offset, perPage);
394
+ if (options.verbose) {
395
+ console.log(`Fetching ${options.entityName ?? "items"} batch: offset=${offset}, pageSize=${pageSize}`);
396
+ }
397
+ pageData = await fetchPage(offset, pageSize);
299
398
  for (const item of pageData) {
300
399
  yield item;
301
400
  }
302
- offset += perPage;
303
- } while (pageData.length === perPage);
401
+ offset += pageSize;
402
+ } while (pageData.length === pageSize);
403
+ }
404
+ var entityBatchSizeDefaults = {
405
+ composition: 100,
406
+ compositionPattern: 100,
407
+ componentPattern: 100,
408
+ entry: 100,
409
+ entryPattern: 100,
410
+ component: 200,
411
+ label: 100,
412
+ asset: 50,
413
+ contentType: 100,
414
+ workflow: 100
415
+ };
416
+ var paginatedEntityTypes = /* @__PURE__ */ new Set([
417
+ "composition",
418
+ "compositionPattern",
419
+ "componentPattern",
420
+ "entry",
421
+ "entryPattern",
422
+ "component",
423
+ "asset",
424
+ "label",
425
+ "contentType",
426
+ "workflow"
427
+ ]);
428
+ function isPaginatedSyncEntity(entityType) {
429
+ return paginatedEntityTypes.has(entityType);
430
+ }
431
+ function getEntityBatchSize(entityType, config) {
432
+ const fromConfig = config.entitiesConfig?.[entityType]?.batchSize;
433
+ if (fromConfig !== void 0) {
434
+ return fromConfig;
435
+ }
436
+ return entityBatchSizeDefaults[entityType];
437
+ }
438
+ function resolveEntityBatchSize({
439
+ entityType,
440
+ cliBatchSize,
441
+ config
442
+ }) {
443
+ if (cliBatchSize !== void 0) {
444
+ return cliBatchSize;
445
+ }
446
+ if (config) {
447
+ return getEntityBatchSize(entityType, config);
448
+ }
449
+ return void 0;
450
+ }
451
+ function withBatchSizeOptions(yargs, entityType) {
452
+ return yargs.option("batchSize", {
453
+ alias: ["b"],
454
+ describe: "Number of items to fetch per API request when reading from Uniform",
455
+ type: "number"
456
+ }).middleware((argv) => {
457
+ const rawSerialization = argv.serialization;
458
+ const config = rawSerialization ? applyDefaultSyncConfiguration({ serialization: rawSerialization }).serialization : void 0;
459
+ argv.resolvedBatchSize = resolveEntityBatchSize({
460
+ entityType,
461
+ cliBatchSize: argv.batchSize,
462
+ config
463
+ });
464
+ });
304
465
  }
305
466
  var defaultSyncConfiguration = {
306
467
  entitiesConfig: {},
@@ -370,6 +531,8 @@ var getDirectoryOrFilename = ({
370
531
 
371
532
  export {
372
533
  __require,
534
+ package_default,
535
+ CLI_USER_AGENT,
373
536
  withConfiguration,
374
537
  withApiOptions,
375
538
  withDebugOptions,
@@ -382,6 +545,9 @@ export {
382
545
  emitWithFormat,
383
546
  readFileToObject,
384
547
  paginateAsync,
548
+ isPaginatedSyncEntity,
549
+ getEntityBatchSize,
550
+ withBatchSizeOptions,
385
551
  applyDefaultSyncConfiguration,
386
552
  getEntityOption,
387
553
  getDirectoryOrFilename
@@ -1,4 +1,4 @@
1
- import { C as CLIConfiguration, E as EntityTypes } from './index-ZI3elAaF.mjs';
1
+ import { C as CLIConfiguration, E as EntityTypes } from './index-DeoTNXj-.mjs';
2
2
 
3
3
  type UniformConfigAllOptions = {
4
4
  /**
@@ -1,8 +1,9 @@
1
- import "./chunk-SRP5OQEZ.mjs";
1
+ import "./chunk-KJOJNPDF.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
5
5
  dataType: {},
6
+ label: {},
6
7
  locale: {},
7
8
  category: {},
8
9
  redirect: {},
@@ -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-ZI3elAaF.mjs';
2
+ export { C as CLIConfiguration } from './index-DeoTNXj-.mjs';