create-mikstack 0.1.21 → 0.1.22
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 +33 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import * as p from "@clack/prompts";
|
|
3
|
-
import {
|
|
3
|
+
import { execSync, spawn } from "node:child_process";
|
|
4
4
|
import path from "node:path";
|
|
5
|
-
import { parseArgs
|
|
5
|
+
import { parseArgs } from "node:util";
|
|
6
6
|
import fs from "node:fs";
|
|
7
7
|
|
|
8
8
|
//#region src/config.ts
|
|
@@ -322,7 +322,6 @@ function renderDir(dir, context) {
|
|
|
322
322
|
|
|
323
323
|
//#endregion
|
|
324
324
|
//#region src/cli.ts
|
|
325
|
-
const execFile$1 = promisify(execFile);
|
|
326
325
|
async function cli() {
|
|
327
326
|
const { values, positionals } = parseArgs({
|
|
328
327
|
allowPositionals: true,
|
|
@@ -359,7 +358,29 @@ async function cli() {
|
|
|
359
358
|
p.log.info(`Scaffolding ${config.projectName} with recommended defaults (non-interactive)...`);
|
|
360
359
|
} else config = await runPrompts(projectName, packageManager);
|
|
361
360
|
const cwd = path.resolve(process.cwd(), config.targetDir);
|
|
362
|
-
|
|
361
|
+
function run(cmd, args, onLine) {
|
|
362
|
+
return new Promise((resolve, reject) => {
|
|
363
|
+
const child = spawn(cmd, args, {
|
|
364
|
+
cwd,
|
|
365
|
+
stdio: [
|
|
366
|
+
"ignore",
|
|
367
|
+
"pipe",
|
|
368
|
+
"pipe"
|
|
369
|
+
]
|
|
370
|
+
});
|
|
371
|
+
const handleData = (data) => {
|
|
372
|
+
if (!onLine) return;
|
|
373
|
+
const line = data.toString().trim().split("\n").pop();
|
|
374
|
+
if (line) onLine(line);
|
|
375
|
+
};
|
|
376
|
+
child.stdout.on("data", handleData);
|
|
377
|
+
child.stderr.on("data", handleData);
|
|
378
|
+
child.on("close", (code) => {
|
|
379
|
+
if (code === 0) resolve();
|
|
380
|
+
else reject(/* @__PURE__ */ new Error(`${cmd} ${args.join(" ")} exited with code ${code}`));
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
}
|
|
363
384
|
await p.tasks([
|
|
364
385
|
{
|
|
365
386
|
title: "Scaffolding project",
|
|
@@ -371,25 +392,28 @@ async function cli() {
|
|
|
371
392
|
},
|
|
372
393
|
{
|
|
373
394
|
title: "Installing dependencies",
|
|
374
|
-
task: async () => {
|
|
375
|
-
await run(packageManager, ["install"]);
|
|
395
|
+
task: async (message) => {
|
|
396
|
+
await run(packageManager, ["install"], message);
|
|
376
397
|
return "Dependencies installed";
|
|
377
398
|
}
|
|
378
399
|
},
|
|
379
400
|
{
|
|
380
401
|
title: "Formatting project",
|
|
381
|
-
task: async () => {
|
|
402
|
+
task: async (message) => {
|
|
382
403
|
try {
|
|
383
|
-
await run(packageManager, ["run", "format"]);
|
|
404
|
+
await run(packageManager, ["run", "format"], message);
|
|
384
405
|
} catch {}
|
|
385
406
|
return "Project formatted";
|
|
386
407
|
}
|
|
387
408
|
},
|
|
388
409
|
{
|
|
389
410
|
title: "Initializing git repository",
|
|
390
|
-
task: async () => {
|
|
411
|
+
task: async (message) => {
|
|
412
|
+
message("git init");
|
|
391
413
|
await run("git", ["init"]);
|
|
414
|
+
message("git add .");
|
|
392
415
|
await run("git", ["add", "."]);
|
|
416
|
+
message("git commit");
|
|
393
417
|
await run("git", [
|
|
394
418
|
"commit",
|
|
395
419
|
"-m",
|