@interactivethings/scripts 2.0.2 → 2.0.4

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/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interactivethings/scripts",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "main": "dist/index.js",
5
5
  "exports": {
6
6
  ".": "./dist/index.js",
@@ -1,189 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
- Object.defineProperty(exports, "__esModule", { value: true });
29
- const vitest_1 = require("vitest");
30
- const argparse_1 = require("argparse");
31
- const cli_1 = require("../figma/cli");
32
- const fs = __importStar(require("fs/promises"));
33
- const path_1 = __importDefault(require("path"));
34
- // Mock the API and other dependencies
35
- vitest_1.vi.mock("../figma/api", () => ({
36
- createAPI: vitest_1.vi.fn(),
37
- }));
38
- vitest_1.vi.mock("@interactivethings/scripts/figma/images", () => ({
39
- optimizeImage: vitest_1.vi.fn(),
40
- }));
41
- vitest_1.vi.mock("../config", () => ({
42
- loadConfig: vitest_1.vi.fn(),
43
- mergeConfigWithArgs: vitest_1.vi.fn(),
44
- validateRequiredConfig: vitest_1.vi.fn(),
45
- }));
46
- vitest_1.vi.mock("fs/promises");
47
- vitest_1.vi.mock("ora", () => ({
48
- default: vitest_1.vi.fn(() => ({
49
- start: vitest_1.vi.fn().mockReturnThis(),
50
- stop: vitest_1.vi.fn().mockReturnThis(),
51
- text: "",
52
- render: vitest_1.vi.fn(),
53
- })),
54
- }));
55
- const api_1 = require("../figma/api");
56
- const images_1 = require("@interactivethings/scripts/figma/images");
57
- const config_1 = require("../config");
58
- (0, vitest_1.describe)("Figma CLI", () => {
59
- const mockAPI = {
60
- images: {
61
- fetch: vitest_1.vi.fn(),
62
- },
63
- nodes: {
64
- fetch: vitest_1.vi.fn(),
65
- },
66
- };
67
- (0, vitest_1.beforeEach)(() => {
68
- vitest_1.vi.clearAllMocks();
69
- vitest_1.vi.mocked(api_1.createAPI).mockReturnValue(mockAPI);
70
- vitest_1.vi.mocked(config_1.loadConfig).mockResolvedValue({});
71
- vitest_1.vi.mocked(config_1.mergeConfigWithArgs).mockReturnValue({
72
- token: "test-token",
73
- assets: [
74
- {
75
- name: "test-assets",
76
- url: "https://www.figma.com/design/test-file-id/Test?node-id=123-456",
77
- output: "./test-output",
78
- },
79
- ],
80
- });
81
- vitest_1.vi.mocked(config_1.validateRequiredConfig).mockImplementation(() => { });
82
- });
83
- (0, vitest_1.describe)("configParser", () => {
84
- (0, vitest_1.it)("should configure the argument parser correctly", () => {
85
- const parser = new argparse_1.ArgumentParser();
86
- const addSubparsersSpy = vitest_1.vi.spyOn(parser, "add_subparsers");
87
- (0, cli_1.configParser)(parser);
88
- (0, vitest_1.expect)(addSubparsersSpy).toHaveBeenCalledWith({
89
- title: "commands",
90
- dest: "subcommand",
91
- });
92
- });
93
- });
94
- (0, vitest_1.describe)("run", () => {
95
- (0, vitest_1.describe)("download subcommand", () => {
96
- (0, vitest_1.it)("should successfully download assets", async () => {
97
- const mockImages = [
98
- {
99
- name: "test-image",
100
- format: "png",
101
- data: Buffer.from("test-data"),
102
- },
103
- ];
104
- mockAPI.images.fetch.mockResolvedValue(mockImages);
105
- vitest_1.vi.mocked(fs.mkdir).mockResolvedValue(undefined);
106
- vitest_1.vi.mocked(fs.writeFile).mockResolvedValue(undefined);
107
- vitest_1.vi.mocked(images_1.optimizeImage).mockResolvedValue(undefined);
108
- const consoleSpy = vitest_1.vi
109
- .spyOn(console, "log")
110
- .mockImplementation(() => { });
111
- const args = {
112
- subcommand: "download",
113
- name: "test-assets",
114
- config: undefined,
115
- token: undefined,
116
- };
117
- await (0, cli_1.run)(args);
118
- (0, vitest_1.expect)(config_1.loadConfig).toHaveBeenCalledWith(undefined);
119
- (0, vitest_1.expect)(api_1.createAPI).toHaveBeenCalledWith("test-token");
120
- (0, vitest_1.expect)(mockAPI.images.fetch).toHaveBeenCalled();
121
- (0, vitest_1.expect)(fs.mkdir).toHaveBeenCalledWith(path_1.default.dirname("./test-output/test-image.png"), { recursive: true });
122
- (0, vitest_1.expect)(fs.writeFile).toHaveBeenCalledWith("./test-output/test-image.png", Buffer.from("test-data"));
123
- (0, vitest_1.expect)(images_1.optimizeImage).toHaveBeenCalledWith("./test-output/test-image.png");
124
- consoleSpy.mockRestore();
125
- });
126
- (0, vitest_1.it)("should throw error when no assets are configured", async () => {
127
- vitest_1.vi.mocked(config_1.mergeConfigWithArgs).mockReturnValue({
128
- token: "test-token",
129
- assets: [],
130
- });
131
- const args = {
132
- subcommand: "download",
133
- name: "test-assets",
134
- config: undefined,
135
- token: undefined,
136
- };
137
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow("No figma assets configured");
138
- });
139
- (0, vitest_1.it)("should throw error when asset is not found", async () => {
140
- vitest_1.vi.mocked(config_1.mergeConfigWithArgs).mockReturnValue({
141
- token: "test-token",
142
- assets: [
143
- {
144
- name: "other-assets",
145
- url: "https://www.figma.com/design/test-file-id/Test?node-id=123-456",
146
- output: "./test-output",
147
- },
148
- ],
149
- });
150
- const args = {
151
- subcommand: "download",
152
- name: "test-assets",
153
- config: undefined,
154
- token: undefined,
155
- };
156
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow('No asset configuration found for name "test-assets"');
157
- });
158
- });
159
- (0, vitest_1.describe)("get subcommand", () => {
160
- (0, vitest_1.it)("should successfully get node data", async () => {
161
- const mockNodeData = { nodes: { "test-node": { id: "test-node" } } };
162
- mockAPI.nodes.fetch.mockResolvedValue(mockNodeData);
163
- const consoleSpy = vitest_1.vi
164
- .spyOn(console, "log")
165
- .mockImplementation(() => { });
166
- const args = {
167
- subcommand: "get",
168
- url: "https://www.figma.com/design/test-file-id/Test?node-id=123-456",
169
- config: undefined,
170
- token: undefined,
171
- };
172
- await (0, cli_1.run)(args);
173
- (0, vitest_1.expect)(mockAPI.nodes.fetch).toHaveBeenCalled();
174
- (0, vitest_1.expect)(consoleSpy).toHaveBeenCalledWith(JSON.stringify(mockNodeData, null, 2));
175
- consoleSpy.mockRestore();
176
- });
177
- });
178
- (0, vitest_1.it)("should validate required configuration", async () => {
179
- const args = {
180
- subcommand: "download",
181
- name: "test-assets",
182
- config: undefined,
183
- token: undefined,
184
- };
185
- await (0, cli_1.run)(args);
186
- (0, vitest_1.expect)(config_1.validateRequiredConfig).toHaveBeenCalledWith(vitest_1.expect.objectContaining({ token: "test-token" }), ["token"]);
187
- });
188
- });
189
- });
@@ -1,197 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const vitest_1 = require("vitest");
27
- const argparse_1 = require("argparse");
28
- const cli_1 = require("../tokens-studio/cli");
29
- const fs = __importStar(require("fs"));
30
- const path = __importStar(require("path"));
31
- // Mock dependencies
32
- vitest_1.vi.mock("../config", () => ({
33
- loadConfig: vitest_1.vi.fn(),
34
- mergeConfigWithArgs: vitest_1.vi.fn(),
35
- validateRequiredConfig: vitest_1.vi.fn(),
36
- }));
37
- vitest_1.vi.mock("../tokens-studio/utils", () => ({
38
- deepMerge: vitest_1.vi.fn(),
39
- }));
40
- vitest_1.vi.mock("fs");
41
- const config_1 = require("../config");
42
- const utils_1 = require("../tokens-studio/utils");
43
- (0, vitest_1.describe)("Tokens Studio CLI", () => {
44
- let tempDir;
45
- let transformerPath;
46
- (0, vitest_1.beforeEach)(() => {
47
- vitest_1.vi.clearAllMocks();
48
- // Set up test paths
49
- tempDir = "/tmp/test-dir";
50
- transformerPath = path.join(tempDir, "test-transformer.js");
51
- // Mock loadConfig
52
- vitest_1.vi.mocked(config_1.loadConfig).mockResolvedValue({});
53
- // Mock validateRequiredConfig to not throw
54
- vitest_1.vi.mocked(config_1.validateRequiredConfig).mockImplementation(() => { });
55
- // Mock deepMerge
56
- vitest_1.vi.mocked(utils_1.deepMerge).mockImplementation((target, source) => {
57
- Object.assign(target, source);
58
- });
59
- });
60
- (0, vitest_1.describe)("configParser", () => {
61
- (0, vitest_1.it)("should configure the argument parser correctly", () => {
62
- const parser = new argparse_1.ArgumentParser();
63
- const addSubparsersSpy = vitest_1.vi.spyOn(parser, "add_subparsers");
64
- (0, cli_1.configParser)(parser);
65
- (0, vitest_1.expect)(addSubparsersSpy).toHaveBeenCalledWith({
66
- title: "tokens-studio commands",
67
- dest: "subcommand",
68
- help: "Use 'ixt tokens-studio <subcommand> --help' for more information",
69
- });
70
- });
71
- });
72
- (0, vitest_1.describe)("run", () => {
73
- (0, vitest_1.beforeEach)(() => {
74
- // Mock mergeConfigWithArgs to return our test configuration
75
- vitest_1.vi.mocked(config_1.mergeConfigWithArgs).mockReturnValue({
76
- handler: transformerPath,
77
- input: path.join(tempDir, "tokens"),
78
- output: path.join(tempDir, "output.json"),
79
- });
80
- // Mock fs.existsSync to return true for our paths
81
- vitest_1.vi.mocked(fs.existsSync).mockReturnValue(true);
82
- // Mock fs.readFileSync for token files
83
- vitest_1.vi.mocked(fs.readFileSync).mockImplementation((pathStr, _encoding) => {
84
- const pathString = pathStr.toString();
85
- if (pathString.includes("$metadata.json")) {
86
- return JSON.stringify({ tokenSetOrder: ["base", "semantic"] });
87
- }
88
- if (pathString.includes("base.json")) {
89
- return JSON.stringify({
90
- colors: { primary: { value: "#007bff", type: "color" } },
91
- });
92
- }
93
- if (pathString.includes("semantic.json")) {
94
- return JSON.stringify({
95
- colors: {
96
- background: { value: "{colors.primary}", type: "color" },
97
- },
98
- });
99
- }
100
- return "";
101
- });
102
- // Mock fs.writeFileSync
103
- vitest_1.vi.mocked(fs.writeFileSync).mockImplementation(() => { });
104
- // Mock require to return a test transformer
105
- const mockRequire = vitest_1.vi.fn().mockReturnValue({
106
- transform: (input) => ({
107
- transformedTokens: input.tokenData,
108
- metadata: input.metadata,
109
- processed: true,
110
- }),
111
- });
112
- vitest_1.vi.stubGlobal("require", mockRequire);
113
- });
114
- (0, vitest_1.it)("should successfully transform tokens", async () => {
115
- const consoleSpy = vitest_1.vi.spyOn(console, "log").mockImplementation(() => { });
116
- const args = {
117
- subcommand: "transform",
118
- config: undefined,
119
- handler: undefined,
120
- input: undefined,
121
- output: undefined,
122
- };
123
- await (0, cli_1.run)(args);
124
- (0, vitest_1.expect)(config_1.loadConfig).toHaveBeenCalledWith(undefined);
125
- (0, vitest_1.expect)(config_1.validateRequiredConfig).toHaveBeenCalledWith(vitest_1.expect.objectContaining({
126
- handler: transformerPath,
127
- output: path.join(tempDir, "output.json"),
128
- }), ["handler", "output"]);
129
- (0, vitest_1.expect)(fs.writeFileSync).toHaveBeenCalledWith(path.join(tempDir, "output.json"), vitest_1.expect.stringContaining('"processed": true'));
130
- (0, vitest_1.expect)(consoleSpy).toHaveBeenCalledWith(`✅ Transformation complete! Output written to: ${path.join(tempDir, "output.json")}`);
131
- consoleSpy.mockRestore();
132
- });
133
- (0, vitest_1.it)("should throw error when handler file does not exist", async () => {
134
- vitest_1.vi.mocked(fs.existsSync).mockReturnValue(false);
135
- const args = {
136
- subcommand: "transform",
137
- config: undefined,
138
- handler: undefined,
139
- input: undefined,
140
- output: undefined,
141
- };
142
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow("Handler file not found");
143
- });
144
- (0, vitest_1.it)("should throw error when input directory does not exist", async () => {
145
- vitest_1.vi.mocked(fs.existsSync).mockImplementation((pathStr) => {
146
- const pathString = pathStr.toString();
147
- return pathString === transformerPath; // only transformer exists
148
- });
149
- const args = {
150
- subcommand: "transform",
151
- config: undefined,
152
- handler: undefined,
153
- input: undefined,
154
- output: undefined,
155
- };
156
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow("Input directory not found");
157
- });
158
- (0, vitest_1.it)("should throw error when transformer does not export transform function", async () => {
159
- // Override the require mock for this test
160
- const mockRequire = vitest_1.vi.fn().mockReturnValue({
161
- someOtherFunction: () => { },
162
- });
163
- vitest_1.vi.stubGlobal("require", mockRequire);
164
- const args = {
165
- subcommand: "transform",
166
- config: undefined,
167
- handler: undefined,
168
- input: undefined,
169
- output: undefined,
170
- };
171
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow("Handler file must export a 'transform' function");
172
- });
173
- (0, vitest_1.it)("should use default input directory when not specified", async () => {
174
- vitest_1.vi.mocked(config_1.mergeConfigWithArgs).mockReturnValue({
175
- handler: transformerPath,
176
- input: undefined,
177
- output: "./output.json",
178
- });
179
- // Mock existsSync to handle the default path
180
- vitest_1.vi.mocked(fs.existsSync).mockImplementation((pathStr) => {
181
- const pathString = pathStr.toString();
182
- return pathString === transformerPath || pathString.includes("tokens"); // Should resolve to './tokens'
183
- });
184
- const consoleSpy = vitest_1.vi.spyOn(console, "log").mockImplementation(() => { });
185
- const args = {
186
- subcommand: "transform",
187
- config: undefined,
188
- handler: undefined,
189
- input: undefined,
190
- output: undefined,
191
- };
192
- await (0, cli_1.run)(args);
193
- (0, vitest_1.expect)(consoleSpy).toHaveBeenCalledWith(vitest_1.expect.stringContaining("✅ Transformation complete!"));
194
- consoleSpy.mockRestore();
195
- });
196
- });
197
- });
@@ -1,86 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const argparse_1 = require("argparse");
5
- const cli_1 = require("../vercel/cli");
6
- // Mock the waitForDeploymentReady function
7
- vitest_1.vi.mock("@interactivethings/scripts/vercel/deployments", () => ({
8
- waitForDeploymentReady: vitest_1.vi.fn(),
9
- }));
10
- const deployments_1 = require("@interactivethings/scripts/vercel/deployments");
11
- (0, vitest_1.describe)("Vercel CLI", () => {
12
- (0, vitest_1.beforeEach)(() => {
13
- vitest_1.vi.clearAllMocks();
14
- // Mock environment variable
15
- process.env.VERCEL_TOKEN = "test-token";
16
- });
17
- (0, vitest_1.describe)("configParser", () => {
18
- (0, vitest_1.it)("should configure the argument parser correctly", () => {
19
- const parser = new argparse_1.ArgumentParser();
20
- const addSubparsersSpy = vitest_1.vi.spyOn(parser, "add_subparsers");
21
- (0, cli_1.configParser)(parser);
22
- (0, vitest_1.expect)(addSubparsersSpy).toHaveBeenCalledWith({
23
- title: "Vercel commands",
24
- dest: "subcommand",
25
- help: "Use 'ixt vercel <command> --help' for more information",
26
- });
27
- });
28
- });
29
- (0, vitest_1.describe)("run", () => {
30
- (0, vitest_1.it)("should successfully wait for deployment with valid args", async () => {
31
- const mockDeployment = {
32
- url: "test-deployment.vercel.app",
33
- state: "READY",
34
- meta: {
35
- githubCommitSha: "test-commit-sha",
36
- },
37
- };
38
- vitest_1.vi.mocked(deployments_1.waitForDeploymentReady).mockResolvedValue(mockDeployment);
39
- const consoleSpy = vitest_1.vi.spyOn(console, "log").mockImplementation(() => { });
40
- const args = {
41
- subcommand: "wait-deployment",
42
- commit: "test-commit-sha",
43
- interval: 5000,
44
- timeout: 600000,
45
- team: "test-team",
46
- project: "test-project",
47
- };
48
- await (0, cli_1.run)(args);
49
- (0, vitest_1.expect)(deployments_1.waitForDeploymentReady).toHaveBeenCalledWith({
50
- commitSha: "test-commit-sha",
51
- interval: 5000,
52
- timeout: 600000,
53
- team: "test-team",
54
- project: "test-project",
55
- accessToken: "test-token",
56
- });
57
- (0, vitest_1.expect)(consoleSpy).toHaveBeenCalledWith("DEPLOYMENT_URL=https://test-deployment.vercel.app");
58
- consoleSpy.mockRestore();
59
- });
60
- (0, vitest_1.it)("should throw error when deployment is not found", async () => {
61
- vitest_1.vi.mocked(deployments_1.waitForDeploymentReady).mockResolvedValue(undefined);
62
- const args = {
63
- subcommand: "wait-deployment",
64
- commit: "test-commit-sha",
65
- interval: 5000,
66
- timeout: 600000,
67
- team: "test-team",
68
- project: "test-project",
69
- };
70
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow("Could not retrieve deployment");
71
- });
72
- (0, vitest_1.it)("should throw error when waitForDeploymentReady fails", async () => {
73
- const error = new Error("Network error");
74
- vitest_1.vi.mocked(deployments_1.waitForDeploymentReady).mockRejectedValue(error);
75
- const args = {
76
- subcommand: "wait-deployment",
77
- commit: "test-commit-sha",
78
- interval: 5000,
79
- timeout: 600000,
80
- team: "test-team",
81
- project: "test-project",
82
- };
83
- await (0, vitest_1.expect)((0, cli_1.run)(args)).rejects.toThrow("Network error");
84
- });
85
- });
86
- });
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
package/dist/config.d.ts DELETED
@@ -1,78 +0,0 @@
1
- import { z } from "zod";
2
- /**
3
- * Figma configuration schema
4
- */
5
- export declare const FigmaAssetConfigSchema: z.ZodObject<{
6
- url: z.ZodString;
7
- output: z.ZodString;
8
- name: z.ZodString;
9
- }, z.core.$strip>;
10
- export declare const FigmaConfigSchema: z.ZodObject<{
11
- token: z.ZodOptional<z.ZodString>;
12
- assets: z.ZodDefault<z.ZodArray<z.ZodObject<{
13
- url: z.ZodString;
14
- output: z.ZodString;
15
- name: z.ZodString;
16
- }, z.core.$strip>>>;
17
- }, z.core.$strip>;
18
- /**
19
- * Tokens Studio configuration schema
20
- */
21
- export declare const TokensStudioConfigSchema: z.ZodObject<{
22
- input: z.ZodDefault<z.ZodString>;
23
- output: z.ZodOptional<z.ZodString>;
24
- handler: z.ZodOptional<z.ZodString>;
25
- }, z.core.$strip>;
26
- /**
27
- * Vercel configuration schema
28
- */
29
- export declare const VercelConfigSchema: z.ZodObject<{
30
- team: z.ZodOptional<z.ZodString>;
31
- project: z.ZodOptional<z.ZodString>;
32
- }, z.core.$strip>;
33
- /**
34
- * Main IXT Scripts configuration schema
35
- */
36
- export declare const IxtConfigSchema: z.ZodObject<{
37
- figma: z.ZodOptional<z.ZodObject<{
38
- token: z.ZodOptional<z.ZodString>;
39
- assets: z.ZodDefault<z.ZodArray<z.ZodObject<{
40
- url: z.ZodString;
41
- output: z.ZodString;
42
- name: z.ZodString;
43
- }, z.core.$strip>>>;
44
- }, z.core.$strip>>;
45
- tokensStudio: z.ZodOptional<z.ZodObject<{
46
- input: z.ZodDefault<z.ZodString>;
47
- output: z.ZodOptional<z.ZodString>;
48
- handler: z.ZodOptional<z.ZodString>;
49
- }, z.core.$strip>>;
50
- vercel: z.ZodOptional<z.ZodObject<{
51
- team: z.ZodOptional<z.ZodString>;
52
- project: z.ZodOptional<z.ZodString>;
53
- }, z.core.$strip>>;
54
- }, z.core.$strip>;
55
- export type IxtConfig = z.infer<typeof IxtConfigSchema>;
56
- export type FigmaConfig = z.infer<typeof FigmaConfigSchema>;
57
- export type FigmaAssetConfig = z.infer<typeof FigmaAssetConfigSchema>;
58
- export type TokensStudioConfig = z.infer<typeof TokensStudioConfigSchema>;
59
- export type VercelConfig = z.infer<typeof VercelConfigSchema>;
60
- /**
61
- * Helper function for type-safe configuration definition
62
- * Provides IntelliSense and validation for the configuration object
63
- */
64
- export declare function defineConfig(config: IxtConfig): IxtConfig;
65
- /**
66
- * Load configuration from a TypeScript file
67
- * Only supports .ts configuration files for better type safety
68
- */
69
- export declare function loadConfig(configPath?: string): Promise<IxtConfig>;
70
- /**
71
- * Merge CLI arguments with configuration
72
- * CLI arguments take precedence over config file values
73
- */
74
- export declare function mergeConfigWithArgs<T extends Record<string, any>>(config: IxtConfig, args: T, section: keyof IxtConfig): T & Partial<IxtConfig[keyof IxtConfig]>;
75
- /**
76
- * Validate that required values are present after merging config and args
77
- */
78
- export declare function validateRequiredConfig<T extends Record<string, any>>(mergedConfig: T, requiredFields: (keyof T)[]): void;
@@ -1,71 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- type Color = {
4
- r: number;
5
- g: number;
6
- b: number;
7
- a: number;
8
- };
9
- type FileId = string;
10
- type NodeId = string;
11
- export type FigmaNode = ({
12
- type: "RECTANGLE";
13
- fills: {
14
- type: "SOLID";
15
- color: Color;
16
- }[];
17
- effects: {
18
- type: "DROP_SHADOW";
19
- offset: {
20
- x: number;
21
- y: number;
22
- };
23
- color: Color;
24
- radius: number;
25
- }[];
26
- } | {
27
- type: "TEXT";
28
- style: {
29
- fontFamily: string;
30
- fontWeight: number;
31
- fontSize: number;
32
- letterSpacing: number;
33
- lineHeightPx: number;
34
- };
35
- }) & {
36
- name: string;
37
- id: string;
38
- };
39
- export declare const createAPI: (figmaToken: string) => {
40
- file: {
41
- fetch: (fileId: FileId) => Promise<any>;
42
- };
43
- nodes: {
44
- fetch: (fileId: FileId, ids: NodeId[]) => Promise<any>;
45
- };
46
- styles: {
47
- fetch: (fileId: FileId) => Promise<{
48
- nodes: {
49
- document: FigmaNode;
50
- }[];
51
- }>;
52
- };
53
- /**
54
- * Given a root node, fetches all exports of the nodes in the tree.
55
- * This is especially useful to fetch all icons or assets from a design system.
56
- */
57
- images: {
58
- fetch: (fileId: FileId, nodeIds: string[], { onFetchSources, onFetchImage, }?: {
59
- onFetchSources?: ((sources: {
60
- name: string;
61
- format: string;
62
- }[]) => void) | undefined;
63
- onFetchImage?: ((url: string) => void) | undefined;
64
- }) => Promise<{
65
- data: string | Buffer;
66
- name: string;
67
- format: string;
68
- }[]>;
69
- };
70
- };
71
- export {};
@@ -1,20 +0,0 @@
1
- /**
2
- * This script downloads the assets from Figma and saves them into the repository.
3
- * It is configured via the unified ixt configuration system.
4
- *
5
- * @example ixt.config.js
6
- * import { defineConfig } from '@interactivethings/scripts';
7
- *
8
- * export default defineConfig({
9
- * figma: {
10
- * assets: [{
11
- * name: "illustrations",
12
- * url: "https://www.figma.com/design/ElWWZIcOGFhiT06rzfIwRO/Design-System?node-id=11861-10071",
13
- * output: "src/assets/illustrations"
14
- * }]
15
- * }
16
- * });
17
- */
18
- import { ArgumentParser } from "argparse";
19
- export declare const configParser: (parser: ArgumentParser) => void;
20
- export declare const run: (parser: ArgumentParser) => Promise<void>;