@navikt/aksel 8.2.0 → 8.2.2

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/README.md CHANGED
@@ -23,6 +23,20 @@ npx @navikt/aksel codemod --help
23
23
 
24
24
  ### v8
25
25
 
26
+ #### Tokens
27
+
28
+ `npx @navikt/aksel codemod v8-tokens ...`
29
+
30
+ Starts interactive token migration.
31
+
32
+ ```diff
33
+ -margin: var(--a-spacing-1);
34
+ +margin: var(--ax-space-4);
35
+
36
+ -background-color: var(--a-surface-subtle);
37
+ +background-color: var(--ax-bg-neutral-soft);
38
+ ```
39
+
26
40
  #### Box
27
41
 
28
42
  `npx @navikt/aksel codemod v8-box ...`
@@ -84,24 +98,17 @@ Updates variant + data-color props based on current variant prop.
84
98
  +<Tag variant="outline" data-color="info">
85
99
  ```
86
100
 
87
- #### Spacing
101
+ #### Spacing on primitives
88
102
 
89
103
  `npx @navikt/aksel codemod v8-primitive-spacing ...`
90
- `npx @navikt/aksel codemod v8-token-spacing ...`
91
- `npx @navikt/aksel codemod v8-token-spacing-js ...`
92
104
 
93
- Updates use of legacy `spacing` token to new `space`-token
105
+ Updates all primitives to new `space`-tokens.
94
106
 
95
107
  ```diff
96
- -<HStack gap="spacing-4" />
108
+ -<HStack gap="4" />
97
109
  +<HStack gap="space-16" />
98
110
  ```
99
111
 
100
- ```diff
101
- -margin: var(--a-spacing-1);
102
- +margin: var(--ax-space-4);
103
- ```
104
-
105
112
  ### v6
106
113
 
107
114
  #### Chat
@@ -144,23 +144,11 @@ exports.migrations = {
144
144
  ignoredExtensions: CSS_EXTENSIONS,
145
145
  },
146
146
  {
147
- description: "Updates all Primitives to use new `space`-tokens. (Works with old and new system)",
147
+ description: "Updates all Primitives to use new `space`-tokens.",
148
148
  value: "v8-primitive-spacing",
149
149
  path: "v8.0.0/primitives-spacing/spacing",
150
150
  ignoredExtensions: CSS_EXTENSIONS,
151
151
  },
152
- {
153
- description: "Updates css, scss and less-variables to use new `space`-tokens. (Works with old and new system)",
154
- value: "v8-token-spacing",
155
- path: "v8.0.0/token-spacing/spacing",
156
- ignoredExtensions: [],
157
- },
158
- {
159
- description: "Updates js-tokens to use new `space`-tokens. (Works with old and new system)",
160
- value: "v8-token-spacing-js",
161
- path: "v8.0.0/token-spacing-js/spacing",
162
- ignoredExtensions: CSS_EXTENSIONS,
163
- },
164
152
  {
165
153
  description: "Updates variant + data-color props on Tag based on current variant prop.",
166
154
  value: "v8-tag-variant",
@@ -68,6 +68,11 @@ overrideHandler) {
68
68
  console.info(chalk_1.default.yellow("\nNo migrations selected. Exiting."));
69
69
  return;
70
70
  }
71
+ // Hack: 'v8-tokens' needs to run last because it's interactive
72
+ if (selectedMigrations.includes("v8-tokens")) {
73
+ selectedMigrations.splice(selectedMigrations.indexOf("v8-tokens"), 1);
74
+ selectedMigrations.push("v8-tokens");
75
+ }
71
76
  console.info(chalk_1.default.gray(`\nRunning ${selectedMigrations.length} migration(s): ${selectedMigrations.join(", ")}\n`));
72
77
  (0, validation_js_1.validateGit)(options, program);
73
78
  for (const migration of selectedMigrations) {
@@ -280,7 +280,7 @@ function getNextTask(status) {
280
280
  message: getMessage("Migrate tailwind tokens", (_k = (_j = status === null || status === void 0 ? void 0 : status.tailwind) === null || _j === void 0 ? void 0 : _j.legacy) !== null && _k !== void 0 ? _k : []),
281
281
  name: "tailwind-tokens",
282
282
  },
283
- { message: "Run all migrations", name: "run-all-migrations" },
283
+ { message: "Run all token migrations", name: "run-all-migrations" },
284
284
  { message: "Exit", name: "exit" },
285
285
  ];
286
286
  try {
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "8.2.0";
4
+ exports.VERSION = "8.2.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navikt/aksel",
3
- "version": "8.2.0",
3
+ "version": "8.2.2",
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,8 +33,8 @@
33
33
  "url": "https://github.com/navikt/aksel/issues"
34
34
  },
35
35
  "dependencies": {
36
- "@navikt/ds-css": "^8.2.0",
37
- "@navikt/ds-tokens": "^8.2.0",
36
+ "@navikt/ds-css": "^8.2.2",
37
+ "@navikt/ds-tokens": "^8.2.2",
38
38
  "chalk": "5.6.2",
39
39
  "cli-progress": "3.12.0",
40
40
  "clipboardy": "5.0.1",
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = transformer;
4
- const translate_token_1 = require("../../../utils/translate-token");
5
- const spacing_utils_1 = require("../spacing.utils");
6
- function transformer(file) {
7
- let src = file.source;
8
- spacing_utils_1.legacySpacingTokenMap.forEach((newVar, oldVar) => {
9
- const oldCSSVar = `--a-spacing-${oldVar}`;
10
- const newCSSVar = `--a-space-${newVar}`;
11
- const CSSRgx = new RegExp("(" + oldCSSVar + ")", "gm");
12
- const SCSSRgx = new RegExp("(\\" + (0, translate_token_1.translateToken)(oldCSSVar, "scss") + ")", "gm");
13
- const LESSRgx = new RegExp("(" + (0, translate_token_1.translateToken)(oldCSSVar, "less") + ")", "gm");
14
- src = src.replace(CSSRgx, newCSSVar);
15
- src = src.replace(SCSSRgx, (0, translate_token_1.translateToken)(newCSSVar, "scss"));
16
- src = src.replace(LESSRgx, (0, translate_token_1.translateToken)(newCSSVar, "less"));
17
- });
18
- return src;
19
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = transformer;
4
- const ast_1 = require("../../../utils/ast");
5
- const lineterminator_1 = require("../../../utils/lineterminator");
6
- const translate_token_1 = require("../../../utils/translate-token");
7
- const spacing_utils_1 = require("../spacing.utils");
8
- function transformer(file, api) {
9
- const j = api.jscodeshift;
10
- let root = j(file.source);
11
- spacing_utils_1.legacySpacingTokenMap.forEach((newVar, oldVar) => {
12
- const oldCSSVar = (0, translate_token_1.translateToken)(`--a-spacing-${oldVar}`, "js");
13
- const newCSSVar = (0, translate_token_1.translateToken)(`--a-space-${newVar}`, "js");
14
- const name = (0, ast_1.findComponentImport)({
15
- root,
16
- j,
17
- name: oldCSSVar,
18
- packageType: "tokens",
19
- });
20
- if (!name) {
21
- return;
22
- }
23
- let code = root.toSource((0, lineterminator_1.getLineTerminator)(file.source));
24
- const rgx = new RegExp("(" + oldCSSVar + ")", "gm");
25
- code = code.replace(rgx, newCSSVar);
26
- root = j(code);
27
- });
28
- return root.toSource((0, lineterminator_1.getLineTerminator)(file.source));
29
- }