@digdir/designsystemet 1.12.1 → 1.13.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.
Files changed (43) hide show
  1. package/dist/bin/config.d.ts +4 -4
  2. package/dist/bin/config.d.ts.map +1 -1
  3. package/dist/bin/config.js +133 -28
  4. package/dist/bin/designsystemet.d.ts.map +1 -1
  5. package/dist/bin/designsystemet.js +208 -149
  6. package/dist/src/config.d.ts +2 -2
  7. package/dist/src/config.d.ts.map +1 -1
  8. package/dist/src/config.js +4 -4
  9. package/dist/src/index.js +5 -5
  10. package/dist/src/migrations/beta-to-v1.js +122 -16
  11. package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
  12. package/dist/src/migrations/codemods/css/run.js +122 -16
  13. package/dist/src/migrations/color-rename-next49.js +122 -16
  14. package/dist/src/migrations/index.js +122 -16
  15. package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -1
  16. package/dist/src/scripts/update-preview-tokens.js +122 -45
  17. package/dist/src/tokens/build.d.ts +2 -1
  18. package/dist/src/tokens/build.d.ts.map +1 -1
  19. package/dist/src/tokens/build.js +128 -62
  20. package/dist/src/tokens/create/files.d.ts +10 -0
  21. package/dist/src/tokens/create/files.d.ts.map +1 -0
  22. package/dist/src/tokens/create/{write.js → files.js} +143 -61
  23. package/dist/src/tokens/create/generators/$designsystemet.js +5 -5
  24. package/dist/src/tokens/format.js +5 -5
  25. package/dist/src/tokens/generate-config.d.ts +0 -1
  26. package/dist/src/tokens/generate-config.d.ts.map +1 -1
  27. package/dist/src/tokens/generate-config.js +145 -26
  28. package/dist/src/tokens/index.js +5 -5
  29. package/dist/src/tokens/process/output/declarations.js +5 -5
  30. package/dist/src/tokens/process/output/theme.js +5 -5
  31. package/dist/src/tokens/process/platform.d.ts +0 -4
  32. package/dist/src/tokens/process/platform.d.ts.map +1 -1
  33. package/dist/src/tokens/types.d.ts +2 -0
  34. package/dist/src/tokens/types.d.ts.map +1 -1
  35. package/dist/src/utils/filesystem.d.ts +40 -0
  36. package/dist/src/utils/filesystem.d.ts.map +1 -0
  37. package/dist/src/utils/filesystem.js +127 -0
  38. package/package.json +6 -6
  39. package/dist/src/tokens/create/write.d.ts +0 -12
  40. package/dist/src/tokens/create/write.d.ts.map +0 -1
  41. package/dist/src/utils.d.ts +0 -18
  42. package/dist/src/utils.d.ts.map +0 -1
  43. package/dist/src/utils.js +0 -70
@@ -1,56 +1,141 @@
1
- // src/tokens/create/write.ts
2
- import path from "path";
1
+ // src/tokens/create/files.ts
2
+ import path2 from "path";
3
3
  import pc2 from "picocolors";
4
4
  import * as R from "ramda";
5
5
 
6
- // src/utils.ts
6
+ // src/utils/filesystem.ts
7
7
  import fs from "fs/promises";
8
+ import path from "path";
8
9
  import pc from "picocolors";
