@navikt/aksel 7.34.0 → 7.35.1

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/README.md +96 -2
  2. package/dist/codemod/codeshift.utils.js +9 -1
  3. package/dist/codemod/migrations.js +75 -22
  4. package/dist/codemod/run-codeshift.js +14 -3
  5. package/dist/codemod/transforms/v8.0.0/accordion-variant/accordion-variant.js +16 -0
  6. package/dist/codemod/transforms/{darkside/box-to-boxnew/box-to-boxnew.js → v8.0.0/box/box.js} +80 -100
  7. package/dist/codemod/transforms/v8.0.0/box-new/box-new.js +91 -0
  8. package/dist/codemod/transforms/v8.0.0/chips-variant/chips-variant.js +31 -0
  9. package/dist/codemod/transforms/v8.0.0/list/list.js +218 -0
  10. package/dist/codemod/transforms/{darkside → v8.0.0}/prop-deprecate/prop-deprecate.js +1 -1
  11. package/dist/codemod/transforms/v8.0.0/tag-variant/tag-variant.js +38 -0
  12. package/dist/codemod/transforms/v8.0.0/toggle-group-variant/toggle-group-variant.js +16 -0
  13. package/dist/codemod/utils/ast.js +1 -1
  14. package/dist/codemod/utils/check.js +35 -0
  15. package/dist/codemod/utils/move-variant-to-data-color.js +120 -0
  16. package/dist/darkside/index.js +3 -9
  17. package/dist/darkside/run-tooling.js +138 -42
  18. package/dist/darkside/tasks/print-remaining.js +143 -38
  19. package/dist/darkside/tasks/status.js +147 -30
  20. package/dist/darkside/transforms/darkside-tokens-css.js +23 -8
  21. package/dist/darkside/transforms/darkside-tokens-tailwind.js +9 -10
  22. package/dist/help.js +0 -10
  23. package/dist/index.js +14 -17
  24. package/package.json +7 -7
  25. package/dist/css-imports/config.js +0 -5
  26. package/dist/css-imports/generate-output.js +0 -147
  27. package/dist/css-imports/get-directories.js +0 -34
  28. package/dist/css-imports/get-version.js +0 -28
  29. package/dist/css-imports/index.js +0 -187
  30. package/dist/css-imports/inquiry.js +0 -35
  31. package/dist/css-imports/scan-code.js +0 -45
  32. /package/dist/codemod/transforms/{spacing → v8.0.0}/primitives-spacing/spacing.js +0 -0
  33. /package/dist/codemod/transforms/{spacing → v8.0.0}/spacing.utils.js +0 -0
  34. /package/dist/codemod/transforms/{spacing → v8.0.0}/token-spacing/spacing.js +0 -0
  35. /package/dist/codemod/transforms/{spacing → v8.0.0}/token-spacing-js/spacing.js +0 -0
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformer;
4
+ const move_variant_to_data_color_1 = require("../../../utils/move-variant-to-data-color");
5
+ const migrationConfigToggleSub = {
6
+ component: "Chips.Toggle",
7
+ prop: "variant",
8
+ changes: {
9
+ action: { color: "accent" },
10
+ neutral: { color: "neutral" },
11
+ },
12
+ };
13
+ const migrationConfigToggleDirect = Object.assign(Object.assign({}, migrationConfigToggleSub), { component: "ChipsToggle" });
14
+ const migrationConfigRemovableSub = Object.assign(Object.assign({}, migrationConfigToggleSub), { component: "Chips.Removable" });
15
+ const migrationConfigRemovableDirect = Object.assign(Object.assign({}, migrationConfigToggleSub), { component: "ChipsRemovable" });
16
+ function transformer(file, api) {
17
+ const configs = [
18
+ migrationConfigToggleSub,
19
+ migrationConfigToggleDirect,
20
+ migrationConfigRemovableSub,
21
+ migrationConfigRemovableDirect,
22
+ ];
23
+ let source = file.source;
24
+ for (const config of configs) {
25
+ const newSource = (0, move_variant_to_data_color_1.moveVariantToDataColor)(Object.assign(Object.assign({}, file), { source }), api, config);
26
+ if (newSource) {
27
+ source = newSource;
28
+ }
29
+ }
30
+ return source;
31
+ }
@@ -0,0 +1,218 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = transformer;
4
+ const lineterminator_1 = require("../../../utils/lineterminator");
5
+ const headingSizeMap = {
6
+ small: "xsmall",
7
+ medium: "small",
8
+ large: "medium",
9
+ };
10
+ const bodySizeMap = {
11
+ small: "small",
12
+ medium: "medium",
13
+ large: "large",
14
+ };
15
+ const boxMarginMap = {
16
+ small: "space-12",
17
+ medium: "space-16",
18
+ large: "space-16",
19
+ };
20
+ function transformer(file, api) {
21
+ var _a;
22
+ const j = api.jscodeshift;
23
+ const root = j(file.source);
24
+ let localListName = "List";
25
+ let hasListImport = false;
26
+ let dsReactImportPath = null;
27
+ let localHeadingName = "Heading";
28
+ let hasHeadingImport = false;
29
+ let localBodyShortName = "BodyShort";
30
+ let hasBodyShortImport = false;
31
+ let localBoxName = "Box";
32
+ let hasBoxImport = false;
33
+ // Find the local name for List import
34
+ root.find(j.ImportDeclaration).forEach((path) => {
35
+ var _a, _b;
36
+ if (path.node.source.value === "@navikt/ds-react") {
37
+ dsReactImportPath = path;
38
+ (_a = path.node.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((specifier) => {
39
+ var _a, _b, _c, _d;
40
+ if (specifier.type === "ImportSpecifier") {
41
+ if (specifier.imported.name === "List") {
42
+ localListName = ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || "List";
43
+ hasListImport = true;
44
+ }
45
+ if (specifier.imported.name === "Heading") {
46
+ localHeadingName = ((_b = specifier.local) === null || _b === void 0 ? void 0 : _b.name) || "Heading";
47
+ hasHeadingImport = true;
48
+ }
49
+ if (specifier.imported.name === "BodyShort") {
50
+ localBodyShortName = ((_c = specifier.local) === null || _c === void 0 ? void 0 : _c.name) || "BodyShort";
51
+ hasBodyShortImport = true;
52
+ }
53
+ if (specifier.imported.name === "Box") {
54
+ localBoxName = ((_d = specifier.local) === null || _d === void 0 ? void 0 : _d.name) || "Box";
55
+ hasBoxImport = true;
56
+ }
57
+ }
58
+ });
59
+ }
60
+ else if (path.node.source.value === "@navikt/ds-react/List") {
61
+ (_b = path.node.specifiers) === null || _b === void 0 ? void 0 : _b.forEach((specifier) => {
62
+ var _a;
63
+ if (specifier.type === "ImportSpecifier") {
64
+ if (specifier.imported.name === "List") {
65
+ localListName = ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || "List";
66
+ hasListImport = true;
67
+ }
68
+ }
69
+ });
70
+ }
71
+ });
72
+ if (!hasListImport) {
73
+ return root.toSource((0, lineterminator_1.getLineTerminator)(file.source));
74
+ }
75
+ const newImports = new Set();
76
+ root
77
+ .find(j.JSXElement, {
78
+ openingElement: { name: { name: localListName } },
79
+ })
80
+ .forEach((path) => {
81
+ var _a, _b;
82
+ const attributes = path.node.openingElement.attributes;
83
+ const titleAttr = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "title");
84
+ const descAttr = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "description");
85
+ if (attributes.some((attr) => attr.type === "JSXAttribute" &&
86
+ attr.name.name === "data-aksel-migrated-v8")) {
87
+ return;
88
+ }
89
+ const headingTagAttr = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "headingTag");
90
+ const sizeAttr = attributes.find((attr) => attr.type === "JSXAttribute" && attr.name.name === "size");
91
+ // Extract values
92
+ const titleValue = titleAttr === null || titleAttr === void 0 ? void 0 : titleAttr.value;
93
+ 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
+ }
102
+ // Separate attributes
103
+ const listAttributes = [
104
+ j.jsxAttribute(j.jsxIdentifier("data-aksel-migrated-v8")),
105
+ ];
106
+ const divAttributes = [];
107
+ attributes.forEach((attr) => {
108
+ if (attr.type !== "JSXAttribute") {
109
+ // Spread attributes or others -> move to div
110
+ divAttributes.push(attr);
111
+ return;
112
+ }
113
+ const name = attr.name.name;
114
+ if (name === "title" ||
115
+ name === "description" ||
116
+ name === "headingTag") {
117
+ // Handled separately
118
+ return;
119
+ }
120
+ if (name === "size" ||
121
+ name === "as" ||
122
+ name === "aria-label" ||
123
+ name === "aria-labelledby") {
124
+ listAttributes.push(attr);
125
+ }
126
+ else {
127
+ divAttributes.push(attr);
128
+ }
129
+ });
130
+ const newNodes = [];
131
+ // Create Heading
132
+ if (titleValue) {
133
+ if (!hasHeadingImport) {
134
+ newImports.add("Heading");
135
+ }
136
+ const headingAttrs = [
137
+ j.jsxAttribute(j.jsxIdentifier("as"), j.stringLiteral(headingAs)),
138
+ ];
139
+ const mappedSize = headingSizeMap[sizeValue];
140
+ if (mappedSize) {
141
+ headingAttrs.push(j.jsxAttribute(j.jsxIdentifier("size"), j.stringLiteral(mappedSize)));
142
+ }
143
+ let children = [];
144
+ if (titleValue.type === "StringLiteral") {
145
+ children = [j.jsxText(titleValue.value)];
146
+ }
147
+ else if (titleValue.type === "JSXExpressionContainer") {
148
+ children = [titleValue];
149
+ }
150
+ const heading = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localHeadingName), headingAttrs), j.jsxClosingElement(j.jsxIdentifier(localHeadingName)), children);
151
+ newNodes.push(heading);
152
+ }
153
+ // Create BodyShort
154
+ if (descValue) {
155
+ if (!hasBodyShortImport) {
156
+ newImports.add("BodyShort");
157
+ }
158
+ const bodyAttrs = [];
159
+ const mappedSize = bodySizeMap[sizeValue];
160
+ if (mappedSize && mappedSize !== "medium") {
161
+ bodyAttrs.push(j.jsxAttribute(j.jsxIdentifier("size"), j.stringLiteral(mappedSize)));
162
+ }
163
+ let children = [];
164
+ if (descValue.type === "StringLiteral") {
165
+ children = [j.jsxText(descValue.value)];
166
+ }
167
+ else if (descValue.type === "JSXExpressionContainer") {
168
+ children = [descValue];
169
+ }
170
+ const body = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localBodyShortName), bodyAttrs), j.jsxClosingElement(j.jsxIdentifier(localBodyShortName)), children);
171
+ newNodes.push(body);
172
+ }
173
+ // Create Box
174
+ if (!hasBoxImport) {
175
+ newImports.add("Box");
176
+ }
177
+ const boxAttrs = [
178
+ j.jsxAttribute(j.jsxIdentifier("marginBlock"), j.stringLiteral(boxMarginMap[sizeValue] || "space-16")),
179
+ j.jsxAttribute(j.jsxIdentifier("asChild")),
180
+ ];
181
+ // Reconstruct List element
182
+ const newList = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localListName), listAttributes), path.node.closingElement, path.node.children);
183
+ const box = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(localBoxName), boxAttrs), j.jsxClosingElement(j.jsxIdentifier(localBoxName)), [newList]);
184
+ newNodes.push(box);
185
+ // Wrap in div
186
+ if (newNodes.length === 1 && divAttributes.length === 0) {
187
+ j(path).replaceWith(newNodes[0]);
188
+ }
189
+ else {
190
+ const div = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier("div"), divAttributes), j.jsxClosingElement(j.jsxIdentifier("div")), newNodes);
191
+ j(path).replaceWith(div);
192
+ }
193
+ });
194
+ // Add imports
195
+ if (newImports.size > 0) {
196
+ if (dsReactImportPath) {
197
+ 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
+ newImports.forEach((imp) => {
199
+ var _a;
200
+ if (!existingSpecifiers.has(imp)) {
201
+ (_a = dsReactImportPath.node.specifiers) === null || _a === void 0 ? void 0 : _a.push(j.importSpecifier(j.identifier(imp)));
202
+ }
203
+ });
204
+ }
205
+ else {
206
+ const specifiers = Array.from(newImports).map((imp) => j.importSpecifier(j.identifier(imp)));
207
+ const newImportDecl = j.importDeclaration(specifiers, j.stringLiteral("@navikt/ds-react"));
208
+ const lastImport = root.find(j.ImportDeclaration).at(-1);
209
+ if (lastImport.length > 0) {
210
+ lastImport.insertAfter(newImportDecl);
211
+ }
212
+ else {
213
+ root.get().node.program.body.unshift(newImportDecl);
214
+ }
215
+ }
216
+ }
217
+ return root.toSource((0, lineterminator_1.getLineTerminator)(file.source));
218
+ }
@@ -8,7 +8,7 @@ const ast_1 = require("../../../utils/ast");
8
8
  const lineterminator_1 = require("../../../utils/lineterminator");
