create-krispya 0.4.2 → 0.4.3
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/cli.cjs +43 -0
- package/dist/cli.mjs +43 -0
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -10,6 +10,7 @@ const commander = require('commander');
|
|
|
10
10
|
const p = require('@clack/prompts');
|
|
11
11
|
const color = require('chalk');
|
|
12
12
|
const undici = require('undici');
|
|
13
|
+
const child_process = require('child_process');
|
|
13
14
|
|
|
14
15
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
15
16
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
@@ -380,6 +381,18 @@ async function promptForOptions(name) {
|
|
|
380
381
|
projectType
|
|
381
382
|
);
|
|
382
383
|
}
|
|
384
|
+
function openInEditor(editor, path) {
|
|
385
|
+
return new Promise((resolve, reject) => {
|
|
386
|
+
const child = child_process.spawn(editor, [path], {
|
|
387
|
+
detached: true,
|
|
388
|
+
stdio: "ignore",
|
|
389
|
+
shell: process.platform === "win32"
|
|
390
|
+
});
|
|
391
|
+
child.on("error", reject);
|
|
392
|
+
child.unref();
|
|
393
|
+
setTimeout(resolve, 100);
|
|
394
|
+
});
|
|
395
|
+
}
|
|
383
396
|
async function main() {
|
|
384
397
|
const program = new commander.Command().name("create-krispya").description(
|
|
385
398
|
"CLI for creating Vanilla, React, and React Three Fiber projects"
|
|
@@ -542,6 +555,36 @@ async function main() {
|
|
|
542
555
|
`${packageManager} run dev`
|
|
543
556
|
].join("\n");
|
|
544
557
|
p__namespace.note(nextSteps, "Next steps");
|
|
558
|
+
const openEditor = await p__namespace.select({
|
|
559
|
+
message: "Open project in editor?",
|
|
560
|
+
options: [
|
|
561
|
+
{ value: "skip", label: "Skip" },
|
|
562
|
+
{ value: "cursor", label: "Cursor" },
|
|
563
|
+
{ value: "code", label: "VS Code" },
|
|
564
|
+
{ value: "webstorm", label: "WebStorm" }
|
|
565
|
+
],
|
|
566
|
+
initialValue: "skip"
|
|
567
|
+
});
|
|
568
|
+
if (!p__namespace.isCancel(openEditor) && openEditor !== "skip") {
|
|
569
|
+
const editorNames = {
|
|
570
|
+
cursor: "Cursor",
|
|
571
|
+
code: "VS Code",
|
|
572
|
+
webstorm: "WebStorm"
|
|
573
|
+
};
|
|
574
|
+
try {
|
|
575
|
+
await openInEditor(
|
|
576
|
+
openEditor,
|
|
577
|
+
basePath
|
|
578
|
+
);
|
|
579
|
+
p__namespace.log.success(
|
|
580
|
+
`Opening in ${editorNames[openEditor]}...`
|
|
581
|
+
);
|
|
582
|
+
} catch {
|
|
583
|
+
p__namespace.log.warn(
|
|
584
|
+
`Could not open ${editorNames[openEditor]}. Make sure the CLI command is in your PATH.`
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
}
|
|
545
588
|
p__namespace.outro(color__default.green("Happy coding! \u2728"));
|
|
546
589
|
} catch (error) {
|
|
547
590
|
s.stop("Failed to create project");
|
package/dist/cli.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { Command } from 'commander';
|
|
|
8
8
|
import * as p from '@clack/prompts';
|
|
9
9
|
import color from 'chalk';
|
|
10
10
|
import { fetch } from 'undici';
|
|
11
|
+
import { spawn } from 'child_process';
|
|
11
12
|
|
|
12
13
|
const require$1 = createRequire(import.meta.url);
|
|
13
14
|
const pkg = require$1("../package.json");
|
|
@@ -360,6 +361,18 @@ async function promptForOptions(name) {
|
|
|
360
361
|
projectType
|
|
361
362
|
);
|
|
362
363
|
}
|
|
364
|
+
function openInEditor(editor, path) {
|
|
365
|
+
return new Promise((resolve, reject) => {
|
|
366
|
+
const child = spawn(editor, [path], {
|
|
367
|
+
detached: true,
|
|
368
|
+
stdio: "ignore",
|
|
369
|
+
shell: process.platform === "win32"
|
|
370
|
+
});
|
|
371
|
+
child.on("error", reject);
|
|
372
|
+
child.unref();
|
|
373
|
+
setTimeout(resolve, 100);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
363
376
|
async function main() {
|
|
364
377
|
const program = new Command().name("create-krispya").description(
|
|
365
378
|
"CLI for creating Vanilla, React, and React Three Fiber projects"
|
|
@@ -522,6 +535,36 @@ async function main() {
|
|
|
522
535
|
`${packageManager} run dev`
|
|
523
536
|
].join("\n");
|
|
524
537
|
p.note(nextSteps, "Next steps");
|
|
538
|
+
const openEditor = await p.select({
|
|
539
|
+
message: "Open project in editor?",
|
|
540
|
+
options: [
|
|
541
|
+
{ value: "skip", label: "Skip" },
|
|
542
|
+
{ value: "cursor", label: "Cursor" },
|
|
543
|
+
{ value: "code", label: "VS Code" },
|
|
544
|
+
{ value: "webstorm", label: "WebStorm" }
|
|
545
|
+
],
|
|
546
|
+
initialValue: "skip"
|
|
547
|
+
});
|
|
548
|
+
if (!p.isCancel(openEditor) && openEditor !== "skip") {
|
|
549
|
+
const editorNames = {
|
|
550
|
+
cursor: "Cursor",
|
|
551
|
+
code: "VS Code",
|
|
552
|
+
webstorm: "WebStorm"
|
|
553
|
+
};
|
|
554
|
+
try {
|
|
555
|
+
await openInEditor(
|
|
556
|
+
openEditor,
|
|
557
|
+
basePath
|
|
558
|
+
);
|
|
559
|
+
p.log.success(
|
|
560
|
+
`Opening in ${editorNames[openEditor]}...`
|
|
561
|
+
);
|
|
562
|
+
} catch {
|
|
563
|
+
p.log.warn(
|
|
564
|
+
`Could not open ${editorNames[openEditor]}. Make sure the CLI command is in your PATH.`
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
525
568
|
p.outro(color.green("Happy coding! \u2728"));
|
|
526
569
|
} catch (error) {
|
|
527
570
|
s.stop("Failed to create project");
|