figma-token 0.1.2 → 0.1.3
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/README.md +11 -7
- package/dist/index.js +19 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install
|
|
8
|
+
npm install -D figma-token
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
The Figma Plugin can download all six formats directly. Use this CLI when a project needs those files written to a predictable folder and checked for changes.
|
|
11
|
+
The Figma Plugin can download a ZIP or all six formats directly. Use this optional CLI when a project needs those files written to a predictable folder and checked for changes.
|
|
12
12
|
|
|
13
13
|
## Apply Plugin Tokens
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
figma-token
|
|
16
|
+
npx figma-token
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Without an input path, the CLI reads `./tokens.json` from the current project and creates the following files in `./figma-token-output/`:
|
|
20
20
|
|
|
21
21
|
```text
|
|
22
22
|
tokens.json
|
|
@@ -30,21 +30,25 @@ tokens.dtcg.json
|
|
|
30
30
|
Choose a project directory with `--out`:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
figma-token
|
|
33
|
+
npx figma-token --out ./src/tokens
|
|
34
|
+
npx figma-token ./figma-export.json
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
Preview all generated files without writing anything:
|
|
37
38
|
|
|
38
39
|
```bash
|
|
39
|
-
figma-token
|
|
40
|
+
npx figma-token --dry-run
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
Check whether generated files are current:
|
|
43
44
|
|
|
44
45
|
```bash
|
|
45
|
-
figma-token check
|
|
46
|
+
npx figma-token --check
|
|
47
|
+
npx figma-token --check --out ./src/tokens
|
|
46
48
|
```
|
|
47
49
|
|
|
50
|
+
`--check` and `--dry-run` cannot be used together. The old `check` subcommand is not supported.
|
|
51
|
+
|
|
48
52
|
## Advanced Sync
|
|
49
53
|
|
|
50
54
|
The hidden `sync` command retains the previous single-format, snapshot, and Figma REST API flow for advanced users. It accepts `--input`, `--output`, `--snapshot`, `--format`, `--export-name`, `--figma-token`, `--file-key`, and `--dry-run`.
|
package/dist/index.js
CHANGED
|
@@ -227,6 +227,9 @@ var tokenFileNames = ["tokens.json", "theme.ts", "variables.css", "tokens.scss",
|
|
|
227
227
|
function defaultOutputDirectory(cwd = process.cwd()) {
|
|
228
228
|
return resolve(cwd, "figma-token-output");
|
|
229
229
|
}
|
|
230
|
+
function defaultInputFile(cwd = process.cwd()) {
|
|
231
|
+
return resolve(cwd, "tokens.json");
|
|
232
|
+
}
|
|
230
233
|
var outputDirectory = (output) => resolve(output ?? defaultOutputDirectory());
|
|
231
234
|
async function readPluginTokens(input) {
|
|
232
235
|
const inputPath = resolve(input);
|
|
@@ -399,11 +402,22 @@ var format = (value) => {
|
|
|
399
402
|
if (!formats.includes(value)) throw new InvalidArgumentError(`format\uC740 ${formats.join(", ")} \uC911 \uD558\uB098\uC5EC\uC57C \uD569\uB2C8\uB2E4.`);
|
|
400
403
|
return value;
|
|
401
404
|
};
|
|
402
|
-
var program = new Command().name("figma-token").description("Plugin tokens.json\uC744 \uD504\uB85C\uC81D\uD2B8 \uD1A0\uD070 \uD30C\uC77C\uB85C \uC801\uC6A9\uD569\uB2C8\uB2E4.").version("0.1.
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
405
|
+
var program = new Command().name("figma-token").description("Plugin tokens.json\uC744 \uD504\uB85C\uC81D\uD2B8 \uD1A0\uD070 \uD30C\uC77C\uB85C \uC801\uC6A9\uD569\uB2C8\uB2E4.").version("0.1.3").argument("[input]", "Figma Plugin\uC5D0\uC11C \uB2E4\uC6B4\uB85C\uB4DC\uD55C tokens.json (default: ./tokens.json)").option("--out <directory>", "\uCD9C\uB825 \uD3F4\uB354 (default: ./figma-token-output)").option("--dry-run", "\uD30C\uC77C\uC744 \uC4F0\uC9C0 \uC54A\uACE0 \uC0DD\uC131 \uACB0\uACFC\uB97C \uD655\uC778").option("--check", "\uD604\uC7AC \uD1A0\uD070 \uD30C\uC77C\uC774 \uCD5C\uC2E0\uC778\uC9C0 \uD655\uC778").action(async (input, options) => {
|
|
406
|
+
if (options.check && options.dryRun) throw new Error("--check\uC640 --dry-run\uC740 \uD568\uAED8 \uC0AC\uC6A9\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. \uD558\uB098\uB9CC \uC0AC\uC6A9\uD558\uC138\uC694.");
|
|
407
|
+
const defaultInput = !input;
|
|
408
|
+
const inputPath = input ?? defaultInputFile();
|
|
409
|
+
try {
|
|
410
|
+
if (options.check) {
|
|
411
|
+
process.exitCode = await checkTokenFiles({ input: inputPath, output: options.out ?? defaultOutputDirectory() });
|
|
412
|
+
return;
|
|
413
|
+
}
|
|
414
|
+
await exportTokenFiles({ input: inputPath, output: options.out ?? defaultOutputDirectory(), dryRun: options.dryRun });
|
|
415
|
+
} catch (error) {
|
|
416
|
+
if (defaultInput && error instanceof Error && error.message.startsWith("Input file not found:")) {
|
|
417
|
+
throw new Error("Expected token file: ./tokens.json\nProvide another file with: figma-token <input>");
|
|
418
|
+
}
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
407
421
|
});
|
|
408
422
|
program.command("sync", { hidden: true }).option("--input <path>", "\uB85C\uCEEC Figma Variables JSON").option("--output <path>", "\uCD9C\uB825 \uD30C\uC77C", "./tokens.json").option("--snapshot <path>", "snapshot \uD30C\uC77C", ".figma-token/snapshot.json").option("--format <format>", "\uCD9C\uB825 \uD3EC\uB9F7", format, "tokens-json").option("--export-name <name>", "theme.ts export \uC774\uB984", "theme").option("--figma-token <token>", "Figma token").option("--file-key <key>", "Figma file key").option("--dry-run", "\uD30C\uC77C\uC744 \uC4F0\uC9C0 \uC54A\uACE0 diff\uB9CC \uCD9C\uB825", false).action(async (options) => sync({
|
|
409
423
|
...options,
|