@interactivethings/scripts 2.1.3 → 2.2.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/README.md +26 -26
- package/dist/cli.d.ts +2 -0
- package/dist/cloudflare/cli.d.ts +13 -0
- package/dist/cloudflare/cloudflare.d.ts +69 -0
- package/dist/cloudflare/deployments.d.ts +9 -0
- package/dist/config.d.ts +92 -0
- package/dist/config.js +0 -11
- package/dist/figma/api.d.ts +69 -0
- package/dist/figma/cli.d.ts +30 -0
- package/dist/figma/cli.test.d.ts +1 -0
- package/dist/figma/images.d.ts +1 -0
- package/dist/figma/utils.d.ts +10 -0
- package/dist/index.d.ts +8 -0
- package/dist/init/cli.d.ts +5 -0
- package/dist/init/cli.js +9 -0
- package/dist/shared/cli.d.ts +32 -0
- package/dist/shared/deployment-service.d.ts +7 -0
- package/dist/shared/wait-deployment.d.ts +7 -0
- package/dist/tokens-studio/__tests__/fixtures/invalid-transformer.d.ts +9 -0
- package/dist/tokens-studio/__tests__/fixtures/test-transformer.d.ts +18 -0
- package/dist/tokens-studio/cli.d.ts +14 -0
- package/dist/tokens-studio/cli.test.d.ts +1 -0
- package/dist/tokens-studio/index.d.ts +9 -0
- package/dist/tokens-studio/index.js +6 -1
- package/dist/tokens-studio/require.d.ts +3 -0
- package/dist/tokens-studio/types.d.ts +22 -0
- package/dist/tokens-studio/utils.d.ts +60 -0
- package/dist/tokens-studio/utils.js +37 -1
- package/dist/types.d.ts +2 -0
- package/dist/vercel/cli.d.ts +11 -0
- package/dist/vercel/cli.test.d.ts +1 -0
- package/dist/vercel/deployments.d.ts +8 -0
- package/dist/vercel/vercel.d.ts +15 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,32 +69,6 @@ ixt-scripts uses a unified configuration system with a single `ixt.config.ts` fi
|
|
|
69
69
|
|
|
70
70
|
For detailed configuration options and schema reference, see [CONFIG.md](./CONFIG.md).
|
|
71
71
|
|
|
72
|
-
## Creating Custom Transformers
|
|
73
|
-
|
|
74
|
-
You can create custom transformers for the tokens-studio command:
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
// transforms/my-transform.ts
|
|
78
|
-
export function transform(input: { metadata: any; tokenData: any }) {
|
|
79
|
-
// Transform the tokens to your desired format
|
|
80
|
-
return {
|
|
81
|
-
colors: transformColors(input.tokenData.colors),
|
|
82
|
-
typography: transformTypography(input.tokenData.typography),
|
|
83
|
-
// ... other transformations
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Then reference it in your config:
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
export default defineConfig({
|
|
92
|
-
tokensStudio: {
|
|
93
|
-
handler: "./transforms/my-transform.ts",
|
|
94
|
-
},
|
|
95
|
-
});
|
|
96
|
-
```
|
|
97
|
-
|
|
98
72
|
## Available Commands
|
|
99
73
|
|
|
100
74
|
### Figma Commands
|
|
@@ -140,6 +114,32 @@ UI frameworks like MUI and Tailwind require variables in specific formats, while
|
|
|
140
114
|
3. Developers store token files in the code repository
|
|
141
115
|
4. Developers run `ixt tokens-studio transform` to convert tokens for their framework
|
|
142
116
|
|
|
117
|
+
#### Creating Custom Transformers
|
|
118
|
+
|
|
119
|
+
You can create custom transformers for the tokens-studio command:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
// transforms/my-transform.ts
|
|
123
|
+
export function transform(input: { metadata: any; tokenData: any }) {
|
|
124
|
+
// Transform the tokens to your desired format
|
|
125
|
+
return {
|
|
126
|
+
colors: transformColors(input.tokenData.colors),
|
|
127
|
+
typography: transformTypography(input.tokenData.typography),
|
|
128
|
+
// ... other transformations
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Then reference it in your config:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
export default defineConfig({
|
|
137
|
+
tokensStudio: {
|
|
138
|
+
handler: "./transforms/my-transform.ts",
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
143
|
### Vercel Commands
|
|
144
144
|
|
|
145
145
|
Utilities for Vercel deployments:
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
type Args = {
|
|
3
|
+
subcommand: "wait-deployment";
|
|
4
|
+
commit: string;
|
|
5
|
+
interval: number;
|
|
6
|
+
timeout: number;
|
|
7
|
+
project?: string;
|
|
8
|
+
email?: string;
|
|
9
|
+
account_id?: string;
|
|
10
|
+
config?: string;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: import("../shared/cli").CLIModule<Args>;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IDeploymentService, Deployment } from "../shared/deployment-service";
|
|
2
|
+
/** /!\ Inferred with ChatGPT */
|
|
3
|
+
export type CloudflareDeployment = {
|
|
4
|
+
id: string;
|
|
5
|
+
short_id: string;
|
|
6
|
+
project_id: string;
|
|
7
|
+
project_name: string;
|
|
8
|
+
environment: string;
|
|
9
|
+
url: string;
|
|
10
|
+
created_on: string;
|
|
11
|
+
modified_on: string;
|
|
12
|
+
latest_stage: {
|
|
13
|
+
name: string;
|
|
14
|
+
started_on: string;
|
|
15
|
+
ended_on: string;
|
|
16
|
+
status: string;
|
|
17
|
+
};
|
|
18
|
+
deployment_trigger: {
|
|
19
|
+
type: string;
|
|
20
|
+
metadata: {
|
|
21
|
+
branch: string;
|
|
22
|
+
commit_hash: string;
|
|
23
|
+
commit_message: string;
|
|
24
|
+
commit_dirty: boolean;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
stages: {
|
|
28
|
+
name: string;
|
|
29
|
+
started_on: string;
|
|
30
|
+
ended_on: string;
|
|
31
|
+
status: string;
|
|
32
|
+
}[];
|
|
33
|
+
build_config: {
|
|
34
|
+
build_command: string;
|
|
35
|
+
destination_dir: string;
|
|
36
|
+
build_caching: boolean;
|
|
37
|
+
root_dir: string;
|
|
38
|
+
web_analytics_tag: string | null;
|
|
39
|
+
web_analytics_token: string | null;
|
|
40
|
+
};
|
|
41
|
+
source: {
|
|
42
|
+
type: string;
|
|
43
|
+
config: {
|
|
44
|
+
owner: string;
|
|
45
|
+
repo_name: string;
|
|
46
|
+
production_branch: string;
|
|
47
|
+
pr_comments_enabled: boolean;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
env_vars: Record<string, {
|
|
51
|
+
type: "secret_text" | "plain_text";
|
|
52
|
+
value: string;
|
|
53
|
+
}>;
|
|
54
|
+
compatibility_date: string;
|
|
55
|
+
compatibility_flags: string[];
|
|
56
|
+
build_image_major_version: number;
|
|
57
|
+
usage_model: string;
|
|
58
|
+
aliases: string[];
|
|
59
|
+
is_skipped: boolean;
|
|
60
|
+
production_branch: string;
|
|
61
|
+
};
|
|
62
|
+
export declare class CloudflareDeploymentService implements IDeploymentService {
|
|
63
|
+
private accountId;
|
|
64
|
+
private projectName;
|
|
65
|
+
private email;
|
|
66
|
+
private apiKey;
|
|
67
|
+
constructor(accountId: string, projectName: string, email: string, apiKey: string);
|
|
68
|
+
fetchForCommit(commitSha: string): Promise<Deployment[]>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function waitForDeploymentReady({ accountId, project, email, apiKey, commitSha, interval, timeout, }: {
|
|
2
|
+
accountId: string;
|
|
3
|
+
project: string;
|
|
4
|
+
email: string;
|
|
5
|
+
apiKey: string;
|
|
6
|
+
commitSha: string;
|
|
7
|
+
interval: number;
|
|
8
|
+
timeout: number;
|
|
9
|
+
}): Promise<import("../shared/deployment-service").Deployment | undefined>;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
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.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
|
+
* Cloudflare configuration schema
|
|
35
|
+
*/
|
|
36
|
+
export declare const CloudflareConfigSchema: z.ZodObject<{
|
|
37
|
+
project: z.ZodOptional<z.ZodString>;
|
|
38
|
+
email: z.ZodOptional<z.ZodString>;
|
|
39
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
/**
|
|
42
|
+
* Main IXT Scripts configuration schema
|
|
43
|
+
*/
|
|
44
|
+
export declare const IxtConfigSchema: z.ZodObject<{
|
|
45
|
+
figma: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
token: z.ZodOptional<z.ZodString>;
|
|
47
|
+
assets: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
48
|
+
url: z.ZodString;
|
|
49
|
+
output: z.ZodString;
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
}, z.core.$strip>>>;
|
|
52
|
+
}, z.core.$strip>>;
|
|
53
|
+
tokensStudio: z.ZodOptional<z.ZodObject<{
|
|
54
|
+
input: z.ZodDefault<z.ZodString>;
|
|
55
|
+
output: z.ZodOptional<z.ZodString>;
|
|
56
|
+
handler: z.ZodString;
|
|
57
|
+
}, z.core.$strip>>;
|
|
58
|
+
vercel: z.ZodOptional<z.ZodObject<{
|
|
59
|
+
team: z.ZodOptional<z.ZodString>;
|
|
60
|
+
project: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>>;
|
|
62
|
+
cloudflare: z.ZodOptional<z.ZodObject<{
|
|
63
|
+
project: z.ZodOptional<z.ZodString>;
|
|
64
|
+
email: z.ZodOptional<z.ZodString>;
|
|
65
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
}, z.core.$strip>;
|
|
68
|
+
export type IxtConfig = z.infer<typeof IxtConfigSchema>;
|
|
69
|
+
export type FigmaConfig = z.infer<typeof FigmaConfigSchema>;
|
|
70
|
+
export type FigmaAssetConfig = z.infer<typeof FigmaAssetConfigSchema>;
|
|
71
|
+
export type TokensStudioConfig = z.infer<typeof TokensStudioConfigSchema>;
|
|
72
|
+
export type VercelConfig = z.infer<typeof VercelConfigSchema>;
|
|
73
|
+
export type CloudflareConfig = z.infer<typeof CloudflareConfigSchema>;
|
|
74
|
+
/**
|
|
75
|
+
* Helper function for type-safe configuration definition
|
|
76
|
+
* Provides IntelliSense and validation for the configuration object
|
|
77
|
+
*/
|
|
78
|
+
export declare function defineConfig(config: IxtConfig): IxtConfig;
|
|
79
|
+
/**
|
|
80
|
+
* Load configuration from a TypeScript file
|
|
81
|
+
* Only supports .ts configuration files for better type safety
|
|
82
|
+
*/
|
|
83
|
+
export declare function loadConfig(configPath?: string): Promise<IxtConfig>;
|
|
84
|
+
/**
|
|
85
|
+
* Merge CLI arguments with configuration
|
|
86
|
+
* CLI arguments take precedence over config file values
|
|
87
|
+
*/
|
|
88
|
+
export declare function mergeConfigWithArgs<T extends Record<string, any>>(config: IxtConfig, args: T, section: keyof IxtConfig): T & Partial<IxtConfig[keyof IxtConfig]>;
|
|
89
|
+
/**
|
|
90
|
+
* Validate that required values are present after merging config and args
|
|
91
|
+
*/
|
|
92
|
+
export declare function validateRequiredConfig<T extends Record<string, any>>(mergedConfig: T, requiredFields: (keyof T)[]): void;
|
package/dist/config.js
CHANGED
|
@@ -107,17 +107,6 @@ exports.IxtConfigSchema = zod_1.z.object({
|
|
|
107
107
|
function defineConfig(config) {
|
|
108
108
|
return exports.IxtConfigSchema.parse(config);
|
|
109
109
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Default configuration values
|
|
112
|
-
*/
|
|
113
|
-
const DEFAULT_CONFIG = {
|
|
114
|
-
figma: {
|
|
115
|
-
assets: [],
|
|
116
|
-
},
|
|
117
|
-
tokensStudio: {
|
|
118
|
-
input: "./tokens",
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
110
|
/**
|
|
122
111
|
* Load configuration from a TypeScript file
|
|
123
112
|
* Only supports .ts configuration files for better type safety
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type Color = {
|
|
2
|
+
r: number;
|
|
3
|
+
g: number;
|
|
4
|
+
b: number;
|
|
5
|
+
a: number;
|
|
6
|
+
};
|
|
7
|
+
type FileId = string;
|
|
8
|
+
type NodeId = string;
|
|
9
|
+
export type FigmaNode = ({
|
|
10
|
+
type: "RECTANGLE";
|
|
11
|
+
fills: {
|
|
12
|
+
type: "SOLID";
|
|
13
|
+
color: Color;
|
|
14
|
+
}[];
|
|
15
|
+
effects: {
|
|
16
|
+
type: "DROP_SHADOW";
|
|
17
|
+
offset: {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
color: Color;
|
|
22
|
+
radius: number;
|
|
23
|
+
}[];
|
|
24
|
+
} | {
|
|
25
|
+
type: "TEXT";
|
|
26
|
+
style: {
|
|
27
|
+
fontFamily: string;
|
|
28
|
+
fontWeight: number;
|
|
29
|
+
fontSize: number;
|
|
30
|
+
letterSpacing: number;
|
|
31
|
+
lineHeightPx: number;
|
|
32
|
+
};
|
|
33
|
+
}) & {
|
|
34
|
+
name: string;
|
|
35
|
+
id: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const createAPI: (figmaToken: string) => {
|
|
38
|
+
file: {
|
|
39
|
+
fetch: (fileId: FileId) => Promise<any>;
|
|
40
|
+
};
|
|
41
|
+
nodes: {
|
|
42
|
+
fetch: (fileId: FileId, ids: NodeId[]) => Promise<any>;
|
|
43
|
+
};
|
|
44
|
+
styles: {
|
|
45
|
+
fetch: (fileId: FileId) => Promise<{
|
|
46
|
+
nodes: {
|
|
47
|
+
document: FigmaNode;
|
|
48
|
+
}[];
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Given a root node, fetches all exports of the nodes in the tree.
|
|
53
|
+
* This is especially useful to fetch all icons or assets from a design system.
|
|
54
|
+
*/
|
|
55
|
+
images: {
|
|
56
|
+
fetch: (fileId: FileId, nodeIds: string[], { onFetchSources, onFetchImage, }?: {
|
|
57
|
+
onFetchSources?: (sources: {
|
|
58
|
+
name: string;
|
|
59
|
+
format: string;
|
|
60
|
+
}[]) => void;
|
|
61
|
+
onFetchImage?: (url: string) => void;
|
|
62
|
+
}) => Promise<{
|
|
63
|
+
data: string | Buffer<ArrayBufferLike>;
|
|
64
|
+
name: string;
|
|
65
|
+
format: string;
|
|
66
|
+
}[]>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
type FigmaArgs = {
|
|
19
|
+
config?: string;
|
|
20
|
+
token?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
subcommand: "download";
|
|
23
|
+
} | {
|
|
24
|
+
config?: string;
|
|
25
|
+
token?: string;
|
|
26
|
+
subcommand: "get";
|
|
27
|
+
url: string;
|
|
28
|
+
};
|
|
29
|
+
declare const _default: import("../shared/cli").CLIModule<FigmaArgs>;
|
|
30
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const optimizeImage: (filepath: string) => Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Should parse a URL in the form https://www.figma.com/design/ElWWZIcOGFhiT06rzfIwRO/Design-System-%5BTPW-Mobile-App%5D?node-id=10404-19140&p=f&t=K5K37NzOSt1uwjsX-0
|
|
3
|
+
* and extracts the pageId and nodeId
|
|
4
|
+
* The page id is the part just after /design
|
|
5
|
+
*/
|
|
6
|
+
export declare const parseFigmaURL: (urlString: string) => {
|
|
7
|
+
figmaFileId: string;
|
|
8
|
+
figmaPageId: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const formatFigmaURL: (figmaFileId: string, figmaPageId: string) => string;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @interactivethings/scripts
|
|
3
|
+
*
|
|
4
|
+
* A collection of useful development tools by Interactive Things
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types";
|
|
7
|
+
export { defineConfig, type IxtConfig, type FigmaConfig, type TokensStudioConfig, } from "./config";
|
|
8
|
+
export * as tokensStudio from "./tokens-studio";
|
package/dist/init/cli.js
CHANGED
|
@@ -282,6 +282,15 @@ async function createProjectStructure(answers) {
|
|
|
282
282
|
const outputDir = path.dirname(path.join(cwd, answers.tokensOutputFile));
|
|
283
283
|
await fs.mkdir(outputDir, { recursive: true });
|
|
284
284
|
}
|
|
285
|
+
if (answers.stylingFramework === "mui") {
|
|
286
|
+
await fs.cp(path.join(__dirname, "../../examples/mui-transform.ts"), path.join(transformsDir, "mui-transform.ts"));
|
|
287
|
+
}
|
|
288
|
+
else if (answers.stylingFramework === "tailwind") {
|
|
289
|
+
await fs.cp(path.join(__dirname, "../../examples/tailwind-transform.ts"), path.join(transformsDir, "tailwind-transform.ts"));
|
|
290
|
+
}
|
|
291
|
+
else if (answers.stylingFramework === "custom") {
|
|
292
|
+
await fs.cp(path.join(__dirname, "../../examples/custom-transform.ts"), path.join(transformsDir, "custom-transform.ts"));
|
|
293
|
+
}
|
|
285
294
|
}
|
|
286
295
|
// Create assets directories if using Figma
|
|
287
296
|
if (answers.useFigma && answers.figmaAssets) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ArgumentParser } from "argparse";
|
|
2
|
+
/**
|
|
3
|
+
* Base interface that all CLI modules must implement
|
|
4
|
+
*/
|
|
5
|
+
export interface CLIModule<TArgs = any> {
|
|
6
|
+
/**
|
|
7
|
+
* Function to configure the argument parser for this module
|
|
8
|
+
*/
|
|
9
|
+
configParser: (parser: ArgumentParser) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Function to execute the module logic with parsed arguments
|
|
12
|
+
*/
|
|
13
|
+
run: (args: TArgs) => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Configuration object for defining a CLI module
|
|
17
|
+
*/
|
|
18
|
+
export interface CLIModuleConfig<TArgs = any> {
|
|
19
|
+
/**
|
|
20
|
+
* Function to configure the argument parser
|
|
21
|
+
*/
|
|
22
|
+
configParser: (parser: ArgumentParser) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Function to execute the module logic
|
|
25
|
+
*/
|
|
26
|
+
run: (args: TArgs) => Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Type-safe factory function for creating CLI modules
|
|
30
|
+
* Provides consistent interface and utilities for all CLI modules
|
|
31
|
+
*/
|
|
32
|
+
export declare function defineCLIModule<TArgs = any>(config: CLIModuleConfig<TArgs>): CLIModule<TArgs>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDeploymentService } from "./deployment-service";
|
|
2
|
+
export declare function waitForDeploymentReady({ commitSha, interval, timeout, deploymentService, }: {
|
|
3
|
+
commitSha: string;
|
|
4
|
+
interval: number;
|
|
5
|
+
timeout: number;
|
|
6
|
+
deploymentService: IDeploymentService;
|
|
7
|
+
}): Promise<import("./deployment-service").Deployment | undefined>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invalid transformer for testing error cases
|
|
3
|
+
* This transformer does not export a transform function
|
|
4
|
+
*/
|
|
5
|
+
declare function someOtherFunction(): string;
|
|
6
|
+
declare const _default: {
|
|
7
|
+
someOtherFunction: typeof someOtherFunction;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test transformer for tokens-studio CLI tests
|
|
3
|
+
* This transformer simply wraps the input tokens with metadata
|
|
4
|
+
*/
|
|
5
|
+
declare function transform(input: {
|
|
6
|
+
metadata: any;
|
|
7
|
+
tokenData: any;
|
|
8
|
+
}): {
|
|
9
|
+
source: string;
|
|
10
|
+
metadata: any;
|
|
11
|
+
tokens: any;
|
|
12
|
+
processed: boolean;
|
|
13
|
+
transformedAt: string;
|
|
14
|
+
};
|
|
15
|
+
declare const _default: {
|
|
16
|
+
transform: typeof transform;
|
|
17
|
+
};
|
|
18
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* CLI entry point for tokens-studio transformations
|
|
4
|
+
* Supports different transformer handlers via --handler argument
|
|
5
|
+
*/
|
|
6
|
+
type TokenStudioArgs = {
|
|
7
|
+
config?: string;
|
|
8
|
+
subcommand: "transform";
|
|
9
|
+
handler?: string;
|
|
10
|
+
input?: string;
|
|
11
|
+
output?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const _default: import("../shared/cli").CLIModule<TokenStudioArgs>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tokens Studio module for @interactivethings/scripts
|
|
3
|
+
*
|
|
4
|
+
* This module provides utilities and transformers for working with
|
|
5
|
+
* tokens exported from Tokens Studio (Figma plugin).
|
|
6
|
+
*/
|
|
7
|
+
export { simplifyValues, kebabCase, mapEntries, maybeParseToNumber, maybeParseToPx, isToken, deepMerge, resolveReferences, formatValues, flattenTokens, makeResolver, mapKeysRecursively, defineTransform, } from "./utils";
|
|
8
|
+
export type { Metadata, TransformInput, TransformerModule, TokenStudioShadowValue, TokenStudioShadowRecord, } from "./types";
|
|
9
|
+
export * as cli from "./cli";
|
|
@@ -39,7 +39,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
39
39
|
};
|
|
40
40
|
})();
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.cli = exports.flattenTokens = exports.formatValues = exports.resolveReferences = exports.deepMerge = exports.isToken = exports.maybeParseToPx = exports.maybeParseToNumber = exports.mapEntries = exports.kebabCase = exports.simplifyValues = void 0;
|
|
42
|
+
exports.cli = exports.defineTransform = exports.mapKeysRecursively = exports.makeResolver = exports.flattenTokens = exports.formatValues = exports.resolveReferences = exports.deepMerge = exports.isToken = exports.maybeParseToPx = exports.maybeParseToNumber = exports.mapEntries = exports.kebabCase = exports.simplifyValues = void 0;
|
|
43
43
|
// Export all utility functions
|
|
44
44
|
var utils_1 = require("./utils");
|
|
45
45
|
Object.defineProperty(exports, "simplifyValues", { enumerable: true, get: function () { return utils_1.simplifyValues; } });
|
|
@@ -52,5 +52,10 @@ Object.defineProperty(exports, "deepMerge", { enumerable: true, get: function ()
|
|
|
52
52
|
Object.defineProperty(exports, "resolveReferences", { enumerable: true, get: function () { return utils_1.resolveReferences; } });
|
|
53
53
|
Object.defineProperty(exports, "formatValues", { enumerable: true, get: function () { return utils_1.formatValues; } });
|
|
54
54
|
Object.defineProperty(exports, "flattenTokens", { enumerable: true, get: function () { return utils_1.flattenTokens; } });
|
|
55
|
+
Object.defineProperty(exports, "makeResolver", { enumerable: true, get: function () { return utils_1.makeResolver; } });
|
|
56
|
+
Object.defineProperty(exports, "mapKeysRecursively", { enumerable: true, get: function () { return utils_1.mapKeysRecursively; } });
|
|
57
|
+
Object.defineProperty(exports, "defineTransform", { enumerable: true, get: function () { return utils_1.defineTransform; } });
|
|
58
|
+
// Note: Transformers are now provided as examples in the examples/ directory
|
|
59
|
+
// Users should copy and customize these examples for their specific needs
|
|
55
60
|
// Export the CLI module (for internal use)
|
|
56
61
|
exports.cli = __importStar(require("./cli"));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface Metadata {
|
|
2
|
+
tokenSetOrder: string[];
|
|
3
|
+
}
|
|
4
|
+
export interface TransformInput {
|
|
5
|
+
metadata: Metadata;
|
|
6
|
+
tokenData: any;
|
|
7
|
+
}
|
|
8
|
+
export interface TransformerModule {
|
|
9
|
+
transform: (input: TransformInput) => any;
|
|
10
|
+
}
|
|
11
|
+
export type TokenStudioShadowValue = {
|
|
12
|
+
color: string;
|
|
13
|
+
x: string;
|
|
14
|
+
y: string;
|
|
15
|
+
blur: string;
|
|
16
|
+
spread: string;
|
|
17
|
+
};
|
|
18
|
+
export type TokenStudioShadowRecord = Record<string, {
|
|
19
|
+
value: TokenStudioShadowValue;
|
|
20
|
+
} | {
|
|
21
|
+
value: TokenStudioShadowValue[];
|
|
22
|
+
}>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { $IntentionalAny } from "../types";
|
|
2
|
+
import { Metadata } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Shared utility functions for tokens-studio transformations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Simplifies nested token values by extracting the 'value' property
|
|
8
|
+
*/
|
|
9
|
+
export declare const simplifyValues: (x: {
|
|
10
|
+
value: unknown;
|
|
11
|
+
} | string | null) => $IntentionalAny;
|
|
12
|
+
/**
|
|
13
|
+
* Converts space-separated strings to camelCase
|
|
14
|
+
*/
|
|
15
|
+
export declare const kebabCase: (x: string) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Maps over object entries with a custom mapper function
|
|
18
|
+
*/
|
|
19
|
+
export declare const mapEntries: <K extends string | number | symbol, V, K2 extends string | number | symbol, V2>(obj: Record<K, V>, mapper: (key: K, value: V) => [K2, V2]) => Record<K2, V2>;
|
|
20
|
+
/**
|
|
21
|
+
* Attempts to parse a string or number to a number, returns original if not possible
|
|
22
|
+
*/
|
|
23
|
+
export declare const maybeParseToNumber: (x: string | number) => string | number;
|
|
24
|
+
/**
|
|
25
|
+
* Converts a value to pixels (adds 'px' suffix if it's a number)
|
|
26
|
+
*/
|
|
27
|
+
export declare const maybeParseToPx: (x: string | number) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Type guard to check if an object is a token with value and type properties
|
|
30
|
+
*/
|
|
31
|
+
export declare const isToken: (obj: any) => obj is {
|
|
32
|
+
value: string;
|
|
33
|
+
type: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Deep merge utility for combining token objects
|
|
37
|
+
*/
|
|
38
|
+
export declare const deepMerge: (mergedTokens: any, tokenData: any) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Resolves token references (strings like "{path.to.token}") using a value map
|
|
41
|
+
*/
|
|
42
|
+
export declare const resolveReferences: (obj: any, map: Map<string, string>) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Formats token values by extracting the value property
|
|
45
|
+
*/
|
|
46
|
+
export declare const formatValues: (v: {
|
|
47
|
+
type: string;
|
|
48
|
+
value: string | number;
|
|
49
|
+
}) => string | number;
|
|
50
|
+
export declare const flattenTokens: (v: any, depth: number | undefined, transformKey: (key: string, depth: number) => string) => unknown;
|
|
51
|
+
/** Creates a resolver function for token references */
|
|
52
|
+
export declare const makeResolver: <T extends object>(data: T, keys: (keyof T)[]) => (str: string) => any;
|
|
53
|
+
export declare const mapKeysRecursively: (obj: $IntentionalAny, keyMapper: (key: string) => string) => Record<string, any>;
|
|
54
|
+
export declare const defineTransform: <TInput, TOutput = unknown>(transformFn: (input: {
|
|
55
|
+
tokenData: TInput;
|
|
56
|
+
metadata: Metadata;
|
|
57
|
+
}) => TOutput) => (input: {
|
|
58
|
+
tokenData: TInput;
|
|
59
|
+
metadata: Metadata;
|
|
60
|
+
}) => TOutput;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.flattenTokens = exports.formatValues = exports.resolveReferences = exports.deepMerge = exports.isToken = exports.maybeParseToPx = exports.maybeParseToNumber = exports.mapEntries = exports.kebabCase = exports.simplifyValues = void 0;
|
|
3
|
+
exports.defineTransform = exports.mapKeysRecursively = exports.makeResolver = exports.flattenTokens = exports.formatValues = exports.resolveReferences = exports.deepMerge = exports.isToken = exports.maybeParseToPx = exports.maybeParseToNumber = exports.mapEntries = exports.kebabCase = exports.simplifyValues = void 0;
|
|
4
4
|
const remeda_1 = require("remeda");
|
|
5
5
|
/**
|
|
6
6
|
* Shared utility functions for tokens-studio transformations
|
|
@@ -154,3 +154,39 @@ const flattenTokens = (v, depth = 0, transformKey) => {
|
|
|
154
154
|
return v;
|
|
155
155
|
};
|
|
156
156
|
exports.flattenTokens = flattenTokens;
|
|
157
|
+
/** Creates a resolver function for token references */
|
|
158
|
+
const makeResolver = (data, keys) => {
|
|
159
|
+
const index = {};
|
|
160
|
+
for (const k of keys) {
|
|
161
|
+
for (const [vName, value] of Object.entries(data[k])) {
|
|
162
|
+
if (typeof k !== "string")
|
|
163
|
+
continue;
|
|
164
|
+
index[`${k}.${vName}`] = value;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return (str) => {
|
|
168
|
+
var _a;
|
|
169
|
+
if (str[0] === "{" && str[str.length - 1] === "}") {
|
|
170
|
+
const path = str.substring(1, str.length - 1);
|
|
171
|
+
return (_a = index[path]) === null || _a === void 0 ? void 0 : _a.value;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
return str;
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
};
|
|
178
|
+
exports.makeResolver = makeResolver;
|
|
179
|
+
const mapKeysRecursively = (obj, keyMapper) => {
|
|
180
|
+
const visitor = (k, v) => {
|
|
181
|
+
if (typeof v === "object") {
|
|
182
|
+
return [keyMapper(k), (0, exports.mapEntries)(v, visitor)];
|
|
183
|
+
}
|
|
184
|
+
else {
|
|
185
|
+
return [keyMapper(k), v];
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
return (0, exports.mapEntries)(obj, visitor);
|
|
189
|
+
};
|
|
190
|
+
exports.mapKeysRecursively = mapKeysRecursively;
|
|
191
|
+
const defineTransform = (transformFn) => transformFn;
|
|
192
|
+
exports.defineTransform = defineTransform;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
type Args = {
|
|
3
|
+
subcommand: "wait-deployment";
|
|
4
|
+
commit: string;
|
|
5
|
+
interval: number;
|
|
6
|
+
timeout: number;
|
|
7
|
+
team: string;
|
|
8
|
+
project: string;
|
|
9
|
+
};
|
|
10
|
+
declare const _default: import("../shared/cli").CLIModule<Args>;
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function waitForDeploymentReady({ team, project, commitSha, interval, timeout, accessToken, }: {
|
|
2
|
+
team: string;
|
|
3
|
+
project: string;
|
|
4
|
+
commitSha: string;
|
|
5
|
+
interval: number;
|
|
6
|
+
timeout: number;
|
|
7
|
+
accessToken: string;
|
|
8
|
+
}): Promise<import("../shared/deployment-service").Deployment | undefined>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IDeploymentService, Deployment } from "../shared/deployment-service";
|
|
2
|
+
export type VercelDeployment = {
|
|
3
|
+
state: string;
|
|
4
|
+
url: string;
|
|
5
|
+
meta: {
|
|
6
|
+
githubCommitSha: string;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export declare class VercelDeploymentService implements IDeploymentService {
|
|
10
|
+
private teamId;
|
|
11
|
+
private projectId;
|
|
12
|
+
private accessToken;
|
|
13
|
+
constructor(teamId: string, projectId: string, accessToken: string);
|
|
14
|
+
fetchForCommit(commitSha: string): Promise<Deployment[]>;
|
|
15
|
+
}
|