@styleframe/cli 2.4.0 → 3.0.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/CHANGELOG.md +12 -0
- package/dist/{build-ur0w63-6.js → build-BFZSJ2Zh.js} +1 -1
- package/dist/{export-DbajI91o.js → export-SH70kD-5.js} +1 -1
- package/dist/{index-D1u8JN2Q.js → index-DH3Hm47n.js} +1 -1
- package/dist/{index-BX6dI2z2.js → index-DtEAy_us.js} +728 -544
- package/dist/index.cjs +930 -657
- package/dist/index.js +4 -4
- package/dist/{init-iaRyWohK.js → init-DnrkQJYO.js} +90 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { defineCommand, runMain } from "citty";
|
|
3
|
-
const version = "
|
|
3
|
+
const version = "3.0.0";
|
|
4
4
|
const description = "A command-line interface for styleframe.";
|
|
5
5
|
const main = defineCommand({
|
|
6
6
|
meta: {
|
|
@@ -9,9 +9,9 @@ const main = defineCommand({
|
|
|
9
9
|
description
|
|
10
10
|
},
|
|
11
11
|
subCommands: {
|
|
12
|
-
init: () => import("./init-
|
|
13
|
-
build: () => import("./build-
|
|
14
|
-
figma: () => import("./index-
|
|
12
|
+
init: () => import("./init-DnrkQJYO.js").then((m) => m.default),
|
|
13
|
+
build: () => import("./build-BFZSJ2Zh.js").then((m) => m.default),
|
|
14
|
+
figma: () => import("./index-DH3Hm47n.js").then((m) => m.default)
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
function run() {
|
|
@@ -14,6 +14,48 @@ async function fileExists(path) {
|
|
|
14
14
|
return false;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
function parseJsonc(text) {
|
|
18
|
+
let result = "";
|
|
19
|
+
let i = 0;
|
|
20
|
+
let inString = false;
|
|
21
|
+
while (i < text.length) {
|
|
22
|
+
const char = text[i];
|
|
23
|
+
const next = text[i + 1];
|
|
24
|
+
if (inString) {
|
|
25
|
+
if (char === "\\" && i + 1 < text.length) {
|
|
26
|
+
result += char + next;
|
|
27
|
+
i += 2;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (char === '"') {
|
|
31
|
+
inString = false;
|
|
32
|
+
}
|
|
33
|
+
result += char;
|
|
34
|
+
i++;
|
|
35
|
+
} else {
|
|
36
|
+
if (char === '"') {
|
|
37
|
+
inString = true;
|
|
38
|
+
result += char;
|
|
39
|
+
i++;
|
|
40
|
+
} else if (char === "/" && next === "/") {
|
|
41
|
+
while (i < text.length && text[i] !== "\n") {
|
|
42
|
+
i++;
|
|
43
|
+
}
|
|
44
|
+
} else if (char === "/" && next === "*") {
|
|
45
|
+
i += 2;
|
|
46
|
+
while (i < text.length && !(text[i] === "*" && text[i + 1] === "/")) {
|
|
47
|
+
i++;
|
|
48
|
+
}
|
|
49
|
+
i += 2;
|
|
50
|
+
} else {
|
|
51
|
+
result += char;
|
|
52
|
+
i++;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
result = result.replace(/,(\s*[}\]])/g, "$1");
|
|
57
|
+
return JSON.parse(result);
|
|
58
|
+
}
|
|
17
59
|
const HOMEPAGE_URL = "https://styleframe.dev";
|
|
18
60
|
const DOCS_URL = `${HOMEPAGE_URL}/docs`;
|
|
19
61
|
const DOCS_MANUAL_INSTALLATION_VITE_URL = `${DOCS_URL}/getting-started/installation/manual/vite`;
|
|
@@ -67,6 +109,23 @@ s.variable("color--primary", "blue");
|
|
|
67
109
|
|
|
68
110
|
export default s;
|
|
69
111
|
`;
|
|
112
|
+
const styleframeIncludes = [
|
|
113
|
+
"styleframe.config.ts",
|
|
114
|
+
"*.styleframe.ts",
|
|
115
|
+
".styleframe/**/*.d.ts"
|
|
116
|
+
];
|
|
117
|
+
const tsconfigTemplate = {
|
|
118
|
+
compilerOptions: {
|
|
119
|
+
target: "ES2022",
|
|
120
|
+
module: "ESNext",
|
|
121
|
+
moduleResolution: "bundler",
|
|
122
|
+
strict: true,
|
|
123
|
+
noEmit: true,
|
|
124
|
+
skipLibCheck: true,
|
|
125
|
+
esModuleInterop: true
|
|
126
|
+
},
|
|
127
|
+
include: styleframeIncludes
|
|
128
|
+
};
|
|
70
129
|
async function initializeConfigFile(cwd) {
|
|
71
130
|
const styleframeConfigPath = sysPath.join(cwd, "styleframe.config.ts");
|
|
72
131
|
if (await fileExists(styleframeConfigPath)) {
|
|
@@ -78,6 +137,34 @@ async function initializeConfigFile(cwd) {
|
|
|
78
137
|
consola.success(`Created "styleframe.config.ts".`);
|
|
79
138
|
}
|
|
80
139
|
}
|
|
140
|
+
async function initializeTsConfig(cwd) {
|
|
141
|
+
const tsconfigPath = sysPath.join(cwd, "tsconfig.json");
|
|
142
|
+
if (await fileExists(tsconfigPath)) {
|
|
143
|
+
const existingConfig = parseJsonc(
|
|
144
|
+
await readFile(tsconfigPath, "utf8")
|
|
145
|
+
);
|
|
146
|
+
if (!existingConfig.include) {
|
|
147
|
+
existingConfig.include = [];
|
|
148
|
+
}
|
|
149
|
+
const includes = existingConfig.include;
|
|
150
|
+
const added = [];
|
|
151
|
+
for (const pattern of styleframeIncludes) {
|
|
152
|
+
if (!includes.includes(pattern)) {
|
|
153
|
+
includes.push(pattern);
|
|
154
|
+
added.push(pattern);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (added.length > 0) {
|
|
158
|
+
await writeFile$1(tsconfigPath, JSON.stringify(existingConfig, null, " "));
|
|
159
|
+
consola.success(
|
|
160
|
+
`Added ${added.map((p) => `"${p}"`).join(", ")} to tsconfig.json includes.`
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
} else {
|
|
164
|
+
await writeFile$1(tsconfigPath, JSON.stringify(tsconfigTemplate, null, " "));
|
|
165
|
+
consola.success(`Created "tsconfig.json".`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
81
168
|
async function addPackageJsonDependencies(cwd) {
|
|
82
169
|
const packageJsonPath = sysPath.join(cwd, "package.json");
|
|
83
170
|
if (await fileExists(packageJsonPath)) {
|
|
@@ -133,6 +220,7 @@ const init = defineCommand({
|
|
|
133
220
|
const { cwd } = args;
|
|
134
221
|
consola.info("Initializing...");
|
|
135
222
|
await initializeConfigFile(cwd);
|
|
223
|
+
await initializeTsConfig(cwd);
|
|
136
224
|
await addPackageJsonDependencies(cwd);
|
|
137
225
|
await initializeFrameworkFile(cwd);
|
|
138
226
|
}
|
|
@@ -141,5 +229,6 @@ export {
|
|
|
141
229
|
addPackageJsonDependencies,
|
|
142
230
|
init as default,
|
|
143
231
|
initializeConfigFile,
|
|
144
|
-
initializeFrameworkFile
|
|
232
|
+
initializeFrameworkFile,
|
|
233
|
+
initializeTsConfig
|
|
145
234
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A command-line interface for styleframe.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -20,21 +20,21 @@
|
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@styleframe/figma": "^1.0.
|
|
23
|
+
"@styleframe/figma": "^1.0.1",
|
|
24
24
|
"citty": "^0.1.6",
|
|
25
25
|
"consola": "^3.0.0-2",
|
|
26
26
|
"magicast": "^0.5.0"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@styleframe/loader": "^
|
|
29
|
+
"@styleframe/loader": "^3.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@styleframe/config-typescript": "^
|
|
33
|
-
"@styleframe/config-vite": "^
|
|
34
|
-
"@styleframe/core": "^
|
|
32
|
+
"@styleframe/config-typescript": "^3.0.0",
|
|
33
|
+
"@styleframe/config-vite": "^3.0.0",
|
|
34
|
+
"@styleframe/core": "^3.0.0",
|
|
35
35
|
"@styleframe/license": "^2.0.2",
|
|
36
|
-
"@styleframe/theme": "^
|
|
37
|
-
"@styleframe/loader": "^
|
|
36
|
+
"@styleframe/theme": "^3.0.0",
|
|
37
|
+
"@styleframe/loader": "^3.0.0",
|
|
38
38
|
"@vitest/coverage-v8": "^3.2.4",
|
|
39
39
|
"tsx": "^4.20.6",
|
|
40
40
|
"typescript": "^5.8.3",
|