@navikt/aksel 7.28.0 → 7.29.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.
|
@@ -6,30 +6,46 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.migrations = void 0;
|
|
7
7
|
exports.getMigrationPath = getMigrationPath;
|
|
8
8
|
exports.getWarning = getWarning;
|
|
9
|
+
exports.getIgnoredFileExtensions = getIgnoredFileExtensions;
|
|
9
10
|
exports.getMigrationNames = getMigrationNames;
|
|
10
11
|
exports.getMigrationString = getMigrationString;
|
|
11
12
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
|
+
const JS_EXTENSIONS = [
|
|
14
|
+
"js",
|
|
15
|
+
"jsx",
|
|
16
|
+
"ts",
|
|
17
|
+
"tsx",
|
|
18
|
+
];
|
|
19
|
+
const CSS_EXTENSIONS = [
|
|
20
|
+
"css",
|
|
21
|
+
"scss",
|
|
22
|
+
"less",
|
|
23
|
+
];
|
|
12
24
|
exports.migrations = {
|
|
13
25
|
"1.0.0": [
|
|
14
26
|
{
|
|
15
27
|
description: "Runs all codemods for beta -> v1 migration",
|
|
16
28
|
value: "v1-preset",
|
|
17
29
|
path: "v1.0.0/preset/preset",
|
|
30
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
18
31
|
},
|
|
19
32
|
{
|
|
20
33
|
description: "Fixes breaking API-changes for <Pagination /> component",
|
|
21
34
|
value: "v1-pagination",
|
|
22
35
|
path: "v1.0.0/pagination/pagination",
|
|
36
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
23
37
|
},
|
|
24
38
|
{
|
|
25
39
|
description: "Fixes breaking API-changes for <Tabs /> component",
|
|
26
40
|
value: "v1-tabs",
|
|
27
41
|
path: "v1.0.0/tabs/tabs",
|
|
42
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
28
43
|
},
|
|
29
44
|
{
|
|
30
45
|
description: "Fixes breaking API-changes for <SpeechBubble /> (now <Chat/>) component",
|
|
31
46
|
value: "v1-chat",
|
|
32
47
|
path: "v1.0.0/chat/chat",
|
|
48
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
33
49
|
},
|
|
34
50
|
],
|
|
35
51
|
"2.0.0": [
|
|
@@ -37,21 +53,25 @@ exports.migrations = {
|
|
|
37
53
|
description: "Patches changed css-variables",
|
|
38
54
|
value: "v2-css",
|
|
39
55
|
path: "v2.0.0/update-css-tokens/update-css-tokens",
|
|
56
|
+
ignoredExtensions: [],
|
|
40
57
|
},
|
|
41
58
|
{
|
|
42
59
|
description: "Patches changed js-variables",
|
|
43
60
|
value: "v2-js",
|
|
44
61
|
path: "v2.0.0/update-js-tokens/update-js-tokens",
|
|
62
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
45
63
|
},
|
|
46
64
|
{
|
|
47
65
|
description: "Patches changed sass-variables",
|
|
48
66
|
value: "v2-sass",
|
|
49
67
|
path: "v2.0.0/update-sass-tokens/update-sass-tokens",
|
|
68
|
+
ignoredExtensions: JS_EXTENSIONS,
|
|
50
69
|
},
|
|
51
70
|
{
|
|
52
71
|
description: "Patches changed less-variables",
|
|
53
72
|
value: "v2-less",
|
|
54
73
|
path: "v2.0.0/update-less-tokens/update-less-tokens",
|
|
74
|
+
ignoredExtensions: JS_EXTENSIONS,
|
|
55
75
|
},
|
|
56
76
|
],
|
|
57
77
|
"v3.0.0": [
|
|
@@ -60,6 +80,7 @@ exports.migrations = {
|
|
|
60
80
|
value: "v3-copybutton",
|
|
61
81
|
path: "v3.0.0/copybutton/copybutton",
|
|
62
82
|
warning: "Remember to clean css-import from '@navikt/ds-css-internal' if no longer needed\nIf non-text was used as children, or different locales were handled, you need to manually fix this",
|
|
83
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
63
84
|
},
|
|
64
85
|
],
|
|
65
86
|
"v4.0.0": [
|
|
@@ -68,17 +89,20 @@ exports.migrations = {
|
|
|
68
89
|
value: "v4-internal-react",
|
|
69
90
|
path: "v4.0.0/internal-react/internal-react",
|
|
70
91
|
warning: "Remember to also run 'v4-internal-css' if you have overwritten any css-classes!",
|
|
92
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
71
93
|
},
|
|
72
94
|
{
|
|
73
95
|
description: "Replaced 'navdsi'-prefixes used to overwrite internal-css to 'navds'-prefixes",
|
|
74
96
|
value: "v4-internal-css",
|
|
75
97
|
path: "v4.0.0/internal-css/internal-css",
|
|
76
98
|
warning: "Remember to remove '@navikt/ds-css-internal' imports if no longer needed! Also run 'v4-internal-react' to convert internal-react imports to core-imports",
|
|
99
|
+
ignoredExtensions: [],
|
|
77
100
|
},
|
|
78
101
|
{
|
|
79
102
|
description: "Removes all instances of UNSAFE_ for datepicker/monthpicker.",
|
|
80
103
|
value: "v4-date",
|
|
81
104
|
path: "v4.0.0/date/date",
|
|
105
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
82
106
|
},
|
|
83
107
|
],
|
|
84
108
|
"v6.0.0": [
|
|
@@ -87,6 +111,7 @@ exports.migrations = {
|
|
|
87
111
|
value: "v6-chat",
|
|
88
112
|
path: "v6.0.0/chat/chat",
|
|
89
113
|
warning: "Remember to update use of `variant`-prop to match previous use of colors. If needed the component exposes css-variables for custom overrides",
|
|
114
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
90
115
|
},
|
|
91
116
|
],
|
|
92
117
|
spacing: [
|
|
@@ -94,16 +119,19 @@ exports.migrations = {
|
|
|
94
119
|
description: "Updates all Primitives to use new `space`-tokens. (Works with old and new system)",
|
|
95
120
|
value: "primitive-spacing",
|
|
96
121
|
path: "spacing/primitives-spacing/spacing",
|
|
122
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
97
123
|
},
|
|
98
124
|
{
|
|
99
125
|
description: "Updates css, scss and less-variables to use new `space`-tokens. (Works with old and new system)",
|
|
100
126
|
value: "token-spacing",
|
|
101
127
|
path: "spacing/token-spacing/spacing",
|
|
128
|
+
ignoredExtensions: [],
|
|
102
129
|
},
|
|
103
130
|
{
|
|
104
131
|
description: "Updates js-tokens to use new `space`-tokens. (Works with old and new system)",
|
|
105
132
|
value: "token-spacing-js",
|
|
106
133
|
path: "spacing/token-spacing-js/spacing",
|
|
134
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
107
135
|
},
|
|
108
136
|
],
|
|
109
137
|
darkside: [
|
|
@@ -111,26 +139,43 @@ exports.migrations = {
|
|
|
111
139
|
description: "marks deprecated prop usage with comments.",
|
|
112
140
|
value: "prop-deprecate",
|
|
113
141
|
path: "darkside/prop-deprecate/prop-deprecate",
|
|
142
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
114
143
|
},
|
|
115
144
|
{
|
|
116
145
|
description: "Update Box to to BoxNew (future Box) using the new token system",
|
|
117
146
|
value: "box-to-boxnew",
|
|
118
147
|
path: "darkside/box-to-boxnew/box-to-boxnew",
|
|
119
148
|
warning: "Remember to check if 'aksel box migration'-comment were added to any files after migration. This comment will help you find and update Box-instances where we could not resolve the update for you.",
|
|
149
|
+
ignoredExtensions: CSS_EXTENSIONS,
|
|
120
150
|
},
|
|
121
151
|
],
|
|
122
152
|
};
|
|
123
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Extracts `path` field for a given migration.
|
|
155
|
+
*/
|
|
156
|
+
function getMigrationPath(migrationName) {
|
|
124
157
|
var _a;
|
|
125
158
|
return (_a = Object.values(exports.migrations)
|
|
126
159
|
.flat()
|
|
127
|
-
.find((x) => x.value ===
|
|
160
|
+
.find((x) => x.value === migrationName)) === null || _a === void 0 ? void 0 : _a.path;
|
|
128
161
|
}
|
|
129
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Extracts `warning` field for a given migration.
|
|
164
|
+
*/
|
|
165
|
+
function getWarning(migrationName) {
|
|
130
166
|
var _a;
|
|
131
167
|
return (_a = Object.values(exports.migrations)
|
|
132
168
|
.flat()
|
|
133
|
-
.find((x) => x.value ===
|
|
169
|
+
.find((x) => x.value === migrationName)) === null || _a === void 0 ? void 0 : _a.warning;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Extracts `ignoredExtensions` field for a given migration.
|
|
173
|
+
*/
|
|
174
|
+
function getIgnoredFileExtensions(migrationName) {
|
|
175
|
+
var _a, _b;
|
|
176
|
+
return ((_b = (_a = Object.values(exports.migrations)
|
|
177
|
+
.flat()
|
|
178
|
+
.find((x) => x.value === migrationName)) === null || _a === void 0 ? void 0 : _a.ignoredExtensions) !== null && _b !== void 0 ? _b : []);
|
|
134
179
|
}
|
|
135
180
|
function getMigrationNames() {
|
|
136
181
|
return Object.values(exports.migrations)
|
|
@@ -70,8 +70,13 @@ function runCodeshift(input, options, program) {
|
|
|
70
70
|
console.info("\nRunning migration:", chalk_1.default.green("input"));
|
|
71
71
|
(options === null || options === void 0 ? void 0 : options.glob) && console.info(`Using glob: ${chalk_1.default.green(options.glob)}\n`);
|
|
72
72
|
const warning = (0, migrations_1.getWarning)(input);
|
|
73
|
+
const unsafeExtensions = (0, migrations_1.getIgnoredFileExtensions)(input);
|
|
74
|
+
let safeFilepaths = filepaths;
|
|
75
|
+
if (unsafeExtensions.length > 0) {
|
|
76
|
+
safeFilepaths = filepaths.filter((f) => !unsafeExtensions.some((ext) => f.endsWith(`.${ext}`)));
|
|
77
|
+
}
|
|
73
78
|
try {
|
|
74
|
-
yield jscodeshift.run(codemodPath,
|
|
79
|
+
yield jscodeshift.run(codemodPath, safeFilepaths, {
|
|
75
80
|
babel: true,
|
|
76
81
|
ignorePattern: ignoreNodeModules,
|
|
77
82
|
parser: "tsx",
|
|
@@ -161,11 +161,21 @@ function executeTask(task, filepaths, options, program) {
|
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
+
const JS_EXTENSIONS = [
|
|
165
|
+
"js",
|
|
166
|
+
"jsx",
|
|
167
|
+
"ts",
|
|
168
|
+
"tsx",
|
|
169
|
+
];
|
|
164
170
|
/**
|
|
165
171
|
* Filter files based on the selected task
|
|
166
172
|
*/
|
|
167
173
|
function getScopedFilesForTask(task, filepaths, status) {
|
|
168
|
-
|
|
174
|
+
let safeFilepaths = filepaths;
|
|
175
|
+
if (task === "js-tokens") {
|
|
176
|
+
safeFilepaths = filepaths.filter((f) => JS_EXTENSIONS.some((ext) => f.endsWith(`.${ext}`)));
|
|
177
|
+
}
|
|
178
|
+
return safeFilepaths.filter((f) => {
|
|
169
179
|
switch (task) {
|
|
170
180
|
case "css-tokens":
|
|
171
181
|
return !!status.css.legacy.find((config) => config.fileName === f);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/aksel",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.29.0",
|
|
4
4
|
"description": "Aksel command line interface. Handles css-imports, codemods and more",
|
|
5
5
|
"author": "Aksel | Nav designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://aksel.nav.no/grunnleggende/kode/kommandolinje",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@navikt/ds-css": "^7.
|
|
33
|
-
"@navikt/ds-tokens": "^7.
|
|
32
|
+
"@navikt/ds-css": "^7.29.0",
|
|
33
|
+
"@navikt/ds-tokens": "^7.29.0",
|
|
34
34
|
"axios": "1.9.0",
|
|
35
35
|
"chalk": "4.1.0",
|
|
36
36
|
"cli-progress": "^3.12.0",
|