@navikt/aksel 7.17.3 → 7.17.4
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/codemod/codeshift.utils.js +30 -0
- package/dist/codemod/migrations.js +9 -12
- package/dist/codemod/run-codeshift.js +3 -17
- package/dist/codemod/transforms/darkside/prop-deprecate/prop-deprecate.js +32 -0
- package/dist/codemod/transforms/{darkside → spacing}/primitives-spacing/spacing.js +7 -6
- package/dist/codemod/transforms/spacing/spacing.utils.js +34 -0
- package/dist/codemod/transforms/{darkside → spacing}/token-spacing/spacing.js +2 -2
- package/dist/codemod/transforms/{darkside → spacing}/token-spacing-js/spacing.js +4 -3
- package/dist/codemod/transforms/v2.0.0/update-js-tokens/update-js-tokens.js +1 -1
- package/dist/codemod/{transforms/darkside/darkside.utils.js → utils/ast.js} +0 -32
- package/dist/darkside/config/TokenStatus.js +145 -0
- package/dist/darkside/config/darkside.tokens.js +398 -0
- package/dist/darkside/config/legacy-component.tokens.js +407 -0
- package/dist/{codemod/transforms/darkside/darkside.tokens.js → darkside/config/legacy.tokens.js} +390 -796
- package/dist/darkside/config/token-regex.js +52 -0
- package/dist/darkside/config/token.utils.js +57 -0
- package/dist/darkside/index.js +28 -0
- package/dist/darkside/run-tooling.js +220 -0
- package/dist/darkside/tasks/print-remaining.js +51 -0
- package/dist/darkside/tasks/status.js +122 -0
- package/dist/darkside/transforms/darkside-tokens-css.js +17 -0
- package/dist/darkside/transforms/darkside-tokens-js.js +51 -0
- package/dist/darkside/transforms/darkside-tokens-less.js +14 -0
- package/dist/darkside/transforms/darkside-tokens-scss.js +14 -0
- package/dist/darkside/transforms/darkside-tokens-tailwind.js +33 -0
- package/dist/help.js +5 -0
- package/dist/index.js +5 -0
- package/package.json +5 -2
- package/dist/codemod/transforms/darkside/darkside.test.js +0 -20
- package/dist/codemod/transforms/darkside/token-update/token-update.js +0 -110
- package/dist/codemod/transforms/darkside/token-update-js/token-update-js.js +0 -96
package/dist/help.js
CHANGED
|
@@ -21,5 +21,10 @@ function helpCommand() {
|
|
|
21
21
|
- ${chalk_1.default.cyan(`npx @navikt/aksel ${chalk_1.default.green("codemod")} ${chalk_1.default.gray("<migration>")}`)}
|
|
22
22
|
✔︎ Code-transformations for breaking changes when updating Aksel
|
|
23
23
|
✔︎ Run with ${chalk_1.default.cyan(`${chalk_1.default.green("--help")}`)} to get started!
|
|
24
|
+
|
|
25
|
+
- ${chalk_1.default.cyan(`npx @navikt/aksel ${chalk_1.default.green("darkside")} ${chalk_1.default.gray("<task>")}`)}
|
|
26
|
+
✔︎ Tooling for migrating to the darkside
|
|
27
|
+
✔︎ Check current status and migrate tokens
|
|
28
|
+
✔︎ Run with ${chalk_1.default.cyan(`${chalk_1.default.green("--help")}`)} to get started!
|
|
24
29
|
`);
|
|
25
30
|
}
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
17
17
|
const fs_1 = __importDefault(require("fs"));
|
|
18
18
|
const index_1 = require("./codemod/index");
|
|
19
19
|
const index_2 = require("./css-imports/index");
|
|
20
|
+
const darkside_1 = require("./darkside");
|
|
20
21
|
const help_1 = require("./help");
|
|
21
22
|
run();
|
|
22
23
|
function run() {
|
|
@@ -33,6 +34,10 @@ function run() {
|
|
|
33
34
|
(0, index_1.codemodCommand)();
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
37
|
+
if (process.argv[2] === "darkside") {
|
|
38
|
+
(0, darkside_1.darksideCommand)();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
36
41
|
if (process.argv[2] === "-v" || process.argv[2] === "--version") {
|
|
37
42
|
const pkg = JSON.parse(fs_1.default.readFileSync("./package.json").toString()).version;
|
|
38
43
|
console.info(pkg);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/aksel",
|
|
3
|
-
"version": "7.17.
|
|
3
|
+
"version": "7.17.4",
|
|
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,9 +29,11 @@
|
|
|
29
29
|
},
|
|
30
30
|
"homepage": "https://aksel.nav.no/grunnleggende/kode/kommandolinje",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@navikt/ds-css": "^7.17.
|
|
32
|
+
"@navikt/ds-css": "^7.17.4",
|
|
33
|
+
"@navikt/ds-tokens": "^7.17.4",
|
|
33
34
|
"axios": "1.8.2",
|
|
34
35
|
"chalk": "4.1.0",
|
|
36
|
+
"cli-progress": "^3.12.0",
|
|
35
37
|
"clipboardy": "^2.3.0",
|
|
36
38
|
"commander": "10.0.1",
|
|
37
39
|
"enquirer": "^2.3.6",
|
|
@@ -44,6 +46,7 @@
|
|
|
44
46
|
"react-scanner": "^1.1.0"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
49
|
+
"@types/cli-progress": "3.11.6",
|
|
47
50
|
"rimraf": "6.0.1",
|
|
48
51
|
"typescript": "5.5.4",
|
|
49
52
|
"vitest": "^2.1.8"
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const vitest_1 = require("vitest");
|
|
4
|
-
const darkside_tokens_1 = require("./darkside.tokens");
|
|
5
|
-
(0, vitest_1.describe)("Darkside codemods", () => {
|
|
6
|
-
(0, vitest_1.test)("Token migration references exists", () => {
|
|
7
|
-
Object.entries(darkside_tokens_1.updatedTokens).forEach(([oldToken, config]) => {
|
|
8
|
-
if (config.replacement.length > 1) {
|
|
9
|
-
(0, vitest_1.expect)(darkside_tokens_1.newTokens, `${oldToken} has valid replacement: ${config.replacement}`).toContain(config.replacement);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
(0, vitest_1.test)("Has raw value if no reference is set", () => {
|
|
14
|
-
Object.values(darkside_tokens_1.updatedTokens).forEach((config) => {
|
|
15
|
-
if (config.replacement.length === 0) {
|
|
16
|
-
(0, vitest_1.expect)(config.raw.length > 0).toBeTruthy();
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = transformer;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const run_codeshift_1 = require("../../../run-codeshift");
|
|
9
|
-
const translate_token_1 = require("../../../utils/translate-token");
|
|
10
|
-
const darkside_tokens_1 = require("../darkside.tokens");
|
|
11
|
-
/**
|
|
12
|
-
* Updates old tokens to new names.
|
|
13
|
-
* Replaces global and semantic tokens with avalaible replacement.
|
|
14
|
-
*/
|
|
15
|
-
function transformer(file) {
|
|
16
|
-
initMessageSetup();
|
|
17
|
-
let src = file.source;
|
|
18
|
-
for (const [oldToken, config] of Object.entries(darkside_tokens_1.updatedTokens)) {
|
|
19
|
-
const oldCSSVar = `--a-${oldToken}`;
|
|
20
|
-
/* We update all re-definitions of a token to a "legacy" version */
|
|
21
|
-
const replaceRegex = new RegExp("(" + `${oldCSSVar}:` + ")", "gm");
|
|
22
|
-
src = src.replace(replaceRegex, `--aksel-legacy${oldCSSVar.replace("--", "__")}:`);
|
|
23
|
-
if (config.replacement.length > 0) {
|
|
24
|
-
src = replaceTokenWithReference({
|
|
25
|
-
src,
|
|
26
|
-
newToken: `--ax-${config.replacement}`,
|
|
27
|
-
oldToken: oldCSSVar,
|
|
28
|
-
});
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
documentLegacyReferences({
|
|
32
|
-
src,
|
|
33
|
-
oldToken: oldCSSVar,
|
|
34
|
-
comment: config.comment,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return src;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Replaces old token with new token reference.
|
|
41
|
-
*/
|
|
42
|
-
function replaceTokenWithReference({ src, newToken, oldToken, }) {
|
|
43
|
-
const CSSRgx = new RegExp("(" + oldToken + ")", "gm");
|
|
44
|
-
const SCSSRgx = new RegExp("(\\" + (0, translate_token_1.translateToken)(oldToken, "scss") + ")", "gm");
|
|
45
|
-
const LESSRgx = new RegExp("(" + (0, translate_token_1.translateToken)(oldToken, "less") + ")", "gm");
|
|
46
|
-
let fileSrc = src;
|
|
47
|
-
fileSrc = fileSrc.replace(CSSRgx, newToken);
|
|
48
|
-
fileSrc = fileSrc.replace(SCSSRgx, (0, translate_token_1.translateToken)(newToken, "scss"));
|
|
49
|
-
fileSrc = fileSrc.replace(LESSRgx, (0, translate_token_1.translateToken)(newToken, "less"));
|
|
50
|
-
return fileSrc;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Replaces old token with new token reference.
|
|
54
|
-
*/
|
|
55
|
-
function documentLegacyReferences({ src, oldToken, comment, }) {
|
|
56
|
-
const CSSRgx = new RegExp("(" + oldToken + ")", "gm");
|
|
57
|
-
const SCSSRgx = new RegExp("(\\" + (0, translate_token_1.translateToken)(oldToken, "scss") + ")", "gm");
|
|
58
|
-
const LESSRgx = new RegExp("(" + (0, translate_token_1.translateToken)(oldToken, "less") + ")", "gm");
|
|
59
|
-
if (CSSRgx.test(src)) {
|
|
60
|
-
addMessage({ token: oldToken, comment, type: "css" });
|
|
61
|
-
}
|
|
62
|
-
else if (SCSSRgx.test(src)) {
|
|
63
|
-
addMessage({
|
|
64
|
-
token: (0, translate_token_1.translateToken)(oldToken, "scss"),
|
|
65
|
-
comment,
|
|
66
|
-
type: "scss",
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
else if (LESSRgx.test(src)) {
|
|
70
|
-
addMessage({
|
|
71
|
-
token: (0, translate_token_1.translateToken)(oldToken, "less"),
|
|
72
|
-
comment,
|
|
73
|
-
type: "less",
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
function initMessageSetup() {
|
|
78
|
-
if (!run_codeshift_1.messages.has("Token update")) {
|
|
79
|
-
run_codeshift_1.messages.set("Token update", {
|
|
80
|
-
format: formatMessage,
|
|
81
|
-
data: {
|
|
82
|
-
scss: [],
|
|
83
|
-
less: [],
|
|
84
|
-
css: [],
|
|
85
|
-
},
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
function addMessage({ token, comment, type, }) {
|
|
90
|
-
var _a;
|
|
91
|
-
(_a = run_codeshift_1.messages
|
|
92
|
-
.get("Token update")) === null || _a === void 0 ? void 0 : _a.data[type].push(`${token}${comment ? ` (${comment})` : ""}`);
|
|
93
|
-
}
|
|
94
|
-
function formatMessage(input) {
|
|
95
|
-
const css = [...new Set(input.css)];
|
|
96
|
-
const scss = [...new Set(input.scss)];
|
|
97
|
-
const less = [...new Set(input.less)];
|
|
98
|
-
const total = css.length + scss.length + less.length;
|
|
99
|
-
if (total === 0) {
|
|
100
|
-
console.info(chalk_1.default.green(`Found no legacy-tokens 🎉, you have now migrated over to the darkside.`));
|
|
101
|
-
}
|
|
102
|
-
console.info(chalk_1.default.green(`\nToken update`));
|
|
103
|
-
console.info(chalk_1.default.green(`Found ${total} legacy tokens that are no longer supported. Until these are updated, you will need to keep the old tokens package imported in your code.`));
|
|
104
|
-
css.length > 0 &&
|
|
105
|
-
console.info(`\nCSS tokens found:${css.map((token) => `\n${token}`).join("")}`);
|
|
106
|
-
scss.length > 1 &&
|
|
107
|
-
console.info(`\nSCSS tokens found:${scss.map((token) => `\n${token}`).join("")}`);
|
|
108
|
-
less.length > 1 &&
|
|
109
|
-
console.info(`\nLESS tokens found:${less.map((token) => `\n${token}`).join("")}`);
|
|
110
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.default = transformer;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const run_codeshift_1 = require("../../../run-codeshift");
|
|
9
|
-
const imports_1 = require("../../../utils/imports");
|
|
10
|
-
const lineterminator_1 = require("../../../utils/lineterminator");
|
|
11
|
-
const moveAndRenameImport_1 = __importDefault(require("../../../utils/moveAndRenameImport"));
|
|
12
|
-
const translate_token_1 = require("../../../utils/translate-token");
|
|
13
|
-
const darkside_tokens_1 = require("../darkside.tokens");
|
|
14
|
-
/**
|
|
15
|
-
* Updates old tokens to new names.
|
|
16
|
-
* Replaces global and semantic tokens with avalaible replacement.
|
|
17
|
-
*/
|
|
18
|
-
function transformer(file, api) {
|
|
19
|
-
initMessageSetup();
|
|
20
|
-
let src = file.source;
|
|
21
|
-
const j = api.jscodeshift;
|
|
22
|
-
let root = j(file.source);
|
|
23
|
-
const jsImport = root.find(j.ImportDeclaration).filter((x) => {
|
|
24
|
-
return ["@navikt/ds-tokens/dist/tokens"].includes(x.node.source.value);
|
|
25
|
-
});
|
|
26
|
-
if (!jsImport) {
|
|
27
|
-
return src;
|
|
28
|
-
}
|
|
29
|
-
for (const [oldToken, config] of Object.entries(darkside_tokens_1.updatedTokens)) {
|
|
30
|
-
const oldCSSVar = `--a-${oldToken}`;
|
|
31
|
-
const oldJsVar = (0, translate_token_1.translateToken)(oldCSSVar, "js");
|
|
32
|
-
let foundName = null;
|
|
33
|
-
(0, imports_1.getImportSpecifier)(j, root, oldJsVar, "@navikt/ds-tokens/dist/tokens").forEach((x) => {
|
|
34
|
-
foundName = x.node.imported.name;
|
|
35
|
-
});
|
|
36
|
-
if (!foundName) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (config.replacement.length > 0) {
|
|
40
|
-
/* We remove the prefix */
|
|
41
|
-
const jsToken = (0, translate_token_1.translateToken)(`--ax-${config.replacement}`, "js").slice(2);
|
|
42
|
-
const localName = (0, moveAndRenameImport_1.default)(j, root, {
|
|
43
|
-
fromImport: "@navikt/ds-tokens/dist/tokens",
|
|
44
|
-
toImport: "@navikt/ds-tokens/darkside-js",
|
|
45
|
-
fromName: foundName,
|
|
46
|
-
toName: jsToken,
|
|
47
|
-
ignoreAlias: true,
|
|
48
|
-
});
|
|
49
|
-
let code = root.toSource((0, lineterminator_1.getLineTerminator)(src));
|
|
50
|
-
const rgx = new RegExp("(" + localName + ")", "gm");
|
|
51
|
-
code = code.replace(rgx, jsToken);
|
|
52
|
-
src = code;
|
|
53
|
-
root = j(code);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
documentLegacyReferences({
|
|
57
|
-
src,
|
|
58
|
-
oldToken: oldCSSVar,
|
|
59
|
-
comment: config.comment,
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return root.toSource((0, lineterminator_1.getLineTerminator)(src));
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Replaces old token with new token reference.
|
|
66
|
-
*/
|
|
67
|
-
function documentLegacyReferences({ src, oldToken, comment, }) {
|
|
68
|
-
const JSRgx = new RegExp("(" + (0, translate_token_1.translateToken)(oldToken, "js") + ")", "gm");
|
|
69
|
-
JSRgx.test(src) && addMessage({ token: oldToken, comment, type: "js" });
|
|
70
|
-
}
|
|
71
|
-
function initMessageSetup() {
|
|
72
|
-
if (!run_codeshift_1.messages.has("Token update")) {
|
|
73
|
-
run_codeshift_1.messages.set("Token update", {
|
|
74
|
-
format: formatMessage,
|
|
75
|
-
data: {
|
|
76
|
-
js: [],
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function addMessage({ token, comment, type, }) {
|
|
82
|
-
var _a;
|
|
83
|
-
(_a = run_codeshift_1.messages
|
|
84
|
-
.get("Token update")) === null || _a === void 0 ? void 0 : _a.data[type].push(`${token}${comment ? ` (${comment})` : ""}`);
|
|
85
|
-
}
|
|
86
|
-
function formatMessage(input) {
|
|
87
|
-
const js = [...new Set(input.js)];
|
|
88
|
-
const total = js.length;
|
|
89
|
-
if (total === 0) {
|
|
90
|
-
console.info(chalk_1.default.green(`Found no legacy-tokens 🎉, you have now migrated over to the darkside.`));
|
|
91
|
-
}
|
|
92
|
-
console.info(chalk_1.default.green(`\nToken update`));
|
|
93
|
-
console.info(chalk_1.default.green(`Found use of ${total} tokens no longer supported. Until these are updated, you will need to keep old tokens imported in your code.`));
|
|
94
|
-
js.length > 0 &&
|
|
95
|
-
console.info(`\nJS:${js.map((token) => `\n${token}`).join("")}`);
|
|
96
|
-
}
|