@navikt/aksel 8.9.0 → 8.10.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.
Files changed (35) hide show
  1. package/dist/codemod/migrations.js +5 -3
  2. package/dist/codemod/run-codeshift.js +1 -1
  3. package/dist/codemod/tokens-map.js +4 -1
  4. package/dist/codemod/transforms/rename-prop/rename-prop.js +0 -4
  5. package/dist/codemod/transforms/v1.0.0/chat/chat.js +29 -14
  6. package/dist/codemod/transforms/v1.0.0/pagination/pagination.js +24 -20
  7. package/dist/codemod/transforms/v1.0.0/preset/preset.js +0 -4
  8. package/dist/codemod/transforms/v1.0.0/tabs/tabs.js +40 -31
  9. package/dist/codemod/transforms/v2.0.0/update-css-tokens/update-css-tokens.js +0 -4
  10. package/dist/codemod/transforms/v2.0.0/update-js-tokens/update-js-tokens.js +1 -1
  11. package/dist/codemod/transforms/v2.0.0/update-less-tokens/update-less-tokens.js +0 -4
  12. package/dist/codemod/transforms/v2.0.0/update-sass-tokens/update-sass-tokens.js +0 -4
  13. package/dist/codemod/transforms/v3.0.0/copybutton/copybutton.js +15 -10
  14. package/dist/codemod/transforms/v4.0.0/date/date.js +0 -4
  15. package/dist/codemod/transforms/v4.0.0/internal-css/internal-css.js +0 -4
  16. package/dist/codemod/transforms/v4.0.0/internal-react/internal-react.js +0 -4
  17. package/dist/codemod/transforms/v6.0.0/chat/chat.js +8 -7
  18. package/dist/codemod/transforms/v8.0.0/box/box.js +4 -4
  19. package/dist/codemod/transforms/v8.0.0/list/list.js +23 -18
  20. package/dist/codemod/transforms/v8.0.0/primitives-spacing/spacing.js +3 -3
  21. package/dist/codemod/utils/ast.js +3 -4
  22. package/dist/codemod/utils/check.js +1 -0
  23. package/dist/codemod/utils/jsx-value.js +75 -0
  24. package/dist/codemod/utils/move-variant-to-data-color.js +3 -19
  25. package/dist/codemod/utils/packageImports.js +3 -2
  26. package/dist/codemod/utils/removeProps.js +3 -0
  27. package/dist/codemod/utils/rename-props.js +4 -2
  28. package/dist/codemod/v8-tokens/config/TokenStatus.js +7 -4
  29. package/dist/codemod/v8-tokens/run-tooling.js +5 -2
  30. package/dist/codemod/v8-tokens/tasks/print-remaining.js +1 -1
  31. package/dist/codemod/v8-tokens/tasks/status.js +1 -1
  32. package/dist/codemod/v8-tokens/transforms/v8-tokens-less.js +1 -1
  33. package/dist/codemod/v8-tokens/transforms/v8-tokens-scss.js +1 -1
  34. package/dist/version.js +1 -1
  35. package/package.json +7 -5
