@navikt/aksel 7.34.0 → 7.35.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/README.md +96 -2
- package/dist/codemod/migrations.js +75 -22
- package/dist/codemod/transforms/v8.0.0/accordion-variant/accordion-variant.js +16 -0
- package/dist/codemod/transforms/{darkside/box-to-boxnew/box-to-boxnew.js → v8.0.0/box/box.js} +31 -99
- package/dist/codemod/transforms/v8.0.0/box-new/box-new.js +91 -0
- package/dist/codemod/transforms/v8.0.0/chips-variant/chips-variant.js +31 -0
- package/dist/codemod/transforms/v8.0.0/list/list.js +218 -0
- package/dist/codemod/transforms/{darkside → v8.0.0}/prop-deprecate/prop-deprecate.js +1 -1
- package/dist/codemod/transforms/v8.0.0/tag-variant/tag-variant.js +38 -0
- package/dist/codemod/transforms/v8.0.0/toggle-group-variant/toggle-group-variant.js +16 -0
- package/dist/codemod/utils/check.js +35 -0
- package/dist/codemod/utils/move-variant-to-data-color.js +120 -0
- package/dist/help.js +0 -10
- package/dist/index.js +5 -7
- package/package.json +4 -5
- package/dist/css-imports/config.js +0 -5
- package/dist/css-imports/generate-output.js +0 -147
- package/dist/css-imports/get-directories.js +0 -34
- package/dist/css-imports/get-version.js +0 -28
- package/dist/css-imports/index.js +0 -187
- package/dist/css-imports/inquiry.js +0 -35
- package/dist/css-imports/scan-code.js +0 -45
- /package/dist/codemod/transforms/{spacing → v8.0.0}/primitives-spacing/spacing.js +0 -0
- /package/dist/codemod/transforms/{spacing → v8.0.0}/spacing.utils.js +0 -0
- /package/dist/codemod/transforms/{spacing → v8.0.0}/token-spacing/spacing.js +0 -0
- /package/dist/codemod/transforms/{spacing → v8.0.0}/token-spacing-js/spacing.js +0 -0
|
@@ -1,147 +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.generateImportOutput = generateImportOutput;
|
|
16
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
17
|
-
const clipboardy_1 = __importDefault(require("clipboardy"));
|
|
18
|
-
const lodash_1 = __importDefault(require("lodash"));
|
|
19
|
-
const _mappings_1 = require("@navikt/ds-css/config/_mappings");
|
|
20
|
-
const config_js_1 = require("./config.js");
|
|
21
|
-
const inquiry_1 = require("./inquiry");
|
|
22
|
-
function generateImportOutput(answers) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
const useCdn = answers.cdn === "yes";
|
|
25
|
-
const useTailwind = answers.tailwind === "yes";
|
|
26
|
-
const version = answers.version;
|
|
27
|
-
const imports = [];
|
|
28
|
-
let importStr = "";
|
|
29
|
-
yield (0, inquiry_1.inquiry)(answers, [
|
|
30
|
-
{
|
|
31
|
-
type: "select",
|
|
32
|
-
name: "output",
|
|
33
|
-
message: "Output format",
|
|
34
|
-
initial: "print-clipboard",
|
|
35
|
-
choices: [
|
|
36
|
-
{ message: "Clipboard & Print", name: "clipboard-print" },
|
|
37
|
-
{ message: "Clipboard", name: "clipboard" },
|
|
38
|
-
{ message: "Print", name: "print" },
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
]);
|
|
42
|
-
answers["config-type"] === "regular"
|
|
43
|
-
? imports.push(simpleOutput(useCdn, answers.layers === "yes", version))
|
|
44
|
-
: imports.push(...advancedOutput(answers, useCdn, answers.layers === "yes", version));
|
|
45
|
-
if (useTailwind) {
|
|
46
|
-
importStr = `@import "tailwindcss/base";
|
|
47
|
-
${imports.join("\n")}
|
|
48
|
-
|
|
49
|
-
@import "tailwindcss/components";
|
|
50
|
-
@import "tailwindcss/utilities";
|
|
51
|
-
`;
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
importStr = imports.join("\n");
|
|
55
|
-
}
|
|
56
|
-
if (answers.output.includes("print")) {
|
|
57
|
-
console.info(chalk_1.default.bold.cyan(`\nImports 🚀 \n`));
|
|
58
|
-
console.info(chalk_1.default.green(`${importStr}`));
|
|
59
|
-
}
|
|
60
|
-
if (useCdn) {
|
|
61
|
-
console.info(chalk_1.default.bold.underline.cyan(`\nNotes on CDN-usage 📝`));
|
|
62
|
-
console.info(`We recommend using Static imports, then uploading the your bundled static-files to your own CDN-instance.
|
|
63
|
-
✔︎ This allows you to control the version of the CSS-files with package.json, and avoids desync between ds-react/ds-css.
|
|
64
|
-
✔︎ Remember to add 'https://cdn.nav.no' to your applications CSP!`);
|
|
65
|
-
}
|
|
66
|
-
if (useTailwind) {
|
|
67
|
-
console.info(chalk_1.default.bold.underline.cyan(`\nNotes on Tailwind-use 📝`));
|
|
68
|
-
console.info(`When using tailwind with Aksel, you will need to add the postcss plugin ${chalk_1.default.cyan("postcss-import")}
|
|
69
|
-
✔︎ NPM: https://www.npmjs.com/package/postcss-import
|
|
70
|
-
✔︎ Read more here: https://aksel.nav.no/grunnleggende/kode/tailwind`);
|
|
71
|
-
}
|
|
72
|
-
if (answers.layers === "yes") {
|
|
73
|
-
console.info(chalk_1.default.bold.underline.cyan(`\nNotes on Layers 📝`));
|
|
74
|
-
console.info(`Layers is not yet supported in Safari <= 15.3. (https://caniuse.com/css-cascade-layers)`);
|
|
75
|
-
}
|
|
76
|
-
answers.output.includes("clipboard") && clipboardy_1.default.writeSync(importStr);
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function simpleOutput(cdn, layers, version) {
|
|
80
|
-
const options = {
|
|
81
|
-
static: `@import "@navikt/ds-css"${layers ? config_js_1.layerSuffix : ""};`,
|
|
82
|
-
cdn: toCdn("index.css", version),
|
|
83
|
-
};
|
|
84
|
-
return cdn ? options.cdn : options.static;
|
|
85
|
-
}
|
|
86
|
-
function advancedOutput(answers, cdn, layers, version) {
|
|
87
|
-
const imports = ["/* Defaults */"];
|
|
88
|
-
const baselineImports = answers.imports.filter((x) => !x.startsWith(config_js_1.ComponentPrefix) && x !== "default");
|
|
89
|
-
const componentImports = answers.imports
|
|
90
|
-
.filter((x) => x.startsWith(config_js_1.ComponentPrefix) && x !== "components")
|
|
91
|
-
.map((x) => x.replace(config_js_1.ComponentPrefix, ""));
|
|
92
|
-
baselineImports.forEach((x) => {
|
|
93
|
-
cdn
|
|
94
|
-
? imports.push(toCdn(`${_mappings_1.globalDir}/${x}.css`, version))
|
|
95
|
-
: imports.push(toCssImport(`${_mappings_1.globalDir}/${x}.css`, layers));
|
|
96
|
-
});
|
|
97
|
-
if (answers["config-type"] === "easy") {
|
|
98
|
-
cdn
|
|
99
|
-
? imports.push(toCdn(_mappings_1.componentsCss, version))
|
|
100
|
-
: imports.push(toCssImport(`${_mappings_1.rootDir}/${_mappings_1.componentsCss}`, layers));
|
|
101
|
-
return imports;
|
|
102
|
-
}
|
|
103
|
-
const components = new Set();
|
|
104
|
-
componentImports.forEach((x) => {
|
|
105
|
-
var _a;
|
|
106
|
-
const styleRef = _mappings_1.StyleMappings.components.find((y) => y.component === x);
|
|
107
|
-
if (styleRef) {
|
|
108
|
-
components.add(styleRef.main);
|
|
109
|
-
(_a = styleRef === null || styleRef === void 0 ? void 0 : styleRef.dependencies) === null || _a === void 0 ? void 0 : _a.forEach((dep) => components.add(dep));
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
let componentImportsList = Array.from(components)
|
|
113
|
-
.filter((x) => x.length > 0)
|
|
114
|
-
.sort((a, b) => a.localeCompare(b));
|
|
115
|
-
if (componentImportsList.find((x) => x === _mappings_1.formCss)) {
|
|
116
|
-
componentImportsList = componentImportsList.filter((x) => x !== _mappings_1.formCss);
|
|
117
|
-
componentImportsList.unshift(_mappings_1.formCss);
|
|
118
|
-
}
|
|
119
|
-
if (componentImportsList.find((x) => x === _mappings_1.primitivesCss)) {
|
|
120
|
-
componentImportsList = componentImportsList.filter((x) => x !== _mappings_1.primitivesCss);
|
|
121
|
-
componentImportsList.unshift(_mappings_1.primitivesCss);
|
|
122
|
-
}
|
|
123
|
-
if (componentImportsList.find((x) => x === _mappings_1.typoCss)) {
|
|
124
|
-
componentImportsList = componentImportsList.filter((x) => x !== _mappings_1.typoCss);
|
|
125
|
-
componentImportsList.unshift(_mappings_1.typoCss);
|
|
126
|
-
}
|
|
127
|
-
if (componentImportsList.length === 0) {
|
|
128
|
-
return imports;
|
|
129
|
-
}
|
|
130
|
-
imports.push(``);
|
|
131
|
-
imports.push(`/* Components */`);
|
|
132
|
-
componentImportsList.forEach((x) => {
|
|
133
|
-
const pascalCase = lodash_1.default.camelCase(x.replace("css", "")).toLowerCase();
|
|
134
|
-
cdn
|
|
135
|
-
? imports.push(toCdn(`${_mappings_1.componentDir}/${pascalCase}.css`, version))
|
|
136
|
-
: imports.push(toCssImport(`${_mappings_1.componentDir}/${pascalCase}.css`, layers));
|
|
137
|
-
});
|
|
138
|
-
return imports;
|
|
139
|
-
}
|
|
140
|
-
function toCdn(str, version) {
|
|
141
|
-
return `<link rel="preload" href="https://cdn.nav.no/aksel/@navikt/ds-css/${version}/${str
|
|
142
|
-
.replace(".css", ".min.css")
|
|
143
|
-
.replace(`${_mappings_1.rootDir}/`, "")}" as="style"></link>`;
|
|
144
|
-
}
|
|
145
|
-
function toCssImport(str, layers) {
|
|
146
|
-
return `@import "@navikt/ds-css/${str}"${layers ? config_js_1.layerSuffix : ""};`;
|
|
147
|
-
}
|
|
@@ -1,34 +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.getDirectories = getDirectories;
|
|
16
|
-
const fast_glob_1 = __importDefault(require("fast-glob"));
|
|
17
|
-
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
-
function getDirectories() {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const baseDir = process.cwd();
|
|
21
|
-
const ignoreNodeModules = [
|
|
22
|
-
"**/node_modules/**",
|
|
23
|
-
"**/dist/**",
|
|
24
|
-
"**/build/**",
|
|
25
|
-
"**/lib/**",
|
|
26
|
-
];
|
|
27
|
-
const directories = yield (0, fast_glob_1.default)(`${baseDir}/**`, {
|
|
28
|
-
onlyDirectories: true,
|
|
29
|
-
ignore: ignoreNodeModules,
|
|
30
|
-
});
|
|
31
|
-
directories.sort((a, b) => a.length - b.length);
|
|
32
|
-
return [baseDir, ...directories].map((x) => x.replace(baseDir, node_path_1.default.basename(baseDir)));
|
|
33
|
-
});
|
|
34
|
-
}
|
|
@@ -1,28 +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.getAllVersions = getAllVersions;
|
|
16
|
-
const axios_1 = __importDefault(require("axios"));
|
|
17
|
-
function getAllVersions() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
try {
|
|
20
|
-
const npmPackageData = yield axios_1.default.get(`https://registry.npmjs.org/@navikt/ds-css`);
|
|
21
|
-
return Object.keys(npmPackageData.data.versions);
|
|
22
|
-
}
|
|
23
|
-
catch (e) {
|
|
24
|
-
console.error(e);
|
|
25
|
-
return [];
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
}
|
|
@@ -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
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|