@contentful/experience-design-system-cli 2.41.1-dev-build-699ca2d9.0 → 2.41.1-dev-build-f74a0859.0

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/app.js CHANGED
@@ -1676,12 +1676,9 @@ var init_schema = __esm({
1676
1676
  $required: { type: "boolean" },
1677
1677
  $default: {},
1678
1678
  $values: { type: "array", items: { type: "string" } },
1679
- "$token.kind": { type: "string", minLength: 1 },
1679
+ "$token.kind": { type: "string" },
1680
1680
  "$token.allowed": { type: "array", items: { type: "string" } }
1681
1681
  },
1682
- // The API rejects a token property that does not say which kind of token it takes.
1683
- if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
1684
- then: { type: "object", required: ["$token.kind"] },
1685
1682
  additionalProperties: false
1686
1683
  },
1687
1684
  slot: {
@@ -18194,7 +18191,7 @@ function FieldForm({
18194
18191
  onSkip,
18195
18192
  skipLabel: skipLabel2 = "skip",
18196
18193
  onQuit,
18197
- quitLabel = "back without saving",
18194
+ quitLabel = "back (unsaved changes are lost)",
18198
18195
  actions = [],
18199
18196
  notice,
18200
18197
  busy = false,
@@ -18257,7 +18254,7 @@ function FieldForm({
18257
18254
  }
18258
18255
  if (isLastField) {
18259
18256
  setEditing(false);
18260
- onSave();
18257
+ setActive(0);
18261
18258
  return;
18262
18259
  }
18263
18260
  const next = fields2[active + 1];
@@ -18321,7 +18318,7 @@ function FieldForm({
18321
18318
  hints: editing ? [
18322
18319
  { keys: "type", label: "edit" },
18323
18320
  { keys: "\u2190/\u2192", label: "move cursor" },
18324
- { keys: "\u23CE", label: enterAdvances ? isLastField ? saveLabel : "next" : "done" },
18321
+ { keys: "\u23CE", label: enterAdvances && !isLastField ? "next" : "done" },
18325
18322
  { keys: "Ctrl+D", label: "clear" },
18326
18323
  { keys: "Esc", label: "cancel edit" }
18327
18324
  ] : [
@@ -22218,12 +22215,9 @@ var cdfJsonSchema2 = {
22218
22215
  $required: { type: "boolean" },
22219
22216
  $default: {},
22220
22217
  $values: { type: "array", items: { type: "string" } },
22221
- "$token.kind": { type: "string", minLength: 1 },
22218
+ "$token.kind": { type: "string" },
22222
22219
  "$token.allowed": { type: "array", items: { type: "string" } }
22223
22220
  },
22224
- // The API rejects a token property that does not say which kind of token it takes.
22225
- if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
22226
- then: { type: "object", required: ["$token.kind"] },
22227
22221
  additionalProperties: false
22228
22222
  },
22229
22223
  slot: {
@@ -22282,42 +22276,14 @@ function parseCDFComponents(obj, prefix = "") {
22282
22276
  }
22283
22277
  return { components, tokens };
22284
22278
  }
22285
- function entryValidator(name) {
22286
- const check = ajv2.getSchema(`${CDF_SCHEMA_URL2}#/definitions/${name}`);
22287
- if (!check)
22288
- throw new Error(`the CDF schema has no "${name}" definition`);
22289
- return check;
22290
- }
22291
- var validateComponentEntry = entryValidator("component");
22292
- var validateTokenEntry = entryValidator("token");
22293
- function toValidationErrors(errors, prefix = "") {
22294
- return (errors ?? []).filter((err) => err.keyword !== "if").map((err) => ({
22295
- path: `${prefix}${err.instancePath}` || "/",
22296
- message: err.message ?? "Unknown validation error",
22297
- expected: err.params ? JSON.stringify(err.params) : void 0
22298
- }));
22299
- }
22300
- function entryErrors(node, prefix) {
22301
- const errors = [];
22302
- for (const [key, value] of Object.entries(node)) {
22303
- if (key.startsWith("$") || typeof value !== "object" || value === null)
22304
- continue;
22305
- const path5 = `${prefix}/${key}`;
22306
- const type = value["$type"];
22307
- const check = type === "component" ? validateComponentEntry : TOKEN_TYPE_SET3.has(type) ? validateTokenEntry : void 0;
22308
- if (!check) {
22309
- errors.push(...entryErrors(value, path5));
22310
- } else if (!check(value)) {
22311
- errors.push(...toValidationErrors(check.errors, path5));
22312
- }
22313
- }
22314
- return errors;
22315
- }
22316
22279
  function validateCDF2(input) {
22317
22280
  const valid = validate2(input);
22318
22281
  if (!valid) {
22319
- const focused = typeof input === "object" && input !== null ? entryErrors(input, "") : [];
22320
- const errors = focused.length > 0 ? focused : toValidationErrors(validate2.errors);
22282
+ const errors = (validate2.errors ?? []).map((err) => ({
22283
+ path: err.instancePath || "/",
22284
+ message: err.message ?? "Unknown validation error",
22285
+ expected: err.params ? JSON.stringify(err.params) : void 0
22286
+ }));
22321
22287
  return { valid: false, errors, components: [], tokens: [] };
22322
22288
  }
22323
22289
  const file = input;
@@ -22369,45 +22335,6 @@ var CDFTokenSchema2 = z3.strictObject({
22369
22335
  $description: z3.optional(z3.string())
22370
22336
  });
22371
22337
 
22372
- // packages/experience-design-system-types/dist/src/cdf/repair-token-kinds.js
22373
- var UNRESOLVED_WARNING = /\s*WARNING: token_kind unknown[^\n]*/;
22374
- function inferTokenKind(propName, prop, tokens) {
22375
- const bound = typeof prop.$default === "string" ? tokens.find(({ path: path5 }) => path5 === prop.$default) : void 0;
22376
- if (bound)
22377
- return bound.entry.$type;
22378
- const name = propName.toLowerCase();
22379
- const kinds = new Set(tokens.filter(({ path: path5 }) => path5.toLowerCase().split(".").includes(name)).map(({ entry }) => entry.$type));
22380
- return kinds.size === 1 ? [...kinds][0] : void 0;
22381
- }
22382
- function withoutWarning(prop) {
22383
- if (prop.$description === void 0)
22384
- return prop;
22385
- const description = prop.$description.replace(UNRESOLVED_WARNING, "").trim();
22386
- const { $description: _stale, ...rest } = prop;
22387
- return description ? { ...rest, $description: description } : rest;
22388
- }
22389
- function repairTokenKinds(entry, componentKey, tokens, note) {
22390
- const properties = { ...entry.$properties };
22391
- let repaired = false;
22392
- for (const [name, prop] of Object.entries(entry.$properties)) {
22393
- if (prop.$type !== "token" || prop["$token.kind"])
22394
- continue;
22395
- repaired = true;
22396
- const kind = inferTokenKind(name, prop, tokens);
22397
- if (kind) {
22398
- properties[name] = { ...withoutWarning(prop), "$token.kind": kind };
22399
- note?.(`${componentKey}.${name} had no token kind, so "${kind}" was taken from the token file`);
22400
- } else {
22401
- const plain = { ...withoutWarning(prop), $type: "string" };
22402
- delete plain["$token.allowed"];
22403
- delete plain.$default;
22404
- properties[name] = plain;
22405
- note?.(`${componentKey}.${name} had no token kind and none could be told, so it was saved as a string property`);
22406
- }
22407
- }
22408
- return repaired ? { ...entry, $properties: properties } : entry;
22409
- }
22410
-
22411
22338
  // packages/experience-design-system-types/dist/src/cdf/build.js
22412
22339
  function stripUnsupportedSlotFields(entry) {
22413
22340
  if (!entry.$slots)
@@ -22444,7 +22371,7 @@ function buildCDF2(components, tokens, opts = {}) {
22444
22371
  return void 0;
22445
22372
  const doc = { $schema: CDF_SCHEMA_URL2 };
22446
22373
  for (const { key, entry } of components) {
22447
- setAtPath(doc, key, stripUnsupportedSlotFields(repairTokenKinds(entry, key, tokens, opts.onRepair)));
22374
+ setAtPath(doc, key, stripUnsupportedSlotFields(entry));
22448
22375
  }
22449
22376
  for (const { path: path5, entry } of resolveTokenPathCollisions(tokens)) {
22450
22377
  setAtPath(doc, path5, entry);
@@ -29268,13 +29195,12 @@ function nextStateAfterPrint(opts) {
29268
29195
 
29269
29196
  // packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts
29270
29197
  var SAVE_CONFIRMATION_DELAY_MS = 1e3;
29271
- var describeCdfError = (error) => `${error.path.replace(/^\//, "").replace("/$properties/", ".").replaceAll("/", ".")}: ${error.message}`;
29272
29198
  function buildSavedCDF(components, tokens, opts = {}) {
29273
29199
  const cdf = buildCDF2(components, toCdfTokens(tokens), opts);
29274
29200
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
29275
29201
  const validation = validateCDF2(cdf);
29276
29202
  if (!validation.valid) {
29277
- throw new Error(`generated CDF failed validation: ${validation.errors.map(describeCdfError).join("; ")}`);
29203
+ throw new Error(`generated CDF failed validation: ${validation.errors.map((error) => error.message).join(", ")}`);
29278
29204
  }
29279
29205
  return cdf;
29280
29206
  }
@@ -29301,11 +29227,7 @@ async function runPrintFiles(input, deps, onPatch) {
29301
29227
  db.close();
29302
29228
  }
29303
29229
  if (!input.tokenSessionId && input.tokensPath) tokens = await deps.readTokens(input.tokensPath);
29304
- const cdf = buildSavedCDF(components, tokens, {
29305
- deleteAll: input.allowEmpty,
29306
- onRepair: (message) => deps.warn(`${message}
29307
- `)
29308
- });
29230
+ const cdf = buildSavedCDF(components, tokens, { deleteAll: input.allowEmpty });
29309
29231
  await deps.writeFile(componentsPath, `${JSON.stringify(cdf, null, 2)}
29310
29232
  `);
29311
29233
  deps.warn(
package/dist/index.js CHANGED
@@ -1986,12 +1986,9 @@ var init_schema = __esm({
1986
1986
  $required: { type: "boolean" },
1987
1987
  $default: {},
1988
1988
  $values: { type: "array", items: { type: "string" } },
1989
- "$token.kind": { type: "string", minLength: 1 },
1989
+ "$token.kind": { type: "string" },
1990
1990
  "$token.allowed": { type: "array", items: { type: "string" } }
1991
1991
  },
1992
- // The API rejects a token property that does not say which kind of token it takes.
1993
- if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
1994
- then: { type: "object", required: ["$token.kind"] },
1995
1992
  additionalProperties: false
1996
1993
  },
1997
1994
  slot: {
@@ -20928,7 +20925,7 @@ function FieldForm({
20928
20925
  onSkip,
20929
20926
  skipLabel: skipLabel2 = "skip",
20930
20927
  onQuit,
20931
- quitLabel = "back without saving",
20928
+ quitLabel = "back (unsaved changes are lost)",
20932
20929
  actions = [],
20933
20930
  notice,
20934
20931
  busy = false,
@@ -20991,7 +20988,7 @@ function FieldForm({
20991
20988
  }
20992
20989
  if (isLastField) {
20993
20990
  setEditing(false);
20994
- onSave();
20991
+ setActive(0);
20995
20992
  return;
20996
20993
  }
20997
20994
  const next = fields2[active + 1];
@@ -21055,7 +21052,7 @@ function FieldForm({
21055
21052
  hints: editing ? [
21056
21053
  { keys: "type", label: "edit" },
21057
21054
  { keys: "\u2190/\u2192", label: "move cursor" },
21058
- { keys: "\u23CE", label: enterAdvances ? isLastField ? saveLabel : "next" : "done" },
21055
+ { keys: "\u23CE", label: enterAdvances && !isLastField ? "next" : "done" },
21059
21056
  { keys: "Ctrl+D", label: "clear" },
21060
21057
  { keys: "Esc", label: "cancel edit" }
21061
21058
  ] : [
@@ -25396,12 +25393,9 @@ var init_schema2 = __esm({
25396
25393
  $required: { type: "boolean" },
25397
25394
  $default: {},
25398
25395
  $values: { type: "array", items: { type: "string" } },
25399
- "$token.kind": { type: "string", minLength: 1 },
25396
+ "$token.kind": { type: "string" },
25400
25397
  "$token.allowed": { type: "array", items: { type: "string" } }
25401
25398
  },
25402
- // The API rejects a token property that does not say which kind of token it takes.
25403
- if: { type: "object", properties: { $type: { const: "token" } }, required: ["$type"] },
25404
- then: { type: "object", required: ["$token.kind"] },
25405
25399
  additionalProperties: false
25406
25400
  },
25407
25401
  slot: {
@@ -25460,40 +25454,14 @@ function parseCDFComponents(obj, prefix = "") {
25460
25454
  }
25461
25455
  return { components, tokens };
25462
25456
  }
25463
- function entryValidator(name) {
25464
- const check = ajv2.getSchema(`${CDF_SCHEMA_URL2}#/definitions/${name}`);
25465
- if (!check)
25466
- throw new Error(`the CDF schema has no "${name}" definition`);
25467
- return check;
25468
- }
25469
- function toValidationErrors(errors, prefix = "") {
25470
- return (errors ?? []).filter((err) => err.keyword !== "if").map((err) => ({
25471
- path: `${prefix}${err.instancePath}` || "/",
25472
- message: err.message ?? "Unknown validation error",
25473
- expected: err.params ? JSON.stringify(err.params) : void 0
25474
- }));
25475
- }
25476
- function entryErrors(node, prefix) {
25477
- const errors = [];
25478
- for (const [key, value] of Object.entries(node)) {
25479
- if (key.startsWith("$") || typeof value !== "object" || value === null)
25480
- continue;
25481
- const path5 = `${prefix}/${key}`;
25482
- const type = value["$type"];
25483
- const check = type === "component" ? validateComponentEntry : TOKEN_TYPE_SET3.has(type) ? validateTokenEntry : void 0;
25484
- if (!check) {
25485
- errors.push(...entryErrors(value, path5));
25486
- } else if (!check(value)) {
25487
- errors.push(...toValidationErrors(check.errors, path5));
25488
- }
25489
- }
25490
- return errors;
25491
- }
25492
25457
  function validateCDF2(input) {
25493
25458
  const valid = validate2(input);
25494
25459
  if (!valid) {
25495
- const focused = typeof input === "object" && input !== null ? entryErrors(input, "") : [];
25496
- const errors = focused.length > 0 ? focused : toValidationErrors(validate2.errors);
25460
+ const errors = (validate2.errors ?? []).map((err) => ({
25461
+ path: err.instancePath || "/",
25462
+ message: err.message ?? "Unknown validation error",
25463
+ expected: err.params ? JSON.stringify(err.params) : void 0
25464
+ }));
25497
25465
  return { valid: false, errors, components: [], tokens: [] };
25498
25466
  }
25499
25467
  const file = input;
@@ -25515,7 +25483,7 @@ function validateCDF2(input) {
25515
25483
  const { components, tokens } = parseCDFComponents(file);
25516
25484
  return { valid: true, errors: [], components, tokens };
25517
25485
  }
25518
- var ajv2, validate2, TOKEN_TYPE_SET3, validateComponentEntry, validateTokenEntry;
25486
+ var ajv2, validate2, TOKEN_TYPE_SET3;
25519
25487
  var init_validate5 = __esm({
25520
25488
  "packages/experience-design-system-types/dist/src/cdf/validate.js"() {
25521
25489
  "use strict";
@@ -25524,8 +25492,6 @@ var init_validate5 = __esm({
25524
25492
  ajv2 = new Ajv2({ allErrors: true });
25525
25493
  validate2 = ajv2.compile(cdfJsonSchema2);
25526
25494
  TOKEN_TYPE_SET3 = new Set(DESIGN_TOKEN_TYPES2);
25527
- validateComponentEntry = entryValidator("component");
25528
- validateTokenEntry = entryValidator("token");
25529
25495
  }
25530
25496
  });
25531
25497
 
@@ -25566,51 +25532,6 @@ var init_types7 = __esm({
25566
25532
  }
25567
25533
  });
25568
25534
 
25569
- // packages/experience-design-system-types/dist/src/cdf/repair-token-kinds.js
25570
- function inferTokenKind(propName, prop, tokens) {
25571
- const bound = typeof prop.$default === "string" ? tokens.find(({ path: path5 }) => path5 === prop.$default) : void 0;
25572
- if (bound)
25573
- return bound.entry.$type;
25574
- const name = propName.toLowerCase();
25575
- const kinds = new Set(tokens.filter(({ path: path5 }) => path5.toLowerCase().split(".").includes(name)).map(({ entry }) => entry.$type));
25576
- return kinds.size === 1 ? [...kinds][0] : void 0;
25577
- }
25578
- function withoutWarning(prop) {
25579
- if (prop.$description === void 0)
25580
- return prop;
25581
- const description = prop.$description.replace(UNRESOLVED_WARNING, "").trim();
25582
- const { $description: _stale, ...rest } = prop;
25583
- return description ? { ...rest, $description: description } : rest;
25584
- }
25585
- function repairTokenKinds(entry, componentKey, tokens, note) {
25586
- const properties = { ...entry.$properties };
25587
- let repaired = false;
25588
- for (const [name, prop] of Object.entries(entry.$properties)) {
25589
- if (prop.$type !== "token" || prop["$token.kind"])
25590
- continue;
25591
- repaired = true;
25592
- const kind = inferTokenKind(name, prop, tokens);
25593
- if (kind) {
25594
- properties[name] = { ...withoutWarning(prop), "$token.kind": kind };
25595
- note?.(`${componentKey}.${name} had no token kind, so "${kind}" was taken from the token file`);
25596
- } else {
25597
- const plain = { ...withoutWarning(prop), $type: "string" };
25598
- delete plain["$token.allowed"];
25599
- delete plain.$default;
25600
- properties[name] = plain;
25601
- note?.(`${componentKey}.${name} had no token kind and none could be told, so it was saved as a string property`);
25602
- }
25603
- }
25604
- return repaired ? { ...entry, $properties: properties } : entry;
25605
- }
25606
- var UNRESOLVED_WARNING;
25607
- var init_repair_token_kinds = __esm({
25608
- "packages/experience-design-system-types/dist/src/cdf/repair-token-kinds.js"() {
25609
- "use strict";
25610
- UNRESOLVED_WARNING = /\s*WARNING: token_kind unknown[^\n]*/;
25611
- }
25612
- });
25613
-
25614
25535
  // packages/experience-design-system-types/dist/src/cdf/build.js
25615
25536
  function stripUnsupportedSlotFields(entry) {
25616
25537
  if (!entry.$slots)
@@ -25646,7 +25567,7 @@ function buildCDF2(components, tokens, opts = {}) {
25646
25567
  return void 0;
25647
25568
  const doc = { $schema: CDF_SCHEMA_URL2 };
25648
25569
  for (const { key, entry } of components) {
25649
- setAtPath(doc, key, stripUnsupportedSlotFields(repairTokenKinds(entry, key, tokens, opts.onRepair)));
25570
+ setAtPath(doc, key, stripUnsupportedSlotFields(entry));
25650
25571
  }
25651
25572
  for (const { path: path5, entry } of resolveTokenPathCollisions(tokens)) {
25652
25573
  setAtPath(doc, path5, entry);
@@ -25688,7 +25609,6 @@ var COLLISION_LEAF_KEY;
25688
25609
  var init_build2 = __esm({
25689
25610
  "packages/experience-design-system-types/dist/src/cdf/build.js"() {
25690
25611
  "use strict";
25691
- init_repair_token_kinds();
25692
25612
  init_schema2();
25693
25613
  COLLISION_LEAF_KEY = "default";
25694
25614
  }
@@ -33031,7 +32951,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
33031
32951
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
33032
32952
  const validation = validateCDF2(cdf);
33033
32953
  if (!validation.valid) {
33034
- throw new Error(`generated CDF failed validation: ${validation.errors.map(describeCdfError).join("; ")}`);
32954
+ throw new Error(`generated CDF failed validation: ${validation.errors.map((error) => error.message).join(", ")}`);
33035
32955
  }
33036
32956
  return cdf;
33037
32957
  }
@@ -33049,11 +32969,7 @@ async function runPrintFiles(input, deps, onPatch) {
33049
32969
  db.close();
33050
32970
  }
33051
32971
  if (!input.tokenSessionId && input.tokensPath) tokens = await deps.readTokens(input.tokensPath);
33052
- const cdf = buildSavedCDF(components, tokens, {
33053
- deleteAll: input.allowEmpty,
33054
- onRepair: (message) => deps.warn(`${message}
33055
- `)
33056
- });
32972
+ const cdf = buildSavedCDF(components, tokens, { deleteAll: input.allowEmpty });
33057
32973
  await deps.writeFile(componentsPath, `${JSON.stringify(cdf, null, 2)}
33058
32974
  `);
33059
32975
  deps.warn(
@@ -33114,7 +33030,7 @@ async function recordRun(input, deps) {
33114
33030
  return null;
33115
33031
  }
33116
33032
  }
33117
- var SAVE_CONFIRMATION_DELAY_MS, describeCdfError, realSaveDeps;
33033
+ var SAVE_CONFIRMATION_DELAY_MS, realSaveDeps;
33118
33034
  var init_save = __esm({
33119
33035
  "packages/experience-design-system-cli/src/tui/import/steps/10-flow/flow/save.ts"() {
33120
33036
  "use strict";
@@ -33122,7 +33038,6 @@ var init_save = __esm({
33122
33038
  init_src4();
33123
33039
  init_run_print_files_helpers();
33124
33040
  SAVE_CONFIRMATION_DELAY_MS = 1e3;
33125
- describeCdfError = (error) => `${error.path.replace(/^\//, "").replace("/$properties/", ".").replaceAll("/", ".")}: ${error.message}`;
33126
33041
  realSaveDeps = () => ({
33127
33042
  openDb: openPipelineDb,
33128
33043
  readTokens: (path5) => readTokensFromPath2({ flag: "tokens", path: path5 }),
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.41.1-dev-build-699ca2d9.0",
3
+ "version": "2.41.1-dev-build-f74a0859.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.41.1-dev-build-699ca2d9.0",
3
+ "version": "2.41.1-dev-build-f74a0859.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "ts-morph": "^27.0.2",
46
46
  "typescript": "^5.9.3",
47
47
  "zod": "^4.6.5",
48
- "@contentful/experience-design-system-types": "2.41.1-dev-build-699ca2d9.0"
48
+ "@contentful/experience-design-system-types": "2.41.1-dev-build-f74a0859.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@tsconfig/node24": "^24.0.4",
@@ -59,7 +59,7 @@
59
59
  "ink-testing-library": "^4.0.0",
60
60
  "typescript-eslint": "^8.67.0",
61
61
  "vitest": "^4.0.16",
62
- "@contentful/experience-design-system-backend-pipeline": "2.41.1-dev-build-699ca2d9.0"
62
+ "@contentful/experience-design-system-backend-pipeline": "2.41.1-dev-build-f74a0859.0"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",