create-mikstack 0.1.21 → 0.1.23

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.
Files changed (2) hide show
  1. package/dist/index.js +36 -9
  2. 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 { execFile, execSync } from "node:child_process";
3
+ import { execSync, spawn } from "node:child_process";
4
4
  import path from "node:path";
5
- import { parseArgs, promisify } from "node:util";
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,32 @@ 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
- const run = (cmd, args) => execFile$1(cmd, args, { cwd });
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 cols = process.stdout.columns || 80;
372
+ const handleData = (data) => {
373
+ if (!onLine) return;
374
+ const line = data.toString().trim().split("\n").pop();
375
+ if (!line) return;
376
+ const maxLen = cols - 5;
377
+ onLine(line.length > maxLen ? line.slice(0, maxLen - 1) + "…" : line);
378
+ };
379
+ child.stdout.on("data", handleData);
380
+ child.stderr.on("data", handleData);
381
+ child.on("close", (code) => {
382
+ if (code === 0) resolve();
383
+ else reject(/* @__PURE__ */ new Error(`${cmd} ${args.join(" ")} exited with code ${code}`));
384
+ });
385
+ });
386
+ }
363
387
  await p.tasks([
364
388
  {
365
389
  title: "Scaffolding project",
@@ -371,25 +395,28 @@ async function cli() {
371
395
  },
372
396
  {
373
397
  title: "Installing dependencies",
374
- task: async () => {
375
- await run(packageManager, ["install"]);
398
+ task: async (message) => {
399
+ await run(packageManager, ["install"], message);
376
400
  return "Dependencies installed";
377
401
  }
378
402
  },
379
403
  {
380
404
  title: "Formatting project",
381
- task: async () => {
405
+ task: async (message) => {
382
406
  try {
383
- await run(packageManager, ["run", "format"]);
407
+ await run(packageManager, ["run", "format"], message);
384
408
  } catch {}
385
409
  return "Project formatted";
386
410
  }
387
411
  },
388
412
  {
389
413
  title: "Initializing git repository",
390
- task: async () => {
414
+ task: async (message) => {
415
+ message("git init");
391
416
  await run("git", ["init"]);
417
+ message("git add .");
392
418
  await run("git", ["add", "."]);
419
+ message("git commit");
393
420
  await run("git", [
394
421
  "commit",
395
422
  "-m",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-mikstack",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",