@uniformdev/cli 20.74.6-alpha.2 → 20.74.6-alpha.5

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.
@@ -21,7 +21,7 @@ import { dirname, extname, isAbsolute, resolve, sep } from "path";
21
21
  // package.json
22
22
  var package_default = {
23
23
  name: "@uniformdev/cli",
24
- version: "20.74.5",
24
+ version: "20.75.0",
25
25
  description: "Uniform command line interface tool",
26
26
  license: "SEE LICENSE IN LICENSE.txt",
27
27
  main: "./cli.js",
@@ -49,6 +49,7 @@ var package_default = {
49
49
  "@inquirer/prompts": "^8.5.2",
50
50
  "@thi.ng/mime": "^2.2.23",
51
51
  "@uniformdev/assets": "workspace:*",
52
+ "@uniformdev/automations-sdk": "workspace:*",
52
53
  "@uniformdev/canvas": "workspace:*",
53
54
  "@uniformdev/context": "workspace:*",
54
55
  "@uniformdev/files": "workspace:*",
@@ -65,8 +66,6 @@ var package_default = {
65
66
  execa: "5.1.1",
66
67
  "file-type": "^22.0.1",
67
68
  "fs-jetpack": "5.1.0",
68
- graphql: "17.0.1",
69
- "graphql-request": "7.4.0",
70
69
  "image-size": "2.0.2",
71
70
  "isomorphic-git": "1.38.5",
72
71
  "js-yaml": "^4.2.0",
@@ -161,12 +160,20 @@ function withConfiguration(yargs) {
161
160
  hidden: true
162
161
  });
163
162
  }
164
- function withApiOptions(yargs) {
165
- return yargs.option("apiKey", {
163
+ function maskApiKey(apiKey) {
164
+ const separatorIndex = apiKey.indexOf("1");
165
+ const prefix = separatorIndex > 0 ? apiKey.slice(0, separatorIndex) : apiKey.slice(0, 3);
166
+ return `${prefix}...${apiKey.slice(-4)}`;
167
+ }
168
+ function withApiOptions(yargs, { includeEdgeApiHost = false } = {}) {
169
+ const resolvedApiKey = process.env.UNIFORM_CLI_API_KEY ?? // deprecated
170
+ process.env.CANVAS_CLI_API_KEY ?? // deprecated
171
+ process.env.UPM_CLI_API_KEY ?? process.env.UNIFORM_API_KEY;
172
+ let result = yargs.option("apiKey", {
166
173
  describe: "Uniform API key. Defaults to UNIFORM_CLI_API_KEY or UNIFORM_API_KEY env. Supports dotenv.",
167
- default: process.env.UNIFORM_CLI_API_KEY ?? // deprecated
168
- process.env.CANVAS_CLI_API_KEY ?? // deprecated
169
- process.env.UPM_CLI_API_KEY ?? process.env.UNIFORM_API_KEY,
174
+ default: resolvedApiKey,
175
+ // Mask the resolved key in --help output so the secret is never printed verbatim.
176
+ defaultDescription: resolvedApiKey ? maskApiKey(resolvedApiKey) : void 0,
170
177
  demandOption: true,
171
178
  type: "string"
172
179
  }).option("apiHost", {
@@ -174,12 +181,16 @@ function withApiOptions(yargs) {
174
181
  default: process.env.UNIFORM_CLI_BASE_URL || "https://uniform.app",
175
182
  demandOption: true,
176
183
  type: "string"
177
- }).option("edgeApiHost", {
178
- describe: "Uniform edge host. Defaults to UNIFORM_CLI_BASE_EDGE_URL env var or https://uniform.global. Supports dotenv.",
179
- default: process.env.UNIFORM_CLI_BASE_EDGE_URL || "https://uniform.global",
180
- demandOption: true,
181
- type: "string"
182
- }).option("proxy", {
184
+ });
185
+ if (includeEdgeApiHost) {
186
+ result = result.option("edgeApiHost", {
187
+ describe: "Uniform edge host. Defaults to UNIFORM_CLI_BASE_EDGE_URL env var or https://uniform.global. Supports dotenv.",
188
+ default: process.env.UNIFORM_CLI_BASE_EDGE_URL || "https://uniform.global",
189
+ demandOption: true,
190
+ type: "string"
191
+ });
192
+ }
193
+ return result.option("proxy", {
183
194
  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.",
184
195
  default: process.env.HTTPS_PROXY || process.env.https_proxy || process.env.ALL_PROXY || process.env.all_proxy,
185
196
  type: "string"
@@ -282,6 +293,16 @@ ${e.message}`;
282
293
  }
283
294
  return wrappedFetch;
284
295
  }
296
+ function exitOnCliError(error) {
297
+ if (error instanceof ApiClientError) {
298
+ console.error(error.message);
299
+ } else if (error instanceof Error) {
300
+ console.error(error.message);
301
+ } else {
302
+ console.error(String(error));
303
+ }
304
+ process.exit(1);
305
+ }
285
306
  function withProjectOptions(yargs) {
286
307
  return yargs.option("project", {
287
308
  describe: "Uniform project ID. Defaults to UNIFORM_CLI_PROJECT_ID or UNIFORM_PROJECT_ID env. Supports dotenv.",
@@ -388,23 +409,41 @@ function readFileToObject(filename) {
388
409
  const file = readFileSync(filename, "utf8");
389
410
  return load(file, { filename, json: true });
390
411
  }
412
+ var ENTITY_ID_CHUNK_SIZE = 100;
413
+ function* chunkEntityIds(ids, chunkSize = ENTITY_ID_CHUNK_SIZE) {
414
+ if (!ids) {
415
+ yield void 0;
416
+ return;
417
+ }
418
+ for (let index = 0; index < ids.length; index += chunkSize) {
419
+ yield ids.slice(index, index + chunkSize);
420
+ }
421
+ }
391
422
  async function* paginateAsync(fetchPage, options) {
392
423
  const pageSize = options.pageSize ?? 100;
393
424
  if (pageSize < 1) {
394
425
  throw new Error(`pageSize must be at least 1, got ${pageSize}`);
395
426
  }
427
+ const { maxItems } = options;
396
428
  let offset = 0;
429
+ let yielded = 0;
430
+ let limit = pageSize;
397
431
  let pageData = [];
398
432
  do {
433
+ limit = maxItems === void 0 ? pageSize : Math.min(pageSize, maxItems - yielded);
434
+ if (limit < 1) {
435
+ return;
436
+ }
399
437
  if (options.verbose) {
400
- console.log(`Fetching ${options.entityName ?? "items"} batch: offset=${offset}, pageSize=${pageSize}`);
438
+ console.log(`Fetching ${options.entityName ?? "items"} batch: offset=${offset}, pageSize=${limit}`);
401
439
  }
402
- pageData = await fetchPage(offset, pageSize);
440
+ pageData = await fetchPage(offset, limit);
403
441
  for (const item of pageData) {
404
442
  yield item;
405
443
  }
406
- offset += pageSize;
407
- } while (pageData.length === pageSize);
444
+ yielded += pageData.length;
445
+ offset += limit;
446
+ } while (pageData.length === limit);
408
447
  }
409
448
  var entityBatchSizeDefaults = {
410
449
  composition: 100,
@@ -440,6 +479,21 @@ function getEntityBatchSize(entityType, config) {
440
479
  }
441
480
  return entityBatchSizeDefaults[entityType];
442
481
  }
482
+ function getPublishScope(entityType, config) {
483
+ const publish = config.entitiesConfig?.[entityType]?.publish;
484
+ if (!publish) {
485
+ return void 0;
486
+ }
487
+ if (publish === true || publish === "all") {
488
+ return "all";
489
+ }
490
+ if (publish === "pushed") {
491
+ return "pushed";
492
+ }
493
+ throw new Error(
494
+ `Invalid publish option '${publish}' for ${entityType}. Expected true, false, 'all', or 'pushed'.`
495
+ );
496
+ }
443
497
  function resolveEntityBatchSize({
444
498
  entityType,
445
499
  cliBatchSize,
@@ -539,9 +593,11 @@ export {
539
593
  package_default,
540
594
  CLI_USER_AGENT,
541
595
  withConfiguration,
596
+ maskApiKey,
542
597
  withApiOptions,
543
598
  withDebugOptions,
544
599
  nodeFetchProxy,
600
+ exitOnCliError,
545
601
  withProjectOptions,
546
602
  withTeamOptions,
547
603
  withFormatOptions,
@@ -549,9 +605,11 @@ export {
549
605
  isPathAPackageFile,
550
606
  emitWithFormat,
551
607
  readFileToObject,
608
+ chunkEntityIds,
552
609
  paginateAsync,
553
610
  isPaginatedSyncEntity,
554
611
  getEntityBatchSize,
612
+ getPublishScope,
555
613
  withBatchSizeOptions,
556
614
  applyDefaultSyncConfiguration,
557
615
  getEntityOption,
@@ -1,4 +1,4 @@
1
- import { C as CLIConfiguration, E as EntityTypes } from './index-DeoTNXj-.mjs';
1
+ import { C as CLIConfiguration, E as EntityTypes } from './index-FdhH3tn0.mjs';
2
2
 
3
3
  type UniformConfigAllOptions = {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import "./chunk-TPAFG3LW.mjs";
1
+ import "./chunk-RXRK6OF5.mjs";
2
2
 
3
3
  // src/sync/allSerializableEntitiesConfig.ts
4
4
  var allSerializableEntitiesConfig = {
@@ -11,11 +11,11 @@ var allSerializableEntitiesConfig = {
11
11
  projectMapDefinition: {},
12
12
  projectMapNode: {},
13
13
  contentType: {},
14
- composition: { publish: true },
15
- entry: { publish: true },
16
- entryPattern: { publish: true },
17
- componentPattern: { publish: true },
18
- compositionPattern: { publish: true },
14
+ composition: { publish: "all" },
15
+ entry: { publish: "all" },
16
+ entryPattern: { publish: "all" },
17
+ componentPattern: { publish: "all" },
18
+ compositionPattern: { publish: "all" },
19
19
  asset: {},
20
20
  workflow: {},
21
21
  webhook: {},
@@ -13,8 +13,21 @@ type EntityConfiguration = {
13
13
  disabled?: true;
14
14
  };
15
15
  type EntityWithStateConfiguration = EntityConfiguration & Partial<StateArgs>;
16
+ /**
17
+ * What a push should publish once it has written its entities to preview.
18
+ *
19
+ * - `all`: publish every entity of this type in the project that has unpublished changes, whether or
20
+ * not it came from the push source. This is what `publish: true` has always done.
21
+ * - `pushed`: publish only the entities this run actually created or updated. This is narrower than
22
+ * "everything in the push source": an entity whose preview copy already matches the source is not
23
+ * written, so it is not published either. A run that changes nothing therefore publishes nothing,
24
+ * which also means a failed publish is not retried by re-running an unchanged push. Use `all` when
25
+ * the publish set needs to converge on its own.
26
+ */
27
+ type PublishScope = 'all' | 'pushed';
16
28
  type PublishableEntitiesConfiguration = EntityWithStateConfiguration & {
17
- publish?: boolean;
29
+ /** `true` is an alias for `'all'`, kept for backwards compatibility. */
30
+ publish?: boolean | PublishScope;
18
31
  batchSize?: number;
19
32
  };
20
33
  type SerializationEntitiesConfiguration = Record<EntityTypes, {
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- export { C as CLIConfiguration } from './index-DeoTNXj-.mjs';
2
+ export { C as CLIConfiguration } from './index-FdhH3tn0.mjs';