@digdir/designsystemet 1.0.6 → 1.0.8
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/configs/digdir.config.json +59 -0
- package/configs/test-tokens.config.json +45 -0
- package/dist/bin/config.d.ts +12 -0
- package/dist/bin/config.d.ts.map +1 -0
- package/dist/bin/config.js +516 -0
- package/dist/bin/designsystemet.js +3389 -3337
- package/dist/config.schema.json +39 -27
- package/dist/src/config.d.ts +46 -187
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +69 -36
- package/dist/src/index.js +60 -36
- package/dist/src/migrations/beta-to-v1.js +11 -4
- package/dist/src/migrations/codemods/css/run.js +11 -4
- package/dist/src/migrations/color-rename-next49.js +11 -4
- package/dist/src/migrations/index.js +11 -4
- package/dist/src/scripts/createJsonSchema.js +40 -1295
- package/dist/src/scripts/update-design-tokens.js +4 -4
- package/dist/src/scripts/update-template.js +16 -9
- package/dist/src/tokens/build.d.ts +1 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +72 -53
- package/dist/src/tokens/create/generators/$designsystemet.js +18 -18
- package/dist/src/tokens/create/write.js +29 -22
- package/dist/src/tokens/format.d.ts +1 -1
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +60 -36
- package/dist/src/tokens/index.js +60 -36
- package/dist/src/tokens/process/configs/color.js +12 -10
- package/dist/src/tokens/process/configs/semantic.js +11 -9
- package/dist/src/tokens/process/configs/storefront.js +11 -1
- package/dist/src/tokens/process/configs/typography.js +11 -9
- package/dist/src/tokens/process/configs.js +13 -26
- package/dist/src/tokens/process/formats/css/color.js +3 -1
- package/dist/src/tokens/process/formats/css.js +3 -1
- package/dist/src/tokens/process/formats/js-tokens.js +11 -1
- package/dist/src/tokens/process/platform.d.ts +3 -5
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +41 -14
- package/dist/src/tokens/process/theme.d.ts.map +1 -1
- package/dist/src/tokens/process/theme.js +18 -21
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +5 -4
- package/dist/src/tokens/types.d.ts +2 -2
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts +2 -2
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +11 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +10 -3
- package/package.json +18 -18
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/scripts/update-design-tokens.ts
|
|
2
|
-
import path from "
|
|
2
|
+
import path from "path";
|
|
3
3
|
|
|
4
4
|
// src/utils.ts
|
|
5
|
-
import fs from "
|
|
5
|
+
import fs from "fs/promises";
|
|
6
6
|
import chalk from "chalk";
|
|
7
7
|
var cp = async (src, dest, dry, filter) => {
|
|
8
8
|
if (dry) {
|
|
@@ -14,8 +14,8 @@ var cp = async (src, dest, dry, filter) => {
|
|
|
14
14
|
|
|
15
15
|
// src/scripts/update-design-tokens.ts
|
|
16
16
|
var DIRNAME = import.meta.dirname || __dirname;
|
|
17
|
-
var TARGET = path.join(DIRNAME, "../../../../design-tokens");
|
|
18
|
-
var INTERNAL = path.join(DIRNAME, "../../
|
|
17
|
+
var TARGET = path.join(DIRNAME, "../../../../internal/design-tokens");
|
|
18
|
+
var INTERNAL = path.join(DIRNAME, "../../temp/digdir/design-tokens");
|
|
19
19
|
async function updateDesignTokens() {
|
|
20
20
|
console.log("\n\u{1F4C1} Copying design tokens");
|
|
21
21
|
await cp(path.join(INTERNAL, "primitives/modes/color-scheme"), path.join(TARGET, "primitives/modes/color-scheme"));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/scripts/update-template.ts
|
|
2
|
-
import path from "
|
|
2
|
+
import path from "path";
|
|
3
3
|
import chalk2 from "chalk";
|
|
4
4
|
import * as R from "ramda";
|
|
5
5
|
|
|
6
|
-
// ../../design-tokens/semantic/color.json
|
|
6
|
+
// ../../internal/design-tokens/semantic/color.json
|
|
7
7
|
var color_default = {
|
|
8
8
|
color: {
|
|
9
9
|
accent: {
|
|
@@ -621,7 +621,7 @@ var color_default = {
|
|
|
621
621
|
}
|
|
622
622
|
};
|
|
623
623
|
|
|
624
|
-
// ../../design-tokens/semantic/modes/main-color/accent.json
|
|
624
|
+
// ../../internal/design-tokens/semantic/modes/main-color/accent.json
|
|
625
625
|
var accent_default = {
|
|
626
626
|
color: {
|
|
627
627
|
main: {
|
|
@@ -693,7 +693,7 @@ var accent_default = {
|
|
|
693
693
|
}
|
|
694
694
|
};
|
|
695
695
|
|
|
696
|
-
// ../../design-tokens/themes/digdir.json
|
|
696
|
+
// ../../internal/design-tokens/themes/digdir.json
|
|
697
697
|
var digdir_default = {
|
|
698
698
|
color: {
|
|
699
699
|
accent: {
|
|
@@ -1082,7 +1082,7 @@ var digdir_default = {
|
|
|
1082
1082
|
};
|
|
1083
1083
|
|
|
1084
1084
|
// src/utils.ts
|
|
1085
|
-
import fs from "
|
|
1085
|
+
import fs from "fs/promises";
|
|
1086
1086
|
import chalk from "chalk";
|
|
1087
1087
|
var mkdir = async (dir, dry) => {
|
|
1088
1088
|
if (dry) {
|
|
@@ -1122,19 +1122,26 @@ var cleanDir = async (dir, dry) => {
|
|
|
1122
1122
|
\u{1F525} Cleaning dir ${chalk.red(`${dir.trim()}`)} `);
|
|
1123
1123
|
return fs.rm(dir, { recursive: true, force: true });
|
|
1124
1124
|
};
|
|
1125
|
-
var readFile = async (path2, dry) => {
|
|
1125
|
+
var readFile = async (path2, dry, allowFileNotFound) => {
|
|
1126
1126
|
if (dry) {
|
|
1127
1127
|
console.log(`${chalk.blue("readFile")} ${path2}`);
|
|
1128
1128
|
return Promise.resolve("");
|
|
1129
1129
|
}
|
|
1130
|
-
|
|
1130
|
+
try {
|
|
1131
|
+
return await fs.readFile(path2, "utf-8");
|
|
1132
|
+
} catch (error) {
|
|
1133
|
+
if (allowFileNotFound && error.code === "ENOENT") {
|
|
1134
|
+
return "";
|
|
1135
|
+
}
|
|
1136
|
+
throw error;
|
|
1137
|
+
}
|
|
1131
1138
|
};
|
|
1132
1139
|
|
|
1133
1140
|
// src/scripts/update-template.ts
|
|
1134
1141
|
var DIRNAME = import.meta.dirname || __dirname;
|
|
1135
|
-
var SOURCE_FILES_PATH = path.join(DIRNAME, "../../../../design-tokens");
|
|
1142
|
+
var SOURCE_FILES_PATH = path.join(DIRNAME, "../../../../internal/design-tokens");
|
|
1136
1143
|
var TEMPLATE_FILES_PATH = path.join(DIRNAME, "../tokens/template/design-tokens");
|
|
1137
|
-
var designTokensPath = (_path) => path.join(
|
|
1144
|
+
var designTokensPath = (_path) => path.join(SOURCE_FILES_PATH, _path);
|
|
1138
1145
|
var argsFromToPaths = (path_) => [
|
|
1139
1146
|
path.join(SOURCE_FILES_PATH, path_),
|
|
1140
1147
|
path.join(TEMPLATE_FILES_PATH, path_)
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type BuildOptions } from './process/platform.js';
|
|
2
|
-
export declare const buildTokens: (options: Omit<BuildOptions, "
|
|
2
|
+
export declare const buildTokens: (options: Omit<BuildOptions, "type" | "$themes">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
3
3
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAiB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAiB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC,2DA6ChF,CAAC"}
|
package/dist/src/tokens/build.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/tokens/build.ts
|
|
2
|
-
import path from "
|
|
2
|
+
import path from "path";
|
|
3
3
|
import chalk5 from "chalk";
|
|
4
4
|
import * as R14 from "ramda";
|
|
5
5
|
|
|
6
6
|
// src/utils.ts
|
|
7
|
-
import fs from "
|
|
7
|
+
import fs from "fs/promises";
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
var mkdir = async (dir, dry) => {
|
|
10
10
|
if (dry) {
|
|
@@ -28,21 +28,19 @@ var writeFile = async (path2, data, dry) => {
|
|
|
28
28
|
throw error;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
var
|
|
32
|
-
if (dry) {
|
|
33
|
-
console.log(`${chalk.blue("cleanDir")} ${dir}`);
|
|
34
|
-
return Promise.resolve();
|
|
35
|
-
}
|
|
36
|
-
console.log(`
|
|
37
|
-
\u{1F525} Cleaning dir ${chalk.red(`${dir.trim()}`)} `);
|
|
38
|
-
return fs.rm(dir, { recursive: true, force: true });
|
|
39
|
-
};
|
|
40
|
-
var readFile = async (path2, dry) => {
|
|
31
|
+
var readFile = async (path2, dry, allowFileNotFound) => {
|
|
41
32
|
if (dry) {
|
|
42
33
|
console.log(`${chalk.blue("readFile")} ${path2}`);
|
|
43
34
|
return Promise.resolve("");
|
|
44
35
|
}
|
|
45
|
-
|
|
36
|
+
try {
|
|
37
|
+
return await fs.readFile(path2, "utf-8");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (allowFileNotFound && error.code === "ENOENT") {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
46
44
|
};
|
|
47
45
|
|
|
48
46
|
// src/tokens/process/theme.ts
|
|
@@ -52,11 +50,11 @@ import chalk2 from "chalk";
|
|
|
52
50
|
// package.json
|
|
53
51
|
var package_default = {
|
|
54
52
|
name: "@digdir/designsystemet",
|
|
55
|
-
version: "1.0.
|
|
53
|
+
version: "1.0.8",
|
|
56
54
|
description: "CLI for Designsystemet",
|
|
57
55
|
author: "Designsystemet team",
|
|
58
56
|
engines: {
|
|
59
|
-
node: ">=22.
|
|
57
|
+
node: ">=22.16.0"
|
|
60
58
|
},
|
|
61
59
|
repository: {
|
|
62
60
|
type: "git",
|
|
@@ -67,7 +65,8 @@ var package_default = {
|
|
|
67
65
|
type: "module",
|
|
68
66
|
main: "./dist/src/index.js",
|
|
69
67
|
files: [
|
|
70
|
-
"./dist/**"
|
|
68
|
+
"./dist/**",
|
|
69
|
+
"./configs/**"
|
|
71
70
|
],
|
|
72
71
|
bin: "dist/bin/designsystemet.js",
|
|
73
72
|
exports: {
|
|
@@ -86,23 +85,23 @@ var package_default = {
|
|
|
86
85
|
},
|
|
87
86
|
scripts: {
|
|
88
87
|
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
89
|
-
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
90
|
-
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
88
|
+
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
89
|
+
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
91
90
|
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
92
91
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
93
92
|
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
94
93
|
types: "tsc --noEmit",
|
|
95
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./
|
|
96
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./
|
|
97
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./
|
|
98
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./
|
|
94
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
95
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
96
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
97
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
99
98
|
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
100
99
|
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
101
100
|
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
102
|
-
"
|
|
101
|
+
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
103
102
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
104
|
-
"update:
|
|
105
|
-
verify: "pnpm test && pnpm update:template && pnpm update:
|
|
103
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
104
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
106
105
|
},
|
|
107
106
|
dependencies: {
|
|
108
107
|
"@commander-js/extra-typings": "^13.1.0",
|
|
@@ -119,8 +118,8 @@ var package_default = {
|
|
|
119
118
|
postcss: "^8.5.3",
|
|
120
119
|
ramda: "^0.30.1",
|
|
121
120
|
"style-dictionary": "^4.4.0",
|
|
122
|
-
zod: "^3.
|
|
123
|
-
"zod-validation-error": "^3.4.
|
|
121
|
+
zod: "^3.25.30",
|
|
122
|
+
"zod-validation-error": "^3.4.1"
|
|
124
123
|
},
|
|
125
124
|
devDependencies: {
|
|
126
125
|
"@tokens-studio/types": "0.5.2",
|
|
@@ -129,16 +128,15 @@ var package_default = {
|
|
|
129
128
|
"@types/fs-extra": "^11.0.4",
|
|
130
129
|
"@types/glob": "^8.1.0",
|
|
131
130
|
"@types/jscodeshift": "^0.12.0",
|
|
132
|
-
"@types/node": "^22.15.
|
|
131
|
+
"@types/node": "^22.15.21",
|
|
133
132
|
"@types/object-hash": "^3.0.6",
|
|
134
133
|
"@types/ramda": "^0.30.2",
|
|
135
134
|
"fs-extra": "^11.3.0",
|
|
136
135
|
"ts-toolbelt": "^9.6.0",
|
|
137
136
|
tslib: "^2.8.1",
|
|
138
|
-
tsup: "^8.
|
|
137
|
+
tsup: "^8.5.0",
|
|
139
138
|
tsx: "^4.19.4",
|
|
140
|
-
typescript: "^5.8.3"
|
|
141
|
-
"zod-to-json-schema": "^3.24.5"
|
|
139
|
+
typescript: "^5.8.3"
|
|
142
140
|
}
|
|
143
141
|
};
|
|
144
142
|
|
|
@@ -192,9 +190,6 @@ order may change due to nondeterminism.`.trim()
|
|
|
192
190
|
return sortIndex;
|
|
193
191
|
});
|
|
194
192
|
const header = `@charset "UTF-8";
|
|
195
|
-
|
|
196
|
-
@layer ds.theme, ds.base, ds.utilities, ds.components;
|
|
197
|
-
|
|
198
193
|
/*
|
|
199
194
|
${fileHeader2}
|
|
200
195
|
*/
|
|
@@ -267,7 +262,9 @@ function isGlobalColorToken(token) {
|
|
|
267
262
|
}
|
|
268
263
|
function isColorCategoryToken(token, category) {
|
|
269
264
|
if (!category) {
|
|
270
|
-
return
|
|
265
|
+
return Object.keys(colorCategories).some(
|
|
266
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
267
|
+
);
|
|
271
268
|
}
|
|
272
269
|
return R2.startsWith(["color", category], token.path);
|
|
273
270
|
}
|
|
@@ -604,7 +601,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
604
601
|
);
|
|
605
602
|
}
|
|
606
603
|
const layer = `ds.theme.color`;
|
|
607
|
-
const isRootColor = color === buildOptions?.
|
|
604
|
+
const isRootColor = color === buildOptions?.defaultColor;
|
|
608
605
|
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
609
606
|
const config = {
|
|
610
607
|
preprocessors: ["tokens-studio"],
|
|
@@ -1011,8 +1008,7 @@ function processThemeObject(theme) {
|
|
|
1011
1008
|
}
|
|
1012
1009
|
function groupThemes(themes) {
|
|
1013
1010
|
const groups = {};
|
|
1014
|
-
for (const
|
|
1015
|
-
const theme = processThemeObject(rawTheme);
|
|
1011
|
+
for (const theme of themes) {
|
|
1016
1012
|
if (theme.group) {
|
|
1017
1013
|
const groupKey = theme.group;
|
|
1018
1014
|
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
@@ -1163,9 +1159,12 @@ var initResult = {
|
|
|
1163
1159
|
};
|
|
1164
1160
|
var buildOptions;
|
|
1165
1161
|
var sd = new StyleDictionary2();
|
|
1166
|
-
var getCustomColors = (processed$themes) => processed$themes.filter(
|
|
1167
|
-
(x
|
|
1168
|
-
|
|
1162
|
+
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
1163
|
+
if (!x.group) {
|
|
1164
|
+
return false;
|
|
1165
|
+
}
|
|
1166
|
+
return colorGroups.includes(x.group);
|
|
1167
|
+
}).map((x) => x.name);
|
|
1169
1168
|
var buildConfigs = {
|
|
1170
1169
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
1171
1170
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
@@ -1206,17 +1205,40 @@ var buildConfigs = {
|
|
|
1206
1205
|
// },
|
|
1207
1206
|
};
|
|
1208
1207
|
async function processPlatform(options) {
|
|
1209
|
-
const {
|
|
1208
|
+
const { type, $themes } = options;
|
|
1210
1209
|
const platform = "css";
|
|
1211
|
-
const tokenSets =
|
|
1212
|
-
const tokensDir =
|
|
1210
|
+
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
1211
|
+
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
1212
|
+
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
1213
|
+
if (UNSAFE_DEFAULT_COLOR) {
|
|
1214
|
+
console.warn(
|
|
1215
|
+
chalk4.yellow(
|
|
1216
|
+
`
|
|
1217
|
+
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk4.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
|
|
1218
|
+
)
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1221
|
+
const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
|
|
1222
|
+
if (UNSAFE_COLOR_GROUPS.length > 0) {
|
|
1223
|
+
console.warn(
|
|
1224
|
+
chalk4.yellow(
|
|
1225
|
+
`
|
|
1226
|
+
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk4.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
|
|
1227
|
+
)
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
1213
1231
|
buildOptions = options;
|
|
1232
|
+
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
1214
1233
|
const processed$themes = $themes.map(processThemeObject).filter((theme) => R13.not(theme.group === "size" && theme.name !== "medium"));
|
|
1215
|
-
const customColors = getCustomColors(processed$themes);
|
|
1216
|
-
if (!buildOptions.
|
|
1234
|
+
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
1235
|
+
if (!buildOptions.defaultColor) {
|
|
1217
1236
|
const firstMainColor = R13.head(customColors);
|
|
1218
|
-
buildOptions.
|
|
1219
|
-
|
|
1237
|
+
buildOptions.defaultColor = firstMainColor;
|
|
1238
|
+
}
|
|
1239
|
+
if (buildOptions.defaultColor) {
|
|
1240
|
+
console.log(`
|
|
1241
|
+
\u{1F3A8} Using ${chalk4.blue(buildOptions.defaultColor)} as default color`);
|
|
1220
1242
|
}
|
|
1221
1243
|
const buildAndSdConfigs = R13.map((buildConfig) => {
|
|
1222
1244
|
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
@@ -1335,12 +1357,9 @@ var buildTokens = async (options) => {
|
|
|
1335
1357
|
...options,
|
|
1336
1358
|
outDir,
|
|
1337
1359
|
tokensDir,
|
|
1338
|
-
|
|
1360
|
+
type: "build",
|
|
1339
1361
|
$themes
|
|
1340
1362
|
});
|
|
1341
|
-
if (options.clean) {
|
|
1342
|
-
await cleanDir(outDir, options.dry);
|
|
1343
|
-
}
|
|
1344
1363
|
console.log(`
|
|
1345
1364
|
\u{1F4BE} Writing build to ${chalk5.green(outDir)}`);
|
|
1346
1365
|
for (const { formatted } of processedBuilds.types) {
|
|
@@ -1349,7 +1368,7 @@ var buildTokens = async (options) => {
|
|
|
1349
1368
|
const fileHeader2 = R14.join("")([
|
|
1350
1369
|
defaultFileHeader,
|
|
1351
1370
|
$designsystemet ? `
|
|
1352
|
-
design-tokens: v${$designsystemet.version}
|
|
1371
|
+
design-tokens: v${$designsystemet.version}` : ""
|
|
1353
1372
|
]);
|
|
1354
1373
|
await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
|
|
1355
1374
|
console.log(`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// package.json
|
|
2
2
|
var package_default = {
|
|
3
3
|
name: "@digdir/designsystemet",
|
|
4
|
-
version: "1.0.
|
|
4
|
+
version: "1.0.8",
|
|
5
5
|
description: "CLI for Designsystemet",
|
|
6
6
|
author: "Designsystemet team",
|
|
7
7
|
engines: {
|
|
8
|
-
node: ">=22.
|
|
8
|
+
node: ">=22.16.0"
|
|
9
9
|
},
|
|
10
10
|
repository: {
|
|
11
11
|
type: "git",
|
|
@@ -16,7 +16,8 @@ var package_default = {
|
|
|
16
16
|
type: "module",
|
|
17
17
|
main: "./dist/src/index.js",
|
|
18
18
|
files: [
|
|
19
|
-
"./dist/**"
|
|
19
|
+
"./dist/**",
|
|
20
|
+
"./configs/**"
|
|
20
21
|
],
|
|
21
22
|
bin: "dist/bin/designsystemet.js",
|
|
22
23
|
exports: {
|
|
@@ -35,23 +36,23 @@ var package_default = {
|
|
|
35
36
|
},
|
|
36
37
|
scripts: {
|
|
37
38
|
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
38
|
-
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
39
|
-
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
39
|
+
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
40
|
+
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
40
41
|
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
41
42
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
42
43
|
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
43
44
|
types: "tsc --noEmit",
|
|
44
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./
|
|
45
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./
|
|
46
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./
|
|
47
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./
|
|
45
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
46
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
47
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
48
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
48
49
|
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
49
50
|
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
50
51
|
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
51
|
-
"
|
|
52
|
+
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
52
53
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
53
|
-
"update:
|
|
54
|
-
verify: "pnpm test && pnpm update:template && pnpm update:
|
|
54
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
55
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
55
56
|
},
|
|
56
57
|
dependencies: {
|
|
57
58
|
"@commander-js/extra-typings": "^13.1.0",
|
|
@@ -68,8 +69,8 @@ var package_default = {
|
|
|
68
69
|
postcss: "^8.5.3",
|
|
69
70
|
ramda: "^0.30.1",
|
|
70
71
|
"style-dictionary": "^4.4.0",
|
|
71
|
-
zod: "^3.
|
|
72
|
-
"zod-validation-error": "^3.4.
|
|
72
|
+
zod: "^3.25.30",
|
|
73
|
+
"zod-validation-error": "^3.4.1"
|
|
73
74
|
},
|
|
74
75
|
devDependencies: {
|
|
75
76
|
"@tokens-studio/types": "0.5.2",
|
|
@@ -78,16 +79,15 @@ var package_default = {
|
|
|
78
79
|
"@types/fs-extra": "^11.0.4",
|
|
79
80
|
"@types/glob": "^8.1.0",
|
|
80
81
|
"@types/jscodeshift": "^0.12.0",
|
|
81
|
-
"@types/node": "^22.15.
|
|
82
|
+
"@types/node": "^22.15.21",
|
|
82
83
|
"@types/object-hash": "^3.0.6",
|
|
83
84
|
"@types/ramda": "^0.30.2",
|
|
84
85
|
"fs-extra": "^11.3.0",
|
|
85
86
|
"ts-toolbelt": "^9.6.0",
|
|
86
87
|
tslib: "^2.8.1",
|
|
87
|
-
tsup: "^8.
|
|
88
|
+
tsup: "^8.5.0",
|
|
88
89
|
tsx: "^4.19.4",
|
|
89
|
-
typescript: "^5.8.3"
|
|
90
|
-
"zod-to-json-schema": "^3.24.5"
|
|
90
|
+
typescript: "^5.8.3"
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/tokens/create/write.ts
|
|
2
|
-
import path from "
|
|
2
|
+
import path from "path";
|
|
3
3
|
import chalk2 from "chalk";
|
|
4
4
|
import * as R from "ramda";
|
|
5
5
|
|
|
6
6
|
// src/utils.ts
|
|
7
|
-
import fs from "
|
|
7
|
+
import fs from "fs/promises";
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
var mkdir = async (dir, dry) => {
|
|
10
10
|
if (dry) {
|
|
@@ -28,22 +28,29 @@ var writeFile = async (path2, data, dry) => {
|
|
|
28
28
|
throw error;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
var readFile = async (path2, dry) => {
|
|
31
|
+
var readFile = async (path2, dry, allowFileNotFound) => {
|
|
32
32
|
if (dry) {
|
|
33
33
|
console.log(`${chalk.blue("readFile")} ${path2}`);
|
|
34
34
|
return Promise.resolve("");
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
try {
|
|
37
|
+
return await fs.readFile(path2, "utf-8");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (allowFileNotFound && error.code === "ENOENT") {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
37
44
|
};
|
|
38
45
|
|
|
39
46
|
// package.json
|
|
40
47
|
var package_default = {
|
|
41
48
|
name: "@digdir/designsystemet",
|
|
42
|
-
version: "1.0.
|
|
49
|
+
version: "1.0.8",
|
|
43
50
|
description: "CLI for Designsystemet",
|
|
44
51
|
author: "Designsystemet team",
|
|
45
52
|
engines: {
|
|
46
|
-
node: ">=22.
|
|
53
|
+
node: ">=22.16.0"
|
|
47
54
|
},
|
|
48
55
|
repository: {
|
|
49
56
|
type: "git",
|
|
@@ -54,7 +61,8 @@ var package_default = {
|
|
|
54
61
|
type: "module",
|
|
55
62
|
main: "./dist/src/index.js",
|
|
56
63
|
files: [
|
|
57
|
-
"./dist/**"
|
|
64
|
+
"./dist/**",
|
|
65
|
+
"./configs/**"
|
|
58
66
|
],
|
|
59
67
|
bin: "dist/bin/designsystemet.js",
|
|
60
68
|
exports: {
|
|
@@ -73,23 +81,23 @@ var package_default = {
|
|
|
73
81
|
},
|
|
74
82
|
scripts: {
|
|
75
83
|
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
76
|
-
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
77
|
-
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
|
|
84
|
+
"build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
85
|
+
"build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
|
|
78
86
|
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
79
87
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
80
88
|
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
81
89
|
types: "tsc --noEmit",
|
|
82
|
-
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./
|
|
83
|
-
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./
|
|
84
|
-
"test:tokens-build": "pnpm run designsystemet tokens build -t ./
|
|
85
|
-
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./
|
|
90
|
+
"test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
|
|
91
|
+
"test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
|
|
92
|
+
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
93
|
+
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
86
94
|
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
87
95
|
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
88
96
|
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
89
|
-
"
|
|
97
|
+
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
90
98
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
91
|
-
"update:
|
|
92
|
-
verify: "pnpm test && pnpm update:template && pnpm update:
|
|
99
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
100
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
93
101
|
},
|
|
94
102
|
dependencies: {
|
|
95
103
|
"@commander-js/extra-typings": "^13.1.0",
|
|
@@ -106,8 +114,8 @@ var package_default = {
|
|
|
106
114
|
postcss: "^8.5.3",
|
|
107
115
|
ramda: "^0.30.1",
|
|
108
116
|
"style-dictionary": "^4.4.0",
|
|
109
|
-
zod: "^3.
|
|
110
|
-
"zod-validation-error": "^3.4.
|
|
117
|
+
zod: "^3.25.30",
|
|
118
|
+
"zod-validation-error": "^3.4.1"
|
|
111
119
|
},
|
|
112
120
|
devDependencies: {
|
|
113
121
|
"@tokens-studio/types": "0.5.2",
|
|
@@ -116,16 +124,15 @@ var package_default = {
|
|
|
116
124
|
"@types/fs-extra": "^11.0.4",
|
|
117
125
|
"@types/glob": "^8.1.0",
|
|
118
126
|
"@types/jscodeshift": "^0.12.0",
|
|
119
|
-
"@types/node": "^22.15.
|
|
127
|
+
"@types/node": "^22.15.21",
|
|
120
128
|
"@types/object-hash": "^3.0.6",
|
|
121
129
|
"@types/ramda": "^0.30.2",
|
|
122
130
|
"fs-extra": "^11.3.0",
|
|
123
131
|
"ts-toolbelt": "^9.6.0",
|
|
124
132
|
tslib: "^2.8.1",
|
|
125
|
-
tsup: "^8.
|
|
133
|
+
tsup: "^8.5.0",
|
|
126
134
|
tsx: "^4.19.4",
|
|
127
|
-
typescript: "^5.8.3"
|
|
128
|
-
"zod-to-json-schema": "^3.24.5"
|
|
135
|
+
typescript: "^5.8.3"
|
|
129
136
|
}
|
|
130
137
|
};
|
|
131
138
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FormatOptions } from './process/platform.js';
|
|
2
2
|
import type { Theme } from './types.js';
|
|
3
|
-
export declare const formatTokens: (options: Omit<FormatOptions, "
|
|
3
|
+
export declare const formatTokens: (options: Omit<FormatOptions, "type">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
4
4
|
export declare const formatTheme: (themeConfig: Theme) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
5
5
|
/**
|
|
6
6
|
* Formats a theme configuration into CSS.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,2DAOtE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2DAYnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC"}
|