9
- var mkdir = async (dir, dry) => {
10
- if (dry) {
11
- console.log(`${pc.blue("mkdir")} ${dir}`);
12
- return Promise.resolve();
13
- }
14
- const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
15
- if (exists) {
16
- return Promise.resolve();
17
- }
18
- return fs.mkdir(dir, { recursive: true });
19
- };
20
- var writeFile = async (path2, data, dry) => {
21
- if (dry) {
22
- console.log(`${pc.blue("writeFile")} ${path2}`);
23
- return Promise.resolve();
24
- }
25
- return fs.writeFile(path2, data, { encoding: "utf-8" }).catch((error) => {
26
- console.error(pc.red(`Error writing file: ${path2}`));
27
- console.error(pc.red(error));
28
- throw error;
29
- });
30
- };
31
- var readFile = async (path2, dry, allowFileNotFound) => {
32
- if (dry) {
33
- console.log(`${pc.blue("readFile")} ${path2}`);
34
- return Promise.resolve("");
35
- }
36
- try {
37
- return await fs.readFile(path2, "utf-8");
38
- } catch (error) {
39
- if (allowFileNotFound && error.code === "ENOENT") {
40
- return "";
10
+ var FileSystem = class {
11
+ isInitialized = false;
12
+ dry = false;
13
+ verbose = false;
14
+ /** Default working directory is where the process was started */
15
+ workingDir = process.cwd();
16
+ outDir = this.workingDir;
17
+ /** Initialize the file system */
18
+ init({ dry, outdir, verbose }) {
19
+ if (this.isInitialized) {
20
+ console.warn(pc.yellow("FileSystem is already initialized. Ignoring subsequent init call."));
21
+ return;
22
+ }
23
+ if (dry) {
24
+ console.log(pc.blue("Initializing FileSystem in dry-run mode. No files will be written."));
41
25
  }
42
- throw error;
26
+ this.dry = dry ?? false;
27
+ this.verbose = verbose ?? false;
28
+ this.outDir = outdir ? path.isAbsolute(outdir) ? outdir : path.join(this.workingDir, outdir) : this.workingDir;
29
+ if (this.verbose) {
30
+ console.log(
31
+ `FileSystem initialized with workingDir: ${pc.green(this.workingDir)}, outDir: ${pc.green(this.outDir)}`
32
+ );
33
+ }
34
+ this.isInitialized = true;
43
35
  }
36
+ /**
37
+ * Creates a directory if it does not already exist.
38
+ *
39
+ * @param dir - The path of the directory to create.
40
+ *
41
+ * @returns A promise that resolves when the operation is complete.
42
+ * If the directory already exists or `dry` is `true`, the promise resolves immediately.
43
+ */
44
+ mkdir = async (dir) => {
45
+ if (this.dry) {
46
+ console.log(`${pc.blue("mkdir")} ${dir}`);
47
+ return Promise.resolve();
48
+ }
49
+ const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
50
+ if (exists) {
51
+ return Promise.resolve();
52
+ }
53
+ return fs.mkdir(dir, { recursive: true });
54
+ };
55
+ writeFile = async (path3, data) => {
56
+ if (this.dry) {
57
+ console.log(`${pc.blue("writeFile")} ${path3}`);
58
+ return Promise.resolve();
59
+ }
60
+ return fs.writeFile(path3, data, { encoding: "utf-8" }).catch((error) => {
61
+ console.error(pc.red(`Error writing file: ${path3}`));
62
+ console.error(pc.red(error));
63
+ throw error;
64
+ });
65
+ };
66
+ cp = async (src, dest, filter2) => {
67
+ if (this.dry) {
68
+ console.log(`${pc.blue("cp")} ${src} ${dest}`);
69
+ return Promise.resolve();
70
+ }
71
+ return fs.cp(src, dest, { recursive: true, filter: filter2 });
72
+ };
73
+ copyFile = async (src, dest) => {
74
+ if (this.dry) {
75
+ console.log(`${pc.blue("copyFile")} ${src} to ${dest}`);
76
+ return Promise.resolve();
77
+ }
78
+ return fs.copyFile(src, dest);
79
+ };
80
+ cleanDir = async (dir) => {
81
+ if (this.dry) {
82
+ console.log(`${pc.blue("cleanDir")} ${dir}`);
83
+ return Promise.resolve();
84
+ }
85
+ console.log(`
86
+ \u{1F525} Cleaning dir ${pc.red(`${dir.trim()}`)} `);
87
+ return fs.rm(dir, { recursive: true, force: true });
88
+ };
89
+ readFile = async (path3, allowFileNotFound) => {
90
+ if (this.dry) {
91
+ console.log(`${pc.blue("readFile")} ${path3}`);
92
+ }
93
+ try {
94
+ return await fs.readFile(path3, "utf-8");
95
+ } catch (error) {
96
+ if (allowFileNotFound && error.code === "ENOENT") {
97
+ return "";
98
+ }
99
+ throw error;
100
+ }
101
+ };
102
+ readdir = async (path3) => {
103
+ if (this.dry) {
104
+ console.log(`${pc.blue("readdir")} ${path3}`);
105
+ }
106
+ try {
107
+ return await fs.readdir(path3);
108
+ } catch (error) {
109
+ if (error.code === "ENOENT") {
110
+ return [];
111
+ }
112
+ throw error;
113
+ }
114
+ };
115
+ writeFiles = async (files, outDir, log) => {
116
+ for (const { destination: filename, output } of files) {
117
+ if (filename) {
118
+ const filePath = path.join(outDir, filename);
119
+ const fileDir = path.dirname(filePath);
120
+ if (log) {
121
+ console.log(filename);
122
+ }
123
+ await this.mkdir(fileDir);
124
+ await this.writeFile(filePath, output);
125
+ }
126
+ }
127
+ };
44
128
  };
129
+ var dsfs = new FileSystem();
45
130
 
46
131
  // package.json
47
132
  var package_default = {
48
133
  name: "@digdir/designsystemet",
49
- version: "1.12.1",
134
+ version: "1.13.0",
50
135
  description: "CLI for Designsystemet",
51
136
  author: "Designsystemet team",
52
137
  engines: {
53
- node: ">=20 <25"
138
+ node: ">=20.20.1"
54
139
  },
55
140
  repository: {
56
141
  type: "git",
@@ -114,16 +199,16 @@ var package_default = {
114
199
  hsluv: "^1.0.1",
115
200
  "object-hash": "^3.0.0",
116
201
  picocolors: "^1.1.1",
117
- postcss: "^8.5.6",
202
+ postcss: "^8.5.8",
118
203
  ramda: "^0.32.0",
119
- "style-dictionary": "^5.3.0",
204
+ "style-dictionary": "^5.3.3",
120
205
  zod: "^4.3.6",
121
206
  "zod-validation-error": "^5.0.0"
122
207
  },
123
208
  devDependencies: {
124
209
  "@tokens-studio/types": "0.5.2",
125
210
  "@types/chroma-js": "^3.1.2",
126
- "@types/node": "^24.10.13",
211
+ "@types/node": "^24.12.0",
127
212
  "@types/object-hash": "^3.0.6",
128
213
  "@types/ramda": "^0.31.1",
129
214
  tsup: "^8.5.1",
@@ -490,24 +575,22 @@ function generateTypographyGroup(themes) {
490
575
  ];
491
576
  }
492
577
 
493
- // src/tokens/create/write.ts
578
+ // src/tokens/create/files.ts
494
579
  var stringify = (data) => JSON.stringify(data, null, 2);
495
- var writeTokens = async (options) => {
580
+ var createTokenFiles = async (options) => {
496
581
  const {
497
582
  outDir,
498
583
  tokenSets,
499
- theme: { name: themeName, colors },
500
- dry
584
+ theme: { name: themeName, colors }
501
585
  } = options;
502
- const targetDir = path.resolve(process.cwd(), String(outDir));
503
- const $themesPath = path.join(targetDir, "$themes.json");
504
- const $metadataPath = path.join(targetDir, "$metadata.json");
505
- const $designsystemetPath = path.join(targetDir, "$designsystemet.jsonc");
586
+ const $themesPath = "$themes.json";
587
+ const $metadataPath = "$metadata.json";
588
+ const $designsystemetPath = "$designsystemet.jsonc";
506
589
  let themeObjects = [];
507
590
  const sizeModes = ["small", "medium", "large"];
508
- await mkdir(targetDir, dry);
591
+ await dsfs.mkdir(outDir);
509
592
  try {
510
- const $themes2 = await readFile($themesPath);
593
+ const $themes2 = await dsfs.readFile(path2.join(outDir, $themesPath));
511
594
  if ($themes2) {
512
595
  themeObjects = JSON.parse($themes2);
513
596
  }
@@ -526,18 +609,17 @@ Themes: ${pc2.blue(themes.join(", "))}`);
526
609
  const $themes = await generate$Themes(["dark", "light"], themes, colors, sizeModes);
527
610
  const $metadata = generate$Metadata(["dark", "light"], themes, colors, sizeModes);
528
611
  const $designsystemet = generate$Designsystemet();
529
- await writeFile($themesPath, stringify($themes), dry);
530
- await writeFile($metadataPath, stringify($metadata), dry);
531
- await writeFile($designsystemetPath, stringify($designsystemet), dry);
612
+ const files = [];
613
+ files.push({ destination: $themesPath, output: stringify($themes) });
614
+ files.push({ destination: $metadataPath, output: stringify($metadata) });
615
+ files.push({ destination: $designsystemetPath, output: stringify($designsystemet) });
532
616
  for (const [set, tokens] of tokenSets) {
533
- const fileDir = path.join(targetDir, path.dirname(set));
534
- await mkdir(fileDir, dry);
535
- const filePath = path.join(targetDir, `${set}.json`);
536
- await writeFile(filePath, stringify(tokens), dry);
617
+ const filePath = `${set}.json`;
618
+ files.push({ destination: filePath, output: stringify(tokens) });
537
619
  }
538
- console.log(`Finished creating Designsystem design tokens in ${pc2.green(outDir)} for theme ${pc2.blue(themeName)}`);
620
+ return files;
539
621
  };
540
622
  export {
541
- stringify,
542
- writeTokens
623
+ createTokenFiles,
624
+ stringify
543
625
  };
@@ -1,11 +1,11 @@
1
1
  // package.json
2
2
  var package_default = {
3
3
  name: "@digdir/designsystemet",
4
- version: "1.12.1",
4
+ version: "1.13.0",
5
5
  description: "CLI for Designsystemet",
6
6
  author: "Designsystemet team",
7
7
  engines: {
8
- node: ">=20 <25"
8
+ node: ">=20.20.1"
9
9
  },
10
10
  repository: {
11
11
  type: "git",
@@ -69,16 +69,16 @@ var package_default = {
69
69
  hsluv: "^1.0.1",
70
70
  "object-hash": "^3.0.0",
71
71
  picocolors: "^1.1.1",
72
- postcss: "^8.5.6",
72
+ postcss: "^8.5.8",
73
73
  ramda: "^0.32.0",
74
- "style-dictionary": "^5.3.0",
74
+ "style-dictionary": "^5.3.3",
75
75
  zod: "^4.3.6",
76
76
  "zod-validation-error": "^5.0.0"
77
77
  },
78
78
  devDependencies: {
79
79
  "@tokens-studio/types": "0.5.2",
80
80
  "@types/chroma-js": "^3.1.2",
81
- "@types/node": "^24.10.13",
81
+ "@types/node": "^24.12.0",
82
82
  "@types/object-hash": "^3.0.6",
83
83
  "@types/ramda": "^0.31.1",
84
84
  tsup: "^8.5.1",
@@ -1910,11 +1910,11 @@ import * as R8 from "ramda";
1910
1910
  // package.json
1911
1911
  var package_default = {
1912
1912
  name: "@digdir/designsystemet",
1913
- version: "1.12.1",
1913
+ version: "1.13.0",
1914
1914
  description: "CLI for Designsystemet",
1915
1915
  author: "Designsystemet team",
1916
1916
  engines: {
1917
- node: ">=20 <25"
1917
+ node: ">=20.20.1"
1918
1918
  },
1919
1919
  repository: {
1920
1920
  type: "git",
@@ -1978,16 +1978,16 @@ var package_default = {
1978
1978
  hsluv: "^1.0.1",
1979
1979
  "object-hash": "^3.0.0",
1980
1980
  picocolors: "^1.1.1",
1981
- postcss: "^8.5.6",
1981
+ postcss: "^8.5.8",
1982
1982
  ramda: "^0.32.0",
1983
- "style-dictionary": "^5.3.0",
1983
+ "style-dictionary": "^5.3.3",
1984
1984
  zod: "^4.3.6",
1985
1985
  "zod-validation-error": "^5.0.0"
1986
1986
  },
1987
1987
  devDependencies: {
1988
1988
  "@tokens-studio/types": "0.5.2",
1989
1989
  "@types/chroma-js": "^3.1.2",
1990
- "@types/node": "^24.10.13",
1990
+ "@types/node": "^24.12.0",
1991
1991
  "@types/object-hash": "^3.0.6",
1992
1992
  "@types/ramda": "^0.31.1",
1993
1993
  tsup: "^8.5.1",
@@ -2,7 +2,6 @@ import type { CreateConfigSchema } from '../config.js';
2
2
  export type GenerateConfigOptions = {
3
3
  tokensDir: string;
4
4
  outFile?: string;
5
- dry?: boolean;
6
5
  };
7
6
  /**
8
7
  * Generates a config file from existing design tokens
@@ -1 +1 @@
1
- {"version":3,"file":"generate-config.d.ts","sourceRoot":"","sources":["../../../src/tokens/generate-config.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA4MvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAoF1G"}
1
+ {"version":3,"file":"generate-config.d.ts","sourceRoot":"","sources":["../../../src/tokens/generate-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA6MvD,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6E1G"}
@@ -1,10 +1,136 @@
1
1
  // src/tokens/generate-config.ts
2
+ import path2 from "path";
3
+ import pc2 from "picocolors";
4
+
5
+ // src/utils/filesystem.ts
2
6
  import fs from "fs/promises";
3
7
  import path from "path";
4
8
  import pc from "picocolors";
9
+ var FileSystem = class {
10
+ isInitialized = false;
11
+ dry = false;
12
+ verbose = false;
13
+ /** Default working directory is where the process was started */
14
+ workingDir = process.cwd();
15
+ outDir = this.workingDir;
16
+ /** Initialize the file system */
17
+ init({ dry, outdir, verbose }) {
18
+ if (this.isInitialized) {
19
+ console.warn(pc.yellow("FileSystem is already initialized. Ignoring subsequent init call."));
20
+ return;
21
+ }
22
+ if (dry) {
23
+ console.log(pc.blue("Initializing FileSystem in dry-run mode. No files will be written."));
24
+ }
25
+ this.dry = dry ?? false;
26
+ this.verbose = verbose ?? false;
27
+ this.outDir = outdir ? path.isAbsolute(outdir) ? outdir : path.join(this.workingDir, outdir) : this.workingDir;
28
+ if (this.verbose) {
29
+ console.log(
30
+ `FileSystem initialized with workingDir: ${pc.green(this.workingDir)}, outDir: ${pc.green(this.outDir)}`
31
+ );
32
+ }
33
+ this.isInitialized = true;
34
+ }
35
+ /**
36
+ * Creates a directory if it does not already exist.
37
+ *
38
+ * @param dir - The path of the directory to create.
39
+ *
40
+ * @returns A promise that resolves when the operation is complete.
41
+ * If the directory already exists or `dry` is `true`, the promise resolves immediately.
42
+ */
43
+ mkdir = async (dir) => {
44
+ if (this.dry) {
45
+ console.log(`${pc.blue("mkdir")} ${dir}`);
46
+ return Promise.resolve();
47
+ }
48
+ const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
49
+ if (exists) {
50
+ return Promise.resolve();
51
+ }
52
+ return fs.mkdir(dir, { recursive: true });
53
+ };
54
+ writeFile = async (path3, data) => {
55
+ if (this.dry) {
56
+ console.log(`${pc.blue("writeFile")} ${path3}`);
57
+ return Promise.resolve();
58
+ }
59
+ return fs.writeFile(path3, data, { encoding: "utf-8" }).catch((error) => {
60
+ console.error(pc.red(`Error writing file: ${path3}`));
61
+ console.error(pc.red(error));
62
+ throw error;
63
+ });
64
+ };
65
+ cp = async (src, dest, filter) => {
66
+ if (this.dry) {
67
+ console.log(`${pc.blue("cp")} ${src} ${dest}`);
68
+ return Promise.resolve();
69
+ }
70
+ return fs.cp(src, dest, { recursive: true, filter });
71
+ };
72
+ copyFile = async (src, dest) => {
73
+ if (this.dry) {
74
+ console.log(`${pc.blue("copyFile")} ${src} to ${dest}`);
75
+ return Promise.resolve();
76
+ }
77
+ return fs.copyFile(src, dest);
78
+ };
79
+ cleanDir = async (dir) => {
80
+ if (this.dry) {
81
+ console.log(`${pc.blue("cleanDir")} ${dir}`);
82
+ return Promise.resolve();
83
+ }
84
+ console.log(`
85
+ \u{1F525} Cleaning dir ${pc.red(`${dir.trim()}`)} `);
86
+ return fs.rm(dir, { recursive: true, force: true });
87
+ };
88
+ readFile = async (path3, allowFileNotFound) => {
89
+ if (this.dry) {
90
+ console.log(`${pc.blue("readFile")} ${path3}`);
91
+ }
92
+ try {
93
+ return await fs.readFile(path3, "utf-8");
94
+ } catch (error) {
95
+ if (allowFileNotFound && error.code === "ENOENT") {
96
+ return "";
97
+ }
98
+ throw error;
99
+ }
100
+ };
101
+ readdir = async (path3) => {
102
+ if (this.dry) {
103
+ console.log(`${pc.blue("readdir")} ${path3}`);
104
+ }
105
+ try {
106
+ return await fs.readdir(path3);
107
+ } catch (error) {
108
+ if (error.code === "ENOENT") {
109
+ return [];
110
+ }
111
+ throw error;
112
+ }
113
+ };
114
+ writeFiles = async (files, outDir, log) => {
115
+ for (const { destination: filename, output } of files) {
116
+ if (filename) {
117
+ const filePath = path.join(outDir, filename);
118
+ const fileDir = path.dirname(filePath);
119
+ if (log) {
120
+ console.log(filename);
121
+ }
122
+ await this.mkdir(fileDir);
123
+ await this.writeFile(filePath, output);
124
+ }
125
+ }
126
+ };
127
+ };
128
+ var dsfs = new FileSystem();
129
+
130
+ // src/tokens/generate-config.ts
5
131
  async function readJsonFile(filePath) {
6
132
  try {
7
- const content = await fs.readFile(filePath, "utf-8");
133
+ const content = await dsfs.readFile(filePath);
8
134
  return JSON.parse(content);
9
135
  } catch (err) {
10
136
  throw new Error(`Failed to read token file at ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
@@ -20,21 +146,21 @@ function extractBaseColor(colorScale) {
20
146
  return null;
21
147
  }
22
148
  async function discoverThemes(tokensDir) {
23
- const lightModePath = path.join(tokensDir, "themes");
149
+ const lightModePath = path2.join(tokensDir, "themes");
24
150
  try {
25
- const files = await fs.readdir(lightModePath);
151
+ const files = await dsfs.readdir(lightModePath);
26
152
  const themes = files.filter((file) => file.endsWith(".json")).map((file) => file.replace(".json", ""));
27
153
  return themes;
28
154
  } catch {
29
- throw new Error(`Could not find themes. Make sure ${pc.blue(lightModePath)} exists and contains theme JSON files.`);
155
+ throw new Error(`Could not find themes. Make sure ${pc2.blue(lightModePath)} exists and contains theme JSON files.`);
30
156
  }
31
157
  }
32
158
  async function readThemeTokens(tokensDir, themeName) {
33
- const themePath = path.join(tokensDir, "primitives", "modes", "color-scheme", "light", `${themeName}.json`);
159
+ const themePath = path2.join(tokensDir, "primitives", "modes", "color-scheme", "light", `${themeName}.json`);
34
160
  return readJsonFile(themePath);
35
161
  }
36
162
  async function readThemeConfig(tokensDir, themeName) {
37
- const themeConfigPath = path.join(tokensDir, "themes", `${themeName}.json`);
163
+ const themeConfigPath = path2.join(tokensDir, "themes", `${themeName}.json`);
38
164
  try {
39
165
  return await readJsonFile(themeConfigPath);
40
166
  } catch {
@@ -68,7 +194,7 @@ function extractFontFamily(themeConfig) {
68
194
  return void 0;
69
195
  }
70
196
  async function readTypographyConfig(tokensDir, themeName) {
71
- const typographyConfigPath = path.join(
197
+ const typographyConfigPath = path2.join(
72
198
  tokensDir,
73
199
  "primitives",
74
200
  "modes",
@@ -128,33 +254,33 @@ function categorizeColors(themeTokens, themeName) {
128
254
  return { main, support, neutral };
129
255
  }
130
256
  async function generateConfigFromTokens(options) {
131
- const { tokensDir, dry = false } = options;
257
+ const { tokensDir } = options;
132
258
  console.log(`
133
- Reading tokens from ${pc.blue(tokensDir)}`);
259
+ Reading tokens from ${pc2.blue(tokensDir)}`);
134
260
  const themes = await discoverThemes(tokensDir);
135
261
  if (themes.length === 0) {
136
262
  throw new Error(`
137
- No themes found in ${pc.blue(tokensDir)}`);
263
+ No themes found in ${pc2.blue(tokensDir)}`);
138
264
  }
139
265
  console.log(`
140
- Found ${pc.green(String(themes.length))} theme(s): ${themes.map((t) => pc.cyan(t)).join(", ")}`);
266
+ Found ${pc2.green(String(themes.length))} theme(s): ${themes.map((t) => pc2.cyan(t)).join(", ")}`);
141
267
  const config = {
142
268
  outDir: tokensDir,
143
269
  themes: {}
144
270
  };
145
271
  for (const themeName of themes) {
146
272
  console.log(`
147
- Processing theme ${pc.cyan(themeName)}...`);
273
+ Processing theme ${pc2.cyan(themeName)}...`);
148
274
  const themeTokens = await readThemeTokens(tokensDir, themeName);
149
275
  const themeConfig = await readThemeConfig(tokensDir, themeName);
150
276
  const typographyConfig = await readTypographyConfig(tokensDir, themeName);
151
277
  const { main, support, neutral } = categorizeColors(themeTokens, themeName);
152
278
  if (Object.keys(main).length === 0) {
153
- console.warn(pc.yellow(`
279
+ console.warn(pc2.yellow(`
154
280
  Warning: No main colors found for theme ${themeName}`));
155
281
  }
156
282
  if (!neutral) {
157
- console.warn(pc.yellow(`
283
+ console.warn(pc2.yellow(`
158
284
  Warning: No neutral color found for theme ${themeName}`));
159
285
  continue;
160
286
  }
@@ -171,30 +297,23 @@ Warning: No neutral color found for theme ${themeName}`));
171
297
  };
172
298
  console.log(
173
299
  `
174
- \u2705 Main colors: ${Object.keys(main).map((c) => pc.cyan(c)).join(", ") || pc.dim("none")}`
300
+ \u2705 Main colors: ${Object.keys(main).map((c) => pc2.cyan(c)).join(", ") || pc2.dim("none")}`
175
301
  );
176
302
  console.log(
177
303
  `
178
- \u2705 Support colors: ${Object.keys(support).map((c) => pc.cyan(c)).join(", ") || pc.dim("none")}`
304
+ \u2705 Support colors: ${Object.keys(support).map((c) => pc2.cyan(c)).join(", ") || pc2.dim("none")}`
179
305
  );
180
306
  console.log(`
181
- \u2705 Neutral: ${pc.cyan(neutral)}`);
307
+ \u2705 Neutral: ${pc2.cyan(neutral)}`);
182
308
  if (borderRadius !== void 0) {
183
309
  console.log(`
184
- \u2705 Border radius: ${pc.cyan(String(borderRadius))}`);
310
+ \u2705 Border radius: ${pc2.cyan(String(borderRadius))}`);
185
311
  }
186
312
  if (fontFamily) {
187
313
  console.log(`
188
- \u2705 Font family: ${pc.cyan(fontFamily)}`);
314
+ \u2705 Font family: ${pc2.cyan(fontFamily)}`);
189
315
  }
190
316
  }
191
- if (!dry && options.outFile) {
192
- const configJson = JSON.stringify(config, null, 2);
193
- await fs.writeFile(options.outFile, configJson, "utf-8");
194
- console.log();
195
- console.log(`
196
- \u2705 Config file written to ${pc.blue(options.outFile)}`);
197
- }
198
317
  return config;
199
318
  }
200
319
  export {
@@ -1926,11 +1926,11 @@ import * as R8 from "ramda";
1926
1926
  // package.json
1927
1927
  var package_default = {
1928
1928
  name: "@digdir/designsystemet",
1929
- version: "1.12.1",
1929
+ version: "1.13.0",
1930
1930
  description: "CLI for Designsystemet",
1931
1931
  author: "Designsystemet team",
1932
1932
  engines: {
1933
- node: ">=20 <25"
1933
+ node: ">=20.20.1"
1934
1934
  },
1935
1935
  repository: {
1936
1936
  type: "git",
@@ -1994,16 +1994,16 @@ var package_default = {
1994
1994
  hsluv: "^1.0.1",
1995
1995
  "object-hash": "^3.0.0",
1996
1996
  picocolors: "^1.1.1",
1997
- postcss: "^8.5.6",
1997
+ postcss: "^8.5.8",
1998
1998
  ramda: "^0.32.0",
1999
- "style-dictionary": "^5.3.0",
1999
+ "style-dictionary": "^5.3.3",
2000
2000
  zod: "^4.3.6",
2001
2001
  "zod-validation-error": "^5.0.0"
2002
2002
  },
2003
2003
  devDependencies: {
2004
2004
  "@tokens-studio/types": "0.5.2",
2005
2005
  "@types/chroma-js": "^3.1.2",
2006
- "@types/node": "^24.10.13",
2006
+ "@types/node": "^24.12.0",
2007
2007
  "@types/object-hash": "^3.0.6",
2008
2008
  "@types/ramda": "^0.31.1",
2009
2009
  tsup: "^8.5.1",
@@ -4,11 +4,11 @@ import pc3 from "picocolors";
4
4
  // package.json
5
5
  var package_default = {
6
6
  name: "@digdir/designsystemet",
7
- version: "1.12.1",
7
+ version: "1.13.0",
8
8
  description: "CLI for Designsystemet",
9
9
  author: "Designsystemet team",
10
10
  engines: {
11
- node: ">=20 <25"
11
+ node: ">=20.20.1"
12
12
  },
13
13
  repository: {
14
14
  type: "git",
@@ -72,16 +72,16 @@ var package_default = {
72
72
  hsluv: "^1.0.1",
73
73
  "object-hash": "^3.0.0",
74
74
  picocolors: "^1.1.1",
75
- postcss: "^8.5.6",
75
+ postcss: "^8.5.8",
76
76
  ramda: "^0.32.0",
77
- "style-dictionary": "^5.3.0",
77
+ "style-dictionary": "^5.3.3",
78
78
  zod: "^4.3.6",
79
79
  "zod-validation-error": "^5.0.0"
80
80
  },
81
81
  devDependencies: {
82
82
  "@tokens-studio/types": "0.5.2",
83
83
  "@types/chroma-js": "^3.1.2",
84
- "@types/node": "^24.10.13",
84
+ "@types/node": "^24.12.0",
85
85
  "@types/object-hash": "^3.0.6",
86
86
  "@types/ramda": "^0.31.1",
87
87
  tsup: "^8.5.1",