9
9
  const removeProps_1 = __importDefault(require("../../../utils/removeProps"));
10
10
  const deprecationMap = {
11
- Accordion: ["headingSize", "variant"],
11
+ Accordion: ["headingSize"],
12
12
  Popover: ["arrow"],
13
13
  Page: ["background"],
14
14
  };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrationConfig = void 0;
4
+ exports.default = transformer;
5
+ const move_variant_to_data_color_1 = require("../../../utils/move-variant-to-data-color");
6
+ exports.migrationConfig = {
7
+ component: "Tag",
8
+ prop: "variant",
9
+ changes: {
10
+ warning: { replacement: "outline", color: "warning" },
11
+ "warning-moderate": { replacement: "moderate", color: "warning" },
12
+ "warning-filled": { replacement: "strong", color: "warning" },
13
+ error: { replacement: "outline", color: "danger" },
14
+ "error-moderate": { replacement: "moderate", color: "danger" },
15
+ "error-filled": { replacement: "strong", color: "danger" },
16
+ info: { replacement: "outline", color: "info" },
17
+ "info-moderate": { replacement: "moderate", color: "info" },
18
+ "info-filled": { replacement: "strong", color: "info" },
19
+ success: { replacement: "outline", color: "success" },
20
+ "success-moderate": { replacement: "moderate", color: "success" },
21
+ "success-filled": { replacement: "strong", color: "success" },
22
+ neutral: { replacement: "outline", color: "neutral" },
23
+ "neutral-moderate": { replacement: "moderate", color: "neutral" },
24
+ "neutral-filled": { replacement: "strong", color: "neutral" },
25
+ alt1: { replacement: "outline", color: "meta-purple" },
26
+ "alt1-moderate": { replacement: "moderate", color: "meta-purple" },
27
+ "alt1-filled": { replacement: "strong", color: "meta-purple" },
28
+ alt2: { replacement: "outline", color: "meta-lime" },
29
+ "alt2-moderate": { replacement: "moderate", color: "meta-lime" },
30
+ "alt2-filled": { replacement: "strong", color: "meta-lime" },
31
+ alt3: { replacement: "outline", color: "info" },
32
+ "alt3-moderate": { replacement: "moderate", color: "info" },
33
+ "alt3-filled": { replacement: "strong", color: "info" },
34
+ },
35
+ };
36
+ function transformer(file, api) {
37
+ return (0, move_variant_to_data_color_1.moveVariantToDataColor)(file, api, exports.migrationConfig);
38
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrationConfig = void 0;
4
+ exports.default = transformer;
5
+ const move_variant_to_data_color_1 = require("../../../utils/move-variant-to-data-color");
6
+ exports.migrationConfig = {
7
+ component: "ToggleGroup",
8
+ prop: "variant",
9
+ changes: {
10
+ action: { color: "accent" },
11
+ neutral: { color: "neutral" },
12
+ },
13
+ };
14
+ function transformer(file, api) {
15
+ return (0, move_variant_to_data_color_1.moveVariantToDataColor)(file, api, exports.migrationConfig);
16
+ }
@@ -64,7 +64,7 @@ function findJSXElement(input) {
64
64
  */
65
65
  function findProps(input) {
66
66
  const { j, path, name } = input;
67
- return j(path).find(j.JSXAttribute, {
67
+ return j(path.get("openingElement")).find(j.JSXAttribute, {
68
68
  name: {
69
69
  name,
70
70
  },
@@ -46,6 +46,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
48
  exports.check = check;
49
+ exports.checkScenarios = checkScenarios;
50
+ exports.checkMoveVariantToDataColor = checkMoveVariantToDataColor;
49
51
  const testUtils_1 = require("jscodeshift/dist/testUtils");
50
52
  const node_fs_1 = __importDefault(require("node:fs"));
51
53
  const node_path_1 = __importDefault(require("node:path"));
@@ -74,3 +76,36 @@ function check(dirName, { fixture, migration, extension = "js", options = {} })
74
76
  }));
75
77
  });
76
78
  }
79
+ function checkScenarios(dirName, { migration, scenarios, extension = "js", options = {} }) {
80
+ (0, vitest_1.describe)(migration, () => {
81
+ const parser = extension;
82
+ for (const [name, { input, output: expected }] of Object.entries(scenarios)) {
83
+ (0, vitest_1.test)(name, () => __awaiter(this, void 0, void 0, function* () {
84
+ const module = yield Promise.resolve(`${node_path_1.default.join(dirName, "..", migration)}`).then(s => __importStar(require(s)));
85
+ const output = (0, testUtils_1.applyTransform)(Object.assign(Object.assign({}, module), { parser: "tsx" }), options, {
86
+ source: input,
87
+ });
88
+ (0, vitest_1.expect)(yield prettier_1.default.format(output, {
89
+ parser: parser === "js" ? "typescript" : parser,
90
+ })).toBe(yield prettier_1.default.format(expected, {
91
+ parser: parser === "js" ? "typescript" : parser,
92
+ }));
93
+ }));
94
+ }
95
+ });
96
+ }
97
+ function checkMoveVariantToDataColor(dirName, { migration, config, }) {
98
+ const scenarios = {};
99
+ for (const [variant, change] of Object.entries(config.changes)) {
100
+ const input = `import { ${config.component} } from "@navikt/ds-react";
101
+ <${config.component} ${config.prop}="${variant}">Text</${config.component}>;`;
102
+ let outputAttrs = `data-color="${change.color}"`;
103
+ if (change.replacement) {
104
+ outputAttrs += ` ${config.prop}="${change.replacement}"`;
105
+ }
106
+ const output = `import { ${config.component} } from "@navikt/ds-react";
107
+ <${config.component} ${outputAttrs}>Text</${config.component}>;`;
108
+ scenarios[`should migrate ${variant}`] = { input, output };
109
+ }
110
+ checkScenarios(dirName, { migration, scenarios });
111
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.moveVariantToDataColor = moveVariantToDataColor;
4
+ const lineterminator_1 = require("./lineterminator");
5
+ function moveVariantToDataColor(file, api, config) {
6
+ const j = api.jscodeshift;
7
+ const root = j(file.source);
8
+ /* Find all imports from @navikt/ds-react */
9
+ const imports = root.find(j.ImportDeclaration).filter((path) => {
10
+ const sourceValue = path.value.source.value;
11
+ return (typeof sourceValue === "string" &&
12
+ (sourceValue === "@navikt/ds-react" ||
13
+ sourceValue.startsWith("@navikt/ds-react/")));
14
+ });
15
+ if (imports.size() === 0) {
16
+ return null;
17
+ }
18
+ const [rootComponent, subComponent] = config.component.split(".");
19
+ let localName = "";
20
+ imports.forEach((path) => {
21
+ var _a;
22
+ (_a = path.value.specifiers) === null || _a === void 0 ? void 0 : _a.forEach((specifier) => {
23
+ var _a;
24
+ if (specifier.type === "ImportSpecifier" &&
25
+ specifier.imported.name === rootComponent) {
26
+ localName = ((_a = specifier.local) === null || _a === void 0 ? void 0 : _a.name) || specifier.imported.name;
27
+ }
28
+ });
29
+ });
30
+ if (!localName) {
31
+ return null;
32
+ }
33
+ const elementSearch = subComponent
34
+ ? {
35
+ openingElement: {
36
+ name: {
37
+ type: "JSXMemberExpression",
38
+ object: { name: localName },
39
+ property: { name: subComponent },
40
+ },
41
+ },
42
+ }
43
+ : { openingElement: { name: { name: localName } } };
44
+ root.find(j.JSXElement, elementSearch).forEach((path) => {
45
+ var _a;
46
+ const attributes = path.value.openingElement.attributes;
47
+ if (!attributes)
48
+ return;
49
+ let variantPropIndex = -1;
50
+ let colorPropIndex = -1;
51
+ let variantValue = "";
52
+ attributes.forEach((attr, index) => {
53
+ if (attr.type !== "JSXAttribute")
54
+ return;
55
+ if (attr.name.name === config.prop) {
56
+ variantPropIndex = index;
57
+ const value = getStringValue(attr.value);
58
+ if (value) {
59
+ variantValue = value;
60
+ }
61
+ }
62
+ if (attr.name.name === "data-color") {
63
+ colorPropIndex = index;
64
+ }
65
+ });
66
+ if (variantPropIndex !== -1 && variantValue) {
67
+ const changeConfig = config.changes[variantValue];
68
+ if (changeConfig) {
69
+ const originalAttr = attributes[variantPropIndex];
70
+ if (originalAttr.type !== "JSXAttribute")
71
+ return;
72
+ // Handle variant prop update or removal
73
+ if (changeConfig.replacement) {
74
+ let newValue;
75
+ if (((_a = originalAttr.value) === null || _a === void 0 ? void 0 : _a.type) === "JSXExpressionContainer") {
76
+ newValue = j.jsxExpressionContainer(j.literal(changeConfig.replacement));
77
+ }
78
+ else {
79
+ newValue = j.literal(changeConfig.replacement);
80
+ }
81
+ const newAttr = j.jsxAttribute(j.jsxIdentifier(config.prop), newValue);
82
+ newAttr.comments = originalAttr.comments;
83
+ attributes[variantPropIndex] = newAttr;
84
+ }
85
+ else {
86
+ // Remove the variant prop if no replacement is specified
87
+ attributes.splice(variantPropIndex, 1);
88
+ // Adjust colorPropIndex if it was after the removed prop
89
+ if (colorPropIndex > variantPropIndex) {
90
+ colorPropIndex--;
91
+ }
92
+ }
93
+ // Add data-color prop if it doesn't exist
94
+ if (colorPropIndex === -1) {
95
+ const colorAttr = j.jsxAttribute(j.jsxIdentifier("data-color"), j.literal(changeConfig.color));
96
+ attributes.unshift(colorAttr);
97
+ }
98
+ }
99
+ }
100
+ });
101
+ const toSourceOptions = (0, lineterminator_1.getLineTerminator)(file.source);
102
+ return root.toSource(toSourceOptions);
103
+ }
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
+ }
@@ -6,23 +6,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.darksideCommand = darksideCommand;
7
7
  const chalk_1 = __importDefault(require("chalk"));
8
8
  const commander_1 = require("commander");
9
- const validation_js_1 = require("../codemod/validation.js");
10
- // import figlet from "figlet";
11
- // import { getMigrationString } from "./migrations.js";
12
9
  const run_tooling_js_1 = require("./run-tooling.js");
13
10
  const program = new commander_1.Command();
14
11
  function darksideCommand() {
15
- program.name(`${chalk_1.default.blueBright(`npx @navikt/aksel`)}`);
12
+ program.name(`${chalk_1.default.blueBright(`npx @navikt/aksel v8-tokens`)}`);
16
13
  program
17
14
  .option("-g, --glob [glob]", "Globbing pattern, overrides --ext! Run with 'noglob' if using zsh-terminal. ")
15
+ .option("-e, --ext [ext]", "File extensions to include, defaults to 'js,ts,jsx,tsx,css,scss,less'")
18
16
  .option("-d, --dry-run", "Dry run, no changes will be made")
19
17
  .option("-f, --force", "Forcibly run updates without checking git-changes")
20
- .description("Update tool for darkside token updates");
18
+ .description("Update tool for v8 token updates");
21
19
  program.parse();
22
20
  const options = program.opts();
23
- /* Makes sure that you don't migrate lots of files while having other uncommitted changes */
24
- if (!options.force) {
25
- (0, validation_js_1.validateGit)(options, program);
26
- }
27
21
  (0, run_tooling_js_1.runTooling)(options, program);
28
22
  }