@navikt/aksel 7.34.0 → 7.35.1

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.
Files changed (35) hide show
  1. package/README.md +96 -2
  2. package/dist/codemod/codeshift.utils.js +9 -1
  3. package/dist/codemod/migrations.js +75 -22
  4. package/dist/codemod/run-codeshift.js +14 -3
  5. package/dist/codemod/transforms/v8.0.0/accordion-variant/accordion-variant.js +16 -0
  6. package/dist/codemod/transforms/{darkside/box-to-boxnew/box-to-boxnew.js → v8.0.0/box/box.js} +80 -100
  7. package/dist/codemod/transforms/v8.0.0/box-new/box-new.js +91 -0
  8. package/dist/codemod/transforms/v8.0.0/chips-variant/chips-variant.js +31 -0
  9. package/dist/codemod/transforms/v8.0.0/list/list.js +218 -0
  10. package/dist/codemod/transforms/{darkside → v8.0.0}/prop-deprecate/prop-deprecate.js +1 -1
  11. package/dist/codemod/transforms/v8.0.0/tag-variant/tag-variant.js +38 -0
  12. package/dist/codemod/transforms/v8.0.0/toggle-group-variant/toggle-group-variant.js +16 -0
  13. package/dist/codemod/utils/ast.js +1 -1
  14. package/dist/codemod/utils/check.js +35 -0
  15. package/dist/codemod/utils/move-variant-to-data-color.js +120 -0
  16. package/dist/darkside/index.js +3 -9
  17. package/dist/darkside/run-tooling.js +138 -42
  18. package/dist/darkside/tasks/print-remaining.js +143 -38
  19. package/dist/darkside/tasks/status.js +147 -30
  20. package/dist/darkside/transforms/darkside-tokens-css.js +23 -8
  21. package/dist/darkside/transforms/darkside-tokens-tailwind.js +9 -10
  22. package/dist/help.js +0 -10
  23. package/dist/index.js +14 -17
  24. package/package.json +7 -7
  25. package/dist/css-imports/config.js +0 -5
  26. package/dist/css-imports/generate-output.js +0 -147
  27. package/dist/css-imports/get-directories.js +0 -34
  28. package/dist/css-imports/get-version.js +0 -28
  29. package/dist/css-imports/index.js +0 -187
  30. package/dist/css-imports/inquiry.js +0 -35
  31. package/dist/css-imports/scan-code.js +0 -45
  32. /package/dist/codemod/transforms/{spacing → v8.0.0}/primitives-spacing/spacing.js +0 -0
  33. /package/dist/codemod/transforms/{spacing → v8.0.0}/spacing.utils.js +0 -0
  34. /package/dist/codemod/transforms/{spacing → v8.0.0}/token-spacing/spacing.js +0 -0
  35. /package/dist/codemod/transforms/{spacing → v8.0.0}/token-spacing-js/spacing.js +0 -0
