@styleframe/cli 2.3.2 → 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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { defineCommand, runMain } from "citty";
3
- const version = "2.3.2";
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,8 +9,9 @@ const main = defineCommand({
9
9
  description
10
10
  },
11
11
  subCommands: {
12
- init: () => import("./init-CzpnWkDQ.js").then((m) => m.default),
13
- build: () => import("./build-aC0xw4RW.js").then((m) => m.default)
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)
14
15
  }
15
16
  });
16
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)) {
@@ -92,6 +179,7 @@ async function addPackageJsonDependencies(cwd) {
92
179
  packageJson.devDependencies["@styleframe/pro"] = "^2.0.0";
93
180
  packageJson.devDependencies["@styleframe/theme"] = "^2.0.0";
94
181
  packageJson.devDependencies["@styleframe/transpiler"] = "^2.0.0";
182
+ if (!packageJson.dependencies) packageJson.dependencies = {};
95
183
  packageJson.dependencies["@styleframe/runtime"] = "^2.0.0";
96
184
  await writeFile$1(packageJsonPath, JSON.stringify(packageJson, null, 2));
97
185
  consola.success(`Added dependencies to "package.json".`);
@@ -132,6 +220,7 @@ const init = defineCommand({
132
220
  const { cwd } = args;
133
221
  consola.info("Initializing...");
134
222
  await initializeConfigFile(cwd);
223
+ await initializeTsConfig(cwd);
135
224
  await addPackageJsonDependencies(cwd);
136
225
  await initializeFrameworkFile(cwd);
137
226
  }
@@ -140,5 +229,6 @@ export {
140
229
  addPackageJsonDependencies,
141
230
  init as default,
142
231
  initializeConfigFile,
143
- initializeFrameworkFile
232
+ initializeFrameworkFile,
233
+ initializeTsConfig
144
234
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@styleframe/cli",
3
- "version": "2.3.2",
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,20 +20,21 @@
20
20
  "README.md"
21
21
  ],
22
22
  "dependencies": {
23
+ "@styleframe/figma": "^1.0.1",
23
24
  "citty": "^0.1.6",
24
25
  "consola": "^3.0.0-2",
25
26
  "magicast": "^0.5.0"
26
27
  },
27
28
  "peerDependencies": {
28
- "@styleframe/loader": "^2.4.0"
29
+ "@styleframe/loader": "^3.0.0"
29
30
  },
30
31
  "devDependencies": {
31
- "@styleframe/config-typescript": "^2",
32
- "@styleframe/config-vite": "^2",
33
- "@styleframe/core": "^2.6.0",
32
+ "@styleframe/config-typescript": "^3.0.0",
33
+ "@styleframe/config-vite": "^3.0.0",
34
+ "@styleframe/core": "^3.0.0",
34
35
  "@styleframe/license": "^2.0.2",
35
- "@styleframe/theme": "^2.4.0",
36
- "@styleframe/loader": "^2.4.0",
36
+ "@styleframe/theme": "^3.0.0",
37
+ "@styleframe/loader": "^3.0.0",
37
38
  "@vitest/coverage-v8": "^3.2.4",
38
39
  "tsx": "^4.20.6",
39
40
  "typescript": "^5.8.3",