@uniformdev/cli 19.92.2 → 19.92.3-alpha.7

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/index.d.mts CHANGED
@@ -24,7 +24,7 @@ type SerializationConfiguration = {
24
24
  } & EntityConfiguration> & {
25
25
  composition?: PublishableEntitiesConfiguration;
26
26
  pattern?: PublishableEntitiesConfiguration;
27
- entry?: EntityWithStateConfiguration;
27
+ entry?: PublishableEntitiesConfiguration;
28
28
  }>;
29
29
  directory: string;
30
30
  mode: SyncMode;
package/dist/index.mjs CHANGED
@@ -3224,9 +3224,8 @@ var EntryListModule = {
3224
3224
  }
3225
3225
  };
3226
3226
 
3227
- // src/commands/canvas/commands/entry/pull.ts
3227
+ // src/commands/canvas/commands/entry/publish.ts
3228
3228
  import { ContentClient as ContentClient10 } from "@uniformdev/canvas";
3229
- import { UncachedFileClient as UncachedFileClient5 } from "@uniformdev/files";
3230
3229
 
3231
3230
  // src/commands/canvas/entryEngineDataSource.ts
3232
3231
  import { convertEntryToPutEntry } from "@uniformdev/canvas";
@@ -3238,19 +3237,27 @@ var selectEntryDisplayName = (e) => `${e.entry._name ?? "Untitled"} (pid: ${e.en
3238
3237
  // src/commands/canvas/entryEngineDataSource.ts
3239
3238
  function createEntryEngineDataSource({
3240
3239
  client,
3241
- state
3240
+ state,
3241
+ onlyEntries,
3242
+ onlyPatterns,
3243
+ entryIDs
3242
3244
  }) {
3243
3245
  const stateId = convertCompositionState(state);
3244
3246
  async function* getObjects() {
3245
- const { entries } = await client.getEntries({
3246
- offset: 0,
3247
- limit: 1e3,
3248
- skipDataResolution: true,
3249
- skipOverridesResolution: true,
3250
- skipPatternResolution: true,
3251
- state: stateId,
3252
- withComponentIDs: true
3253
- });
3247
+ const entries = paginateAsync(
3248
+ async (offset, limit) => (await client.getEntries({
3249
+ offset,
3250
+ limit,
3251
+ entryIDs,
3252
+ pattern: onlyEntries ? false : onlyPatterns ? true : void 0,
3253
+ skipDataResolution: true,
3254
+ skipOverridesResolution: true,
3255
+ skipPatternResolution: true,
3256
+ state: stateId,
3257
+ withComponentIDs: true
3258
+ })).entries,
3259
+ { pageSize: 100 }
3260
+ );
3254
3261
  for await (const e of entries) {
3255
3262
  const result = {
3256
3263
  id: selectEntryIdentifier(e),
@@ -3272,7 +3279,87 @@ function createEntryEngineDataSource({
3272
3279
  };
3273
3280
  }
3274
3281
 
3282
+ // src/commands/canvas/commands/entry/publish.ts
3283
+ var EntryPublishModule = {
3284
+ command: "publish [ids]",
3285
+ describe: "Publishes entry(ies)",
3286
+ builder: (yargs28) => withConfiguration(
3287
+ withApiOptions(
3288
+ withProjectOptions(
3289
+ withDiffOptions(
3290
+ yargs28.positional("ids", {
3291
+ describe: "Publishes entry(ies) by ID. Comma-separate multiple IDs. Use --all to publish all instead.",
3292
+ type: "string"
3293
+ }).option("all", {
3294
+ alias: ["a"],
3295
+ describe: "Publishes all entries. Use --ids to publish selected entries instead.",
3296
+ default: false,
3297
+ type: "boolean"
3298
+ }).option("what-if", {
3299
+ alias: ["w"],
3300
+ describe: "What-if mode reports what would be done but does not perform any publishing",
3301
+ default: false,
3302
+ type: "boolean"
3303
+ }).option("onlyEntries", {
3304
+ describe: "Only publishing entries and not patterns",
3305
+ default: false,
3306
+ type: "boolean"
3307
+ }).option("onlyPatterns", {
3308
+ describe: "Only pulling patterns and not entries",
3309
+ default: false,
3310
+ type: "boolean",
3311
+ hidden: true
3312
+ })
3313
+ )
3314
+ )
3315
+ )
3316
+ ),
3317
+ handler: async ({
3318
+ apiHost,
3319
+ apiKey,
3320
+ proxy,
3321
+ ids,
3322
+ all,
3323
+ whatIf,
3324
+ project: projectId,
3325
+ onlyEntries,
3326
+ onlyPatterns
3327
+ }) => {
3328
+ if (!all && !ids || all && ids) {
3329
+ console.error(`Specify --all or entry ID(s) to publish.`);
3330
+ process.exit(1);
3331
+ }
3332
+ const entryIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
3333
+ const fetch3 = nodeFetchProxy(proxy);
3334
+ const client = new ContentClient10({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3335
+ const source = createEntryEngineDataSource({
3336
+ client,
3337
+ state: "preview",
3338
+ entryIDs: entryIDsArray,
3339
+ onlyEntries,
3340
+ onlyPatterns
3341
+ });
3342
+ const target = createEntryEngineDataSource({
3343
+ client,
3344
+ state: "published",
3345
+ entryIDs: entryIDsArray,
3346
+ onlyEntries,
3347
+ onlyPatterns
3348
+ });
3349
+ await syncEngine({
3350
+ source,
3351
+ target,
3352
+ // Publishing is one-direction operation, so no need to support automatic un-publishing
3353
+ mode: "createOrUpdate",
3354
+ whatIf,
3355
+ log: createPublishStatusSyncEngineConsoleLogger({ status: "publish" })
3356
+ });
3357
+ }
3358
+ };
3359
+
3275
3360
  // src/commands/canvas/commands/entry/pull.ts
3361
+ import { ContentClient as ContentClient11 } from "@uniformdev/canvas";
3362
+ import { UncachedFileClient as UncachedFileClient5 } from "@uniformdev/files";
3276
3363
  var EntryPullModule = {
3277
3364
  command: "pull <directory>",
3278
3365
  describe: "Pulls all entries to local files in a directory",
@@ -3321,7 +3408,7 @@ var EntryPullModule = {
3321
3408
  allowEmptySource
3322
3409
  }) => {
3323
3410
  const fetch3 = nodeFetchProxy(proxy);
3324
- const client = new ContentClient10({
3411
+ const client = new ContentClient11({
3325
3412
  apiKey,
3326
3413
  apiHost,
3327
3414
  fetch: fetch3,
@@ -3375,7 +3462,7 @@ var EntryPullModule = {
3375
3462
  };
3376
3463
 
3377
3464
  // src/commands/canvas/commands/entry/push.ts
3378
- import { ContentClient as ContentClient11 } from "@uniformdev/canvas";
3465
+ import { ContentClient as ContentClient12 } from "@uniformdev/canvas";
3379
3466
  import { UncachedFileClient as UncachedFileClient6 } from "@uniformdev/files";
3380
3467
  var EntryPushModule = {
3381
3468
  command: "push <directory>",
@@ -3418,7 +3505,7 @@ var EntryPushModule = {
3418
3505
  allowEmptySource
3419
3506
  }) => {
3420
3507
  const fetch3 = nodeFetchProxy(proxy);
3421
- const client = new ContentClient11({
3508
+ const client = new ContentClient12({
3422
3509
  apiKey,
3423
3510
  apiHost,
3424
3511
  fetch: fetch3,
@@ -3466,7 +3553,7 @@ var EntryPushModule = {
3466
3553
  };
3467
3554
 
3468
3555
  // src/commands/canvas/commands/entry/remove.ts
3469
- import { ContentClient as ContentClient12 } from "@uniformdev/canvas";
3556
+ import { ContentClient as ContentClient13 } from "@uniformdev/canvas";
3470
3557
  var EntryRemoveModule = {
3471
3558
  command: "remove <id>",
3472
3559
  aliases: ["delete", "rm"],
@@ -3480,13 +3567,110 @@ var EntryRemoveModule = {
3480
3567
  ),
3481
3568
  handler: async ({ apiHost, apiKey, proxy, id, project: projectId }) => {
3482
3569
  const fetch3 = nodeFetchProxy(proxy);
3483
- const client = new ContentClient12({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3570
+ const client = new ContentClient13({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3484
3571
  await client.deleteEntry({ entryId: id });
3485
3572
  }
3486
3573
  };
3487
3574
 
3575
+ // src/commands/canvas/commands/entry/unpublish.ts
3576
+ import { CANVAS_PUBLISHED_STATE as CANVAS_PUBLISHED_STATE3, ContentClient as ContentClient14 } from "@uniformdev/canvas";
3577
+ import { diffJson as diffJson3 } from "diff";
3578
+ var EntryUnpublishModule = {
3579
+ command: "unpublish [ids]",
3580
+ describe: "Unpublish an entry(ies)",
3581
+ builder: (yargs28) => withConfiguration(
3582
+ withApiOptions(
3583
+ withProjectOptions(
3584
+ yargs28.positional("ids", {
3585
+ describe: "Un-publishes entry(ies) by ID. Comma-separate multiple IDs. Use --all to un-publish all instead.",
3586
+ type: "string"
3587
+ }).option("all", {
3588
+ alias: ["a"],
3589
+ describe: "Un-publishes all entries. Use --all to un-publish selected entries instead.",
3590
+ default: false,
3591
+ type: "boolean"
3592
+ }).option("what-if", {
3593
+ alias: ["w"],
3594
+ describe: "What-if mode reports what would be done but does not perform any un-publishing",
3595
+ default: false,
3596
+ type: "boolean"
3597
+ }).option("onlyEntries", {
3598
+ describe: "Only un-publishing entries and not patterns",
3599
+ default: false,
3600
+ type: "boolean"
3601
+ }).option("onlyPatterns", {
3602
+ describe: "Only un-publishing patterns and not entries",
3603
+ default: false,
3604
+ type: "boolean",
3605
+ hidden: true
3606
+ })
3607
+ )
3608
+ )
3609
+ ),
3610
+ handler: async ({
3611
+ apiHost,
3612
+ apiKey,
3613
+ proxy,
3614
+ ids,
3615
+ all,
3616
+ onlyEntries,
3617
+ onlyPatterns,
3618
+ project: projectId,
3619
+ whatIf
3620
+ }) => {
3621
+ if (!all && !ids || all && ids) {
3622
+ console.error(`Specify --all or entry ID(s) to publish.`);
3623
+ process.exit(1);
3624
+ }
3625
+ const entryIDsArray = ids ? ids.split(",").map((id) => id.trim()) : void 0;
3626
+ const targetItems = /* @__PURE__ */ new Map();
3627
+ const fetch3 = nodeFetchProxy(proxy);
3628
+ const client = new ContentClient14({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3629
+ const source = createEntryEngineDataSource({
3630
+ client,
3631
+ state: "published",
3632
+ entryIDs: entryIDsArray,
3633
+ onlyEntries,
3634
+ onlyPatterns
3635
+ });
3636
+ const target = createEntryEngineDataSource({
3637
+ client,
3638
+ state: "preview",
3639
+ entryIDs: entryIDsArray,
3640
+ onlyEntries,
3641
+ onlyPatterns
3642
+ });
3643
+ const actions = [];
3644
+ const log = createPublishStatusSyncEngineConsoleLogger({ status: "unpublish" });
3645
+ for await (const obj of target.objects) {
3646
+ if (Array.isArray(obj.id)) {
3647
+ obj.id.forEach((o) => targetItems.set(o, obj));
3648
+ } else {
3649
+ targetItems.set(obj.id, obj);
3650
+ }
3651
+ }
3652
+ for await (const sourceObject of source.objects) {
3653
+ const id = Array.isArray(sourceObject.id) ? sourceObject.id[0] : sourceObject.id;
3654
+ const targetObject = targetItems.get(id);
3655
+ if (!targetObject) {
3656
+ console.log(`Entry ${id} was not found`);
3657
+ return;
3658
+ }
3659
+ actions.push(client.deleteEntry({ entryId: id, state: CANVAS_PUBLISHED_STATE3 }));
3660
+ log({
3661
+ action: "update",
3662
+ id,
3663
+ providerId: sourceObject.providerId,
3664
+ displayName: sourceObject.displayName ?? sourceObject.providerId,
3665
+ whatIf,
3666
+ diff: diffJson3(targetObject.object, sourceObject.object)
3667
+ });
3668
+ }
3669
+ }
3670
+ };
3671
+
3488
3672
  // src/commands/canvas/commands/entry/update.ts
3489
- import { ContentClient as ContentClient13 } from "@uniformdev/canvas";
3673
+ import { ContentClient as ContentClient15 } from "@uniformdev/canvas";
3490
3674
  var EntryUpdateModule = {
3491
3675
  command: "update <filename>",
3492
3676
  aliases: ["put"],
@@ -3500,7 +3684,7 @@ var EntryUpdateModule = {
3500
3684
  ),
3501
3685
  handler: async ({ apiHost, apiKey, proxy, filename, project: projectId }) => {
3502
3686
  const fetch3 = nodeFetchProxy(proxy);
3503
- const client = new ContentClient13({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3687
+ const client = new ContentClient15({ apiKey, apiHost, fetch: fetch3, projectId, bypassCache: true });
3504
3688
  const file = readFileToObject(filename);
3505
3689
  await client.upsertEntry(file);
3506
3690
  }
@@ -3510,7 +3694,7 @@ var EntryUpdateModule = {
3510
3694
  var EntryModule = {
3511
3695
  command: "entry <command>",
3512
3696
  describe: "Commands for Entries",
3513
- builder: (yargs28) => yargs28.command(EntryGetModule).command(EntryListModule).command(EntryRemoveModule).command(EntryUpdateModule).command(EntryPullModule).command(EntryPushModule).demandCommand(),
3697
+ builder: (yargs28) => yargs28.command(EntryGetModule).command(EntryListModule).command(EntryRemoveModule).command(EntryUpdateModule).command(EntryPullModule).command(EntryPushModule).command(EntryPublishModule).command(EntryUnpublishModule).demandCommand(),
3514
3698
  handler: () => {
3515
3699
  yargs7.help();
3516
3700
  }
@@ -5937,7 +6121,7 @@ var package_default = {
5937
6121
  "@types/js-yaml": "4.0.9",
5938
6122
  "@types/jsonwebtoken": "9.0.5",
5939
6123
  "@types/lodash.isequalwith": "4.4.9",
5940
- "@types/node": "18.19.3",
6124
+ "@types/node": "20.10.5",
5941
6125
  "@types/yargs": "17.0.32"
5942
6126
  },
5943
6127
  bin: {
@@ -8111,7 +8295,7 @@ var SyncPushModule = {
8111
8295
  )
8112
8296
  ),
8113
8297
  handler: async ({ serialization, ...otherParams }) => {
8114
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
8298
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
8115
8299
  const config2 = serialization;
8116
8300
  const enabledEntities = Object.entries({
8117
8301
  locale: LocalePushModule,
@@ -8166,6 +8350,9 @@ var SyncPushModule = {
8166
8350
  if (((_g = config2.entitiesConfig) == null ? void 0 : _g.composition) && ((_j = (_i = (_h = config2.entitiesConfig) == null ? void 0 : _h.composition) == null ? void 0 : _i.push) == null ? void 0 : _j.disabled) !== true && ((_l = (_k = config2.entitiesConfig) == null ? void 0 : _k.composition) == null ? void 0 : _l.publish)) {
8167
8351
  await CompositionPublishModule.handler({ ...otherParams, all: true });
8168
8352
  }
8353
+ if (((_m = config2.entitiesConfig) == null ? void 0 : _m.entry) && ((_p = (_o = (_n = config2.entitiesConfig) == null ? void 0 : _n.entry) == null ? void 0 : _o.push) == null ? void 0 : _p.disabled) !== true && ((_r = (_q = config2.entitiesConfig) == null ? void 0 : _q.entry) == null ? void 0 : _r.publish)) {
8354
+ await EntryPublishModule.handler({ ...otherParams, all: true });
8355
+ }
8169
8356
  }
8170
8357
  };
8171
8358
  var getPushMode = (entityType, config2) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniformdev/cli",
3
- "version": "19.92.2",
3
+ "version": "19.92.3-alpha.7+a4ee2d638",
4
4
  "description": "Uniform command line interface tool",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "./cli.js",
@@ -17,12 +17,12 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@thi.ng/mime": "^2.2.23",
20
- "@uniformdev/assets": "19.92.2",
21
- "@uniformdev/canvas": "19.92.2",
22
- "@uniformdev/context": "19.92.2",
23
- "@uniformdev/files": "19.92.2",
24
- "@uniformdev/project-map": "19.92.2",
25
- "@uniformdev/redirect": "19.92.2",
20
+ "@uniformdev/assets": "19.92.3-alpha.7+a4ee2d638",
21
+ "@uniformdev/canvas": "19.92.3-alpha.7+a4ee2d638",
22
+ "@uniformdev/context": "19.92.3-alpha.7+a4ee2d638",
23
+ "@uniformdev/files": "19.92.3-alpha.7+a4ee2d638",
24
+ "@uniformdev/project-map": "19.92.3-alpha.7+a4ee2d638",
25
+ "@uniformdev/redirect": "19.92.3-alpha.7+a4ee2d638",
26
26
  "call-bind": "^1.0.2",
27
27
  "colorette": "2.0.20",
28
28
  "cosmiconfig": "8.3.6",
@@ -57,7 +57,7 @@
57
57
  "@types/js-yaml": "4.0.9",
58
58
  "@types/jsonwebtoken": "9.0.5",
59
59
  "@types/lodash.isequalwith": "4.4.9",
60
- "@types/node": "18.19.3",
60
+ "@types/node": "20.10.5",
61
61
  "@types/yargs": "17.0.32"
62
62
  },
63
63
  "bin": {
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "8a0bea83eef2d7353758902ed61920b39187c00a"
72
+ "gitHead": "a4ee2d638902c3fb978d7c7344a1dbc52ec25912"
73
73
  }