@@ -1,187 +0,0 @@
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.cssImportsCommand = cssImportsCommand;
16
- const chalk_1 = __importDefault(require("chalk"));
17
- const child_process_1 = require("child_process");
18
- const _mappings_1 = require("@navikt/ds-css/config/_mappings");
19
- const config_1 = require("./config");
20
- const generate_output_1 = require("./generate-output");
21
- const get_directories_1 = require("./get-directories");
22
- const get_version_1 = require("./get-version");
23
- const inquiry_1 = require("./inquiry");
24
- function cssImportsCommand() {
25
- return __awaiter(this, void 0, void 0, function* () {
26
- const answers = {
27
- "config-type": "regular",
28
- cdn: "no",
29
- version: "0.0.0",
30
- autoscan: "no",
31
- scandir: "",
32
- tailwind: "no",
33
- layers: "no",
34
- imports: null,
35
- output: "print-clipboard",
36
- };
37
- yield (0, inquiry_1.inquiry)(answers, [
38
- {
39
- type: "select",
40
- name: "config-type",
41
- message: "Import variants:",
42
- initial: 0,
43
- choices: [
44
- { message: "Regular import (recommended)", name: "regular" },
45
- { message: "Partial control (global)", name: "easy" },
46
- { message: "Full control (global + components)", name: "advanced" },
47
- ],
48
- footer() {
49
- return chalk_1.default.grey(`${chalk_1.default.cyan(`\n Documentation:`)}\n Regular: https://aksel.nav.no/grunnleggende/kode/css-import
50
- Partial: https://aksel.nav.no/grunnleggende/kode/css-import#h64650b1a4ad6
51
- Full: https://aksel.nav.no/grunnleggende/kode/css-import#h4037598416ef\n`);
52
- },
53
- },
54
- {
55
- type: "select",
56
- name: "cdn",
57
- message: "Import format",
58
- initial: 0,
59
- choices: [
60
- { message: "Static import (default)", name: "no" },
61
- { message: "CDN import (not recommended)", name: "yes" },
62
- ],
63
- },
64
- ]);
65
- if ((answers === null || answers === void 0 ? void 0 : answers.cdn) === "no") {
66
- yield (0, inquiry_1.inquiry)(answers, [
67
- {
68
- type: "select",
69
- name: "tailwind",
70
- message: "Add tailwind support?",
71
- initial: 0,
72
- choices: [
73
- { message: "No", name: "no" },
74
- { message: "Yes", name: "yes" },
75
- ],
76
- },
77
- {
78
- type: "select",
79
- name: "layers",
80
- message: "Add styling to custom @layer rule?",
81
- initial: 0,
82
- choices: [
83
- { message: "No", name: "no" },
84
- { message: "Yes", name: "yes" },
85
- ],
86
- },
87
- ]);
88
- }
89
- else {
90
- let versions = (yield (0, get_version_1.getAllVersions)()).filter((x) => !x.includes("-"));
91
- const index = versions.findIndex((x) => x.startsWith("2.9.0"));
92
- versions = versions.slice(index).reverse();
93
- yield (0, inquiry_1.inquiry)(answers, [
94
- {
95
- type: "autocomplete",
96
- name: "version",
97
- message: `@navikt/ds-css version from CDN:`,
98
- limit: 6,
99
- initial: 0,
100
- choices: versions,
101
- footer() {
102
- return chalk_1.default.grey('Remember to match version with @navikt/ds-react!\nNote: CDN was introduced in v2.9.0, older versions not available.\nUse "static" import instead.');
103
- },
104
- },
105
- ]);
106
- }
107
- if (answers["config-type"] === "regular") {
108
- yield (0, generate_output_1.generateImportOutput)(answers);
109
- return;
110
- }
111
- answers["config-type"] === "advanced" &&
112
- (yield (0, inquiry_1.inquiry)(answers, [
113
- {
114
- type: "select",
115
- name: "autoscan",
116
- message: "Scan current directory for '@navikt/ds-react' components?",
117
- initial: 0,
118
- choices: [
119
- { message: "No", name: "no" },
120
- { message: "Yes", name: "yes" },
121
- ],
122
- },
123
- ]));
124
- answers.autoscan === "yes" &&
125
- (yield (0, inquiry_1.inquiry)(answers, [
126
- {
127
- type: "autocomplete",
128
- name: "scandir",
129
- message: `Directory to scan`,
130
- limit: 6,
131
- initial: 0,
132
- choices: (0, get_directories_1.getDirectories)(),
133
- footer() {
134
- return chalk_1.default.grey("filtered out: node_moduels, dist, build, lib, .* (dotfiles)");
135
- },
136
- },
137
- ]));
138
- let foundComponents = [];
139
- if (answers.autoscan === "yes") {
140
- foundComponents = yield new Promise((resolve) => {
141
- (0, child_process_1.exec)(`node ${__dirname}/scan-code.js ${answers.scandir}`, (_, stdout) => {
142
- resolve(stdout ? JSON.parse(stdout.trim().split("\n").slice(1).join("")) : []);
143
- });
144
- });
145
- }
146
- yield (0, inquiry_1.inquiry)(answers, [
147
- {
148
- type: "multiselect",
149
- name: "imports",
150
- message: "Imports",
151
- initial: [
152
- ..._mappings_1.StyleMappings.baseline.map((x) => x.main.replace(".css", "")),
153
- ..._mappings_1.StyleMappings.components
154
- .filter((x) => foundComponents.includes(x.component))
155
- .map((x) => `${config_1.ComponentPrefix}${x.component}`),
156
- ],
157
- choices: [
158
- {
159
- message: "Default-imports",
160
- name: "default",
161
- choices: [
162
- ..._mappings_1.StyleMappings.baseline.map((x) => ({
163
- message: `${x.main.replace(".css", "")}${x.optional ? "" : " (required)"}`,
164
- name: x.main.replace(".css", ""),
165
- })),
166
- ],
167
- },
168
- ...(answers["config-type"] === "advanced"
169
- ? [
170
- {
171
- message: "Components",
172
- name: "components",
173
- choices: [
174
- ..._mappings_1.StyleMappings.components.map((x) => ({
175
- message: x.component,
176
- name: `${config_1.ComponentPrefix}${x.component}`,
177
- })),
178
- ],
179
- },
180
- ]
181
- : []),
182
- ],
183
- },
184
- ]);
185
- yield (0, generate_output_1.generateImportOutput)(answers);
186
- });
187
- }
@@ -1,35 +0,0 @@
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.inquiry = inquiry;
16
- const chalk_1 = __importDefault(require("chalk"));
17
- const enquirer_1 = __importDefault(require("enquirer"));
18
- function inquiry(answers, questions) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- return yield enquirer_1.default.prompt(questions.map((x) => (Object.assign(Object.assign({}, x), { cancel: () => process.exit(1), header: `\n${chalk_1.default.gray("Command 'css-imports' will not edit your files directly!")}\n` }))))
21
- .then((a) => {
22
- Object.entries(a).forEach(([key, value]) => {
23
- answers[key] = value;
24
- });
25
- })
26
- .catch((error) => {
27
- if (error.isTtyError) {
28
- console.info("Oops, something went wrong! Looks like @navikt/aksel-cli can't run in this terminal. Contact Aksel");
29
- }
30
- else {
31
- console.error(error);
32
- }
33
- });
34
- });
35
- }
@@ -1,45 +0,0 @@
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
- const node_path_1 = __importDefault(require("node:path"));
16
- const react_scanner_1 = __importDefault(require("react-scanner"));
17
- run();
18
- function run() {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- yield scanCode();
21
- });
22
- }
23
- function scanCode() {
24
- return __awaiter(this, void 0, void 0, function* () {
25
- var _a;
26
- const cwd = process.cwd();
27
- const config = {
28
- rootDir: cwd,
29
- crawlFrom: `${(_a = process.argv[2]) !== null && _a !== void 0 ? _a : ""}`.replace(node_path_1.default.basename(cwd), "."),
30
- globs: ["**/!(*.test|*.spec|*.stories|*.story).@(jsx|tsx)"],
31
- exclude: (dirname) => dirname === "node_modules",
32
- getComponentName: ({ imported, moduleName, }) => imported || node_path_1.default.basename(moduleName),
33
- };
34
- let result = null;
35
- yield react_scanner_1.default
36
- .run(Object.assign(Object.assign({}, config), { importedFrom: /@navikt\/ds-react/, processors: [
37
- "count-components",
38
- ({ report }) => {
39
- result = report;
40
- },
41
- ] }))
42
- .catch(() => null);
43
- console.info(JSON.stringify(Object.keys(result)));
44
- });
45
- }