@interactivethings/scripts 2.0.0 → 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/README.md +12 -14
- package/dist/cli.js +18 -9
- package/dist/config.js +22 -12
- package/dist/figma/cli.js +17 -7
- package/dist/figma/cli.test.js +17 -7
- package/dist/figma/images.js +17 -7
- package/dist/index.js +17 -7
- package/dist/init/cli.js +20 -12
- package/dist/tokens-studio/cli.js +42 -8
- package/dist/tokens-studio/cli.test.js +17 -7
- package/dist/tokens-studio/index.js +17 -7
- package/dist/vercel/deployments.js +1 -2
- package/package.json +2 -2
- package/dist/__tests__/figma-cli.test.js +0 -189
- package/dist/__tests__/tokens-studio-cli.test.js +0 -197
- package/dist/__tests__/vercel-cli.test.js +0 -86
- package/dist/cli.d.ts +0 -2
- package/dist/config.d.ts +0 -78
- package/dist/figma/api.d.ts +0 -71
- package/dist/figma/cli.d.ts +0 -20
- package/dist/figma/optimizeImage.js +0 -53
- package/dist/figma/utils.d.ts +0 -10
- package/dist/index.d.ts +0 -8
- package/dist/init/cli.d.ts +0 -3
- package/dist/mui-tokens-studio.js +0 -177
- package/dist/plugins/figma/index.js +0 -653
- package/dist/plugins/tokens-studio/utils.js +0 -155
- package/dist/tokens-studio/cli.d.ts +0 -8
- package/dist/tokens-studio/index.d.ts +0 -14
- package/dist/tokens-studio/mui.js +0 -212
- package/dist/tokens-studio/tailwind.js +0 -211
- package/dist/tokens-studio/utils.d.ts +0 -49
- package/dist/types.d.ts +0 -1
- package/dist/vercel/cli.d.ts +0 -4
- package/dist/vercel/waitForDeploymentReady.js +0 -43
- package/dist/wait-for-vercel-deploy.js +0 -79
|
@@ -1,53 +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
|
-
exports.optimizeImage = void 0;
|
|
27
|
-
const child_process_1 = require("child_process");
|
|
28
|
-
const path = __importStar(require("path"));
|
|
29
|
-
const optimizeImage = async (filepath) => {
|
|
30
|
-
try {
|
|
31
|
-
const extension = path.extname(filepath).toLowerCase();
|
|
32
|
-
const binaryForExtensions = new Map([
|
|
33
|
-
[".png", "optipng"],
|
|
34
|
-
[".jpg", "jpegoptim"],
|
|
35
|
-
]);
|
|
36
|
-
const binaryName = binaryForExtensions.get(extension);
|
|
37
|
-
if (!binaryName) {
|
|
38
|
-
// console.log(`No optimizer found for ${extension}, skipping optimization`);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
const binaryPath = (0, child_process_1.execSync)(`which ${binaryName}`).toString().trim();
|
|
42
|
-
if (!binaryPath) {
|
|
43
|
-
throw new Error(`Cannot find ${binaryName} in PATH. Please install it.`);
|
|
44
|
-
}
|
|
45
|
-
console.log(`Optimizing with ${filepath} with ${binaryName}`);
|
|
46
|
-
await (0, child_process_1.execSync)(`${binaryPath} "${filepath}"`);
|
|
47
|
-
console.log(`Image optimized successfully: ${filepath}`);
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
console.error(`Error optimizing image ${filepath}: ${error instanceof Error ? error.message : error}`);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
exports.optimizeImage = optimizeImage;
|
package/dist/figma/utils.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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.d.ts
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
/**
|
|
4
|
-
* This script transforms tokens exported with tokens-studio in Figma into
|
|
5
|
-
* a format that is easier to work with when using MUI.
|
|
6
|
-
* You can run it via `pnpm run design:tokens`
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const argparse_1 = require("argparse");
|
|
11
|
-
const remeda_1 = require("remeda");
|
|
12
|
-
const simplifyValues = (x) => {
|
|
13
|
-
if (typeof x === "string") {
|
|
14
|
-
return x;
|
|
15
|
-
}
|
|
16
|
-
else if (typeof x === "object" && !!x) {
|
|
17
|
-
if ("value" in x) {
|
|
18
|
-
return x.value;
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
return (0, remeda_1.mapValues)(x, simplifyValues);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const kebabCase = (x) => {
|
|
26
|
-
return x
|
|
27
|
-
.split(" ")
|
|
28
|
-
.map((t, i) => {
|
|
29
|
-
if (i === 0) {
|
|
30
|
-
return t.toLowerCase();
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
return `${t[0].toUpperCase()}${t.substring(1).toLowerCase()}`;
|
|
34
|
-
}
|
|
35
|
-
})
|
|
36
|
-
.join("");
|
|
37
|
-
};
|
|
38
|
-
const renameColorKeys = (k) => {
|
|
39
|
-
return kebabCase(k
|
|
40
|
-
.replace(/-[a-zA-Z0-9]+/, "")
|
|
41
|
-
.replace(" - ", " ")
|
|
42
|
-
.replace(",", "")
|
|
43
|
-
.replace(/^\d+\s+/, ""));
|
|
44
|
-
};
|
|
45
|
-
const renameColorKeysEntries = (obj) => {
|
|
46
|
-
const visitor = (k, v) => {
|
|
47
|
-
if (typeof v === "object") {
|
|
48
|
-
return [renameColorKeys(k), mapEntries(v, visitor)];
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
return [renameColorKeys(k), v];
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
return mapEntries(obj, visitor);
|
|
55
|
-
};
|
|
56
|
-
const mapEntries = (x, mapper) => {
|
|
57
|
-
return Object.fromEntries(Object.entries(x).map(([k, v]) => mapper(k, v)));
|
|
58
|
-
};
|
|
59
|
-
const getPalette = (tokensData) => {
|
|
60
|
-
const data = tokensData.global;
|
|
61
|
-
const colorKeys = ["Base", "Functional"];
|
|
62
|
-
let palette = (0, remeda_1.pick)(data, colorKeys);
|
|
63
|
-
palette = (0, remeda_1.mapValues)(palette, simplifyValues);
|
|
64
|
-
palette = renameColorKeysEntries(palette);
|
|
65
|
-
palette = {
|
|
66
|
-
...palette.base,
|
|
67
|
-
...(0, remeda_1.pick)(palette, ["functional"]),
|
|
68
|
-
};
|
|
69
|
-
return palette;
|
|
70
|
-
};
|
|
71
|
-
const getTypography = (tokensData) => {
|
|
72
|
-
const sizes = ["Desktop", "Mobile"];
|
|
73
|
-
const res = {};
|
|
74
|
-
const index = {};
|
|
75
|
-
for (const k of [
|
|
76
|
-
"fontFamilies",
|
|
77
|
-
"lineHeights",
|
|
78
|
-
"fontWeights",
|
|
79
|
-
"fontSize",
|
|
80
|
-
"letterSpacing",
|
|
81
|
-
"textDecoration",
|
|
82
|
-
]) {
|
|
83
|
-
for (const [vName, value] of Object.entries(tokensData.global[k])) {
|
|
84
|
-
index[`${k}.${vName}`] = value;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
const maybeParseToNumber = (x) => {
|
|
88
|
-
const parsed = Number(x);
|
|
89
|
-
if (Number.isNaN(x)) {
|
|
90
|
-
return x;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
return parsed;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
const maybeParseToPx = (x) => {
|
|
97
|
-
if (typeof x === "number") {
|
|
98
|
-
return `${x}px`;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return x;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
const cleanupFns = {
|
|
105
|
-
fontWeight: (x) => {
|
|
106
|
-
const lowered = x.toLowerCase();
|
|
107
|
-
if (lowered == "regular") {
|
|
108
|
-
return 400;
|
|
109
|
-
}
|
|
110
|
-
return lowered;
|
|
111
|
-
},
|
|
112
|
-
fontSize: maybeParseToNumber,
|
|
113
|
-
lineHeight: (x) => maybeParseToPx(maybeParseToNumber(x)),
|
|
114
|
-
paragraphSpacing: maybeParseToNumber,
|
|
115
|
-
letterSpacing: maybeParseToNumber,
|
|
116
|
-
};
|
|
117
|
-
const cleanup = (k, v) => {
|
|
118
|
-
if (k in cleanupFns) {
|
|
119
|
-
return [k, cleanupFns[k](v)];
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return [k, v];
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const resolve = (str) => {
|
|
126
|
-
if (str[0] === "{" && str[str.length - 1] === "}") {
|
|
127
|
-
const path = str.substring(1, str.length - 1);
|
|
128
|
-
return index[path]?.value;
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
return str;
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
for (const size of sizes) {
|
|
135
|
-
const typographies = tokensData.global[size];
|
|
136
|
-
for (const [typo, typoDataRaw] of Object.entries(typographies)) {
|
|
137
|
-
const typoData = typoDataRaw;
|
|
138
|
-
const typoKey = kebabCase(typo.toLowerCase());
|
|
139
|
-
res[typoKey] = res[typoKey] || {};
|
|
140
|
-
res[typoKey][size.toLowerCase()] = mapEntries((0, remeda_1.mapValues)(typoData.value, resolve), cleanup);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return res;
|
|
144
|
-
};
|
|
145
|
-
const getShadows = (tokenData) => {
|
|
146
|
-
const transformShadow = (shadowData) => {
|
|
147
|
-
const { color, x, y, blur, spread } = shadowData;
|
|
148
|
-
return `${x}px ${y}px ${blur}px ${spread}px ${color}`;
|
|
149
|
-
};
|
|
150
|
-
const shadows = mapEntries(tokenData.global.Elevation, (k, v) => [
|
|
151
|
-
`${Number(k.replace("dp", "").replace("pd", ""))}`,
|
|
152
|
-
Array.isArray(v.value)
|
|
153
|
-
? v.value.map(transformShadow).join(", ")
|
|
154
|
-
: transformShadow(v.value),
|
|
155
|
-
]);
|
|
156
|
-
return shadows;
|
|
157
|
-
};
|
|
158
|
-
const transform = (tokenData) => {
|
|
159
|
-
const palette = getPalette(tokenData);
|
|
160
|
-
const typography = getTypography(tokenData);
|
|
161
|
-
const shadows = getShadows(tokenData);
|
|
162
|
-
return {
|
|
163
|
-
palette,
|
|
164
|
-
typography,
|
|
165
|
-
shadows,
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
const main = () => {
|
|
169
|
-
const parser = new argparse_1.ArgumentParser();
|
|
170
|
-
parser.add_argument("input");
|
|
171
|
-
parser.add_argument("output");
|
|
172
|
-
const args = parser.parse_args();
|
|
173
|
-
const content = JSON.parse(fs.readFileSync(args.input).toString());
|
|
174
|
-
const transformed = transform(content);
|
|
175
|
-
fs.writeFileSync(args.output === "-" ? process.stdout.fd : args.output, JSON.stringify(transformed, null, 2));
|
|
176
|
-
};
|
|
177
|
-
main();
|