create-struere 0.1.0 → 0.1.2
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 +10 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import prompts from "prompts";
|
|
|
7
7
|
// src/create-project.ts
|
|
8
8
|
import { mkdir, writeFile } from "fs/promises";
|
|
9
9
|
import { join } from "path";
|
|
10
|
+
import { spawn } from "child_process";
|
|
10
11
|
import chalk from "chalk";
|
|
11
12
|
import ora from "ora";
|
|
12
13
|
|
|
@@ -178,7 +179,7 @@ export const tools = defineTools([
|
|
|
178
179
|
},
|
|
179
180
|
handler: async (params) => {
|
|
180
181
|
const expression = params.expression as string
|
|
181
|
-
const sanitized = expression.replace(/[^0-9
|
|
182
|
+
const sanitized = expression.replace(/[^0-9+*/().\\s-]/g, '')
|
|
182
183
|
try {
|
|
183
184
|
const result = new Function(\`return \${sanitized}\`)()
|
|
184
185
|
return { expression, result }
|
|
@@ -362,13 +363,15 @@ async function createProject(name, options) {
|
|
|
362
363
|
spinner.succeed("Template files written");
|
|
363
364
|
if (options.install) {
|
|
364
365
|
spinner.start("Installing dependencies");
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
366
|
+
const exitCode = await new Promise((resolve) => {
|
|
367
|
+
const proc = spawn("bun", ["install"], {
|
|
368
|
+
cwd: projectPath,
|
|
369
|
+
stdio: "pipe"
|
|
370
|
+
});
|
|
371
|
+
proc.on("close", (code) => resolve(code ?? 1));
|
|
372
|
+
proc.on("error", () => resolve(1));
|
|
369
373
|
});
|
|
370
|
-
|
|
371
|
-
if (proc.exitCode === 0) {
|
|
374
|
+
if (exitCode === 0) {
|
|
372
375
|
spinner.succeed("Dependencies installed");
|
|
373
376
|
} else {
|
|
374
377
|
spinner.warn("Failed to install dependencies. Run `bun install` manually.");
|
package/package.json
CHANGED