@navikt/aksel 7.37.0 → 7.39.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.
- package/dist/codemod/index.js +23 -5
- package/dist/codemod/migrations.js +33 -7
- package/dist/codemod/run-codeshift.js +0 -1
- package/dist/codemod/run-version-migration.js +85 -0
- package/dist/codemod/transforms/v8.0.0/primitives-spacing/spacing.js +1 -1
- package/dist/darkside/index.js +1 -0
- package/dist/index.js +10 -3
- package/dist/version.js +1 -1
- package/package.json +4 -4
package/dist/codemod/index.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -9,27 +18,36 @@ const commander_1 = require("commander");
|
|
|
9
18
|
const figlet_1 = __importDefault(require("figlet"));
|
|
10
19
|
const migrations_js_1 = require("./migrations.js");
|
|
11
20
|
const run_codeshift_js_1 = require("./run-codeshift.js");
|
|
21
|
+
const run_version_migration_js_1 = require("./run-version-migration.js");
|
|
12
22
|
const validation_js_1 = require("./validation.js");
|
|
13
23
|
const program = new commander_1.Command();
|
|
14
|
-
function codemodCommand() {
|
|
24
|
+
function codemodCommand(overrideHandler) {
|
|
15
25
|
program.name(`${chalk_1.default.blueBright(`npx @navikt/aksel`)}`);
|
|
16
26
|
program
|
|
17
27
|
.command("codemod")
|
|
18
28
|
.addHelpText("beforeAll", figlet_1.default.textSync("Codemods"))
|
|
19
29
|
.addHelpText("afterAll", chalk_1.default.gray(`\nAvailable migrations:\n${(0, migrations_js_1.getMigrationString)()}`))
|
|
20
30
|
.description("Migrations for Aksel components and more")
|
|
21
|
-
.argument("<migration>", "Migration name")
|
|
31
|
+
.argument("<migration>", "Migration name or version (e.g. v8)")
|
|
22
32
|
.option("-e, --ext [extension]", "default: js,ts,jsx,tsx,css,scss,less")
|
|
23
33
|
.option("-g, --glob [glob]", "Globbing pattern, overrides --ext! Run with 'noglob' if using zsh-terminal. ")
|
|
24
34
|
.option("-d, --dry-run", "Dry run, no changes will be made")
|
|
25
35
|
.option("-p, --print", "Print transformed files")
|
|
26
36
|
.option("-f, --force", "Forcibly run migrations without checking git-changes")
|
|
27
37
|
.addHelpText("after", `\nExample:
|
|
28
|
-
$ npx @navikt/aksel --dry-run v2-css
|
|
29
|
-
|
|
38
|
+
$ npx @navikt/aksel codemod --dry-run v2-css
|
|
39
|
+
$ npx @navikt/aksel codemod v8 # Interactive selection for version`)
|
|
40
|
+
.action((str, options) => __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
/* Check if the argument is a version key for interactive selection */
|
|
42
|
+
if (/^v\d+$/.test(str)) {
|
|
43
|
+
(0, run_version_migration_js_1.validateVersion)(str, program);
|
|
44
|
+
yield (0, run_version_migration_js_1.runVersionMigration)(str, options, program, overrideHandler);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
/* Otherwise, treat it as a specific migration name */
|
|
30
48
|
(0, validation_js_1.validateMigration)(str, program);
|
|
31
49
|
(0, validation_js_1.validateGit)(options, program);
|
|
32
50
|
(0, run_codeshift_js_1.runCodeshift)(str, options, program);
|
|
33
|
-
});
|
|
51
|
+
}));
|
|
34
52
|
program.parse();
|
|
35
53
|
}
|
|
@@ -8,6 +8,9 @@ exports.getMigrationPath = getMigrationPath;
|
|
|
8
8
|
exports.getWarning = getWarning;
|
|
9
9
|
exports.getIgnoredFileExtensions = getIgnoredFileExtensions;
|
|
10
10
|
exports.getMigrationNames = getMigrationNames;
|
|
11
|
+
exports.getVersionKeys = getVersionKeys;
|
|
12
|
+
exports.getMigrationsForVersion = getMigrationsForVersion;
|
|
13
|
+
exports.getOverridesForVersion = getOverridesForVersion;
|
|
11
14
|
exports.getMigrationString = getMigrationString;
|
|
12
15
|
const chalk_1 = __importDefault(require("chalk"));
|
|
13
16
|
const JS_EXTENSIONS = [
|
|
@@ -22,7 +25,7 @@ const CSS_EXTENSIONS = [
|
|
|
22
25
|
"less",
|
|
23
26
|
];
|
|
24
27
|
exports.migrations = {
|
|
25
|
-
|
|
28
|
+
v1: [
|
|
26
29
|
{
|
|
27
30
|
description: "Runs all codemods for beta -> v1 migration",
|
|
28
31
|
value: "v1-preset",
|
|
@@ -48,7 +51,7 @@ exports.migrations = {
|
|
|
48
51
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
49
52
|
},
|
|
50
53
|
],
|
|
51
|
-
|
|
54
|
+
v2: [
|
|
52
55
|
{
|
|
53
56
|
description: "Patches changed css-variables",
|
|
54
57
|
value: "v2-css",
|
|
@@ -74,7 +77,7 @@ exports.migrations = {
|
|
|
74
77
|
ignoredExtensions: JS_EXTENSIONS,
|
|
75
78
|
},
|
|
76
79
|
],
|
|
77
|
-
|
|
80
|
+
v3: [
|
|
78
81
|
{
|
|
79
82
|
description: "Replaces deprecated <CopyToClipboard /> with <CopyButton />",
|
|
80
83
|
value: "v3-copybutton",
|
|
@@ -83,7 +86,7 @@ exports.migrations = {
|
|
|
83
86
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
84
87
|
},
|
|
85
88
|
],
|
|
86
|
-
|
|
89
|
+
v4: [
|
|
87
90
|
{
|
|
88
91
|
description: "Replaced deprecated 'internal'-component import to 'core'-imports",
|
|
89
92
|
value: "v4-internal-react",
|
|
@@ -105,7 +108,7 @@ exports.migrations = {
|
|
|
105
108
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
106
109
|
},
|
|
107
110
|
],
|
|
108
|
-
|
|
111
|
+
v6: [
|
|
109
112
|
{
|
|
110
113
|
description: "Removes `backgroundColor` and `avatarBgColor` properties from `Chat` and `Chat.Bubble`",
|
|
111
114
|
value: "v6-chat",
|
|
@@ -114,7 +117,7 @@ exports.migrations = {
|
|
|
114
117
|
ignoredExtensions: CSS_EXTENSIONS,
|
|
115
118
|
},
|
|
116
119
|
],
|
|
117
|
-
|
|
120
|
+
v8: [
|
|
118
121
|
{
|
|
119
122
|
description: "Updates Box with legacy-tokens to Box using the new token system, and renames already migrated BoxNew/Box.New instances to Box.",
|
|
120
123
|
value: "v8-box",
|
|
@@ -216,6 +219,26 @@ function getMigrationNames() {
|
|
|
216
219
|
.flat()
|
|
217
220
|
.map((x) => x.value);
|
|
218
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* Returns all available version keys from the migrations object.
|
|
224
|
+
*/
|
|
225
|
+
function getVersionKeys() {
|
|
226
|
+
return Object.keys(exports.migrations);
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Returns the migrations available for a specific version.
|
|
230
|
+
*/
|
|
231
|
+
function getMigrationsForVersion(version) {
|
|
232
|
+
var _a;
|
|
233
|
+
return (_a = exports.migrations[version]) !== null && _a !== void 0 ? _a : [];
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Returns the override migrations available for a specific version.
|
|
237
|
+
*/
|
|
238
|
+
function getOverridesForVersion(version) {
|
|
239
|
+
var _a;
|
|
240
|
+
return (_a = exports.migrationStringOverride[version]) !== null && _a !== void 0 ? _a : [];
|
|
241
|
+
}
|
|
219
242
|
/**
|
|
220
243
|
* Allows injecting additional migration names that are not part of the main migrations-list.
|
|
221
244
|
* This is used for interactive migrations that should not be part of the main list.
|
|
@@ -224,7 +247,7 @@ function getMigrationNames() {
|
|
|
224
247
|
* which is not the case for interactive migrations that are handled differently.
|
|
225
248
|
*/
|
|
226
249
|
exports.migrationStringOverride = {
|
|
227
|
-
|
|
250
|
+
v8: [
|
|
228
251
|
{
|
|
229
252
|
value: "v8-tokens",
|
|
230
253
|
description: "Starts interactive token migration for v8",
|
|
@@ -243,5 +266,8 @@ function getMigrationString() {
|
|
|
243
266
|
str += `${chalk_1.default.blue(migration.value)}: ${migration.description}\n`;
|
|
244
267
|
});
|
|
245
268
|
});
|
|
269
|
+
str += `\n${chalk_1.default.bold(chalk_1.default.blueBright("Interactive version selection:"))}\n`;
|
|
270
|
+
str += chalk_1.default.gray("Run with a version key to interactively select migrations:\n");
|
|
271
|
+
str += chalk_1.default.blue(getVersionKeys().join(", "));
|
|
246
272
|
return str;
|
|
247
273
|
}
|
|
@@ -63,7 +63,6 @@ function runCodeshift(input, options, program) {
|
|
|
63
63
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
64
|
var _a;
|
|
65
65
|
const codemodPath = node_path_1.default.join(__dirname, `./transforms/${(0, migrations_1.getMigrationPath)(input)}.js`);
|
|
66
|
-
console.info(chalk_1.default.greenBright.bold("\nWelcome to Aksel codemods!"));
|
|
67
66
|
console.info("\nRunning migration:", chalk_1.default.green(input));
|
|
68
67
|
const globList = (_a = options.glob) !== null && _a !== void 0 ? _a : (0, codeshift_utils_1.getDefaultGlob)(options === null || options === void 0 ? void 0 : options.ext);
|
|
69
68
|
console.info(chalk_1.default.gray(`Using glob pattern(s): ${globList}\nWorking directory: ${process.cwd()}\n`));
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.runVersionMigration = runVersionMigration;
|
|
16
|
+
exports.validateVersion = validateVersion;
|
|
17
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
18
|
+
const enquirer_1 = __importDefault(require("enquirer"));
|
|
19
|
+
const migrations_js_1 = require("./migrations.js");
|
|
20
|
+
const run_codeshift_js_1 = require("./run-codeshift.js");
|
|
21
|
+
const validation_js_1 = require("./validation.js");
|
|
22
|
+
/**
|
|
23
|
+
* Validates that the provided version key exists in the migrations object.
|
|
24
|
+
*/
|
|
25
|
+
function validateVersion(version, program) {
|
|
26
|
+
const versionKeys = (0, migrations_js_1.getVersionKeys)();
|
|
27
|
+
if (!versionKeys.includes(version)) {
|
|
28
|
+
program.error(chalk_1.default.red(`Version <${version}> not found!\n${chalk_1.default.gray(`\nAvailable versions:\n${versionKeys.map((v) => ` ${v}`).join("\n")}`)}`));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Runs interactive migration selection for a specific version.
|
|
33
|
+
*/
|
|
34
|
+
function runVersionMigration(version, options, program,
|
|
35
|
+
/**
|
|
36
|
+
* Handler for override migrations that need special handling (e.g., v8-tokens).
|
|
37
|
+
* If provided and an override migration is selected, this will be called instead of runCodeshift.
|
|
38
|
+
*/
|
|
39
|
+
overrideHandler) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
const availableMigrations = (0, migrations_js_1.getMigrationsForVersion)(version);
|
|
42
|
+
const overrideMigrations = (0, migrations_js_1.getOverridesForVersion)(version);
|
|
43
|
+
if (availableMigrations.length === 0 && overrideMigrations.length === 0) {
|
|
44
|
+
program.error(chalk_1.default.red(`No migrations found for version ${version}`));
|
|
45
|
+
}
|
|
46
|
+
console.info(chalk_1.default.greenBright.bold(`\nAvailable migrations for ${version}:\n`));
|
|
47
|
+
const overrideValues = new Set(overrideMigrations.map((m) => m.value));
|
|
48
|
+
const choices = [
|
|
49
|
+
...overrideMigrations.map((migration) => ({
|
|
50
|
+
name: migration.value,
|
|
51
|
+
message: `${chalk_1.default.blue(migration.value)}: ${chalk_1.default.gray(migration.description)}`,
|
|
52
|
+
value: migration.value,
|
|
53
|
+
})),
|
|
54
|
+
...availableMigrations.map((migration) => ({
|
|
55
|
+
name: migration.value,
|
|
56
|
+
message: `${chalk_1.default.blue(migration.value)}: ${chalk_1.default.gray(migration.description)}`,
|
|
57
|
+
value: migration.value,
|
|
58
|
+
})),
|
|
59
|
+
];
|
|
60
|
+
const response = yield enquirer_1.default.prompt({
|
|
61
|
+
type: "multiselect",
|
|
62
|
+
name: "selectedMigrations",
|
|
63
|
+
message: `Select migrations to run for ${version}`,
|
|
64
|
+
choices,
|
|
65
|
+
});
|
|
66
|
+
const { selectedMigrations } = response;
|
|
67
|
+
if (selectedMigrations.length === 0) {
|
|
68
|
+
console.info(chalk_1.default.yellow("\nNo migrations selected. Exiting."));
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
console.info(chalk_1.default.gray(`\nRunning ${selectedMigrations.length} migration(s): ${selectedMigrations.join(", ")}\n`));
|
|
72
|
+
(0, validation_js_1.validateGit)(options, program);
|
|
73
|
+
for (const migration of selectedMigrations) {
|
|
74
|
+
console.info(chalk_1.default.blue(`\n\n--- Running: ${migration} ---`));
|
|
75
|
+
/* Check if this is an override migration that needs special handling */
|
|
76
|
+
if (overrideValues.has(migration) && overrideHandler) {
|
|
77
|
+
yield overrideHandler(migration);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
yield (0, run_codeshift_js_1.runCodeshift)(migration, options, program);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
console.info(chalk_1.default.greenBright.bold("\nAll selected migrations completed!"));
|
|
84
|
+
});
|
|
85
|
+
}
|
package/dist/darkside/index.js
CHANGED
|
@@ -9,6 +9,7 @@ const commander_1 = require("commander");
|
|
|
9
9
|
const run_tooling_js_1 = require("./run-tooling.js");
|
|
10
10
|
const program = new commander_1.Command();
|
|
11
11
|
function darksideCommand() {
|
|
12
|
+
program.allowExcessArguments();
|
|
12
13
|
program.name(`${chalk_1.default.blueBright(`npx @navikt/aksel v8-tokens`)}`);
|
|
13
14
|
program
|
|
14
15
|
.option("-g, --glob [glob]", "Globbing pattern, overrides --ext! Run with 'noglob' if using zsh-terminal. ")
|
package/dist/index.js
CHANGED
|
@@ -22,9 +22,12 @@ const version_1 = require("./version");
|
|
|
22
22
|
run();
|
|
23
23
|
function run() {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
-
|
|
25
|
+
let program = new commander_1.Command();
|
|
26
26
|
program.version(version_1.VERSION, "-v, --version");
|
|
27
|
-
program
|
|
27
|
+
program = program
|
|
28
|
+
.allowUnknownOption()
|
|
29
|
+
.allowExcessArguments()
|
|
30
|
+
.helpOption(false);
|
|
28
31
|
program.parse();
|
|
29
32
|
const args = program.args;
|
|
30
33
|
if (args.length === 0 || args[0] === "help") {
|
|
@@ -36,7 +39,11 @@ function run() {
|
|
|
36
39
|
(0, darkside_1.darksideCommand)();
|
|
37
40
|
return;
|
|
38
41
|
}
|
|
39
|
-
(0, index_1.codemodCommand)()
|
|
42
|
+
(0, index_1.codemodCommand)((migration) => {
|
|
43
|
+
if (migration === "v8-tokens") {
|
|
44
|
+
(0, darkside_1.darksideCommand)();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
40
47
|
return;
|
|
41
48
|
}
|
|
42
49
|
console.info(chalk_1.default.red(`Unknown command: ${args[0]}.\nRun ${chalk_1.default.cyan("npx @navikt/aksel help")} for all available commands.`));
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/aksel",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.39.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,12 +33,12 @@
|
|
|
33
33
|
"url": "https://github.com/navikt/aksel/issues"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@navikt/ds-css": "^7.
|
|
37
|
-
"@navikt/ds-tokens": "^7.
|
|
36
|
+
"@navikt/ds-css": "^7.39.0",
|
|
37
|
+
"@navikt/ds-tokens": "^7.39.0",
|
|
38
38
|
"chalk": "5.6.2",
|
|
39
39
|
"cli-progress": "3.12.0",
|
|
40
40
|
"clipboardy": "5.0.1",
|
|
41
|
-
"commander": "
|
|
41
|
+
"commander": "14.0.2",
|
|
42
42
|
"enquirer": "2.4.1",
|
|
43
43
|
"fast-glob": "3.2.11",
|
|
44
44
|
"figlet": "1.8.0",
|