@digdir/designsystemet 0.1.0-next.29 → 0.1.0-next.30

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.
@@ -16,10 +16,10 @@ function makeTokenCommands() {
16
16
  console.log(`Bulding tokens in ${chalk.green(tokens)}`);
17
17
  return buildTokens({ tokens, out, preview });
18
18
  });
19
- tokenCmd.command("create").description("Create Designsystemet tokens").option("-w, --write [string]", `Output directory for created ${chalk.blue("design-tokens")}`, "./design-tokens").option("-a, --accent <number>", `Accent hex color`).option("-n, --neutral <number>", `Neutral hex color`).option("-b1, --brand1 <number>", `Brand1 hex color`).option("-b2, --brand2 <number>", `Brand2 hex color`).option("-b3, --brand3 <number>", `Brand3 hex color`).option("-f, --font-family <string>", `Font family`).action(async (opts) => {
19
+ tokenCmd.command("create").description("Create Designsystemet tokens").option("-w, --write [string]", `Output directory for created ${chalk.blue("design-tokens")}`).option("-a, --accent <number>", `Accent hex color`).option("-n, --neutral <number>", `Neutral hex color`).option("-b1, --brand1 <number>", `Brand1 hex color`).option("-b2, --brand2 <number>", `Brand2 hex color`).option("-b3, --brand3 <number>", `Brand3 hex color`).option("-f, --font-family <string>", `Font family`).action(async (opts) => {
20
20
  console.log(`Creating tokens with options ${chalk.green(JSON.stringify(opts))}`);
21
- const outPath = typeof opts.write === "string" ? opts.write : "./design-tokens";
22
21
  const family = typeof opts.fontFamily === "string" ? opts.fontFamily : "Inter";
22
+ const write2 = typeof opts.write === "boolean" ? "./design-tokens" : opts.write;
23
23
  const props = {
24
24
  colors: {
25
25
  accent: convertToHex(opts.accent),
@@ -31,7 +31,7 @@ function makeTokenCommands() {
31
31
  typography: {
32
32
  family
33
33
  },
34
- outPath
34
+ write: write2
35
35
  };
36
36
  await createTokens(props);
37
37
  });
@@ -101,7 +101,7 @@ const generateGlobalTokens = (theme) => {
101
101
  };
102
102
  };
103
103
  const createTokens = async (opts) => {
104
- const { colors, outPath, typography } = opts;
104
+ const { colors, write, typography } = opts;
105
105
  const tokens = {
106
106
  colors: {
107
107
  light: {
@@ -115,9 +115,8 @@ const createTokens = async (opts) => {
115
115
  primary: generateTypographyTokens(typography)
116
116
  }
117
117
  };
118
- const write = R.isNotNil(outPath);
119
- if (write) {
120
- const targetDir = path.resolve(process.cwd(), outPath);
118
+ if (R.isNotNil(write)) {
119
+ const targetDir = path.resolve(process.cwd(), String(write));
121
120
  await fs.mkdir(targetDir, { recursive: true });
122
121
  console.log("Generating metadata and themes files");
123
122
  const $theme = generateThemesJson(["Light", "Dark", "Contrast"], ["theme"]);
@@ -129,14 +128,14 @@ const createTokens = async (opts) => {
129
128
  recursive: true
130
129
  });
131
130
  const files = [
132
- generateColorModeFile("light", "theme", tokens.colors.light.theme, outPath),
133
- generateColorModeFile("light", "global", tokens.colors.light.global, outPath),
134
- generateColorModeFile("dark", "theme", tokens.colors.dark.theme, outPath),
135
- generateColorModeFile("dark", "global", tokens.colors.dark.global, outPath),
136
- generateColorModeFile("contrast", "theme", tokens.colors.contrast.theme, outPath),
137
- generateColorModeFile("contrast", "global", tokens.colors.contrast.global, outPath),
138
- generateTypographyFile("primary", "theme", tokens.typography.primary, outPath),
139
- generateTypographyFile("secondary", "theme", tokens.typography.primary, outPath)
131
+ generateColorModeFile("light", "theme", tokens.colors.light.theme, targetDir),
132
+ generateColorModeFile("light", "global", tokens.colors.light.global, targetDir),
133
+ generateColorModeFile("dark", "theme", tokens.colors.dark.theme, targetDir),
134
+ generateColorModeFile("dark", "global", tokens.colors.dark.global, targetDir),
135
+ generateColorModeFile("contrast", "theme", tokens.colors.contrast.theme, targetDir),
136
+ generateColorModeFile("contrast", "global", tokens.colors.contrast.global, targetDir),
137
+ generateTypographyFile("primary", "theme", tokens.typography.primary, targetDir),
138
+ generateTypographyFile("secondary", "theme", tokens.typography.primary, targetDir)
140
139
  ];
141
140
  for (const file of files) {
142
141
  const path_ = path.resolve(file.path);
@@ -5,7 +5,7 @@ type Typography = Record<string, string>;
5
5
  type CreateTokens = {
6
6
  colors: Colors;
7
7
  typography: Typography;
8
- outPath: string;
8
+ write?: string;
9
9
  };
10
10
  type DesignTokens = Record<string, {
11
11
  $value: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,KAAK,EAAwB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI/E,KAAK,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC5C,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAGzC,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAQF,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACtE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC/D,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAC/C,KAAK,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AA2GtC,eAAO,MAAM,YAAY,SAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyDpD,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,OAAO,KAAK,EAAwB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAI/E,KAAK,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;AAC5C,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAGzC,KAAK,YAAY,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,UAAU,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAQF,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AACtE,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;AAC/D,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAC/C,KAAK,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC;AA2GtC,eAAO,MAAM,YAAY,SAAgB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuDpD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digdir/designsystemet",
3
- "version": "0.1.0-next.29",
3
+ "version": "0.1.0-next.30",
4
4
  "description": "CLI for Designsystemet",
5
5
  "author": "Designsystemet team",
6
6
  "repository": {