@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.
package/dist/src/index.js CHANGED
@@ -2201,98 +2201,7 @@ var createTokens = async (opts) => {
2201
2201
  };
2202
2202
 
2203
2203
  // src/tokens/format.ts
2204
- import * as R19 from "ramda";
2205
- import chalk3 from "chalk";
2206
-
2207
- // package.json
2208
- var package_default = {
2209
- name: "@digdir/designsystemet",
2210
- version: "1.0.4",
2211
- description: "CLI for Designsystemet",
2212
- author: "Designsystemet team",
2213
- engines: {
2214
- node: ">=22.14.0"
2215
- },
2216
- repository: {
2217
- type: "git",
2218
- url: "git+https://github.com/digdir/designsystemet.git"
2219
- },
2220
- homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
2221
- license: "MIT",
2222
- type: "module",
2223
- main: "./dist/src/index.js",
2224
- files: [
2225
- "./dist/**"
2226
- ],
2227
- bin: "dist/bin/designsystemet.js",
2228
- exports: {
2229
- ".": {
2230
- import: "./dist/src/index.js"
2231
- },
2232
- "./color": {
2233
- import: "./dist/src/colors/index.js"
2234
- },
2235
- "./tokens": {
2236
- import: "./dist/src/tokens/index.js"
2237
- }
2238
- },
2239
- publishConfig: {
2240
- access: "public"
2241
- },
2242
- scripts: {
2243
- designsystemet: "tsx ./bin/designsystemet.ts",
2244
- "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2245
- "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
2246
- build: "tsup && yarn build:types && yarn build:json-schema",
2247
- "build:types": "tsc --emitDeclarationOnly --declaration",
2248
- "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
2249
- types: "tsc --noEmit",
2250
- "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens-create --theme options-test --clean",
2251
- "test:tokens-create-config": "yarn designsystemet tokens create --config ./test-tokens-create-complex.config.json",
2252
- "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens-create -o ./test-tokens-build --clean",
2253
- "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
2254
- "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build",
2255
- test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
2256
- "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
2257
- "update:template": "tsx ./src/scripts/update-template.ts",
2258
- "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
2259
- verify: "yarn test && yarn update:template && yarn update:design-tokens"
2260
- },
2261
- dependencies: {
2262
- "@commander-js/extra-typings": "^13.1.0",
2263
- "@tokens-studio/sd-transforms": "1.2.12",
2264
- "apca-w3": "^0.1.9",
2265
- chalk: "^5.4.1",
2266
- "change-case": "^5.4.4",
2267
- "chroma-js": "^3.1.2",
2268
- commander: "^13.1.0",
2269
- "fast-glob": "^3.3.3",
2270
- hsluv: "^1.0.1",
2271
- "object-hash": "^3.0.0",
2272
- postcss: "^8.5.3",
2273
- ramda: "^0.30.1",
2274
- "style-dictionary": "^4.3.3",
2275
- zod: "^3.24.2",
2276
- "zod-validation-error": "^3.4.0"
2277
- },
2278
- devDependencies: {
2279
- "@types/apca-w3": "^0.1.3",
2280
- "@types/chroma-js": "^3.1.1",
2281
- "@types/fs-extra": "^11.0.4",
2282
- "@types/glob": "^8.1.0",
2283
- "@types/jscodeshift": "^0.12.0",
2284
- "@types/node": "^22.14.0",
2285
- "@types/object-hash": "^3.0.6",
2286
- "@types/ramda": "^0.30.2",
2287
- "fs-extra": "^11.3.0",
2288
- "ts-toolbelt": "^9.6.0",
2289
- tslib: "^2.8.1",
2290
- tsup: "^8.4.0",
2291
- tsx: "^4.19.3",
2292
- typescript: "^5.8.2",
2293
- "zod-to-json-schema": "^3.24.5"
2294
- }
2295
- };
2204
+ import * as R20 from "ramda";
2296
2205
 
2297
2206
  // ../../node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
2298
2207
  var BoxShadowTypes;
@@ -3448,7 +3357,7 @@ var buildConfigs = {
3448
3357
  // },
3449
3358
  };
3450
3359
  async function processPlatform(options) {
3451
- const { dry, process, $themes } = options;
3360
+ const { process, $themes } = options;
3452
3361
  const platform = "css";
3453
3362
  const tokenSets = process === "format" ? options.tokenSets : void 0;
3454
3363
  const tokensDir = process === "build" ? options.tokensDir : void 0;
@@ -3549,36 +3458,116 @@ ${colors.map((color) => ` ${color}: never;`).join("\n")}
3549
3458
  return typeDeclaration;
3550
3459
  }
3551
3460
 
