@navikt/aksel 7.35.3 → 7.36.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.
|
@@ -29,6 +29,7 @@ class TokenStatus {
|
|
|
29
29
|
js: { legacy: [], updated: [] },
|
|
30
30
|
tailwind: { legacy: [], updated: [] },
|
|
31
31
|
component: { legacy: [], updated: [] },
|
|
32
|
+
deprecated: { legacy: [], updated: [] },
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
add(_a) {
|
|
@@ -50,6 +51,12 @@ class TokenStatus {
|
|
|
50
51
|
case "tailwind":
|
|
51
52
|
this.status.tailwind[statusType].push(hit);
|
|
52
53
|
break;
|
|
54
|
+
case "component":
|
|
55
|
+
this.status.component[statusType].push(hit);
|
|
56
|
+
break;
|
|
57
|
+
case "deprecated":
|
|
58
|
+
this.status.deprecated[statusType].push(hit);
|
|
59
|
+
break;
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
printStatusForAll() {
|
|
@@ -136,9 +143,15 @@ class TokenStatus {
|
|
|
136
143
|
}
|
|
137
144
|
const componentTokens = this.status.component.legacy.length;
|
|
138
145
|
if (componentTokens > 0) {
|
|
139
|
-
console.info(chalk_1.default.underline(
|
|
140
|
-
console.info(
|
|
141
|
-
console.info(`
|
|
146
|
+
console.info(chalk_1.default.underline(`\nCOMPONENT Tokens Migration`));
|
|
147
|
+
console.info(`${chalk_1.default.yellow("!")} Found ${componentTokens} component token definition${componentTokens > 1 ? "s" : ""} that require manual migration.`);
|
|
148
|
+
console.info(`We no longer support component tokens. Please migrate to the new darkside tokens using theming or other methods.`);
|
|
149
|
+
}
|
|
150
|
+
const deprecatedTokens = this.status.deprecated.legacy.length;
|
|
151
|
+
if (deprecatedTokens > 0) {
|
|
152
|
+
console.info(chalk_1.default.underline(`\nLEGACY TOKEN DEFINITIONS (--a-token:)`));
|
|
153
|
+
console.info(`${chalk_1.default.yellow("!")} Found ${deprecatedTokens} legacy token definition${deprecatedTokens > 1 ? "s" : ""} that require manual migration.`);
|
|
154
|
+
console.info(`These are custom property definitions using legacy tokens that need to be updated to use new darkside tokens.`);
|
|
142
155
|
}
|
|
143
156
|
}
|
|
144
157
|
}
|
|
@@ -39,6 +39,11 @@ function getStatus(files, action = "print") {
|
|
|
39
39
|
* Pre-computed regex for legacy component tokens
|
|
40
40
|
*/
|
|
41
41
|
const legacyRegex = new RegExp(`(${legacy_component_tokens_1.legacyComponentTokenList.map((t) => `${t}:`).join("|")})`, "gm");
|
|
42
|
+
/**
|
|
43
|
+
* Pre-computed regex for legacy token definitions (--a-token:)
|
|
44
|
+
* These are custom property definitions that need manual migration.
|
|
45
|
+
*/
|
|
46
|
+
const legacyDefinitionRegex = /(--a-[a-zA-Z0-9-]+)(?=\s*:)/gm;
|
|
42
47
|
/**
|
|
43
48
|
* Process each file to find and record token usages
|
|
44
49
|
*/
|
|
@@ -127,6 +132,31 @@ function getStatus(files, action = "print") {
|
|
|
127
132
|
legacyMatch = legacyRegex.exec(fileSrc);
|
|
128
133
|
}
|
|
129
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Detect legacy token definitions (--a-token:)
|
|
137
|
+
* These are custom property definitions using legacy tokens
|
|
138
|
+
* that need manual intervention from the user.
|
|
139
|
+
*/
|
|
140
|
+
legacyDefinitionRegex.lastIndex = 0;
|
|
141
|
+
let definitionMatch = legacyDefinitionRegex.exec(fileSrc);
|
|
142
|
+
while (definitionMatch !== null) {
|
|
143
|
+
const tokenKey = definitionMatch[1].replace("--a-", "");
|
|
144
|
+
/* Only report if it's a known legacy token */
|
|
145
|
+
if (legacy_tokens_1.legacyTokenConfig[tokenKey]) {
|
|
146
|
+
const { row, column } = getCharacterPositionInFile(definitionMatch.index, getLineStartsLazy());
|
|
147
|
+
StatusStore.add({
|
|
148
|
+
isLegacy: true,
|
|
149
|
+
type: "deprecated",
|
|
150
|
+
columnNumber: column,
|
|
151
|
+
lineNumber: row,
|
|
152
|
+
canAutoMigrate: false,
|
|
153
|
+
fileName,
|
|
154
|
+
name: definitionMatch[1],
|
|
155
|
+
comment: "Legacy token definition - requires manual migration to new darkside tokens",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
definitionMatch = legacyDefinitionRegex.exec(fileSrc);
|
|
159
|
+
}
|
|
130
160
|
for (const [newTokenName, config] of Object.entries(darkside_tokens_1.darksideTokenConfig)) {
|
|
131
161
|
const terms = darksideSearchTerms.get(newTokenName);
|
|
132
162
|
/* Optimization: Check if any of the search terms exist in the file words set */
|
|
@@ -5,22 +5,11 @@ const legacy_tokens_1 = require("../config/legacy.tokens");
|
|
|
5
5
|
function transformer(file) {
|
|
6
6
|
let src = file.source;
|
|
7
7
|
/*
|
|
8
|
-
|
|
9
|
-
Matches "--a-token" followed by optional whitespace and a colon.
|
|
10
|
-
Uses negative lookbehind to ensure we don't match "--not-a-token".
|
|
11
|
-
*/
|
|
12
|
-
src = src.replace(/(?<![\w-])(--a-[\w-]+)(\s*:)/g, (match, tokenName, suffix) => {
|
|
13
|
-
const key = tokenName.replace("--a-", "");
|
|
14
|
-
if (legacy_tokens_1.legacyTokenConfig[key]) {
|
|
15
|
-
return `--aksel-legacy${tokenName.replace("--", "__")}${suffix}`;
|
|
16
|
-
}
|
|
17
|
-
return match;
|
|
18
|
-
});
|
|
19
|
-
/*
|
|
20
|
-
2. Replace usages: --a-token -> --ax-replacement
|
|
8
|
+
Replace usages: --a-token -> --ax-replacement
|
|
21
9
|
Matches "--a-token" with word boundaries.
|
|
10
|
+
Uses negative lookahead to skip definitions (--a-token:)
|
|
22
11
|
*/
|
|
23
|
-
src = src.replace(/(?<![\w-])(--a-[\w-]+)(?![\w-])/g, (match, tokenName) => {
|
|
12
|
+
src = src.replace(/(?<![\w-])(--a-[\w-]+)(?![\w-])(?!\s*:)/g, (match, tokenName) => {
|
|
24
13
|
const key = tokenName.replace("--a-", "");
|
|
25
14
|
const config = legacy_tokens_1.legacyTokenConfig[key];
|
|
26
15
|
if (config === null || config === void 0 ? void 0 : config.replacement) {
|
package/dist/index.js
CHANGED
|
@@ -15,16 +15,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
const chalk_1 = __importDefault(require("chalk"));
|
|
17
17
|
const commander_1 = require("commander");
|
|
18
|
-
const node_fs_1 = __importDefault(require("node:fs"));
|
|
19
18
|
const index_1 = require("./codemod/index");
|
|
20
19
|
const darkside_1 = require("./darkside");
|
|
21
20
|
const help_1 = require("./help");
|
|
21
|
+
const version_1 = require("./version");
|
|
22
22
|
run();
|
|
23
23
|
function run() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
const pkg = JSON.parse(node_fs_1.default.readFileSync("./package.json").toString()).version;
|
|
26
25
|
const program = new commander_1.Command();
|
|
27
|
-
program.version(
|
|
26
|
+
program.version(version_1.VERSION, "-v, --version");
|
|
28
27
|
program.allowUnknownOption().helpOption(false);
|
|
29
28
|
program.parse();
|
|
30
29
|
const args = program.args;
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/aksel",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.36.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",
|
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"clean": "rimraf dist",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
19
|
+
"generate-version": "node -e \"const fs=require('fs');const v=require('./package.json').version;fs.writeFileSync('src/version.ts','export const VERSION = \\\"'+v+'\\\";\\n')\"",
|
|
20
|
+
"build": "yarn clean && yarn generate-version && tsc -p tsconfig.json",
|
|
21
|
+
"dev": "yarn generate-version && tsc --watch -p tsconfig.json",
|
|
21
22
|
"test": "vitest run",
|
|
22
23
|
"test:watch": "vitest watch"
|
|
23
24
|
},
|
|
@@ -32,9 +33,8 @@
|
|
|
32
33
|
"url": "https://github.com/navikt/aksel/issues"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@navikt/ds-css": "^7.
|
|
36
|
-
"@navikt/ds-tokens": "^7.
|
|
37
|
-
"axios": "1.13.2",
|
|
36
|
+
"@navikt/ds-css": "^7.36.0",
|
|
37
|
+
"@navikt/ds-tokens": "^7.36.0",
|
|
38
38
|
"chalk": "5.6.2",
|
|
39
39
|
"cli-progress": "3.12.0",
|
|
40
40
|
"clipboardy": "5.0.1",
|