@digdir/designsystemet 1.1.0 → 1.1.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.
- package/dist/bin/config.d.ts +3 -3
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +26 -27
- package/dist/bin/designsystemet.js +393 -376
- package/dist/config.schema.json +4 -4
- package/dist/src/config.d.ts +6 -21
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +24 -22
- package/dist/src/index.js +34 -46
- package/dist/src/scripts/createJsonSchema.js +5 -6
- 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 +349 -331
- package/dist/src/tokens/create/generators/$designsystemet.js +9 -7
- package/dist/src/tokens/create/write.js +9 -7
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +34 -46
- package/dist/src/tokens/index.js +34 -46
- package/dist/src/tokens/process/output/declarations.d.ts +4 -0
- package/dist/src/tokens/process/output/declarations.d.ts.map +1 -0
- package/dist/src/tokens/process/output/declarations.js +860 -0
- package/dist/src/tokens/process/output/theme.js +10 -8
- package/dist/src/tokens/process/platform.d.ts +5 -3
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +22 -51
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts +1 -0
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -1
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +7 -0
- package/package.json +9 -7
package/dist/config.schema.json
CHANGED
|
@@ -9,10 +9,6 @@
|
|
|
9
9
|
"description": "Path to the output directory for the created design tokens",
|
|
10
10
|
"type": "string"
|
|
11
11
|
},
|
|
12
|
-
"clean": {
|
|
13
|
-
"description": "Delete the output directory before building or creating tokens",
|
|
14
|
-
"type": "boolean"
|
|
15
|
-
},
|
|
16
12
|
"themes": {
|
|
17
13
|
"description": "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name.",
|
|
18
14
|
"type": "object",
|
|
@@ -85,6 +81,10 @@
|
|
|
85
81
|
],
|
|
86
82
|
"additionalProperties": false
|
|
87
83
|
}
|
|
84
|
+
},
|
|
85
|
+
"clean": {
|
|
86
|
+
"description": "Delete the output directory before building or creating tokens",
|
|
87
|
+
"type": "boolean"
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
"required": [
|
package/dist/src/config.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { z } from 'zod/v4';
|
|
|
9
9
|
* @throws Exits the process with code 1 if validation fails, after logging a friendly error message.
|
|
10
10
|
*/
|
|
11
11
|
export declare function validateConfig<T>(schema: z.ZodType<T>, unvalidatedConfig: Record<string, unknown>, configPath: string): T;
|
|
12
|
-
export declare function parseConfig<T>(
|
|
12
|
+
export declare function parseConfig<T>(configFile: string, configPath: string): T;
|
|
13
13
|
export declare const colorRegex: RegExp;
|
|
14
14
|
declare const themeSchema: z.ZodObject<{
|
|
15
15
|
colors: z.ZodObject<{
|
|
@@ -22,28 +22,13 @@ declare const themeSchema: z.ZodObject<{
|
|
|
22
22
|
}, z.core.$strip>>;
|
|
23
23
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
24
24
|
}, z.core.$strip>;
|
|
25
|
-
export declare const
|
|
25
|
+
export declare const commonConfig: z.ZodObject<{
|
|
26
26
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
27
27
|
}, z.core.$strip>;
|
|
28
|
-
export declare const configFileCreateSchema: z.ZodObject<{
|
|
29
|
-
outDir: z.ZodNonOptional<z.ZodString>;
|
|
30
|
-
clean: z.ZodNonOptional<z.ZodOptional<z.ZodBoolean>>;
|
|
31
|
-
themes: z.ZodNonOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
32
|
-
colors: z.ZodObject<{
|
|
33
|
-
main: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
34
|
-
support: z.ZodDefault<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>>>;
|
|
35
|
-
neutral: z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
typography: z.ZodOptional<z.ZodObject<{
|
|
38
|
-
fontFamily: z.ZodString;
|
|
39
|
-
}, z.core.$strip>>;
|
|
40
|
-
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
41
|
-
}, z.core.$strip>>>;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
28
|
/**
|
|
44
29
|
* This defines the structure of the final configuration file
|
|
45
30
|
*/
|
|
46
|
-
export declare const
|
|
31
|
+
export declare const configFileCreateSchema: z.ZodObject<{
|
|
47
32
|
outDir: z.ZodNonOptional<z.ZodString>;
|
|
48
33
|
themes: z.ZodNonOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
49
34
|
colors: z.ZodObject<{
|
|
@@ -58,9 +43,9 @@ export declare const combinedConfigSchema: z.ZodObject<{
|
|
|
58
43
|
}, z.core.$strip>>>;
|
|
59
44
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
60
45
|
}, z.core.$strip>;
|
|
61
|
-
export type
|
|
62
|
-
export type
|
|
63
|
-
export type
|
|
46
|
+
export type CommonConfigSchema = z.infer<typeof commonConfig>;
|
|
47
|
+
export type BuildConfigSchema = z.infer<typeof commonConfig>;
|
|
48
|
+
export type CreateConfigSchema = z.infer<typeof configFileCreateSchema>;
|
|
64
49
|
export type ConfigSchemaTheme = z.infer<typeof themeSchema>;
|
|
65
50
|
export {};
|
|
66
51
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAsC3B;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,UAAU,EAAE,MAAM,GACjB,CAAC,CAUH;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,CAexE;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AAyBnE,QAAA,MAAM,WAAW;;;;;;;;;;iBAiBmG,CAAC;AAErH,eAAO,MAAM,YAAY;;iBAEvB,CAAC;AAYH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;iBAAqD,CAAC;AACzF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
package/dist/src/config.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import * as R7 from "ramda";
|
|
4
4
|
import { z } from "zod/v4";
|
|
5
|
-
import { fromError } from "zod-validation-error";
|
|
5
|
+
import { fromError } from "zod-validation-error/v4";
|
|
6
6
|
|
|
7
7
|
// src/colors/colorMetadata.ts
|
|
8
8
|
import * as R from "ramda";
|
|
@@ -322,16 +322,21 @@ function mapPathToOptionName(path2) {
|
|
|
322
322
|
return option;
|
|
323
323
|
}
|
|
324
324
|
function makeFriendlyError(err) {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
325
|
+
try {
|
|
326
|
+
return fromError(err, {
|
|
327
|
+
messageBuilder: (issues) => issues.map((issue) => {
|
|
328
|
+
const issuePath = issue.path.join(".");
|
|
329
|
+
const optionName = mapPathToOptionName(issue.path);
|
|
330
|
+
const errorCode = `(error code: ${issue.code})`;
|
|
331
|
+
const optionMessage = optionName ? ` or CLI option --${optionName}` : "";
|
|
332
|
+
return ` - Error in JSON value ${chalk.red(issuePath)}${optionMessage}:
|
|
333
|
+
${issue.message} ${chalk.dim(errorCode)}`;
|
|
334
|
+
}).join("\n")
|
|
335
|
+
});
|
|
336
|
+
} catch (_err2) {
|
|
337
|
+
console.error(chalk.red(err instanceof Error ? err.message : "Unknown error occurred while parsing config file"));
|
|
338
|
+
console.error(err instanceof Error ? err.stack : "No stack trace available");
|
|
339
|
+
}
|
|
335
340
|
}
|
|
336
341
|
function validateConfig(schema, unvalidatedConfig, configPath) {
|
|
337
342
|
try {
|
|
@@ -339,21 +344,20 @@ function validateConfig(schema, unvalidatedConfig, configPath) {
|
|
|
339
344
|
} catch (err) {
|
|
340
345
|
console.error(chalk.redBright(`Invalid config file at ${chalk.red(configPath)}`));
|
|
341
346
|
const validationError = makeFriendlyError(err);
|
|
342
|
-
console.error(validationError
|
|
347
|
+
console.error(validationError?.toString());
|
|
343
348
|
process.exit(1);
|
|
344
349
|
}
|
|
345
350
|
}
|
|
346
|
-
function parseConfig(
|
|
351
|
+
function parseConfig(configFile, configPath) {
|
|
347
352
|
if (!configFile) {
|
|
348
353
|
return {};
|
|
349
354
|
}
|
|
350
355
|
try {
|
|
351
|
-
|
|
352
|
-
return schema.parse(parsedConfig);
|
|
356
|
+
return JSON.parse(configFile);
|
|
353
357
|
} catch (err) {
|
|
354
358
|
console.error(chalk.redBright(`Failed parsing config file at ${chalk.red(configPath)}`));
|
|
355
359
|
const validationError = makeFriendlyError(err);
|
|
356
|
-
console.error(validationError
|
|
360
|
+
console.error(validationError?.toString());
|
|
357
361
|
process.exit(1);
|
|
358
362
|
}
|
|
359
363
|
}
|
|
@@ -391,21 +395,19 @@ var themeSchema = z.object({
|
|
|
391
395
|
}).describe("Defines the typography for a given theme").optional(),
|
|
392
396
|
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
393
397
|
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
394
|
-
var
|
|
398
|
+
var commonConfig = z.object({
|
|
395
399
|
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional()
|
|
396
400
|
});
|
|
397
|
-
var
|
|
401
|
+
var _configFileCreateSchema = z.object({
|
|
398
402
|
outDir: z.string().meta({ description: "Path to the output directory for the created design tokens" }),
|
|
399
|
-
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional(),
|
|
400
403
|
themes: z.record(z.string(), themeSchema).meta({
|
|
401
404
|
description: "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
|
|
402
405
|
})
|
|
403
406
|
}).required();
|
|
404
|
-
var
|
|
407
|
+
var configFileCreateSchema = _configFileCreateSchema.extend(commonConfig.shape);
|
|
405
408
|
export {
|
|
406
409
|
colorRegex,
|
|
407
|
-
|
|
408
|
-
configFileBuildSchema,
|
|
410
|
+
commonConfig,
|
|
409
411
|
configFileCreateSchema,
|
|
410
412
|
parseConfig,
|
|
411
413
|
validateConfig
|
package/dist/src/index.js
CHANGED
|
@@ -2572,7 +2572,7 @@ import * as R7 from "ramda";
|
|
|
2572
2572
|
// package.json
|
|
2573
2573
|
var package_default = {
|
|
2574
2574
|
name: "@digdir/designsystemet",
|
|
2575
|
-
version: "1.1.
|
|
2575
|
+
version: "1.1.1",
|
|
2576
2576
|
description: "CLI for Designsystemet",
|
|
2577
2577
|
author: "Designsystemet team",
|
|
2578
2578
|
engines: {
|
|
@@ -2607,6 +2607,7 @@ var package_default = {
|
|
|
2607
2607
|
},
|
|
2608
2608
|
scripts: {
|
|
2609
2609
|
designsystemet: "tsx ./bin/designsystemet.ts",
|
|
2610
|
+
"designsystemet:inspect": "tsx --inspect-brk ./bin/designsystemet.ts",
|
|
2610
2611
|
build: "tsup && pnpm build:types && pnpm build:json-schema",
|
|
2611
2612
|
"build:types": "tsc --emitDeclarationOnly --declaration",
|
|
2612
2613
|
"build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
|
|
@@ -2616,6 +2617,7 @@ var package_default = {
|
|
|
2616
2617
|
"test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
|
|
2617
2618
|
"test:tokens-build-tailwind": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean --experimental-tailwind",
|
|
2618
2619
|
"test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
2620
|
+
"test:tokens-build-config:inspect": "pnpm run designsystemet:inspect tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
|
|
2619
2621
|
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
2620
2622
|
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
2621
2623
|
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
@@ -2634,15 +2636,15 @@ var package_default = {
|
|
|
2634
2636
|
"change-case": "^5.4.4",
|
|
2635
2637
|
"chroma-js": "^3.1.2",
|
|
2636
2638
|
"colorjs.io": "^0.6.0-alpha.1",
|
|
2637
|
-
commander: "^
|
|
2639
|
+
commander: "^14.0.0",
|
|
2638
2640
|
"fast-glob": "^3.3.3",
|
|
2639
2641
|
hsluv: "^1.0.1",
|
|
2640
2642
|
"object-hash": "^3.0.0",
|
|
2641
|
-
postcss: "^8.5.
|
|
2643
|
+
postcss: "^8.5.6",
|
|
2642
2644
|
ramda: "^0.30.1",
|
|
2643
|
-
"style-dictionary": "^
|
|
2644
|
-
zod: "^3.25.
|
|
2645
|
-
"zod-validation-error": "^3.5.
|
|
2645
|
+
"style-dictionary": "^5.0.0",
|
|
2646
|
+
zod: "^3.25.67",
|
|
2647
|
+
"zod-validation-error": "^3.5.2"
|
|
2646
2648
|
},
|
|
2647
2649
|
devDependencies: {
|
|
2648
2650
|
"@tokens-studio/types": "0.5.2",
|
|
@@ -2650,7 +2652,7 @@ var package_default = {
|
|
|
2650
2652
|
"@types/chroma-js": "^3.1.1",
|
|
2651
2653
|
"@types/fs-extra": "^11.0.4",
|
|
2652
2654
|
"@types/glob": "^8.1.0",
|
|
2653
|
-
"@types/node": "^22.15.
|
|
2655
|
+
"@types/node": "^22.15.32",
|
|
2654
2656
|
"@types/object-hash": "^3.0.6",
|
|
2655
2657
|
"@types/ramda": "^0.30.2",
|
|
2656
2658
|
"fs-extra": "^11.3.0",
|
|
@@ -2668,7 +2670,7 @@ var createThemeCSSFiles = ({
|
|
|
2668
2670
|
fileHeader: fileHeader2 = defaultFileHeader
|
|
2669
2671
|
}) => {
|
|
2670
2672
|
const groupedByTheme = {};
|
|
2671
|
-
for (const [_, buildResults] of Object.entries(
|
|
2673
|
+
for (const [_, buildResults] of Object.entries(processedBuilds)) {
|
|
2672
2674
|
for (const buildResult of buildResults) {
|
|
2673
2675
|
const themeName = buildResult.permutation.theme;
|
|
2674
2676
|
const newOutputs = buildResult.formatted;
|
|
@@ -3435,6 +3437,12 @@ function filterTokenSets(tokensets) {
|
|
|
3435
3437
|
function cartesian(a) {
|
|
3436
3438
|
return a.reduce((a2, b) => a2.flatMap((d) => b.map((e) => [d, e].flat())));
|
|
3437
3439
|
}
|
|
3440
|
+
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3441
|
+
if (!x.group) {
|
|
3442
|
+
return false;
|
|
3443
|
+
}
|
|
3444
|
+
return colorGroups.includes(x.group);
|
|
3445
|
+
}).map((x) => x.name);
|
|
3438
3446
|
|
|
3439
3447
|
// src/tokens/process/configs.ts
|
|
3440
3448
|
void register(StyleDictionary, { withSDBuiltins: false });
|
|
@@ -3517,12 +3525,6 @@ var initResult = {
|
|
|
3517
3525
|
};
|
|
3518
3526
|
var buildOptions;
|
|
3519
3527
|
var sd = new StyleDictionary2();
|
|
3520
|
-
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3521
|
-
if (!x.group) {
|
|
3522
|
-
return false;
|
|
3523
|
-
}
|
|
3524
|
-
return colorGroups.includes(x.group);
|
|
3525
|
-
}).map((x) => x.name);
|
|
3526
3528
|
var buildConfigs = {
|
|
3527
3529
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3528
3530
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
@@ -3563,7 +3565,7 @@ var buildConfigs = {
|
|
|
3563
3565
|
// },
|
|
3564
3566
|
};
|
|
3565
3567
|
async function processPlatform(options) {
|
|
3566
|
-
const { type, $themes } = options;
|
|
3568
|
+
const { type, processed$themes } = options;
|
|
3567
3569
|
const platform = "css";
|
|
3568
3570
|
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3569
3571
|
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
@@ -3588,8 +3590,11 @@ async function processPlatform(options) {
|
|
|
3588
3590
|
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
3589
3591
|
buildOptions = options;
|
|
3590
3592
|
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3591
|
-
|
|
3592
|
-
const
|
|
3593
|
+
buildOptions.colorGroups = colorGroups;
|
|
3594
|
+
const filteredProcessed$themes = processed$themes.filter(
|
|
3595
|
+
(theme) => R19.not(theme.group === "size" && theme.name !== "medium")
|
|
3596
|
+
);
|
|
3597
|
+
const customColors = getCustomColors(filteredProcessed$themes, colorGroups);
|
|
3593
3598
|
if (!buildOptions.defaultColor) {
|
|
3594
3599
|
const firstMainColor = R19.head(customColors);
|
|
3595
3600
|
buildOptions.defaultColor = firstMainColor;
|
|
@@ -3599,10 +3604,15 @@ async function processPlatform(options) {
|
|
|
3599
3604
|
\u{1F3A8} Using ${chalk3.blue(buildOptions.defaultColor)} as default color`);
|
|
3600
3605
|
}
|
|
3601
3606
|
const buildAndSdConfigs = R19.map((buildConfig) => {
|
|
3602
|
-
const sdConfigs = getConfigsForThemeDimensions(
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3607
|
+
const sdConfigs = getConfigsForThemeDimensions(
|
|
3608
|
+
buildConfig.getConfig,
|
|
3609
|
+
filteredProcessed$themes,
|
|
3610
|
+
buildConfig.dimensions,
|
|
3611
|
+
{
|
|
3612
|
+
tokensDir,
|
|
3613
|
+
tokenSets
|
|
3614
|
+
}
|
|
3615
|
+
);
|
|
3606
3616
|
const unknownConfigs = buildConfig.dimensions.map(
|
|
3607
3617
|
(dimension) => sdConfigs.filter((x) => x.permutation[dimension] === "unknown")
|
|
3608
3618
|
);
|
|
@@ -3626,8 +3636,7 @@ async function processPlatform(options) {
|
|
|
3626
3636
|
"warning-color": [initResult],
|
|
3627
3637
|
"info-color": [initResult],
|
|
3628
3638
|
semantic: [initResult],
|
|
3629
|
-
typography: [initResult]
|
|
3630
|
-
types: [initResult]
|
|
3639
|
+
typography: [initResult]
|
|
3631
3640
|
};
|
|
3632
3641
|
try {
|
|
3633
3642
|
for (const [buildName, { buildConfig, sdConfigs }] of R19.toPairs(buildAndSdConfigs)) {
|
|
@@ -3662,30 +3671,8 @@ async function processPlatform(options) {
|
|
|
3662
3671
|
}
|
|
3663
3672
|
throw err;
|
|
3664
3673
|
}
|
|
3665
|
-
const colorsFileName = "colors.d.ts";
|
|
3666
|
-
const reactColorTypes = await createColorTypeDeclaration(customColors);
|
|
3667
|
-
processedBuilds.types = [
|
|
3668
|
-
{
|
|
3669
|
-
...initResult,
|
|
3670
|
-
formatted: [{ output: reactColorTypes, destination: colorsFileName }]
|
|
3671
|
-
}
|
|
3672
|
-
];
|
|
3673
3674
|
return processedBuilds;
|
|
3674
3675
|
}
|
|
3675
|
-
async function createColorTypeDeclaration(colors) {
|
|
3676
|
-
console.log(`
|
|
3677
|
-
\u{1F371} Building ${chalk3.green("type declarations")}`);
|
|
3678
|
-
const typeDeclaration = `
|
|
3679
|
-
import type {} from '@digdir/designsystemet-react/colors';
|
|
3680
|
-
|
|
3681
|
-
declare module '@digdir/designsystemet-react/colors' {
|
|
3682
|
-
export interface MainAndSupportColors {
|
|
3683
|
-
${colors.map((color) => ` ${color}: never;`).join("\n")}
|
|
3684
|
-
}
|
|
3685
|
-
}
|
|
3686
|
-
`.trimStart();
|
|
3687
|
-
return typeDeclaration;
|
|
3688
|
-
}
|
|
3689
3676
|
|
|
3690
3677
|
// src/tokens/format.ts
|
|
3691
3678
|
var formatTokens = async (options) => {
|
|
@@ -3698,9 +3685,10 @@ var formatTokens = async (options) => {
|
|
|
3698
3685
|
var formatTheme = async (themeConfig) => {
|
|
3699
3686
|
const { tokenSets } = await createTokens(themeConfig);
|
|
3700
3687
|
const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
|
|
3688
|
+
const processed$themes = $themes.map(processThemeObject);
|
|
3701
3689
|
const processedBuilds = await formatTokens({
|
|
3702
3690
|
tokenSets,
|
|
3703
|
-
$themes,
|
|
3691
|
+
processed$themes,
|
|
3704
3692
|
verbose: false,
|
|
3705
3693
|
preview: false
|
|
3706
3694
|
});
|
|
@@ -7,7 +7,7 @@ import { z as z2 } from "zod/v4";
|
|
|
7
7
|
import chalk from "chalk";
|
|
8
8
|
import * as R7 from "ramda";
|
|
9
9
|
import { z } from "zod/v4";
|
|
10
|
-
import { fromError } from "zod-validation-error";
|
|
10
|
+
import { fromError } from "zod-validation-error/v4";
|
|
11
11
|
|
|
12
12
|
// src/colors/colorMetadata.ts
|
|
13
13
|
import * as R from "ramda";
|
|
@@ -334,22 +334,21 @@ var themeSchema = z.object({
|
|
|
334
334
|
}).describe("Defines the typography for a given theme").optional(),
|
|
335
335
|
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
336
336
|
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
337
|
-
var
|
|
337
|
+
var commonConfig = z.object({
|
|
338
338
|
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional()
|
|
339
339
|
});
|
|
340
|
-
var
|
|
340
|
+
var _configFileCreateSchema = z.object({
|
|
341
341
|
outDir: z.string().meta({ description: "Path to the output directory for the created design tokens" }),
|
|
342
|
-
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional(),
|
|
343
342
|
themes: z.record(z.string(), themeSchema).meta({
|
|
344
343
|
description: "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
|
|
345
344
|
})
|
|
346
345
|
}).required();
|
|
347
|
-
var
|
|
346
|
+
var configFileCreateSchema = _configFileCreateSchema.extend(commonConfig.shape);
|
|
348
347
|
|
|
349
348
|
// src/scripts/createJsonSchema.ts
|
|
350
349
|
var schema = z2.object({
|
|
351
350
|
$schema: z2.string().optional()
|
|
352
|
-
}).extend(
|
|
351
|
+
}).extend(configFileCreateSchema.shape);
|
|
353
352
|
writeFile(
|
|
354
353
|
resolve(import.meta.dirname, "../../dist/config.schema.json"),
|
|
355
354
|
JSON.stringify(
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type BuildOptions } from './process/platform.js';
|
|
2
|
-
export declare const buildTokens: (options: Omit<BuildOptions, "type" | "$themes">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
2
|
+
export declare const buildTokens: (options: Omit<BuildOptions, "type" | "processed$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":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAkB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,MAAM,GAAG,kBAAkB,CAAC,2DAqDzF,CAAC"}
|