@digdir/designsystemet 1.0.4 → 1.0.5

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.
@@ -1,7 +1,7 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@digdir/designsystemet",
4
- version: "1.0.4",
4
+ version: "1.0.5",
5
5
  description: "CLI for Designsystemet",
6
6
  author: "Designsystemet team",
7
7
  engines: {
@@ -41,11 +41,12 @@ var package_default = {
41
41
  "build:types": "tsc --emitDeclarationOnly --declaration",
42
42
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
43
43
  types: "tsc --noEmit",
44
- "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
45
- "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
46
- "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
44
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
45
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
46
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
47
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
47
48
  "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
48
- "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
49
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
49
50
  test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
50
51
  "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
51
52
  "update:template": "tsx ./src/scripts/update-template.ts",
@@ -39,7 +39,7 @@ var readFile = async (path2, dry) => {
39
39
  // package.json
40
40
  var package_default = {
41
41
  name: "@digdir/designsystemet",
42
- version: "1.0.4",
42
+ version: "1.0.5",
43
43
  description: "CLI for Designsystemet",
44
44
  author: "Designsystemet team",
45
45
  engines: {
@@ -79,11 +79,12 @@ var package_default = {
79
79
  "build:types": "tsc --emitDeclarationOnly --declaration",
80
80
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
81
81
  types: "tsc --noEmit",
82
- "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
83
- "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
84
- "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
82
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
83
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
84
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
85
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
85
86
  "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
86
- "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
87
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
87
88
  test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
88
89
  "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
89
90
  "update:template": "tsx ./src/scripts/update-template.ts",
@@ -1,7 +1,7 @@
1
- import { type FormatOptions, type ProcessReturn } from './process/platform.js';
2
- import type { OutputFile, Theme } from './types.js';
3
- export declare const formatTokens: (options: Omit<FormatOptions, "process">) => Promise<ProcessReturn>;
4
- export declare const formatTheme: (themeConfig: Theme) => Promise<ProcessReturn>;
1
+ import { type FormatOptions } from './process/platform.js';
2
+ import type { Theme } from './types.js';
3
+ export declare const formatTokens: (options: Omit<FormatOptions, "process">) => Promise<import("./process/platform.js").ProcessReturn>;
4
+ export declare const formatTheme: (themeConfig: Theme) => Promise<import("./process/platform.js").ProcessReturn>;
5
5
  /**
6
6
  * Formats a theme configuration into CSS.
7
7
  *
@@ -12,5 +12,4 @@ export declare const formatTheme: (themeConfig: Theme) => Promise<ProcessReturn>
12
12
  * @returns A promise that resolves to the generated CSS string.
13
13
  */
14
14
  export declare const formatThemeCSS: (themeConfig: Theme) => Promise<string>;
15
- export declare const createThemeCSSFiles: (processedBuilds: ProcessReturn) => OutputFile[];
16
15
  //# sourceMappingURL=format.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAChG,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,SAAS,CAAC,2BAOzE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2BAYnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,iBAAiB,aAAa,iBA2EjE,CAAC"}
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,SAAS,CAAC,2DAOzE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2DAYnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC"}
@@ -1,96 +1,5 @@
1
1
  // src/tokens/format.ts
2
- import * as R19 from "ramda";
3
- import chalk3 from "chalk";
4
-
5
- // package.json
6
- var package_default = {
7
- name: "@digdir/designsystemet",
8
- version: "1.0.4",
9
- description: "CLI for Designsystemet",
10
- author: "Designsystemet team",
11
- engines: {
12
- node: ">=22.14.0"
13
- },
14
- repository: {
15
- type: "git",
16
- url: "git+https://github.com/digdir/designsystemet.git"
17
- },
18
- homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
19
- license: "MIT",
20
- type: "module",
21
- main: "./dist/src/index.js",
22
- files: [
23
- "./dist/**"
24
- ],
25
- bin: "dist/bin/designsystemet.js",
26
- exports: {
27
- ".": {
28
- import: "./dist/src/index.js"
29
- },
30
- "./color": {
31
- import: "./dist/src/colors/index.js"
32
- },
33
- "./tokens": {
34
- import: "./dist/src/tokens/index.js"
35
- }
36
- },
37
- publishConfig: {
38
- access: "public"
39
- },
40
- scripts: {
41
- designsystemet: "tsx ./bin/designsystemet.ts",
42
- "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
43
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
44
- build: "tsup && yarn build:types && yarn build:json-schema",
45
- "build:types": "tsc --emitDeclarationOnly --declaration",
46
- "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
47
- types: "tsc --noEmit",
48
- "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
49
- "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
50
- "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
51
- "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
52
- "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
53
- test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
54
- "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
55
- "update:template": "tsx ./src/scripts/update-template.ts",
56
- "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
57
- verify: "yarn test && yarn update:template && yarn update:design-tokens"
58
- },
59
- dependencies: {
60
- "@commander-js/extra-typings": "^13.1.0",
61
- "@tokens-studio/sd-transforms": "1.2.12",
62
- "apca-w3": "^0.1.9",
63
- chalk: "^5.4.1",
64
- "change-case": "^5.4.4",
65
- "chroma-js": "^3.1.2",
66
- commander: "^13.1.0",
67
- "fast-glob": "^3.3.3",
68
- hsluv: "^1.0.1",
69
- "object-hash": "^3.0.0",
70
- postcss: "^8.5.3",
71
- ramda: "^0.30.1",
72
- "style-dictionary": "^4.3.3",
73
- zod: "^3.24.2",
74
- "zod-validation-error": "^3.4.0"
75
- },
76
- devDependencies: {
77
- "@types/apca-w3": "^0.1.3",
78
- "@types/chroma-js": "^3.1.1",
79
- "@types/fs-extra": "^11.0.4",
80
- "@types/glob": "^8.1.0",
81
- "@types/jscodeshift": "^0.12.0",
82
- "@types/node": "^22.14.0",
83
- "@types/object-hash": "^3.0.6",
84
- "@types/ramda": "^0.30.2",
85
- "fs-extra": "^11.3.0",
86
- "ts-toolbelt": "^9.6.0",
87
- tslib: "^2.8.1",
88
- tsup: "^8.4.0",
89
- tsx: "^4.19.3",
90
- typescript: "^5.8.2",
91
- "zod-to-json-schema": "^3.24.5"
92
- }
93
- };
2
+ import * as R20 from "ramda";
94
3
 
95
4
  // src/tokens/create/defaults.ts
96
5
  import * as R from "ramda";
@@ -3319,7 +3228,7 @@ var buildConfigs = {
3319
3228
  // },
3320
3229
  };
3321
3230
  async function processPlatform(options) {
3322
- const { dry, process, $themes } = options;
3231
+ const { process, $themes } = options;
3323
3232
  const platform = "css";
3324
3233
  const tokenSets = process === "format" ? options.tokenSets : void 0;
3325
3234
  const tokensDir = process === "build" ? options.tokensDir : void 0;
@@ -3420,36 +3329,116 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
3420
3329
  return typeDeclaration;
3421
3330
  }
3422
3331
 
3423
- // src/tokens/format.ts
3424
- var formatTokens = async (options) => {
3425
- const processedBuilds = await processPlatform({
3426
- process: "format",
3427
- ...options
3428
- });
3429
- return processedBuilds;
3430
- };
3431
- var formatTheme = async (themeConfig) => {
3432
- const { tokenSets } = await createTokens(themeConfig);
3433
- const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3434
- const processedBuilds = await formatTokens({
3435
- tokenSets,
3436
- $themes,
3437
- verbose: false,
3438
- preview: false
3439
- });
3440
- return processedBuilds;
3441
- };
3442
- var formatThemeCSS = async (themeConfig) => {
3443
- const processedBuilds = await formatTheme(themeConfig);
3444
- const themeCSSFiles = createThemeCSSFiles(processedBuilds);
3445
- return R19.head(themeCSSFiles)?.output ?? "";
3332
+ // src/tokens/process/theme.ts
3333
+ import * as R19 from "ramda";
3334
+ import chalk3 from "chalk";
3335
+
3336
+ // package.json
3337
+ var package_default = {
3338
+ name: "@digdir/designsystemet",
3339
+ version: "1.0.5",
3340
+ description: "CLI for Designsystemet",
3341
+ author: "Designsystemet team",
3342
+ engines: {
3343
+ node: ">=22.14.0"
3344
+ },
3345
+ repository: {
3346
+ type: "git",
3347
+ url: "git+https://github.com/digdir/designsystemet.git"
3348
+ },
3349
+ homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
3350
+ license: "MIT",
3351
+ type: "module",
3352
+ main: "./dist/src/index.js",
3353
+ files: [
3354
+ "./dist/**"
3355
+ ],
3356
+ bin: "dist/bin/designsystemet.js",
3357
+ exports: {
3358
+ ".": {
3359
+ import: "./dist/src/index.js"
3360
+ },
3361
+ "./color": {
3362
+ import: "./dist/src/colors/index.js"
3363
+ },
3364
+ "./tokens": {
3365
+ import: "./dist/src/tokens/index.js"
3366
+ }
3367
+ },
3368
+ publishConfig: {
3369
+ access: "public"
3370
+ },
3371
+ scripts: {
3372
+ designsystemet: "tsx ./bin/designsystemet.ts",
3373
+ "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3374
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3375
+ build: "tsup && yarn build:types && yarn build:json-schema",
3376
+ "build:types": "tsc --emitDeclarationOnly --declaration",
3377
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3378
+ types: "tsc --noEmit",
3379
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
3380
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
3381
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
3382
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
3383
+ "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
3384
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
3385
+ test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
3386
+ "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
3387
+ "update:template": "tsx ./src/scripts/update-template.ts",
3388
+ "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3389
+ verify: "yarn test && yarn update:template && yarn update:design-tokens"
3390
+ },
3391
+ dependencies: {
3392
+ "@commander-js/extra-typings": "^13.1.0",
3393
+ "@tokens-studio/sd-transforms": "1.2.12",
3394
+ "apca-w3": "^0.1.9",
3395
+ chalk: "^5.4.1",
3396
+ "change-case": "^5.4.4",
3397
+ "chroma-js": "^3.1.2",
3398
+ commander: "^13.1.0",
3399
+ "fast-glob": "^3.3.3",
3400
+ hsluv: "^1.0.1",
3401
+ "object-hash": "^3.0.0",
3402
+ postcss: "^8.5.3",
3403
+ ramda: "^0.30.1",
3404
+ "style-dictionary": "^4.3.3",
3405
+ zod: "^3.24.2",
3406
+ "zod-validation-error": "^3.4.0"
3407
+ },
3408
+ devDependencies: {
3409
+ "@types/apca-w3": "^0.1.3",
3410
+ "@types/chroma-js": "^3.1.1",
3411
+ "@types/fs-extra": "^11.0.4",
3412
+ "@types/glob": "^8.1.0",
3413
+ "@types/jscodeshift": "^0.12.0",
3414
+ "@types/node": "^22.14.0",
3415
+ "@types/object-hash": "^3.0.6",
3416
+ "@types/ramda": "^0.30.2",
3417
+ "fs-extra": "^11.3.0",
3418
+ "ts-toolbelt": "^9.6.0",
3419
+ tslib: "^2.8.1",
3420
+ tsup: "^8.4.0",
3421
+ tsx: "^4.19.3",
3422
+ typescript: "^5.8.2",
3423
+ "zod-to-json-schema": "^3.24.5"
3424
+ }
3446
3425
  };
3447
- var createThemeCSSFiles = (processedBuilds) => {
3426
+
3427
+ // src/tokens/process/theme.ts
3428
+ var defaultFileHeader = `build: v${package_default.version}`;
3429
+ var createThemeCSSFiles = ({
3430
+ processedBuilds,
3431
+ fileHeader: fileHeader2 = defaultFileHeader
3432
+ }) => {
3448
3433
  const groupedByTheme = {};
3449
3434
  for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
3450
3435
  for (const buildResult of buildResults) {
3451
- const previous = groupedByTheme[buildResult.permutation.theme] ?? [];
3452
- groupedByTheme[buildResult.permutation.theme] = R19.concat(previous, buildResult.formatted);
3436
+ const themeName = buildResult.permutation.theme;
3437
+ const newOutputs = buildResult.formatted;
3438
+ if (R19.isNotEmpty(newOutputs)) {
3439
+ const currentOutputs = groupedByTheme[themeName] ?? [];
3440
+ groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
3441
+ }
3453
3442
  }
3454
3443
  }
3455
3444
  const sortOrder = [
@@ -3488,7 +3477,9 @@ order may change due to nondeterminism.`.trim()
3488
3477
 
3489
3478
  @layer ds.theme, ds.base, ds.utilities, ds.components;
3490
3479
 
3491
- /* This file is generated by ${package_default.name}@${package_default.version} */
3480
+ /*
3481
+ ${fileHeader2}
3482
+ */
3492
3483
 
3493
3484
  `;
3494
3485
  const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
@@ -3506,8 +3497,32 @@ order may change due to nondeterminism.`.trim()
3506
3497
  }));
3507
3498
  return themeCSSFiles;
3508
3499
  };
3500
+
3501
+ // src/tokens/format.ts
3502
+ var formatTokens = async (options) => {
3503
+ const processedBuilds = await processPlatform({
3504
+ process: "format",
3505
+ ...options
3506
+ });
3507
+ return processedBuilds;
3508
+ };
3509
+ var formatTheme = async (themeConfig) => {
3510
+ const { tokenSets } = await createTokens(themeConfig);
3511
+ const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3512
+ const processedBuilds = await formatTokens({
3513
+ tokenSets,
3514
+ $themes,
3515
+ verbose: false,
3516
+ preview: false
3517
+ });
3518
+ return processedBuilds;
3519
+ };
3520
+ var formatThemeCSS = async (themeConfig) => {
3521
+ const processedBuilds = await formatTheme(themeConfig);
3522
+ const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
3523
+ return R20.head(themeCSSFiles)?.output ?? "";
3524
+ };
3509
3525
  export {
3510
- createThemeCSSFiles,
3511
3526
  formatTheme,
3512
3527
  formatThemeCSS,
3513
3528
  formatTokens
@@ -2087,98 +2087,7 @@ var createTokens = async (opts) => {
2087
2087
  };
2088
2088
 
2089
2089
  // src/tokens/format.ts
2090
- import * as R19 from "ramda";
2091
- import chalk3 from "chalk";
2092
-
2093
- // package.json
2094
- var package_default = {
2095
- name: "@digdir/designsystemet",
2096
- version: "1.0.4",
2097
- description: "CLI for Designsystemet",
2098
- author: "Designsystemet team",
2099
- engines: {
2100
- node: ">=22.14.0"
2101
- },
2102
- repository: {
2103
- type: "git",
2104
- url: "git+https://github.com/digdir/designsystemet.git"
2105
- },
2106
- homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
2107
- license: "MIT",
2108
- type: "module",
2109
- main: "./dist/src/index.js",
2110
- files: [
2111
- "./dist/**"
2112
- ],
2113
- bin: "dist/bin/designsystemet.js",
2114
- exports: {
2115
- ".": {
2116
- import: "./dist/src/index.js"
2117
- },
2118
- "./color": {
2119
- import: "./dist/src/colors/index.js"
2120
- },
2121
- "./tokens": {
2122
- import: "./dist/src/tokens/index.js"
2123
- }
2124
- },
2125
- publishConfig: {
2126
- access: "public"
2127
- },
2128
- scripts: {
2129
- designsystemet: "tsx ./bin/designsystemet.ts",
2130
- "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2131
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2132
- build: "tsup && yarn build:types && yarn build:json-schema",
2133
- "build:types": "tsc --emitDeclarationOnly --declaration",
2134
- "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
2135
- types: "tsc --noEmit",
2136
- "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
2137
- "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
2138
- "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
2139
- "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
2140
- "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
2141
- test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
2142
- "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
2143
- "update:template": "tsx ./src/scripts/update-template.ts",
2144
- "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
2145
- verify: "yarn test && yarn update:template && yarn update:design-tokens"
2146
- },
2147
- dependencies: {
2148
- "@commander-js/extra-typings": "^13.1.0",
2149
- "@tokens-studio/sd-transforms": "1.2.12",
2150
- "apca-w3": "^0.1.9",
2151
- chalk: "^5.4.1",
2152
- "change-case": "^5.4.4",
2153
- "chroma-js": "^3.1.2",
2154
- commander: "^13.1.0",
2155
- "fast-glob": "^3.3.3",
2156
- hsluv: "^1.0.1",
2157
- "object-hash": "^3.0.0",
2158
- postcss: "^8.5.3",
2159
- ramda: "^0.30.1",
2160
- "style-dictionary": "^4.3.3",
2161
- zod: "^3.24.2",
2162
- "zod-validation-error": "^3.4.0"
2163
- },
2164
- devDependencies: {
2165
- "@types/apca-w3": "^0.1.3",
2166
- "@types/chroma-js": "^3.1.1",
2167
- "@types/fs-extra": "^11.0.4",
2168
- "@types/glob": "^8.1.0",
2169
- "@types/jscodeshift": "^0.12.0",
2170
- "@types/node": "^22.14.0",
2171
- "@types/object-hash": "^3.0.6",
2172
- "@types/ramda": "^0.30.2",
2173
- "fs-extra": "^11.3.0",
2174
- "ts-toolbelt": "^9.6.0",
2175
- tslib: "^2.8.1",
2176
- tsup: "^8.4.0",
2177
- tsx: "^4.19.3",
2178
- typescript: "^5.8.2",
2179
- "zod-to-json-schema": "^3.24.5"
2180
- }
2181
- };
2090
+ import * as R20 from "ramda";
2182
2091
 
2183
2092
  // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
2184
2093
  var BoxShadowTypes;
@@ -3334,7 +3243,7 @@ var buildConfigs = {
3334
3243
  // },
3335
3244
  };
3336
3245
  async function processPlatform(options) {
3337
- const { dry, process, $themes } = options;
3246
+ const { process, $themes } = options;
3338
3247
  const platform = "css";
3339
3248
  const tokenSets = process === "format" ? options.tokenSets : void 0;
3340
3249
  const tokensDir = process === "build" ? options.tokensDir : void 0;
@@ -3435,36 +3344,116 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
3435
3344
  return typeDeclaration;
3436
3345
  }
3437
3346
 
3438
- // src/tokens/format.ts
3439
- var formatTokens = async (options) => {
3440
- const processedBuilds = await processPlatform({
3441
- process: "format",
3442
- ...options
3443
- });
3444
- return processedBuilds;
3445
- };
3446
- var formatTheme = async (themeConfig) => {
3447
- const { tokenSets } = await createTokens(themeConfig);
3448
- const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3449
- const processedBuilds = await formatTokens({
3450
- tokenSets,
3451
- $themes,
3452
- verbose: false,
3453
- preview: false
3454
- });
3455
- return processedBuilds;
3456
- };
3457
- var formatThemeCSS = async (themeConfig) => {
3458
- const processedBuilds = await formatTheme(themeConfig);
3459
- const themeCSSFiles = createThemeCSSFiles(processedBuilds);
3460
- return R19.head(themeCSSFiles)?.output ?? "";
3347
+ // src/tokens/process/theme.ts
3348
+ import * as R19 from "ramda";
3349
+ import chalk3 from "chalk";
3350
+
3351
+ // package.json
3352
+ var package_default = {
3353
+ name: "@digdir/designsystemet",
3354
+ version: "1.0.5",
3355
+ description: "CLI for Designsystemet",
3356
+ author: "Designsystemet team",
3357
+ engines: {
3358
+ node: ">=22.14.0"
3359
+ },
3360
+ repository: {
3361
+ type: "git",
3362
+ url: "git+https://github.com/digdir/designsystemet.git"
3363
+ },
3364
+ homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
3365
+ license: "MIT",
3366
+ type: "module",
3367
+ main: "./dist/src/index.js",
3368
+ files: [
3369
+ "./dist/**"
3370
+ ],
3371
+ bin: "dist/bin/designsystemet.js",
3372
+ exports: {
3373
+ ".": {
3374
+ import: "./dist/src/index.js"
3375
+ },
3376
+ "./color": {
3377
+ import: "./dist/src/colors/index.js"
3378
+ },
3379
+ "./tokens": {
3380
+ import: "./dist/src/tokens/index.js"
3381
+ }
3382
+ },
3383
+ publishConfig: {
3384
+ access: "public"
3385
+ },
3386
+ scripts: {
3387
+ designsystemet: "tsx ./bin/designsystemet.ts",
3388
+ "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3389
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3390
+ build: "tsup && yarn build:types && yarn build:json-schema",
3391
+ "build:types": "tsc --emitDeclarationOnly --declaration",
3392
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3393
+ types: "tsc --noEmit",
3394
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
3395
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
3396
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
3397
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
3398
+ "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
3399
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
3400
+ test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
3401
+ "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
3402
+ "update:template": "tsx ./src/scripts/update-template.ts",
3403
+ "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3404
+ verify: "yarn test && yarn update:template && yarn update:design-tokens"
3405
+ },
3406
+ dependencies: {
3407
+ "@commander-js/extra-typings": "^13.1.0",
3408
+ "@tokens-studio/sd-transforms": "1.2.12",
3409
+ "apca-w3": "^0.1.9",
3410
+ chalk: "^5.4.1",
3411
+ "change-case": "^5.4.4",
3412
+ "chroma-js": "^3.1.2",
3413
+ commander: "^13.1.0",
3414
+ "fast-glob": "^3.3.3",
3415
+ hsluv: "^1.0.1",
3416
+ "object-hash": "^3.0.0",
3417
+ postcss: "^8.5.3",
3418
+ ramda: "^0.30.1",
3419
+ "style-dictionary": "^4.3.3",
3420
+ zod: "^3.24.2",
3421
+ "zod-validation-error": "^3.4.0"
3422
+ },
3423
+ devDependencies: {
3424
+ "@types/apca-w3": "^0.1.3",
3425
+ "@types/chroma-js": "^3.1.1",
3426
+ "@types/fs-extra": "^11.0.4",
3427
+ "@types/glob": "^8.1.0",
3428
+ "@types/jscodeshift": "^0.12.0",
3429
+ "@types/node": "^22.14.0",
3430
+ "@types/object-hash": "^3.0.6",
3431
+ "@types/ramda": "^0.30.2",
3432
+ "fs-extra": "^11.3.0",
3433
+ "ts-toolbelt": "^9.6.0",
3434
+ tslib: "^2.8.1",
3435
+ tsup: "^8.4.0",
3436
+ tsx: "^4.19.3",
3437
+ typescript: "^5.8.2",
3438
+ "zod-to-json-schema": "^3.24.5"
3439
+ }
3461
3440
  };
3462
- var createThemeCSSFiles = (processedBuilds) => {
3441
+
3442
+ // src/tokens/process/theme.ts
3443
+ var defaultFileHeader = `build: v${package_default.version}`;
3444
+ var createThemeCSSFiles = ({
3445
+ processedBuilds,
3446
+ fileHeader: fileHeader2 = defaultFileHeader
3447
+ }) => {
3463
3448
  const groupedByTheme = {};
3464
3449
  for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
3465
3450
  for (const buildResult of buildResults) {
3466
- const previous = groupedByTheme[buildResult.permutation.theme] ?? [];
3467
- groupedByTheme[buildResult.permutation.theme] = R19.concat(previous, buildResult.formatted);
3451
+ const themeName = buildResult.permutation.theme;
3452
+ const newOutputs = buildResult.formatted;
3453
+ if (R19.isNotEmpty(newOutputs)) {
3454
+ const currentOutputs = groupedByTheme[themeName] ?? [];
3455
+ groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
3456
+ }
3468
3457
  }
3469
3458
  }
3470
3459
  const sortOrder = [
@@ -3503,7 +3492,9 @@ order may change due to nondeterminism.`.trim()
3503
3492
 
3504
3493
  @layer ds.theme, ds.base, ds.utilities, ds.components;
3505
3494
 
3506
- /* This file is generated by ${package_default.name}@${package_default.version} */
3495
+ /*
3496
+ ${fileHeader2}
3497
+ */
3507
3498
 
3508
3499
  `;
3509
3500
  const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
@@ -3521,6 +3512,31 @@ order may change due to nondeterminism.`.trim()
3521
3512
  }));
3522
3513
  return themeCSSFiles;
3523
3514
  };
3515
+
3516
+ // src/tokens/format.ts
3517
+ var formatTokens = async (options) => {
3518
+ const processedBuilds = await processPlatform({
3519
+ process: "format",
3520
+ ...options
3521
+ });
3522
+ return processedBuilds;
3523
+ };
3524
+ var formatTheme = async (themeConfig) => {
3525
+ const { tokenSets } = await createTokens(themeConfig);
3526
+ const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3527
+ const processedBuilds = await formatTokens({
3528
+ tokenSets,
3529
+ $themes,
3530
+ verbose: false,
3531
+ preview: false
3532
+ });
3533
+ return processedBuilds;
3534
+ };
3535
+ var formatThemeCSS = async (themeConfig) => {
3536
+ const processedBuilds = await formatTheme(themeConfig);
3537
+ const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
3538
+ return R20.head(themeCSSFiles)?.output ?? "";
3539
+ };
3524
3540
  export {
3525
3541
  cliOptions,
3526
3542
  createTokens,