@@ -235,9 +235,11 @@ function getMigrationsForVersion(version) {
235
235
  /**
236
236
  * Returns the override migrations available for a specific version.
237
237
  */
238
+ function isOverrideVersion(version) {
239
+ return version in exports.migrationStringOverride;
240
+ }
238
241
  function getOverridesForVersion(version) {
239
- var _a;
240
- return (_a = exports.migrationStringOverride[version]) !== null && _a !== void 0 ? _a : [];
242
+ return isOverrideVersion(version) ? exports.migrationStringOverride[version] : [];
241
243
  }
242
244
  /**
243
245
  * Allows injecting additional migration names that are not part of the main migrations-list.
@@ -258,7 +260,7 @@ function getMigrationString() {
258
260
  let str = "";
259
261
  Object.entries(exports.migrations).forEach(([version, vMigrations]) => {
260
262
  str += `\n${chalk_1.default.underline(version)}\n`;
261
- const overrideMigrations = exports.migrationStringOverride[version] || [];
263
+ const overrideMigrations = getOverridesForVersion(version);
262
264
  overrideMigrations.forEach((migration) => {
263
265
  str += `${chalk_1.default.blue(migration.value)}: ${migration.description}\n`;
264
266
  });
@@ -101,7 +101,7 @@ function runCodeshift(input, options, program) {
101
101
  warning && console.info(`\n${chalk_1.default.yellow(warning)}\n`);
102
102
  }
103
103
  catch (error) {
104
- program.error(chalk_1.default.red("Error:", error.message));
104
+ program.error(chalk_1.default.red("Error:", error instanceof Error ? error.message : String(error)));
105
105
  }
106
106
  });
107
107
  }
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tokens = void 0;
1
4
  /* prettier-ignore */
2
5
  const tokens = [
3
6
  ["--navds-semantic-color-text-inverted", "--a-text-on-inverted"],
@@ -359,4 +362,4 @@ const tokens = [
359
362
  ["--navdsi-header-color-active", "--a-surface-inverted-active"],
360
363
  ["--navds-button-icon-adjustment", "--ac-button-icon-margin"]
361
364
  ];
362
- module.exports = { tokens };
365
+ exports.tokens = tokens;
@@ -5,10 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = transformer;
7
7
  const rename_props_1 = __importDefault(require("../../utils/rename-props"));
8
- /**
9
- * @param {import('jscodeshift').FileInfo} file
10
- * @param {import('jscodeshift').API} api
11
- */
12
8
  function transformer(file, api, options) {
13
9
  const j = api.jscodeshift;
14
10
  const root = j(file.source);
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = transformer;
7
7
  const lineterminator_1 = require("../../../utils/lineterminator");
8
8
  const rename_props_1 = __importDefault(require("../../../utils/rename-props"));
9
- /**
10
- * @param {import('jscodeshift').FileInfo} file
11
- * @param {import('jscodeshift').API} api
12
- */
13
9
  function transformer(file, api) {
14
10
  const j = api.jscodeshift;
15
11
  let localName = "SpeechBubble";
@@ -19,15 +15,20 @@ function transformer(file, api) {
19
15
  .find(j.ImportDeclaration)
20
16
  .filter((path) => path.node.source.value === "@navikt/ds-react")
21
17
  .forEach((imp) => {
22
- imp.value.specifiers.forEach((x) => {
18
+ var _a;
19
+ (_a = imp.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((x) => {
20
+ if (x.type !== "ImportSpecifier")
21
+ return;
23
22
  if (x.imported.name === "SpeechBubble") {
24
- if (x.local.name !== x.imported.name) {
25
- localName = x.local.name;
23
+ if (x.local && x.local.name !== x.imported.name) {
24
+ localName = String(x.local.name);
26
25
  x.imported.name = "Chat";
27
26
  }
28
27
  else {
29
28
  x.imported.name = "Chat";
30
- x.local.name = "Chat";
29
+ if (x.local) {
30
+ x.local.name = "Chat";
31
+ }
31
32
  }
32
33
  }
33
34
  });
@@ -47,18 +48,32 @@ function transformer(file, api) {
47
48
  openingElement: { name: { name: localName } },
48
49
  });
49
50
  compRoot.forEach((x) => {
51
+ var _a;
50
52
  if (localName !== "SpeechBubble")
51
53
  return;
52
- x.node.openingElement.name.name = "Chat";
53
- x.node.closingElement.name.name = "Chat";
54
+ const opening = x.node.openingElement.name;
55
+ if (opening.type === "JSXIdentifier") {
56
+ opening.name = "Chat";
57
+ }
58
+ const closing = (_a = x.node.closingElement) === null || _a === void 0 ? void 0 : _a.name;
59
+ if ((closing === null || closing === void 0 ? void 0 : closing.type) === "JSXIdentifier") {
60
+ closing.name = "Chat";
61
+ }
54
62
  });
55
63
  /* Need to handle dot-notations differently */
56
64
  const child = root.find(j.JSXElement);
57
65
  child.forEach((x) => {
58
- if (x.value.openingElement.name.type === "JSXMemberExpression" &&
59
- x.value.openingElement.name.object.name === "SpeechBubble") {
60
- x.value.openingElement.name.object.name = "Chat";
61
- x.value.closingElement.name.object.name = "Chat";
66
+ var _a;
67
+ const openingName = x.value.openingElement.name;
68
+ if (openingName.type === "JSXMemberExpression" &&
69
+ openingName.object.type === "JSXIdentifier" &&
70
+ openingName.object.name === "SpeechBubble") {
71
+ openingName.object.name = "Chat";
72
+ const closingName = (_a = x.value.closingElement) === null || _a === void 0 ? void 0 : _a.name;
73
+ if ((closingName === null || closingName === void 0 ? void 0 : closingName.type) === "JSXMemberExpression" &&
74
+ closingName.object.type === "JSXIdentifier") {
75
+ closingName.object.name = "Chat";
76
+ }
62
77
  }
63
78
  });
64
79
  }
@@ -1,29 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
+ const jsx_value_1 = require("../../../utils/jsx-value");
4
5
  const lineterminator_1 = require("../../../utils/lineterminator");
5
- /**
6
- * @param {import('jscodeshift').FileInfo} file
7
- * @param {import('jscodeshift').API} api
8
- */
9
6
  function transformer(file, api) {
10
7
  const j = api.jscodeshift;
11
8
  let localName = "Pagination";
12
9
  const root = j(file.source);
13
10
  function addMigrationTag(node) {
14
11
  const attributes = node.openingElement.attributes;
15
- const isMigrated = attributes.find((attr) => attr.type === "JSXAttribute" &&
12
+ const isMigrated = attributes === null || attributes === void 0 ? void 0 : attributes.find((attr) => attr.type === "JSXAttribute" &&
16
13
  attr.name.name === "data-version" &&
17
- attr.value.value === "v1");
18
- if (!isMigrated) {
14
+ (0, jsx_value_1.getJSXLiteralValue)(attr.value) === "v1");
15
+ if (!isMigrated && attributes) {
19
16
  attributes.push(j.jsxAttribute(j.jsxIdentifier("data-version"), j.literal("v1")));
20
17
  }
21
18
  }
22
19
  /* https://github.com/mui/material-ui/blob/master/packages/mui-codemod/src/v5.0.0/variant-prop.js */
23
20
  function addExplicitStandardProp(node) {
24
21
  const attributes = node.openingElement.attributes;
25
- const variant = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "size");
26
- if (!variant) {
22
+ const variant = attributes === null || attributes === void 0 ? void 0 : attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "size");
23
+ if (!variant && attributes) {
27
24
  attributes.unshift(j.jsxAttribute(j.jsxIdentifier("size"), j.literal("small")));
28
25
  addMigrationTag(node);
29
26
  }
@@ -33,27 +30,34 @@ function transformer(file, api) {
33
30
  .find(j.ImportDeclaration)
34
31
  .filter((path) => path.node.source.value === "@navikt/ds-react")
35
32
  .forEach((imp) => {
36
- imp.value.specifiers.forEach((x) => {
37
- if (x.imported.name === "Pagination" &&
38
- x.local.name !== x.imported.name) {
39
- localName = x.local.name;
33
+ var _a;
34
+ (_a = imp.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((x) => {
35
+ var _a, _b;
36
+ if (x.type === "ImportSpecifier" &&
37
+ x.imported.type === "Identifier" &&
38
+ x.imported.name === "Pagination" &&
39
+ ((_a = x.local) === null || _a === void 0 ? void 0 : _a.name) !== x.imported.name &&
40
+ ((_b = x.local) === null || _b === void 0 ? void 0 : _b.name)) {
41
+ localName = String(x.local.name);
40
42
  }
41
43
  });
42
44
  });
43
45
  if (j(file.source).findJSXElements(localName)) {
44
46
  root.findJSXElements(`${localName}`).forEach((parent) => {
45
- var _a, _b;
46
- const skip = !!((_a = parent.value.openingElement) === null || _a === void 0 ? void 0 : _a.attributes.find((x) => x.name.name === "data-version" && x.value.value === "v1"));
47
- (_b = parent.value.openingElement) === null || _b === void 0 ? void 0 : _b.attributes.forEach((x) => {
47
+ var _a, _b, _c, _d;
48
+ const skip = !!((_b = (_a = parent.value.openingElement) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b.find((attr) => attr.type === "JSXAttribute" &&
49
+ attr.name.name === "data-version" &&
50
+ (0, jsx_value_1.getJSXLiteralValue)(attr.value) === "v1"));
51
+ (_d = (_c = parent.value.openingElement) === null || _c === void 0 ? void 0 : _c.attributes) === null || _d === void 0 ? void 0 : _d.forEach((x) => {
48
52
  var _a;
49
53
  let didUpdate = false;
50
- if (((_a = x.name) === null || _a === void 0 ? void 0 : _a.name) === "size" && x.type === "JSXAttribute" && !skip) {
51
- /* addExplicitStandardProp */
52
- if (x.value.value === "medium") {
54
+ if (x.type === "JSXAttribute" && ((_a = x.name) === null || _a === void 0 ? void 0 : _a.name) === "size" && !skip) {
55
+ const value = (0, jsx_value_1.getJSXLiteralValue)(x.value);
56
+ if (value === "medium") {
53
57
  x.value = j.literal("small");
54
58
  didUpdate = true;
55
59
  }
56
- else if (x.value.value === "small") {
60
+ else if (value === "small") {
57
61
  x.value = j.literal("xsmall");
58
62
  didUpdate = true;
59
63
  }
@@ -7,10 +7,6 @@ exports.default = transformer;
7
7
  const chat_1 = __importDefault(require("../chat/chat"));
8
8
  const pagination_1 = __importDefault(require("../pagination/pagination"));
9
9
  const tabs_1 = __importDefault(require("../tabs/tabs"));
10
- /**
11
- * @param {import('jscodeshift').FileInfo} file
12
- * @param {import('jscodeshift').API} api
13
- */
14
10
  function transformer(file, api) {
15
11
  file.source = (0, tabs_1.default)(file, api);
16
12
  file.source = (0, chat_1.default)(file, api);
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = transformer;
7
7
  const lineterminator_1 = require("../../../utils/lineterminator");
8
8
  const rename_props_1 = __importDefault(require("../../../utils/rename-props"));
9
- /**
10
- * @param {import('jscodeshift').FileInfo} file
11
- * @param {import('jscodeshift').API} api
12
- */
13
9
  function transformer(file, api) {
14
10
  const j = api.jscodeshift;
15
11
  let localName = "Tabs";
@@ -20,9 +16,13 @@ function transformer(file, api) {
20
16
  .find(j.ImportDeclaration)
21
17
  .filter((path) => path.node.source.value === "@navikt/ds-react")
22
18
  .forEach((imp) => {
23
- imp.value.specifiers.forEach((x) => {
24
- if (x.imported.name === "Tabs" && x.local.name !== x.imported.name) {
25
- localName = x.local.name;
19
+ var _a;
20
+ (_a = imp.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((x) => {
21
+ if (x.type === "ImportSpecifier" &&
22
+ x.imported.name === "Tabs" &&
23
+ x.local &&
24
+ x.local.name !== x.imported.name) {
25
+ localName = String(x.local.name);
26
26
  }
27
27
  });
28
28
  });
@@ -35,43 +35,52 @@ function transformer(file, api) {
35
35
  },
36
36
  });
37
37
  root.findJSXElements(`${localName}`).forEach((parent) => {
38
- parent.value.children.forEach((el) => {
38
+ var _a, _b;
39
+ (_a = parent.value.children) === null || _a === void 0 ? void 0 : _a.forEach((el) => {
40
+ var _a, _b;
41
+ if (el.type !== "JSXElement")
42
+ return;
39
43
  const openingEl = el.openingElement;
40
- if ((openingEl === null || openingEl === void 0 ? void 0 : openingEl.name) && openingEl.name.type === "JSXMemberExpression") {
41
- if (openingEl.name.object.name === localName &&
44
+ if (openingEl.name.type === "JSXMemberExpression") {
45
+ if (openingEl.name.object.type === "JSXIdentifier" &&
46
+ openingEl.name.object.name === localName &&
42
47
  openingEl.name.property.name === "List") {
43
48
  /* Move loop-prop */
44
- el.openingElement.attributes.forEach((x, index) => {
45
- var _a;
46
- if (((_a = x.name) === null || _a === void 0 ? void 0 : _a.name) === "loop" && x.type === "JSXAttribute") {
47
- parent.value.openingElement.attributes.push(x);
48
- delete el.openingElement.attributes[index];
49
+ (_a = openingEl.attributes) === null || _a === void 0 ? void 0 : _a.forEach((x, index) => {
50
+ var _a, _b;
51
+ if (x.type === "JSXAttribute" && x.name.name === "loop") {
52
+ (_a = parent.value.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.push(x);
53
+ (_b = openingEl.attributes) === null || _b === void 0 ? void 0 : _b.splice(index, 1);
49
54
  }
50
55
  });
51
56
  /* Find and move iconPosition-prop to <Tabs/> */
52
- el.children.forEach((tab) => {
57
+ (_b = el.children) === null || _b === void 0 ? void 0 : _b.forEach((tab) => {
58
+ var _a;
59
+ if (tab.type !== "JSXElement")
60
+ return;
53
61
  const tabEl = tab.openingElement;
54
- if ((tabEl === null || tabEl === void 0 ? void 0 : tabEl.name) && tabEl.name.type === "JSXMemberExpression") {
55
- if (tabEl.name.object.name === localName &&
56
- tabEl.name.property.name === "Tab") {
57
- tabEl === null || tabEl === void 0 ? void 0 : tabEl.attributes.forEach((x, index) => {
58
- var _a;
59
- if (((_a = x.name) === null || _a === void 0 ? void 0 : _a.name) === "iconPosition" &&
60
- x.type === "JSXAttribute") {
61
- if (!iconPositionProp) {
62
- iconPositionProp = x;
63
- }
64
- delete tabEl.attributes[index];
62
+ if (tabEl.name.type === "JSXMemberExpression" &&
63
+ tabEl.name.object.type === "JSXIdentifier" &&
64
+ tabEl.name.object.name === localName &&
65
+ tabEl.name.property.name === "Tab") {
66
+ (_a = tabEl.attributes) === null || _a === void 0 ? void 0 : _a.forEach((x, index) => {
67
+ var _a;
68
+ if (x.type === "JSXAttribute" &&
69
+ x.name.name === "iconPosition") {
70
+ if (!iconPositionProp) {
71
+ iconPositionProp = x;
65
72
  }
66
- });
67
- }
73
+ (_a = tabEl.attributes) === null || _a === void 0 ? void 0 : _a.splice(index, 1);
74
+ }
75
+ });
68
76
  }
69
77
  });
70
78
  }
71
79
  }
72
80
  });
73
- iconPositionProp &&
74
- parent.value.openingElement.attributes.push(iconPositionProp);
81
+ if (iconPositionProp) {
82
+ (_b = parent.value.openingElement.attributes) === null || _b === void 0 ? void 0 : _b.push(iconPositionProp);
83
+ }
75
84
  iconPositionProp = null;
76
85
  });
77
86
  }
@@ -2,10 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
4
  const tokens_map_js_1 = require("../../../tokens-map.js");
5
- /**
6
- * @param {import('jscodeshift').FileInfo} file
7
- * @param {import('jscodeshift').API} api
8
- */
9
5
  function transformer(file) {
10
6
  let src = file.source;
11
7
  tokens_map_js_1.tokens.forEach((tok) => {
@@ -24,7 +24,7 @@ function transformer(file, api) {
24
24
  const out = (0, translate_token_1.translateToken)(token[1], "js");
25
25
  let foundName = "";
26
26
  (0, imports_1.getImportSpecifier)(j, root, name, "@navikt/ds-tokens/dist/tokens").forEach((x) => {
27
- foundName = x.node.imported.name;
27
+ foundName = String(x.node.imported.name);
28
28
  });
29
29
  if (name === foundName) {
30
30
  const localName = (0, imports_1.getImportSpecifierName)(j, root, name, "@navikt/ds-tokens/dist/tokens") || name;
@@ -3,10 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
4
  const tokens_map_js_1 = require("../../../tokens-map.js");
5
5
  const translate_token_1 = require("../../../utils/translate-token");
6
- /**
7
- * @param {import('jscodeshift').FileInfo} file
8
- * @param {import('jscodeshift').API} api
9
- */
10
6
  function transformer(file) {
11
7
  let src = file.source;
12
8
  tokens_map_js_1.tokens.forEach((tok) => {
@@ -3,10 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
4
  const tokens_map_js_1 = require("../../../tokens-map.js");
5
5
  const translate_token_1 = require("../../../utils/translate-token");
6
- /**
7
- * @param {import('jscodeshift').FileInfo} file
8
- * @param {import('jscodeshift').API} api
9
- */
10
6
  function transformer(file) {
11
7
  let src = file.source;
12
8
  tokens_map_js_1.tokens.forEach((tok) => {
@@ -8,10 +8,6 @@ const chalk_1 = __importDefault(require("chalk"));
8
8
  const lineterminator_1 = require("../../../utils/lineterminator");
9
9
  const packageImports_1 = __importDefault(require("../../../utils/packageImports"));
10
10
  const removeProps_1 = __importDefault(require("../../../utils/removeProps"));
11
- /**
12
- * @param {import('jscodeshift').FileInfo} file
13
- * @param {import('jscodeshift').API} api
14
- */
15
11
  function transformer(file, api) {
16
12
  const j = api.jscodeshift;
17
13
  let root;
@@ -42,12 +38,14 @@ function transformer(file, api) {
42
38
  ]);
43
39
  const component = root.findJSXElements(localName);
44
40
  component.forEach((node) => {
41
+ var _a, _b;
45
42
  const children = node.node.children;
46
43
  let flagged = false;
47
- if (children.length > 0 &&
48
- !node.node.openingElement.attributes.some((attr) => attr.name.name === "text")) {
44
+ if (children &&
45
+ children.length > 0 &&
46
+ !((_a = node.node.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.some((attr) => attr.type === "JSXAttribute" && attr.name.name === "text"))) {
49
47
  if (children.length === 1 && children[0].type === "JSXText") {
50
- node.node.openingElement.attributes.push(j.jsxAttribute(j.jsxIdentifier("text"), j.literal(children[0].value.trim())));
48
+ (_b = node.node.openingElement.attributes) === null || _b === void 0 ? void 0 : _b.push(j.jsxAttribute(j.jsxIdentifier("text"), j.literal(children[0].value.trim())));
51
49
  }
52
50
  else {
53
51
  flagged = true;
@@ -64,9 +62,16 @@ function transformer(file, api) {
64
62
  openingElement: { name: { name: localName } },
65
63
  });
66
64
  compRoot.forEach((x) => {
67
- x.node.openingElement.name.name = "CopyButton";
68
- if (x.node.children.length > 0) {
69
- x.node.closingElement.name.name = "CopyButton";
65
+ var _a;
66
+ const openingName = x.node.openingElement.name;
67
+ if (openingName.type === "JSXIdentifier") {
68
+ openingName.name = "CopyButton";
69
+ }
70
+ if (x.node.children && x.node.children.length > 0) {
71
+ const closingName = (_a = x.node.closingElement) === null || _a === void 0 ? void 0 : _a.name;
72
+ if ((closingName === null || closingName === void 0 ? void 0 : closingName.type) === "JSXIdentifier") {
73
+ closingName.name = "CopyButton";
74
+ }
70
75
  }
71
76
  });
72
77
  }
@@ -1,10 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
- /**
5
- * @param {import('jscodeshift').FileInfo} file
6
- * @param {import('jscodeshift').API} api
7
- */
8
4
  function transformer(file) {
9
5
  const names = [
10
6
  "UNSAFE_useDatepicker",
@@ -11,10 +11,6 @@ const cssConversions = {
11
11
  "--ac-header-hover-bg": "--ac-internalheader-hover-bg",
12
12
  "--ac-header-active-bg": "--ac-internalheader-active-bg",
13
13
  };
14
- /**
15
- * @param {import('jscodeshift').FileInfo} file
16
- * @param {import('jscodeshift').API} api
17
- */
18
14
  function transformer(file) {
19
15
  let src = file.source;
20
16
  Object.entries(cssConversions).forEach(([key, value]) => {
@@ -6,10 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = transformer;
7
7
  const lineterminator_1 = require("../../../utils/lineterminator");
8
8
  const packageImports_1 = __importDefault(require("../../../utils/packageImports"));
9
- /**
10
- * @param {import('jscodeshift').FileInfo} file
11
- * @param {import('jscodeshift').API} api
12
- */
13
9
  function transformer(file, api) {
14
10
  const j = api.jscodeshift;
15
11
  let root;
@@ -2,10 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
4
  const lineterminator_1 = require("../../../utils/lineterminator");
5
- /**
6
- * @param {import('jscodeshift').FileInfo} file
7
- * @param {import('jscodeshift').API} api
8
- */
9
5
  function transformer(file, api) {
10
6
  const j = api.jscodeshift;
11
7
  let localName = "Chat";
@@ -15,9 +11,14 @@ function transformer(file, api) {
15
11
  .find(j.ImportDeclaration)
16
12
  .filter((path) => path.node.source.value === "@navikt/ds-react")
17
13
  .forEach((imp) => {
18
- imp.value.specifiers.forEach((x) => {
19
- if (x.imported.name === "Chat" && x.local.name !== x.imported.name) {
20
- localName = x.local.name;
14
+ var _a;
15
+ (_a = imp.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((x) => {
16
+ if (x.type !== "ImportSpecifier")
17
+ return;
18
+ if (x.imported.name === "Chat" &&
19
+ x.local &&
20
+ x.local.name !== x.imported.name) {
21
+ localName = String(x.local.name);
21
22
  }
22
23
  });
23
24
  });
@@ -39,7 +39,7 @@ function transformer(file, api) {
39
39
  for (const prop of propsAffected) {
40
40
  (0, ast_1.findProps)({ j, path: astElement, name: prop }).forEach((attr) => {
41
41
  const attrvalue = attr.value.value;
42
- if (attrvalue.type === "StringLiteral") {
42
+ if ((attrvalue === null || attrvalue === void 0 ? void 0 : attrvalue.type) === "StringLiteral") {
43
43
  /**
44
44
  * Skips if the replacement token already set
45
45
  */
@@ -61,7 +61,7 @@ function transformer(file, api) {
61
61
  tokenComments.push(tokenComment);
62
62
  }
63
63
  }
64
- else if (attrvalue.type === "JSXExpressionContainer" &&
64
+ else if ((attrvalue === null || attrvalue === void 0 ? void 0 : attrvalue.type) === "JSXExpressionContainer" &&
65
65
  attrvalue.expression.type === "StringLiteral") {
66
66
  const literal = attrvalue.expression;
67
67
  /**
@@ -89,11 +89,11 @@ function transformer(file, api) {
89
89
  }
90
90
  (0, ast_1.findProps)({ j, path: astElement, name: "borderRadius" }).forEach((attr) => {
91
91
  const attrValue = attr.value.value;
92
- if (attrValue.type === "StringLiteral") {
92
+ if ((attrValue === null || attrValue === void 0 ? void 0 : attrValue.type) === "StringLiteral") {
93
93
  /* borderRadius="xlarge" */
94
94
  attrValue.value = convertBorderRadiusToRadius(attrValue.value);
95
95
  }
96
- else if (attrValue.type === "JSXExpressionContainer") {
96
+ else if ((attrValue === null || attrValue === void 0 ? void 0 : attrValue.type) === "JSXExpressionContainer") {
97
97
  /* borderRadius={{xs: "xlarge", sm: "large"}} */
98
98
  const expression = attrValue.expression;
99
99
  if (expression.type === "ObjectExpression") {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = transformer;
4
+ const jsx_value_1 = require("../../../utils/jsx-value");
4
5
  const lineterminator_1 = require("../../../utils/lineterminator");
5
6
  const headingSizeMap = {
6
7
  small: "xsmall",
@@ -23,7 +24,7 @@ function transformer(file, api) {
23
24
  const root = j(file.source);
24
25
  let localListName = "List";
25
26
  let hasListImport = false;
26
- let dsReactImportPath = null;
27
+ let dsReactImportPath;
27
28
  let localHeadingName = "Heading";
28
29
  let hasHeadingImport = false;
29
30
  let localBodyShortName = "BodyShort";
@@ -39,19 +40,19 @@ function transformer(file, api) {
39
40
  var _a, _b, _c, _d;
40
41
  if (specifier.type === "ImportSpecifier") {
41
42
  if (specifier.imported.name === "List") {
42
- localListName = ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || "List";
43
+ localListName = String(((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || "List");
43
44
  hasListImport = true;
44
45
  }
45
46
  if (specifier.imported.name === "Heading") {
46
- localHeadingName = ((_b = specifier.local) === null || _b === void 0 ? void 0 : _b.name) || "Heading";
47
+ localHeadingName = String(((_b = specifier.local) === null || _b === void 0 ? void 0 : _b.name) || "Heading");
47
48
  hasHeadingImport = true;
48
49
  }
49
50
  if (specifier.imported.name === "BodyShort") {
50
- localBodyShortName = ((_c = specifier.local) === null || _c === void 0 ? void 0 : _c.name) || "BodyShort";
51
+ localBodyShortName = String(((_c = specifier.local) === null || _c === void 0 ? void 0 : _c.name) || "BodyShort");
51
52
  hasBodyShortImport = true;
52
53
  }
53
54
  if (specifier.imported.name === "Box") {
54
- localBoxName = ((_d = specifier.local) === null || _d === void 0 ? void 0 : _d.name) || "Box";
55
+ localBoxName = String(((_d = specifier.local) === null || _d === void 0 ? void 0 : _d.name) || "Box");
55
56
  hasBoxImport = true;
56
57
  }
57
58
  }
@@ -62,7 +63,7 @@ function transformer(file, api) {
62
63
  var _a;
63
64
  if (specifier.type === "ImportSpecifier") {
64
65
  if (specifier.imported.name === "List") {
65
- localListName = ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || "List";
66
+ localListName = String(((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || "List");
66
67
  hasListImport = true;
67
68
  }
68
69
  }
@@ -78,8 +79,10 @@ function transformer(file, api) {
78
79
  openingElement: { name: { name: localListName } },
79
80
  })
80
81
  .forEach((path) => {
81
- var _a, _b;
82
82
  const attributes = path.node.openingElement.attributes;
83
+ if (!attributes) {
84
+ return;
85
+ }
83
86
  const titleAttr = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "title");
84
87
  const descAttr = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "description");
85
88
  if (attributes.some((attr) => attr.type === "JSXAttribute" &&
@@ -91,14 +94,10 @@ function transformer(file, api) {
91
94
  // Extract values
92
95
  const titleValue = titleAttr === null || titleAttr === void 0 ? void 0 : titleAttr.value;
93
96
  const descValue = descAttr === null || descAttr === void 0 ? void 0 : descAttr.value;
94
- let sizeValue = "medium";
95
- if (sizeAttr && ((_a = sizeAttr.value) === null || _a === void 0 ? void 0 : _a.type) === "StringLiteral") {
96
- sizeValue = sizeAttr.value.value;
97
- }
98
- let headingAs = "h3";
99
- if (headingTagAttr && ((_b = headingTagAttr.value) === null || _b === void 0 ? void 0 : _b.type) === "StringLiteral") {
100
- headingAs = headingTagAttr.value.value;
101
- }
97
+ const extractedSize = (0, jsx_value_1.getJSXStringValue)(sizeAttr === null || sizeAttr === void 0 ? void 0 : sizeAttr.value);
98
+ const sizeValue = extractedSize || "medium";
99
+ const extractedHeadingAs = (0, jsx_value_1.getJSXStringValue)(headingTagAttr === null || headingTagAttr === void 0 ? void 0 : headingTagAttr.value);
100
+ const headingAs = extractedHeadingAs || "h3";
102
101
  // Separate attributes
103
102
  const listAttributes = [
104
103
  j.jsxAttribute(j.jsxIdentifier("data-aksel-migrated-v8")),
@@ -140,13 +139,16 @@ function transformer(file, api) {
140
139
  if (mappedSize) {
141
140
  headingAttrs.push(j.jsxAttribute(j.jsxIdentifier("size"), j.stringLiteral(mappedSize)));
142
141
  }
143
- let children = [];
142
+ let children;
144
143
  if (titleValue.type === "StringLiteral") {
145
144
  children = [j.jsxText(titleValue.value)];
146
145
  }
147
146
  else if (titleValue.type === "JSXExpressionContainer") {
148
147
  children = [titleValue];
149
148
  }
149
+ else {
150
+ children = [];
151
+ }
150
152
  const heading = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localHeadingName), headingAttrs), j.jsxClosingElement(j.jsxIdentifier(localHeadingName)), children);
151
153
  newNodes.push(heading);
152
154
  }
@@ -160,13 +162,16 @@ function transformer(file, api) {
160
162
  if (mappedSize && mappedSize !== "medium") {
161
163
  bodyAttrs.push(j.jsxAttribute(j.jsxIdentifier("size"), j.stringLiteral(mappedSize)));
162
164
  }
163
- let children = [];
165
+ let children;
164
166
  if (descValue.type === "StringLiteral") {
165
167
  children = [j.jsxText(descValue.value)];
166
168
  }
167
169
  else if (descValue.type === "JSXExpressionContainer") {
168
170
  children = [descValue];
169
171
  }
172
+ else {
173
+ children = [];
174
+ }
170
175
  const body = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localBodyShortName), bodyAttrs), j.jsxClosingElement(j.jsxIdentifier(localBodyShortName)), children);
171
176
  newNodes.push(body);
172
177
  }
@@ -197,7 +202,7 @@ function transformer(file, api) {
197
202
  const existingSpecifiers = new Set((_a = dsReactImportPath.node.specifiers) === null || _a === void 0 ? void 0 : _a.map((specifier) => { var _a; return (_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name; }));
198
203
  newImports.forEach((imp) => {
199
204
  var _a;
200
- if (!existingSpecifiers.has(imp)) {
205
+ if (!existingSpecifiers.has(imp) && dsReactImportPath) {
201
206
  (_a = dsReactImportPath.node.specifiers) === null || _a === void 0 ? void 0 : _a.push(j.importSpecifier(j.identifier(imp)));
202
207
  }
203
208
  });
@@ -48,15 +48,15 @@ function transformer(file, api) {
48
48
  for (const prop of affectedProps) {
49
49
  (0, ast_1.findProps)({ j, path, name: prop }).forEach((attr) => {
50
50
  const attrValue = attr.value.value;
51
- if (attrValue.type === "StringLiteral") {
51
+ if ((attrValue === null || attrValue === void 0 ? void 0 : attrValue.type) === "StringLiteral") {
52
52
  /* padding="32" */
53
53
  attrValue.value = convertSpacingToSpace(attrValue.value);
54
54
  }
55
- else if (attrValue.type === "JSXExpressionContainer" &&
55
+ else if ((attrValue === null || attrValue === void 0 ? void 0 : attrValue.type) === "JSXExpressionContainer" &&
56
56
  attrValue.expression.type === "StringLiteral") {
57
57
  attrValue.expression.value = convertSpacingToSpace(attrValue.expression.value);
58
58
  }
59
- else if (attrValue.type === "JSXExpressionContainer") {
59
+ else if ((attrValue === null || attrValue === void 0 ? void 0 : attrValue.type) === "JSXExpressionContainer") {
60
60
  /* padding={{xs: "16", sm: "32"}} */
61
61
  const expression = attrValue.expression;
62
62
  if (expression.type === "ObjectExpression") {
@@ -14,18 +14,17 @@ function findComponentImport(input) {
14
14
  const name = _name.includes(".") ? _name.split(".")[0] : _name;
15
15
  let foundName = null;
16
16
  root.find(j.ImportDeclaration).forEach((path) => {
17
+ var _a;
17
18
  if (packageType === "react" && !isAkselReactImport(path)) {
18
19
  return;
19
20
  }
20
21
  if (packageType === "tokens" && !isAkselTokensImport(path)) {
21
22
  return;
22
23
  }
23
- path.node.specifiers.forEach((specifier) => {
24
+ (_a = path.node.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((specifier) => {
24
25
  if (specifier.type === "ImportSpecifier" &&
25
26
  specifier.imported.name === name) {
26
- foundName = specifier.local
27
- ? specifier.local.name
28
- : specifier.imported.name;
27
+ foundName = String(specifier.local ? specifier.local.name : specifier.imported.name);
29
28
  }
30
29
  });
31
30
  });
@@ -48,6 +48,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.check = check;
49
49
  exports.checkScenarios = checkScenarios;
50
50
  exports.checkMoveVariantToDataColor = checkMoveVariantToDataColor;
51
+ /* @ts-expect-error No avaliable types for testUtils */
51
52
  const testUtils_1 = require("jscodeshift/dist/testUtils");
52
53
  const node_fs_1 = __importDefault(require("node:fs"));
53
54
  const node_path_1 = __importDefault(require("node:path"));
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getJSXLiteralValue = getJSXLiteralValue;
4
+ exports.getJSXStringValue = getJSXStringValue;
5
+ /**
6
+ * Extracts a literal value (string, number, or boolean) from a JSX attribute value.
7
+ * Handles the following patterns:
8
+ * - `prop="value"` (StringLiteral)
9
+ * - `prop={"value"}` (JSXExpressionContainer with StringLiteral)
10
+ * - `prop={`value`}` (TemplateLiteral with no expressions)
11
+ * - `prop={42}` (NumericLiteral)
12
+ * - `prop={true}` / `prop={false}` (BooleanLiteral)
13
+ *
14
+ * @param node - The JSX attribute value node to extract the value from
15
+ * @returns The literal value if it can be extracted, otherwise null
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * getJSXLiteralValue(attr.value) // where attr is prop="hello" => "hello"
20
+ * getJSXLiteralValue(attr.value) // where attr is prop={42} => 42
21
+ * getJSXLiteralValue(attr.value) // where attr is prop={true} => true
22
+ * ```
23
+ */
24
+ function getJSXLiteralValue(node) {
25
+ var _a;
26
+ if (!node)
27
+ return null;
28
+ if (node.type === "StringLiteral") {
29
+ return node.value;
30
+ }
31
+ if (node.type === "NumericLiteral") {
32
+ return node.value;
33
+ }
34
+ if (node.type === "UnaryExpression") {
35
+ const unary = node;
36
+ if (unary.operator === "-" && unary.argument.type === "NumericLiteral") {
37
+ return -unary.argument.value;
38
+ }
39
+ return null;
40
+ }
41
+ if (node.type === "BooleanLiteral") {
42
+ return node.value;
43
+ }
44
+ if (node.type === "Literal") {
45
+ const value = node.value;
46
+ if (typeof value === "string" ||
47
+ typeof value === "number" ||
48
+ typeof value === "boolean") {
49
+ return value;
50
+ }
51
+ return null;
52
+ }
53
+ if (node.type === "TemplateLiteral") {
54
+ const template = node;
55
+ if (template.expressions.length === 0 && template.quasis.length === 1) {
56
+ return (_a = template.quasis[0].value.cooked) !== null && _a !== void 0 ? _a : null;
57
+ }
58
+ return null;
59
+ }
60
+ if (node.type === "JSXExpressionContainer") {
61
+ return getJSXLiteralValue(node.expression);
62
+ }
63
+ return null;
64
+ }
65
+ /**
66
+ * Extracts the string value from a JSX attribute value.
67
+ * Convenience wrapper around `getJSXLiteralValue` that only returns strings.
68
+ *
69
+ * @param node - The JSX attribute value node to extract the string from
70
+ * @returns The string value if it can be extracted, otherwise null
71
+ */
72
+ function getJSXStringValue(node) {
73
+ const value = getJSXLiteralValue(node);
74
+ return typeof value === "string" ? value : null;
75
+ }
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moveVariantToDataColor = moveVariantToDataColor;
4
+ const jsx_value_1 = require("./jsx-value");
4
5
  const lineterminator_1 = require("./lineterminator");
5
6
  function moveVariantToDataColor(file, api, config) {
6
7
  const j = api.jscodeshift;
@@ -23,7 +24,7 @@ function moveVariantToDataColor(file, api, config) {
23
24
  var _a;
24
25
  if (specifier.type === "ImportSpecifier" &&
25
26
  specifier.imported.name === rootComponent) {
26
- localName = ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || specifier.imported.name;
27
+ localName = String(((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || specifier.imported.name);
27
28
  }
28
29
  });
29
30
  });
@@ -54,7 +55,7 @@ function moveVariantToDataColor(file, api, config) {
54
55
  return;
55
56
  if (attr.name.name === config.prop) {
56
57
  variantPropIndex = index;
57
- const value = getStringValue(attr.value);
58
+ const value = (0, jsx_value_1.getJSXStringValue)(attr.value);
58
59
  if (value) {
59
60
  variantValue = value;
60
61
  }
@@ -101,20 +102,3 @@ function moveVariantToDataColor(file, api, config) {
101
102
  const toSourceOptions = (0, lineterminator_1.getLineTerminator)(file.source);
102
103
  return root.toSource(toSourceOptions);
103
104
  }
104
- function getStringValue(node) {
105
- var _a;
106
- if (!node)
107
- return null;
108
- if (node.type === "StringLiteral" || node.type === "Literal") {
109
- return node.value;
110
- }
111
- if (node.type === "TemplateLiteral" &&
112
- node.expressions.length === 0 &&
113
- node.quasis.length === 1) {
114
- return (_a = node.quasis[0].value.cooked) !== null && _a !== void 0 ? _a : null;
115
- }
116
- if (node.type === "JSXExpressionContainer") {
117
- return getStringValue(node.expression);
118
- }
119
- return null;
120
- }
@@ -28,8 +28,9 @@ function moveAndRenameImport(j, root, { fromImport, toImport, fromName, toName,
28
28
  }
29
29
  let localname = fromName;
30
30
  const existingFromImportSpecifier = existingFromImport === null || existingFromImport === void 0 ? void 0 : existingFromImport.find(j.ImportSpecifier, (node) => {
31
- if (node.imported.name === fromName) {
32
- localname = node.local.name;
31
+ var _a;
32
+ if (node.imported.name === fromName && ((_a = node.local) === null || _a === void 0 ? void 0 : _a.name)) {
33
+ localname = String(node.local.name);
33
34
  }
34
35
  return node.imported.name === fromName;
35
36
  });
@@ -5,6 +5,9 @@ function removePropsFromComponent(_, root, componentName, propsToRemove) {
5
5
  const component = root.findJSXElements(componentName);
6
6
  component.forEach((node) => {
7
7
  const attributes = node.node.openingElement.attributes;
8
+ if (!attributes) {
9
+ return;
10
+ }
8
11
  for (let i = attributes.length - 1; i >= 0; i--) {
9
12
  const attribute = attributes[i];
10
13
  if (attribute.type === "JSXAttribute" &&
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = renameProps;
4
- function renameProps({ root, componentName, props }) {
4
+ function renameProps({ root, componentName, props, }) {
5
5
  return root.findJSXElements(componentName).forEach((path) => {
6
- path.node.openingElement.attributes.forEach((node) => {
6
+ var _a;
7
+ (_a = path.node.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.forEach((node) => {
7
8
  if (node.type === "JSXAttribute" &&
9
+ typeof node.name.name === "string" &&
8
10
  Object.keys(props).includes(node.name.name)) {
9
11
  node.name.name = props[node.name.name];
10
12
  }
@@ -19,10 +19,10 @@ const chalk_1 = __importDefault(require("chalk"));
19
19
  const cli_progress_1 = __importDefault(require("cli-progress"));
20
20
  class TokenStatus {
21
21
  constructor() {
22
- this.initStatus();
22
+ this.status = this.initStatus();
23
23
  }
24
24
  initStatus() {
25
- this.status = {
25
+ return {
26
26
  css: { legacy: [], updated: [] },
27
27
  scss: { legacy: [], updated: [] },
28
28
  less: { legacy: [], updated: [] },
@@ -32,6 +32,9 @@ class TokenStatus {
32
32
  deprecated: { legacy: [], updated: [] },
33
33
  };
34
34
  }
35
+ resetStatus() {
36
+ this.status = this.initStatus();
37
+ }
35
38
  add(_a) {
36
39
  var { isLegacy, type } = _a, hit = __rest(_a, ["isLegacy", "type"]);
37
40
  const statusType = isLegacy ? "legacy" : "updated";
@@ -69,8 +72,8 @@ class TokenStatus {
69
72
  let statusDataObj;
70
73
  if (type === "summary") {
71
74
  statusDataObj = {
72
- legacy: [].concat(...Object.values(this.status).map((_status) => _status.legacy)),
73
- updated: [].concat(...Object.values(this.status).map((_status) => _status.updated)),
75
+ legacy: Object.values(this.status).flatMap((_status) => _status.legacy),
76
+ updated: Object.values(this.status).flatMap((_status) => _status.updated),
74
77
  };
75
78
  const uniqueFiles = new Set(statusDataObj.legacy.map((token) => token.fileName));
76
79
  const automigratedN = statusDataObj.legacy.filter((legacy) => legacy.canAutoMigrate).length;
@@ -100,7 +100,7 @@ function runTooling(options, program) {
100
100
  currentStatus = yield executeTask(task, filepaths, options, program, currentStatus, () => (0, status_1.getStatus)(filepaths, "no-print"));
101
101
  }
102
102
  catch (error) {
103
- program.error(chalk_1.default.red("Error:", error.message));
103
+ program.error(chalk_1.default.red("Error:", error instanceof Error ? error.message : String(error)));
104
104
  }
105
105
  task = yield getNextTask(currentStatus.status);
106
106
  }
@@ -295,7 +295,10 @@ function getNextTask(status) {
295
295
  return response.task;
296
296
  }
297
297
  catch (error) {
298
- if (error.isTtyError) {
298
+ if (error != null &&
299
+ typeof error === "object" &&
300
+ "isTtyError" in error &&
301
+ error.isTtyError) {
299
302
  console.info("Oops, something went wrong! Looks like @navikt/aksel can't run in this terminal. " +
300
303
  "Contact Aksel for support if this persists, or try another terminal.");
301
304
  }
@@ -146,7 +146,7 @@ function printRemaining(files, status) {
146
146
  console.info("✅ Report (JSON) copied to clipboard!");
147
147
  }
148
148
  catch (error) {
149
- console.error("❌ Failed to copy to clipboard:", error.message);
149
+ console.error("❌ Failed to copy to clipboard:", error instanceof Error ? error.message : String(error));
150
150
  }
151
151
  }
152
152
  });
@@ -27,7 +27,7 @@ function getStatus(files, action = "print") {
27
27
  if (action === "print") {
28
28
  progressBar.start(files.length, 0);
29
29
  }
30
- StatusStore.initStatus();
30
+ StatusStore.resetStatus();
31
31
  /**
32
32
  * Prepare search terms for legacy and v8 tokens.
33
33
  * By pre-computing these sets, we save re-calculating them for each file,
@@ -13,7 +13,7 @@ const axBorderRadiusMap = {
13
13
  function transformer(file) {
14
14
  let src = file.source;
15
15
  for (const config of Object.values(legacy_tokens_1.legacyTokenConfig)) {
16
- if (config.replacement.length > 0) {
16
+ if (config.replacement.length > 0 && config.regexes.less) {
17
17
  src = src.replace(config.regexes.less, (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "less"));
18
18
  }
19
19
  }
@@ -13,7 +13,7 @@ const axBorderRadiusMap = {
13
13
  function transformer(file) {
14
14
  let src = file.source;
15
15
  for (const config of Object.values(legacy_tokens_1.legacyTokenConfig)) {
16
- if (config.replacement.length > 0) {
16
+ if (config.replacement.length > 0 && config.regexes.scss) {
17
17
  src = src.replace(config.regexes.scss, (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "scss"));
18
18
  }
19
19
  }
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "8.9.0";
4
+ exports.VERSION = "8.10.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/aksel",
3
- "version": "8.9.0",
3
+ "version": "8.10.0",
4
4
  "description": "Aksel command line interface. Codemods and other utilities for Aksel users.",
5
5
  "author": "Aksel | Nav designsystem team",
6
6
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  "url": "https://github.com/navikt/aksel/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@navikt/ds-css": "^8.9.0",
37
- "@navikt/ds-tokens": "^8.9.0",
36
+ "@navikt/ds-css": "^8.10.0",
37
+ "@navikt/ds-tokens": "^8.10.0",
38
38
  "chalk": "5.6.2",
39
39
  "cli-progress": "3.12.0",
40
40
  "clipboardy": "5.0.1",
@@ -45,12 +45,14 @@
45
45
  "is-git-clean": "1.1.0",
46
46
  "jscodeshift": "17.3.0",
47
47
  "jscodeshift-add-imports": "1.0.11",
48
- "lodash": "4.17.23"
48
+ "lodash": "4.18.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@types/cli-progress": "3.11.6",
52
+ "@types/is-git-clean": "1.1.2",
53
+ "@types/jscodeshift": "17.3.0",
52
54
  "rimraf": "6.1.3",
53
- "typescript": "5.9.3",
55
+ "typescript": "6.0.2",
54
56
  "vitest": "4.1.0"
55
57
  },
56
58
  "sideEffects": false,