@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.
- package/dist/bin/config.d.ts +4 -4
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +133 -28
- package/dist/bin/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +208 -149
- package/dist/src/config.d.ts +2 -2
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +4 -4
- package/dist/src/index.js +5 -5
- package/dist/src/migrations/beta-to-v1.js +122 -16
- package/dist/src/migrations/codemods/css/run.d.ts.map +1 -1
- package/dist/src/migrations/codemods/css/run.js +122 -16
- package/dist/src/migrations/color-rename-next49.js +122 -16
- package/dist/src/migrations/index.js +122 -16
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -1
- package/dist/src/scripts/update-preview-tokens.js +122 -45
- package/dist/src/tokens/build.d.ts +2 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +128 -62
- package/dist/src/tokens/create/files.d.ts +10 -0
- package/dist/src/tokens/create/files.d.ts.map +1 -0
- package/dist/src/tokens/create/{write.js → files.js} +143 -61
- package/dist/src/tokens/create/generators/$designsystemet.js +5 -5
- package/dist/src/tokens/format.js +5 -5
- package/dist/src/tokens/generate-config.d.ts +0 -1
- package/dist/src/tokens/generate-config.d.ts.map +1 -1
- package/dist/src/tokens/generate-config.js +145 -26
- package/dist/src/tokens/index.js +5 -5
- package/dist/src/tokens/process/output/declarations.js +5 -5
- package/dist/src/tokens/process/output/theme.js +5 -5
- package/dist/src/tokens/process/platform.d.ts +0 -4
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/types.d.ts +2 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/utils/filesystem.d.ts +40 -0
- package/dist/src/utils/filesystem.d.ts.map +1 -0
- package/dist/src/utils/filesystem.js +127 -0
- package/package.json +6 -6
- package/dist/src/tokens/create/write.d.ts +0 -12
- package/dist/src/tokens/create/write.d.ts.map +0 -1
- package/dist/src/utils.d.ts +0 -18
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/utils.js +0 -70
|
@@ -5,11 +5,11 @@ import * as R2 from "ramda";
|
|
|
5
5
|
// package.json
|
|
6
6
|
var package_default = {
|
|
7
7
|
name: "@digdir/designsystemet",
|
|
8
|
-
version: "1.
|
|
8
|
+
version: "1.13.0",
|
|
9
9
|
description: "CLI for Designsystemet",
|
|
10
10
|
author: "Designsystemet team",
|
|
11
11
|
engines: {
|
|
12
|
-
node: ">=20
|
|
12
|
+
node: ">=20.20.1"
|
|
13
13
|
},
|
|
14
14
|
repository: {
|
|
15
15
|
type: "git",
|
|
@@ -73,16 +73,16 @@ var package_default = {
|
|
|
73
73
|
hsluv: "^1.0.1",
|
|
74
74
|
"object-hash": "^3.0.0",
|
|
75
75
|
picocolors: "^1.1.1",
|
|
76
|
-
postcss: "^8.5.
|
|
76
|
+
postcss: "^8.5.8",
|
|
77
77
|
ramda: "^0.32.0",
|
|
78
|
-
"style-dictionary": "^5.3.
|
|
78
|
+
"style-dictionary": "^5.3.3",
|
|
79
79
|
zod: "^4.3.6",
|
|
80
80
|
"zod-validation-error": "^5.0.0"
|
|
81
81
|
},
|
|
82
82
|
devDependencies: {
|
|
83
83
|
"@tokens-studio/types": "0.5.2",
|
|
84
84
|
"@types/chroma-js": "^3.1.2",
|
|
85
|
-
"@types/node": "^24.
|
|
85
|
+
"@types/node": "^24.12.0",
|
|
86
86
|
"@types/object-hash": "^3.0.6",
|
|
87
87
|
"@types/ramda": "^0.31.1",
|
|
88
88
|
tsup: "^8.5.1",
|
|
@@ -11,8 +11,6 @@ type SharedOptions = {
|
|
|
11
11
|
defaultSize?: string;
|
|
12
12
|
/** Set the available size modes */
|
|
13
13
|
sizeModes?: string[];
|
|
14
|
-
/** Dry run, no files will be written */
|
|
15
|
-
dry?: boolean;
|
|
16
14
|
/** Token Studio `$themes.json` content */
|
|
17
15
|
processed$themes: ProcessedThemeObject[];
|
|
18
16
|
/** Color groups */
|
|
@@ -27,8 +25,6 @@ export type BuildOptions = {
|
|
|
27
25
|
type: 'build';
|
|
28
26
|
/** Design tokens path */
|
|
29
27
|
tokensDir: string;
|
|
30
|
-
/** Output directory for built tokens */
|
|
31
|
-
outDir: string;
|
|
32
28
|
/** Tailwind CSS configuration */
|
|
33
29
|
tailwind?: boolean;
|
|
34
30
|
} & SharedOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAqC,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAElG,KAAK,aAAa,GAAG;IACnB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/platform.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAqC,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEvF,OAAO,EAAmB,KAAK,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;A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,aAIxB,CAAC;AAOF,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCqB,CAAC;AAExC,wBAAsB,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CA2IrF"}
|
|
@@ -61,6 +61,8 @@ export type SDConfigForThemePermutation = {
|
|
|
61
61
|
permutation: ThemePermutation;
|
|
62
62
|
config: SDConfig;
|
|
63
63
|
};
|
|
64
|
+
/** This type is taken from Style Dictionary `formatPlatform`.
|
|
65
|
+
* Metadata for a file output */
|
|
64
66
|
export type OutputFile = {
|
|
65
67
|
output: string;
|
|
66
68
|
destination: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,MAAM,MAAM,KAAK,GACb;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,GAAG,GAAG,GAAG,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,CAAA;CAAE,GACzF;IACE,KAAK,EAAE,YAAY,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC,YAAY,GAAG,YAAY,GAAG,YAAY,GAAG,UAAU,GAAG,eAAe,EAAE,MAAM,CAAC,CAAC;CACnG,CAAC;AAEN,MAAM,MAAM,QAAQ,GAAG;IACrB,CA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EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,SAAS,EAAE,wBAAwB,CAAC;IACpC,0FAA0F;IAC1F,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,+DAA+D;IAC/D,OAAO,CAAC,EAAE,MAAM,OAAO,CAAC;IACxB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,2BAA2B,KAAK,MAAM,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IAAE,WAAW,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC;AAE9F;gCACgC;AAChC,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CopyOptions, PathLike } from 'node:fs';
|
|
2
|
+
import type { OutputFile } from '../tokens/types.js';
|
|
3
|
+
declare class FileSystem {
|
|
4
|
+
private isInitialized;
|
|
5
|
+
private dry;
|
|
6
|
+
private verbose;
|
|
7
|
+
/** Default working directory is where the process was started */
|
|
8
|
+
workingDir: string;
|
|
9
|
+
outDir: string;
|
|
10
|
+
/** Initialize the file system */
|
|
11
|
+
init({ dry, outdir, verbose }: {
|
|
12
|
+
dry?: boolean;
|
|
13
|
+
outdir?: string;
|
|
14
|
+
verbose?: boolean;
|
|
15
|
+
}): void;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a directory if it does not already exist.
|
|
18
|
+
*
|
|
19
|
+
* @param dir - The path of the directory to create.
|
|
20
|
+
*
|
|
21
|
+
* @returns A promise that resolves when the operation is complete.
|
|
22
|
+
* If the directory already exists or `dry` is `true`, the promise resolves immediately.
|
|
23
|
+
*/
|
|
24
|
+
mkdir: (dir: PathLike) => Promise<string | void>;
|
|
25
|
+
writeFile: (path: PathLike, data: string) => Promise<void>;
|
|
26
|
+
cp: (src: string, dest: string, filter?: CopyOptions["filter"]) => Promise<void>;
|
|
27
|
+
copyFile: (src: PathLike, dest: PathLike) => Promise<void>;
|
|
28
|
+
cleanDir: (dir: string) => Promise<void>;
|
|
29
|
+
readFile: (path: PathLike, allowFileNotFound?: boolean) => Promise<string>;
|
|
30
|
+
readdir: (path: PathLike) => Promise<string[]>;
|
|
31
|
+
writeFiles: (files: OutputFile[], outDir: string, log?: boolean) => Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* An abstraction of Node's file system API and helper functions for Designsystemet CLI interaction with the file system.
|
|
35
|
+
*
|
|
36
|
+
* Allows dry-running destructive operations, logging and store relevant file system state.
|
|
37
|
+
*/
|
|
38
|
+
export declare const dsfs: FileSystem;
|
|
39
|
+
export {};
|
|
40
|
+
//# sourceMappingURL=filesystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesystem.d.ts","sourceRoot":"","sources":["../../../src/utils/filesystem.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAIrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,cAAM,UAAU;IACd,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,OAAO,CAAS;IACxB,iEAAiE;IACjE,UAAU,SAAiB;IAC3B,MAAM,SAAmB;IAEzB,iCAAiC;IACjC,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE;QAAE,GAAG,CAAC,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAwBpF;;;;;;;OAOG;IACH,KAAK,GAAU,KAAK,QAAQ,4BAgB1B;IAEF,SAAS,GAAU,MAAM,QAAQ,EAAE,MAAM,MAAM,mBAW7C;IAEF,EAAE,GAAU,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,SAAS,WAAW,CAAC,QAAQ,CAAC,mBAOnE;IAEF,QAAQ,GAAU,KAAK,QAAQ,EAAE,MAAM,QAAQ,mBAO7C;IAEF,QAAQ,GAAU,KAAK,MAAM,mBAS3B;IAEF,QAAQ,GAAU,MAAM,QAAQ,EAAE,oBAAoB,OAAO,qBAa3D;IACF,OAAO,GAAU,MAAM,QAAQ,uBAa7B;IACF,UAAU,GAAU,OAAO,UAAU,EAAE,EAAE,QAAQ,MAAM,EAAE,MAAM,OAAO,mBAcpE;CACH;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,YAAmB,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
// src/utils/filesystem.ts
|
|
2
|
+
import fs from "fs/promises";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import pc from "picocolors";
|
|
5
|
+
var FileSystem = class {
|
|
6
|
+
isInitialized = false;
|
|
7
|
+
dry = false;
|
|
8
|
+
verbose = false;
|
|
9
|
+
/** Default working directory is where the process was started */
|
|
10
|
+
workingDir = process.cwd();
|
|
11
|
+
outDir = this.workingDir;
|
|
12
|
+
/** Initialize the file system */
|
|
13
|
+
init({ dry, outdir, verbose }) {
|
|
14
|
+
if (this.isInitialized) {
|
|
15
|
+
console.warn(pc.yellow("FileSystem is already initialized. Ignoring subsequent init call."));
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (dry) {
|
|
19
|
+
console.log(pc.blue("Initializing FileSystem in dry-run mode. No files will be written."));
|
|
20
|
+
}
|
|
21
|
+
this.dry = dry ?? false;
|
|
22
|
+
this.verbose = verbose ?? false;
|
|
23
|
+
this.outDir = outdir ? path.isAbsolute(outdir) ? outdir : path.join(this.workingDir, outdir) : this.workingDir;
|
|
24
|
+
if (this.verbose) {
|
|
25
|
+
console.log(
|
|
26
|
+
`FileSystem initialized with workingDir: ${pc.green(this.workingDir)}, outDir: ${pc.green(this.outDir)}`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
this.isInitialized = true;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a directory if it does not already exist.
|
|
33
|
+
*
|
|
34
|
+
* @param dir - The path of the directory to create.
|
|
35
|
+
*
|
|
36
|
+
* @returns A promise that resolves when the operation is complete.
|
|
37
|
+
* If the directory already exists or `dry` is `true`, the promise resolves immediately.
|
|
38
|
+
*/
|
|
39
|
+
mkdir = async (dir) => {
|
|
40
|
+
if (this.dry) {
|
|
41
|
+
console.log(`${pc.blue("mkdir")} ${dir}`);
|
|
42
|
+
return Promise.resolve();
|
|
43
|
+
}
|
|
44
|
+
const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
|
|
45
|
+
if (exists) {
|
|
46
|
+
return Promise.resolve();
|
|
47
|
+
}
|
|
48
|
+
return fs.mkdir(dir, { recursive: true });
|
|
49
|
+
};
|
|
50
|
+
writeFile = async (path2, data) => {
|
|
51
|
+
if (this.dry) {
|
|
52
|
+
console.log(`${pc.blue("writeFile")} ${path2}`);
|
|
53
|
+
return Promise.resolve();
|
|
54
|
+
}
|
|
55
|
+
return fs.writeFile(path2, data, { encoding: "utf-8" }).catch((error) => {
|
|
56
|
+
console.error(pc.red(`Error writing file: ${path2}`));
|
|
57
|
+
console.error(pc.red(error));
|
|
58
|
+
throw error;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
cp = async (src, dest, filter) => {
|
|
62
|
+
if (this.dry) {
|
|
63
|
+
console.log(`${pc.blue("cp")} ${src} ${dest}`);
|
|
64
|
+
return Promise.resolve();
|
|
65
|
+
}
|
|
66
|
+
return fs.cp(src, dest, { recursive: true, filter });
|
|
67
|
+
};
|
|
68
|
+
copyFile = async (src, dest) => {
|
|
69
|
+
if (this.dry) {
|
|
70
|
+
console.log(`${pc.blue("copyFile")} ${src} to ${dest}`);
|
|
71
|
+
return Promise.resolve();
|
|
72
|
+
}
|
|
73
|
+
return fs.copyFile(src, dest);
|
|
74
|
+
};
|
|
75
|
+
cleanDir = async (dir) => {
|
|
76
|
+
if (this.dry) {
|
|
77
|
+
console.log(`${pc.blue("cleanDir")} ${dir}`);
|
|
78
|
+
return Promise.resolve();
|
|
79
|
+
}
|
|
80
|
+
console.log(`
|
|
81
|
+
\u{1F525} Cleaning dir ${pc.red(`${dir.trim()}`)} `);
|
|
82
|
+
return fs.rm(dir, { recursive: true, force: true });
|
|
83
|
+
};
|
|
84
|
+
readFile = async (path2, allowFileNotFound) => {
|
|
85
|
+
if (this.dry) {
|
|
86
|
+
console.log(`${pc.blue("readFile")} ${path2}`);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return await fs.readFile(path2, "utf-8");
|
|
90
|
+
} catch (error) {
|
|
91
|
+
if (allowFileNotFound && error.code === "ENOENT") {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
readdir = async (path2) => {
|
|
98
|
+
if (this.dry) {
|
|
99
|
+
console.log(`${pc.blue("readdir")} ${path2}`);
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return await fs.readdir(path2);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error.code === "ENOENT") {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
writeFiles = async (files, outDir, log) => {
|
|
111
|
+
for (const { destination: filename, output } of files) {
|
|
112
|
+
if (filename) {
|
|
113
|
+
const filePath = path.join(outDir, filename);
|
|
114
|
+
const fileDir = path.dirname(filePath);
|
|
115
|
+
if (log) {
|
|
116
|
+
console.log(filename);
|
|
117
|
+
}
|
|
118
|
+
await this.mkdir(fileDir);
|
|
119
|
+
await this.writeFile(filePath, output);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
var dsfs = new FileSystem();
|
|
125
|
+
export {
|
|
126
|
+
dsfs
|
|
127
|
+
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digdir/designsystemet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "CLI for Designsystemet",
|
|
5
5
|
"author": "Designsystemet team",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=20
|
|
7
|
+
"node": ">=20.20.1"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
"hsluv": "^1.0.1",
|
|
47
47
|
"object-hash": "^3.0.0",
|
|
48
48
|
"picocolors": "^1.1.1",
|
|
49
|
-
"postcss": "^8.5.
|
|
49
|
+
"postcss": "^8.5.8",
|
|
50
50
|
"ramda": "^0.32.0",
|
|
51
|
-
"style-dictionary": "^5.3.
|
|
51
|
+
"style-dictionary": "^5.3.3",
|
|
52
52
|
"zod": "^4.3.6",
|
|
53
53
|
"zod-validation-error": "^5.0.0",
|
|
54
|
-
"@digdir/designsystemet-types": "^1.
|
|
54
|
+
"@digdir/designsystemet-types": "^1.13.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@tokens-studio/types": "0.5.2",
|
|
58
58
|
"@types/chroma-js": "^3.1.2",
|
|
59
|
-
"@types/node": "^24.
|
|
59
|
+
"@types/node": "^24.12.0",
|
|
60
60
|
"@types/object-hash": "^3.0.6",
|
|
61
61
|
"@types/ramda": "^0.31.1",
|
|
62
62
|
"tsup": "^8.5.1",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Theme, TokenSets } from '../types.js';
|
|
2
|
-
export declare const stringify: (data: unknown) => string;
|
|
3
|
-
type WriteTokensOptions = {
|
|
4
|
-
outDir: string;
|
|
5
|
-
theme: Theme;
|
|
6
|
-
/** Dry run, no files will be written */
|
|
7
|
-
dry?: boolean;
|
|
8
|
-
tokenSets: TokenSets;
|
|
9
|
-
};
|
|
10
|
-
export declare const writeTokens: (options: WriteTokensOptions) => Promise<void>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=write.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../../../src/tokens/create/write.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAa,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAK/D,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,WAAkC,CAAC;AAE1E,KAAK,kBAAkB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IACb,wCAAwC;IACxC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,SAAS,kBAAkB,kBAuD5D,CAAC"}
|
package/dist/src/utils.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { CopyOptions } from 'node:fs';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a directory if it does not already exist.
|
|
4
|
-
*
|
|
5
|
-
* @param dir - The path of the directory to create.
|
|
6
|
-
* @param dry - Optional. If `true`, the function will log the operation
|
|
7
|
-
* without actually creating the directory.
|
|
8
|
-
*
|
|
9
|
-
* @returns A promise that resolves when the operation is complete.
|
|
10
|
-
* If the directory already exists or `dry` is `true`, the promise resolves immediately.
|
|
11
|
-
*/
|
|
12
|
-
export declare const mkdir: (dir: string, dry?: boolean) => Promise<string | void>;
|
|
13
|
-
export declare const writeFile: (path: string, data: string, dry?: boolean) => Promise<void>;
|
|
14
|
-
export declare const cp: (src: string, dest: string, dry?: boolean, filter?: CopyOptions["filter"]) => Promise<void>;
|
|
15
|
-
export declare const copyFile: (src: string, dest: string, dry?: boolean) => Promise<void>;
|
|
16
|
-
export declare const cleanDir: (dir: string, dry?: boolean) => Promise<void>;
|
|
17
|
-
export declare const readFile: (path: string, dry?: boolean, allowFileNotFound?: boolean) => Promise<string>;
|
|
18
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/dist/src/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C;;;;;;;;;GASG;AACH,eAAO,MAAM,KAAK,GAAU,KAAK,MAAM,EAAE,MAAM,OAAO,2BAgBrD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAU,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,kBAWxE,CAAC;AAEF,eAAO,MAAM,EAAE,GAAU,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,EAAE,SAAS,WAAW,CAAC,QAAQ,CAAC,kBAOhG,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,KAAK,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,OAAO,kBAOtE,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,KAAK,MAAM,EAAE,MAAM,OAAO,kBASxD,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,EAAE,MAAM,OAAO,EAAE,oBAAoB,OAAO,oBActF,CAAC"}
|
package/dist/src/utils.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
|
-
import fs from "fs/promises";
|
|
3
|
-
import pc from "picocolors";
|
|
4
|
-
var mkdir = async (dir, dry) => {
|
|
5
|
-
if (dry) {
|
|
6
|
-
console.log(`${pc.blue("mkdir")} ${dir}`);
|
|
7
|
-
return Promise.resolve();
|
|
8
|
-
}
|
|
9
|
-
const exists = await fs.access(dir, fs.constants.F_OK).then(() => true).catch(() => false);
|
|
10
|
-
if (exists) {
|
|
11
|
-
return Promise.resolve();
|
|
12
|
-
}
|
|
13
|
-
return fs.mkdir(dir, { recursive: true });
|
|
14
|
-
};
|
|
15
|
-
var writeFile = async (path, data, dry) => {
|
|
16
|
-
if (dry) {
|
|
17
|
-
console.log(`${pc.blue("writeFile")} ${path}`);
|
|
18
|
-
return Promise.resolve();
|
|
19
|
-
}
|
|
20
|
-
return fs.writeFile(path, data, { encoding: "utf-8" }).catch((error) => {
|
|
21
|
-
console.error(pc.red(`Error writing file: ${path}`));
|
|
22
|
-
console.error(pc.red(error));
|
|
23
|
-
throw error;
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var cp = async (src, dest, dry, filter) => {
|
|
27
|
-
if (dry) {
|
|
28
|
-
console.log(`${pc.blue("cp")} ${src} ${dest}`);
|
|
29
|
-
return Promise.resolve();
|
|
30
|
-
}
|
|
31
|
-
return fs.cp(src, dest, { recursive: true, filter });
|
|
32
|
-
};
|
|
33
|
-
var copyFile = async (src, dest, dry) => {
|
|
34
|
-
if (dry) {
|
|
35
|
-
console.log(`${pc.blue("copyFile")} ${src} to ${dest}`);
|
|
36
|
-
return Promise.resolve();
|
|
37
|
-
}
|
|
38
|
-
return fs.copyFile(src, dest);
|
|
39
|
-
};
|
|
40
|
-
var cleanDir = async (dir, dry) => {
|
|
41
|
-
if (dry) {
|
|
42
|
-
console.log(`${pc.blue("cleanDir")} ${dir}`);
|
|
43
|
-
return Promise.resolve();
|
|
44
|
-
}
|
|
45
|
-
console.log(`
|
|
46
|
-
\u{1F525} Cleaning dir ${pc.red(`${dir.trim()}`)} `);
|
|
47
|
-
return fs.rm(dir, { recursive: true, force: true });
|
|
48
|
-
};
|
|
49
|
-
var readFile = async (path, dry, allowFileNotFound) => {
|
|
50
|
-
if (dry) {
|
|
51
|
-
console.log(`${pc.blue("readFile")} ${path}`);
|
|
52
|
-
return Promise.resolve("");
|
|
53
|
-
}
|
|
54
|
-
try {
|
|
55
|
-
return await fs.readFile(path, "utf-8");
|
|
56
|
-
} catch (error) {
|
|
57
|
-
if (allowFileNotFound && error.code === "ENOENT") {
|
|
58
|
-
return "";
|
|
59
|
-
}
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
export {
|
|
64
|
-
cleanDir,
|
|
65
|
-
copyFile,
|
|
66
|
-
cp,
|
|
67
|
-
mkdir,
|
|
68
|
-
readFile,
|
|
69
|
-
writeFile
|
|
70
|
-
};
|