3552
- // src/tokens/format.ts
3553
- var formatTokens = async (options) => {
3554
- const processedBuilds = await processPlatform({
3555
- process: "format",
3556
- ...options
3557
- });
3558
- return processedBuilds;
3559
- };
3560
- var formatTheme = async (themeConfig) => {
3561
- const { tokenSets } = await createTokens(themeConfig);
3562
- const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3563
- const processedBuilds = await formatTokens({
3564
- tokenSets,
3565
- $themes,
3566
- verbose: false,
3567
- preview: false
3568
- });
3569
- return processedBuilds;
3570
- };
3571
- var formatThemeCSS = async (themeConfig) => {
3572
- const processedBuilds = await formatTheme(themeConfig);
3573
- const themeCSSFiles = createThemeCSSFiles(processedBuilds);
3574
- return R19.head(themeCSSFiles)?.output ?? "";
3461
+ // src/tokens/process/theme.ts
3462
+ import * as R19 from "ramda";
3463
+ import chalk3 from "chalk";
3464
+
3465
+ // package.json
3466
+ var package_default = {
3467
+ name: "@digdir/designsystemet",
3468
+ version: "1.0.5",
3469
+ description: "CLI for Designsystemet",
3470
+ author: "Designsystemet team",
3471
+ engines: {
3472
+ node: ">=22.14.0"
3473
+ },
3474
+ repository: {
3475
+ type: "git",
3476
+ url: "git+https://github.com/digdir/designsystemet.git"
3477
+ },
3478
+ homepage: "https://github.com/digdir/designsystemet/tree/main/scripts/cli",
3479
+ license: "MIT",
3480
+ type: "module",
3481
+ main: "./dist/src/index.js",
3482
+ files: [
3483
+ "./dist/**"
3484
+ ],
3485
+ bin: "dist/bin/designsystemet.js",
3486
+ exports: {
3487
+ ".": {
3488
+ import: "./dist/src/index.js"
3489
+ },
3490
+ "./color": {
3491
+ import: "./dist/src/colors/index.js"
3492
+ },
3493
+ "./tokens": {
3494
+ import: "./dist/src/tokens/index.js"
3495
+ }
3496
+ },
3497
+ publishConfig: {
3498
+ access: "public"
3499
+ },
3500
+ scripts: {
3501
+ designsystemet: "tsx ./bin/designsystemet.ts",
3502
+ "build:tokens": "yarn designsystemet tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3503
+ "build:tokens:debug": "tsx --inspect-brk ./bin/designsystemet.ts tokens build -p -t ../../design-tokens -o ../../packages/theme/brand --clean",
3504
+ build: "tsup && yarn build:types && yarn build:json-schema",
3505
+ "build:types": "tsc --emitDeclarationOnly --declaration",
3506
+ "build:json-schema": "tsx ./src/scripts/createJsonSchema.ts",
3507
+ types: "tsc --noEmit",
3508
+ "test:tokens-create-options": "yarn designsystemet tokens create -m dominant:#007682 -n #003333 -b 99 -o ./test-tokens/options --theme options --clean",
3509
+ "test:tokens-create-config": "yarn designsystemet tokens create --config ./test/test-tokens.config.json",
3510
+ "test:tokens-build": "yarn designsystemet tokens build -t ./test-tokens/options -o ./test-tokens/options-build --clean",
3511
+ "test:tokens-build-config": "yarn designsystemet tokens build -t ./test-tokens/config -o ./test-tokens/config-build --clean",
3512
+ "test:tokens-create-and-build-options": "yarn test:tokens-create-options && yarn test:tokens-build",
3513
+ "test:tokens-create-and-build-config": "yarn test:tokens-create-config && yarn test:tokens-build-config",
3514
+ test: "yarn test:tokens-create-and-build-options && yarn test:tokens-create-and-build-config",
3515
+ "internal:tokens-create": "yarn designsystemet tokens create --config ./internal.config.json",
3516
+ "update:template": "tsx ./src/scripts/update-template.ts",
3517
+ "update:design-tokens": "yarn internal:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
3518
+ verify: "yarn test && yarn update:template && yarn update:design-tokens"
3519
+ },
3520
+ dependencies: {
3521
+ "@commander-js/extra-typings": "^13.1.0",
3522
+ "@tokens-studio/sd-transforms": "1.2.12",
3523
+ "apca-w3": "^0.1.9",
3524
+ chalk: "^5.4.1",
3525
+ "change-case": "^5.4.4",
3526
+ "chroma-js": "^3.1.2",
3527
+ commander: "^13.1.0",
3528
+ "fast-glob": "^3.3.3",
3529
+ hsluv: "^1.0.1",
3530
+ "object-hash": "^3.0.0",
3531
+ postcss: "^8.5.3",
3532
+ ramda: "^0.30.1",
3533
+ "style-dictionary": "^4.3.3",
3534
+ zod: "^3.24.2",
3535
+ "zod-validation-error": "^3.4.0"
3536
+ },
3537
+ devDependencies: {
3538
+ "@types/apca-w3": "^0.1.3",
3539
+ "@types/chroma-js": "^3.1.1",
3540
+ "@types/fs-extra": "^11.0.4",
3541
+ "@types/glob": "^8.1.0",
3542
+ "@types/jscodeshift": "^0.12.0",
3543
+ "@types/node": "^22.14.0",
3544
+ "@types/object-hash": "^3.0.6",
3545
+ "@types/ramda": "^0.30.2",
3546
+ "fs-extra": "^11.3.0",
3547
+ "ts-toolbelt": "^9.6.0",
3548
+ tslib: "^2.8.1",
3549
+ tsup: "^8.4.0",
3550
+ tsx: "^4.19.3",
3551
+ typescript: "^5.8.2",
3552
+ "zod-to-json-schema": "^3.24.5"
3553
+ }
3575
3554
  };
3576
- var createThemeCSSFiles = (processedBuilds) => {
3555
+
3556
+ // src/tokens/process/theme.ts
3557
+ var defaultFileHeader = `build: v${package_default.version}`;
3558
+ var createThemeCSSFiles = ({
3559
+ processedBuilds,
3560
+ fileHeader: fileHeader2 = defaultFileHeader
3561
+ }) => {
3577
3562
  const groupedByTheme = {};
3578
3563
  for (const [_, buildResults] of Object.entries(R19.dissoc("types", processedBuilds))) {
3579
3564
  for (const buildResult of buildResults) {
3580
- const previous = groupedByTheme[buildResult.permutation.theme] ?? [];
3581
- groupedByTheme[buildResult.permutation.theme] = R19.concat(previous, buildResult.formatted);
3565
+ const themeName = buildResult.permutation.theme;
3566
+ const newOutputs = buildResult.formatted;
3567
+ if (R19.isNotEmpty(newOutputs)) {
3568
+ const currentOutputs = groupedByTheme[themeName] ?? [];
3569
+ groupedByTheme[themeName] = R19.concat(currentOutputs, newOutputs);
3570
+ }
3582
3571
  }
3583
3572
  }
3584
3573
  const sortOrder = [
@@ -3617,7 +3606,9 @@ order may change due to nondeterminism.`.trim()
3617
3606
 
3618
3607
  @layer ds.theme, ds.base, ds.utilities, ds.components;
3619
3608
 
3620
- /* This file is generated by ${package_default.name}@${package_default.version} */
3609
+ /*
3610
+ ${fileHeader2}
3611
+ */
3621
3612
 
3622
3613
  `;
3623
3614
  const sortAlphabetically = R19.sort(R19.ascend((x) => x.destination || ""));
@@ -3635,6 +3626,31 @@ order may change due to nondeterminism.`.trim()
3635
3626
  }));
3636
3627
  return themeCSSFiles;
3637
3628
  };
3629
+
3630
+ // src/tokens/format.ts
3631
+ var formatTokens = async (options) => {
3632
+ const processedBuilds = await processPlatform({
3633
+ process: "format",
3634
+ ...options
3635
+ });
3636
+ return processedBuilds;
3637
+ };
3638
+ var formatTheme = async (themeConfig) => {
3639
+ const { tokenSets } = await createTokens(themeConfig);
3640
+ const $themes = await generate$Themes(["dark", "light"], [themeConfig.name], themeConfig.colors);
3641
+ const processedBuilds = await formatTokens({
3642
+ tokenSets,
3643
+ $themes,
3644
+ verbose: false,
3645
+ preview: false
3646
+ });
3647
+ return processedBuilds;
3648
+ };
3649
+ var formatThemeCSS = async (themeConfig) => {
3650
+ const processedBuilds = await formatTheme(themeConfig);
3651
+ const themeCSSFiles = createThemeCSSFiles({ processedBuilds });
3652
+ return R20.head(themeCSSFiles)?.output ?? "";
3653
+ };
3638
3654
  export {
3639
3655
  HSLToHex,
3640
3656
  RESERVED_COLORS,
@@ -31,6 +31,7 @@ async function updateDesignTokens() {
31
31
  await cp(path.join(INTERNAL, "primitives/globals.json"), path.join(TARGET, "primitives/globals.json"));
32
32
  await cp(path.join(INTERNAL, "semantic"), path.join(TARGET, "semantic"));
33
33
  await cp(path.join(INTERNAL, "themes"), path.join(TARGET, "themes"));
34
+ await cp(path.join(INTERNAL, "$designsystemet.json"), path.join(TARGET, "$designsystemet.json"));
34
35
  console.log("\u2705 Finished copying design tokens");
35
36
  }
36
37
  await updateDesignTokens();
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAiB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC,2DAuCnF,CAAC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/tokens/build.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,uBAAuB,CAAC;AAiB3E,eAAO,MAAM,WAAW,GAAU,SAAS,IAAI,CAAC,YAAY,EAAE,SAAS,GAAG,SAAS,CAAC,2DAiDnF,CAAC"}