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