@digdir/designsystemet 1.0.6 → 1.0.7

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.
@@ -0,0 +1,59 @@
1
+ {
2
+ "$schema": "../dist/config.schema.json",
3
+ "outDir": "./temp/digdir/design-tokens",
4
+ "clean": true,
5
+ "themes": {
6
+ "digdir": {
7
+ "colors": {
8
+ "main": {
9
+ "accent": "#0062BA"
10
+ },
11
+ "support": {
12
+ "brand1": "#F45F63",
13
+ "brand2": "#E5AA20",
14
+ "brand3": "#1E98F5"
15
+ },
16
+ "neutral": "#1E2B3C"
17
+ }
18
+ },
19
+ "altinn": {
20
+ "colors": {
21
+ "main": {
22
+ "accent": "#0062BA"
23
+ },
24
+ "support": {
25
+ "brand1": "#0162BA",
26
+ "brand2": "#3F3161",
27
+ "brand3": "#E02F4A"
28
+ },
29
+ "neutral": "#1E2B3C"
30
+ }
31
+ },
32
+ "uutilsynet": {
33
+ "colors": {
34
+ "main": {
35
+ "accent": "#0062BA"
36
+ },
37
+ "support": {
38
+ "brand1": "#5B60D1",
39
+ "brand2": "#FEA769",
40
+ "brand3": "#5DA290"
41
+ },
42
+ "neutral": "#1E2B3C"
43
+ }
44
+ },
45
+ "portal": {
46
+ "colors": {
47
+ "main": {
48
+ "accent": "#38628C"
49
+ },
50
+ "support": {
51
+ "brand1": "#D9ECFF",
52
+ "brand2": "#FFCA99",
53
+ "brand3": "#D96C79"
54
+ },
55
+ "neutral": "#203040"
56
+ }
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,45 @@
1
+ {
2
+ "$schema": "../dist/config.schema.json",
3
+ "outDir": "./temp/config/design-tokens",
4
+ "clean": true,
5
+ "themes": {
6
+ "some-org": {
7
+ "colors": {
8
+ "main": {
9
+ "dominant": "#0062BA",
10
+ "complimentary": "#94237C"
11
+ },
12
+ "support": {
13
+ "first": "#F45F63",
14
+ "second": "#E5AA20",
15
+ "third": "#1E98F5",
16
+ "fourth": "#F167EC"
17
+ },
18
+ "neutral": "#303030"
19
+ },
20
+ "typography": {
21
+ "fontFamily": "Inter"
22
+ },
23
+ "borderRadius": 8
24
+ },
25
+ "other-org": {
26
+ "colors": {
27
+ "main": {
28
+ "dominant": "#ffaaaa",
29
+ "complimentary": "#00ff00"
30
+ },
31
+ "support": {
32
+ "first": "#abcdef",
33
+ "second": "#123456",
34
+ "third": "#994a22",
35
+ "fourth": "#3d5f30"
36
+ },
37
+ "neutral": "#c05030"
38
+ },
39
+ "typography": {
40
+ "fontFamily": "Roboto"
41
+ },
42
+ "borderRadius": 99
43
+ }
44
+ }
45
+ }
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // bin/designsystemet.ts
4
- import path4 from "node:path";
4
+ import path4 from "path";
5
5
  import { Argument, createCommand, program } from "@commander-js/extra-typings";
6
6
  import chalk8 from "chalk";
7
7
  import * as R25 from "ramda";
@@ -361,7 +361,7 @@ var generateColorContrast = (color, type) => {
361
361
 
362
362
  // src/config.ts
363
363
  import * as R7 from "ramda";
364
- import { z } from "zod";
364
+ import { z } from "zod/v4";
365
365
 
366
366
  // src/tokens/create/defaults.ts
367
367
  import * as R3 from "ramda";
@@ -2137,45 +2137,35 @@ var hexPatterns = [
2137
2137
  ];
2138
2138
  var reservedColorsPattern = `^(?!(?:${RESERVED_COLORS.join("|")})$)`;
2139
2139
  var colorRegex = new RegExp(`^${hexPatterns.join("|")}$`);
2140
- var colorSchema = z.string({
2141
- description: `A hex color, which is used for creating a color scale. Invalid color names: ${RESERVED_COLORS.join(", ")}`
2142
- }).regex(colorRegex).transform(convertToHex);
2140
+ var colorSchema = z.string().regex(colorRegex).transform(convertToHex).describe(
2141
+ `A hex color, which is used for creating a color scale. Invalid color names: ${RESERVED_COLORS.join(", ")}`
2142
+ );
2143
2143
  var colorCategorySchema = z.record(
2144
2144
  z.string().regex(new RegExp(reservedColorsPattern, "i"), {
2145
- message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
2145
+ error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
2146
2146
  }),
2147
2147
  colorSchema,
2148
2148
  {
2149
- description: "One or more color definitions",
2150
- invalid_type_error: "Color definitions must be hex color values"
2149
+ error: "Color definitions must be hex color values"
2151
2150
  }
2152
2151
  ).refine((colors2) => !Object.keys(colors2).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
2153
- message: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
2154
- });
2155
- var themeSchema = z.object(
2156
- {
2157
- colors: z.object(
2158
- {
2159
- main: colorCategorySchema,
2160
- support: colorCategorySchema.optional().default({}),
2161
- neutral: colorSchema
2162
- },
2163
- { description: "Defines the colors for this theme" }
2164
- ),
2165
- typography: z.object(
2166
- {
2167
- fontFamily: z.string({ description: "Sets the font-family for this theme" })
2168
- },
2169
- { description: "Defines the typography for a given theme" }
2170
- ).optional(),
2171
- borderRadius: z.number({ description: "Defines the border-radius for this theme" }).optional()
2172
- },
2173
- { description: "An object defining a theme. The property name holding the object becomes the theme name." }
2174
- );
2152
+ error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
2153
+ }).describe("An object with one or more color definitions. The property name is used as the color name.");
2154
+ var themeSchema = z.object({
2155
+ colors: z.object({
2156
+ main: colorCategorySchema,
2157
+ support: colorCategorySchema.optional().default({}),
2158
+ neutral: colorSchema
2159
+ }).meta({ description: "Defines the colors for this theme" }),
2160
+ typography: z.object({
2161
+ fontFamily: z.string().meta({ description: "Sets the font-family for this theme" })
2162
+ }).describe("Defines the typography for a given theme").optional(),
2163
+ borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
2164
+ }).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
2175
2165
  var configFileSchema = z.object({
2176
- outDir: z.string({ description: "Path to the output directory for the created design tokens" }).optional(),
2177
- clean: z.boolean({ description: "Delete the output directory before building or creating tokens" }).optional(),
2178
- themes: z.record(themeSchema, {
2166
+ outDir: z.string().meta({ description: "Path to the output directory for the created design tokens" }).optional(),
2167
+ clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional(),
2168
+ themes: z.record(z.string(), themeSchema).meta({
2179
2169
  description: "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
2180
2170
  })
2181
2171
  });
@@ -2225,12 +2215,12 @@ var cssVarRename = (dictionary) => ({
2225
2215
  });
2226
2216
 
2227
2217
  // src/migrations/codemods/css/run.ts
2228
- import fs2 from "node:fs";
2218
+ import fs2 from "fs";
2229
2219
  import glob from "fast-glob";
2230
2220
  import postcss from "postcss";
2231
2221
 
2232
2222
  // src/utils.ts
2233
- import fs from "node:fs/promises";
2223
+ import fs from "fs/promises";
2234
2224
  import chalk2 from "chalk";
2235
2225
  var mkdir = async (dir, dry) => {
2236
2226
  if (dry) {
@@ -2677,7 +2667,7 @@ var migrations_default = {
2677
2667
  };
2678
2668
 
2679
2669
  // src/tokens/build.ts
2680
- import path2 from "node:path";
2670
+ import path2 from "path";
2681
2671
  import chalk6 from "chalk";
2682
2672
  import * as R23 from "ramda";
2683
2673
 
@@ -2688,11 +2678,11 @@ import chalk3 from "chalk";
2688
2678
  // package.json
2689
2679
  var package_default = {
2690
2680
  name: "@digdir/designsystemet",
2691
- version: "1.0.6",
2681
+ version: "1.0.7",
2692
2682
  description: "CLI for Designsystemet",
2693
2683
  author: "Designsystemet team",
2694
2684
  engines: {
2695
- node: ">=22.15.0"
2685
+ node: ">=22.16.0"
2696
2686
  },
2697
2687
  repository: {
2698
2688
  type: "git",
@@ -2703,7 +2693,8 @@ var package_default = {
2703
2693
  type: "module",
2704
2694
  main: "./dist/src/index.js",
2705
2695
  files: [
2706
- "./dist/**"
2696
+ "./dist/**",
2697
+ "./configs/**"
2707
2698
  ],
2708
2699
  bin: "dist/bin/designsystemet.js",
2709
2700
  exports: {
@@ -2722,22 +2713,22 @@ var package_default = {
2722
2713
  },
2723
2714
  scripts: {
2724
2715
  designsystemet: "tsx ./bin/designsystemet.ts",
2725
- "build:tokens": "pnpm run designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2726
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2716
+ "build:tokens": "pnpm run designsystemet tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
2717
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../internal/design-tokens -o ../../packages/theme/brand --clean",
2727
2718
  build: "tsup && pnpm build:types && pnpm build:json-schema",
2728
2719
  "build:types": "tsc --emitDeclarationOnly --declaration",
2729
2720
  "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
2730
2721
  types: "tsc --noEmit",
2731
- "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./test-tokens/options --theme options --clean',
2732
- "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./test/test-tokens.config.json",
2733
- "test:tokens-build": "pnpm run designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
2734
- "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
2722
+ "test:tokens-create-options": 'pnpm run designsystemet tokens create -m dominant:"#007682" -n "#003333" -b 99 -o ./temp/options/design-tokens --theme options --clean',
2723
+ "test:tokens-create-config": "pnpm run designsystemet tokens create --config ./configs/test-tokens.config.json",
2724
+ "test:tokens-build": "pnpm run designsystemet tokens build -t ./temp/options/design-tokens -o ./temp/options/build --clean",
2725
+ "test:tokens-build-config": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean",
2735
2726
  "test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
2736
2727
  "test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
2737
2728
  test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
2738
- "internal:tokens-create": "pnpm run designsystemet tokens create --config ./internal.config.json",
2729
+ "digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
2739
2730
  "update:template": "tsx ./src/scripts/update-template.ts",
2740
- "update:design-tokens": "pnpm internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
2731
+ "update:design-tokens": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
2741
2732
  verify: "pnpm test && pnpm update:template && pnpm update:design-tokens"
2742
2733
  },
2743
2734
  dependencies: {
@@ -2755,8 +2746,8 @@ var package_default = {
2755
2746
  postcss: "^8.5.3",
2756
2747
  ramda: "^0.30.1",
2757
2748
  "style-dictionary": "^4.4.0",
2758
- zod: "^3.24.4",
2759
- "zod-validation-error": "^3.4.0"
2749
+ zod: "^3.25.30",
2750
+ "zod-validation-error": "^3.4.1"
2760
2751
  },
2761
2752
  devDependencies: {
2762
2753
  "@tokens-studio/types": "0.5.2",
@@ -2765,16 +2756,15 @@ var package_default = {
2765
2756
  "@types/fs-extra": "^11.0.4",
2766
2757
  "@types/glob": "^8.1.0",
2767
2758
  "@types/jscodeshift": "^0.12.0",
2768
- "@types/node": "^22.15.3",
2759
+ "@types/node": "^22.15.21",
2769
2760
  "@types/object-hash": "^3.0.6",
2770
2761
  "@types/ramda": "^0.30.2",
2771
2762
  "fs-extra": "^11.3.0",
2772
2763
  "ts-toolbelt": "^9.6.0",
2773
2764
  tslib: "^2.8.1",
2774
- tsup: "^8.4.0",
2765
+ tsup: "^8.5.0",
2775
2766
  tsx: "^4.19.4",
2776
- typescript: "^5.8.3",
2777
- "zod-to-json-schema": "^3.24.5"
2767
+ typescript: "^5.8.3"
2778
2768
  }
2779
2769
  };
2780
2770
 
@@ -2828,9 +2818,6 @@ order may change due to nondeterminism.`.trim()
2828
2818
  return sortIndex;
2829
2819
  });
2830
2820
  const header = `@charset "UTF-8";
2831
-
2832
- @layer ds.theme, ds.base, ds.utilities, ds.components;
2833
-
2834
2821
  /*
2835
2822
  ${fileHeader2}
2836
2823
  */
@@ -3985,7 +3972,7 @@ var buildTokens = async (options) => {
3985
3972
  const fileHeader2 = R23.join("")([
3986
3973
  defaultFileHeader,
3987
3974
  $designsystemet ? `
3988
- design-tokens: v${$designsystemet.version} ` : ""
3975
+ design-tokens: v${$designsystemet.version}` : ""
3989
3976
  ]);
3990
3977
  await write(createThemeCSSFiles({ processedBuilds, fileHeader: fileHeader2 }), outDir, options.dry);
3991
3978
  console.log(`
@@ -3994,7 +3981,7 @@ design-tokens: v${$designsystemet.version} ` : ""
3994
3981
  };
3995
3982
 
3996
3983
  // src/tokens/create/write.ts
3997
- import path3 from "node:path";
3984
+ import path3 from "path";
3998
3985
  import chalk7 from "chalk";
3999
3986
  import * as R24 from "ramda";
4000
3987
 
@@ -1,83 +1,94 @@
1
1
  {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
2
3
  "type": "object",
3
4
  "properties": {
4
5
  "$schema": {
5
6
  "type": "string"
6
7
  },
7
8
  "outDir": {
8
- "type": "string",
9
- "description": "Path to the output directory for the created design tokens"
9
+ "description": "Path to the output directory for the created design tokens",
10
+ "type": "string"
10
11
  },
11
12
  "clean": {
12
- "type": "boolean",
13
- "description": "Delete the output directory before building or creating tokens"
13
+ "description": "Delete the output directory before building or creating tokens",
14
+ "type": "boolean"
14
15
  },
15
16
  "themes": {
17
+ "description": "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name.",
16
18
  "type": "object",
19
+ "propertyNames": {
20
+ "type": "string"
21
+ },
17
22
  "additionalProperties": {
23
+ "description": "An object defining a theme. The property name holding the object becomes the theme name.",
18
24
  "type": "object",
19
25
  "properties": {
20
26
  "colors": {
27
+ "description": "Defines the colors for this theme",
21
28
  "type": "object",
22
29
  "properties": {
23
30
  "main": {
31
+ "description": "An object with one or more color definitions. The property name is used as the color name.",
24
32
  "type": "object",
25
- "additionalProperties": {
26
- "type": "string",
27
- "pattern": "^#[0-9a-fA-F]{3}|#[0-9a-fA-F]{4}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{8}$",
28
- "description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
29
- },
30
33
  "propertyNames": {
34
+ "type": "string",
31
35
  "pattern": "^(?!(?:neutral|success|warning|danger|info|blue|green|orange|purple|red)$)"
32
36
  },
33
- "description": "One or more color definitions"
37
+ "additionalProperties": {
38
+ "description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
39
+ }
34
40
  },
35
41
  "support": {
36
- "$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main",
37
- "default": {}
42
+ "default": {},
43
+ "description": "An object with one or more color definitions. The property name is used as the color name.",
44
+ "type": "object",
45
+ "propertyNames": {
46
+ "type": "string",
47
+ "pattern": "^(?!(?:neutral|success|warning|danger|info|blue|green|orange|purple|red)$)"
48
+ },
49
+ "additionalProperties": {
50
+ "description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
51
+ }
38
52
  },
39
53
  "neutral": {
40
- "$ref": "#/properties/themes/additionalProperties/properties/colors/properties/main/additionalProperties"
54
+ "description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
41
55
  }
42
56
  },
43
57
  "required": [
44
58
  "main",
59
+ "support",
45
60
  "neutral"
46
61
  ],
47
- "additionalProperties": false,
48
- "description": "Defines the colors for this theme"
62
+ "additionalProperties": false
49
63
  },
50
64
  "typography": {
65
+ "description": "Defines the typography for a given theme",
51
66
  "type": "object",
52
67
  "properties": {
53
68
  "fontFamily": {
54
- "type": "string",
55
- "description": "Sets the font-family for this theme"
69
+ "description": "Sets the font-family for this theme",
70
+ "type": "string"
56
71
  }
57
72
  },
58
73
  "required": [
59
74
  "fontFamily"
60
75
  ],
61
- "additionalProperties": false,
62
- "description": "Defines the typography for a given theme"
76
+ "additionalProperties": false
63
77
  },
64
78
  "borderRadius": {
65
- "type": "number",
66
- "description": "Defines the border-radius for this theme"
79
+ "description": "Defines the border-radius for this theme",
80
+ "type": "number"
67
81
  }
68
82
  },
69
83
  "required": [
70
84
  "colors"
71
85
  ],
72
- "additionalProperties": false,
73
- "description": "An object defining a theme. The property name holding the object becomes the theme name."
74
- },
75
- "description": "An object with one or more themes. Each property defines a theme, and the property name is used as the theme name."
86
+ "additionalProperties": false
87
+ }
76
88
  }
77
89
  },
78
90
  "required": [
79
91
  "themes"
80
92
  ],
81
- "additionalProperties": false,
82
- "$schema": "http://json-schema.org/draft-07/schema#"
93
+ "additionalProperties": false
83
94
  }