create-v-kit-spa 1.0.12 → 1.1.1

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.
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=commands.d.ts.map
package/dist/commands.js CHANGED
@@ -14,65 +14,67 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  const path_1 = __importDefault(require("path"));
16
16
  const fs_1 = __importDefault(require("fs"));
17
+ const chalk_1 = __importDefault(require("chalk"));
18
+ const yargs_1 = __importDefault(require("yargs"));
19
+ const helpers_1 = require("yargs/helpers");
20
+ const prompts_1 = require("@clack/prompts");
17
21
  const utils_1 = require("./utils");
18
- const prompts_1 = require("./prompts");
22
+ const prompts_2 = require("./prompts");
19
23
  const messages_1 = require("./messages");
20
- const count_1 = require("./count");
21
- const yargs_1 = __importDefault(require("yargs"));
22
24
  function createProject() {
23
25
  return __awaiter(this, void 0, void 0, function* () {
24
- const argv = yargs_1.default.argv;
25
- let projectName = process.argv[2];
26
- if (!projectName) {
27
- projectName = yield (0, prompts_1.getProjectName)();
28
- }
29
- // Checks the Destination Path if the inserted project name is already exists
26
+ const argv = yield (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
27
+ .scriptName('create-v-kit-spa')
28
+ .option('template', {
29
+ alias: 't',
30
+ type: 'string',
31
+ describe: `Boilerplate id (${prompts_2.TEMPLATES.map((t) => t.id).join(', ')}) skips the prompt`,
32
+ })
33
+ .help()
34
+ .parse();
35
+ (0, prompts_1.intro)(chalk_1.default.bgCyan.black(' create-v-kit-spa '));
36
+ // Project name: positional arg wins, otherwise prompt.
37
+ const projectName = argv._[0] ? String(argv._[0]) : yield (0, prompts_2.getProjectName)();
30
38
  const destinationPath = path_1.default.join(process.cwd(), projectName);
31
- const dirExists = yield fs_1.default.promises
32
- .access(destinationPath, fs_1.default.constants.F_OK)
33
- .then(() => true)
34
- .catch(() => false);
35
- if (dirExists) {
36
- (0, messages_1.errorMessage)(new Error(`\n✖ The directory "${projectName}" already exists.`));
37
- (0, prompts_1.closeReadline)();
38
- return;
39
+ if (fs_1.default.existsSync(destinationPath)) {
40
+ (0, messages_1.errorMessage)(new Error(`The directory "${projectName}" already exists.`));
41
+ process.exit(1);
39
42
  }
40
- // Proceeds to Selection of Boilerplate
41
- const boilerplateChoice = yield (0, prompts_1.getBoilerplateChoice)();
42
- const templatePath = getTemplatePath(boilerplateChoice);
43
- if (!templatePath) {
44
- (0, messages_1.errorMessage)(new Error('\n✖ Invalid boilerplate choice.'));
45
- (0, prompts_1.closeReadline)();
46
- return;
43
+ // Scan PHP (informational boilerplates still install without it locally).
44
+ const phpSpinner = (0, prompts_1.spinner)();
45
+ phpSpinner.start('Scanning php');
46
+ const phpVersion = yield (0, prompts_2.detectPhp)();
47
+ phpSpinner.stop(phpVersion
48
+ ? `php ${phpVersion} detected`
49
+ : 'php not found in PATH — install it before running the project');
50
+ // Template: --template flag wins (validated), otherwise prompt.
51
+ let templateId = argv.template;
52
+ if (templateId && !prompts_2.TEMPLATES.some((t) => t.id === templateId)) {
53
+ (0, messages_1.errorMessage)(new Error(`Invalid template "${templateId}". Valid ids: ${prompts_2.TEMPLATES.map((t) => t.id).join(', ')}`));
54
+ process.exit(1);
47
55
  }
48
- const sourcePath = path_1.default.join(__dirname, '../lib', templatePath);
56
+ if (!templateId)
57
+ templateId = yield (0, prompts_2.getTemplateChoice)();
58
+ const template = prompts_2.TEMPLATES.find((t) => t.id === templateId);
59
+ const sourcePath = path_1.default.join(__dirname, '../lib', template.id);
60
+ const copySpinner = (0, prompts_1.spinner)();
61
+ copySpinner.start(`Creating ${template.label} project`);
49
62
  try {
50
63
  yield fs_1.default.promises.mkdir(destinationPath);
51
64
  yield (0, utils_1.copyProjectStructure)(sourcePath, destinationPath);
52
- (0, count_1.getCount)(sourcePath, templatePath);
65
+ copySpinner.stop(`Created ${chalk_1.default.cyan(projectName)} (${template.label})`);
53
66
  }
54
67
  catch (error) {
68
+ copySpinner.stop('Failed to create project');
55
69
  (0, messages_1.errorMessage)(error);
70
+ process.exit(1);
56
71
  }
57
- finally {
58
- (0, prompts_1.closeReadline)();
59
- }
72
+ (0, messages_1.successMessage)(template.id, projectName);
73
+ (0, prompts_1.outro)(chalk_1.default.green(`${template.label} ready`) + chalk_1.default.dim(' · ') + chalk_1.default.cyan('http://127.0.0.1:8000'));
60
74
  });
61
75
  }
62
- function getTemplatePath(boilerplateChoice) {
63
- switch (boilerplateChoice) {
64
- case 1:
65
- return '158';
66
- case 2:
67
- return '159';
68
- case 3:
69
- return '160';
70
- case 4:
71
- return '161';
72
- case 5:
73
- return '162';
74
- default:
75
- return null;
76
- }
77
- }
78
- createProject();
76
+ createProject().catch((error) => {
77
+ var _a;
78
+ prompts_1.log.error((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : String(error));
79
+ process.exit(1);
80
+ });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- #!/usr/bin/env node
2
- import './commands';
1
+ #!/usr/bin/env node
2
+ import './commands';
3
3
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- require("./commands");
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ require("./commands");
@@ -1,3 +1,3 @@
1
- export declare function successMessage(sourceVal: string): Promise<void>;
2
- export declare function errorMessage(error: Error): void;
1
+ export declare function successMessage(sourceVal: string, projectName: string): void;
2
+ export declare function errorMessage(error: Error): void;
3
3
  //# sourceMappingURL=messages.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAGA,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,iBAuCrD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAExC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAOA,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QAqCpE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAExC"}
package/dist/messages.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -15,55 +6,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
6
  exports.successMessage = successMessage;
16
7
  exports.errorMessage = errorMessage;
17
8
  const chalk_1 = __importDefault(require("chalk"));
18
- const prompts_1 = require("./prompts");
19
- function successMessage(sourceVal) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- // console.log(sourceVal)
22
- let tempVal = '';
23
- if (sourceVal == '158') {
24
- tempVal = 'Vue2-Laravel8';
25
- }
26
- else if (sourceVal == '159') {
27
- tempVal = 'Vue3-Laravel8';
28
- }
29
- else if (sourceVal == '160') {
30
- tempVal = 'Vue3-Laravel9';
31
- }
32
- else if (sourceVal == '161') {
33
- tempVal = 'Vue3-Laravel10';
34
- }
35
- else if (sourceVal == '162') {
36
- tempVal = 'Vue3-Laravel11';
37
- }
38
- console.log(chalk_1.default.green(`\n✔ ${tempVal} boilerplate is successfully downloaded!. \n`));
39
- setTimeout(() => {
40
- console.log(chalk_1.default.yellow.bold("              *       ˜"));
41
- console.log(chalk_1.default.cyan.bold("        ˜                  |"));
42
- console.log(chalk_1.default.red.bold("    ()    .-.,='``'=.    - o -"));
43
- console.log(chalk_1.default.yellow.bold("          '=/_       〵    |"));
44
- console.log(chalk_1.default.cyanBright.bold("       *   |  '=._     )"));
45
- console.log(chalk_1.default.yellow.bold("           \\      `=../`,        '"));
46
- console.log(chalk_1.default.redBright.bold("         .   '=.__.=' `='      *"));
47
- console.log(chalk_1.default.yellow.bold("˜                         +"));
48
- console.log(chalk_1.default.cyanBright.bold("     O      *        '       .\n"));
49
- }, 300);
50
- setTimeout(() => {
51
- console.log('Well done 🎉🎉,', chalk_1.default.green('These Boilerplates are created with coffee & passion by', chalk_1.default.green.underline('Joshua Tania'), chalk_1.default.whiteBright('\nFor more info (github): >>'), chalk_1.default.green.underline('https://github.com/Shuashuaa/create-v-kit-spa'), chalk_1.default.whiteBright('\nFor more info (gitlab): >>'), chalk_1.default.green.underline('https://gitlab.com/shuashuaa/create-v-kit-spa\n')));
52
- }, 800);
53
- setTimeout(() => {
54
- if (sourceVal == "158" || sourceVal == "159") {
55
- console.log(chalk_1.default.bgBlack('Locate Project:'), chalk_1.default.cyanBright(`cd ${prompts_1.fileNameVariable},`));
56
- console.log(chalk_1.default.bgBlack('Install Dependencies:'), chalk_1.default.cyanBright('npm install') + ',', chalk_1.default.cyanBright('composer install') + ',', chalk_1.default.cyanBright('\ncopy .env.example .env'), 'and', chalk_1.default.cyanBright('php artisan key:generate'));
57
- console.log(chalk_1.default.bgBlack('Run Project:'), chalk_1.default.cyanBright('npm run artisan-watch') + '.\n');
58
- }
59
- else if (sourceVal == "160" || sourceVal == "161" || sourceVal == "162") {
60
- console.log(chalk_1.default.bgBlack('Locate Project:'), chalk_1.default.cyanBright(`cd ${prompts_1.fileNameVariable},`));
61
- console.log(chalk_1.default.bgBlack('Install Dependencies:'), chalk_1.default.cyanBright('yarn install') + ',', chalk_1.default.cyanBright('composer install') + ',', chalk_1.default.cyanBright('\ncopy .env.example .env'), 'and', chalk_1.default.cyanBright('php artisan key:generate'));
62
- console.log(chalk_1.default.bgBlack('Run Project:'), chalk_1.default.cyanBright('npm run artisan-dev') + '.\n');
63
- }
64
- console.log(chalk_1.default.bgBlack('Visit:'), chalk_1.default.bold('http://127.0.0.1:8000\n'));
65
- }, 500);
66
- });
9
+ const prompts_1 = require("@clack/prompts");
10
+ const prompts_2 = require("./prompts");
11
+ // Templates whose install hint uses npm; the rest use yarn.
12
+ const NPM_TEMPLATES = ['158', '159'];
13
+ function successMessage(sourceVal, projectName) {
14
+ var _a, _b;
15
+ const label = (_b = (_a = prompts_2.TEMPLATES.find((t) => t.id === sourceVal)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : sourceVal;
16
+ const isNpm = NPM_TEMPLATES.includes(sourceVal);
17
+ const installCmd = isNpm ? 'npm install' : 'yarn install';
18
+ const runCmd = isNpm ? 'npm run artisan-watch' : 'npm run artisan-dev';
19
+ console.log(chalk_1.default.green(`\n✔ ${label} boilerplate downloaded\n`));
20
+ // Galaxy created with coffee & passion.
21
+ console.log(chalk_1.default.gray(" ˚ · ⋆ ✦ · ˚ ✧ ·"));
22
+ console.log(chalk_1.default.white(" ✧ · ˚ ✦ · ⋆ · ✦ · ˚"));
23
+ console.log(chalk_1.default.white(" · ⋆ ✦ · ✺ ") + chalk_1.default.whiteBright.bold("★ ★") + chalk_1.default.white(" ✺ · ✦ ⋆ ·"));
24
+ console.log(chalk_1.default.white(" · ✧ · ✦ · ⋆ · ✦ ˚ · ✧"));
25
+ console.log(chalk_1.default.gray(" ˚ · ✦ ⋆ · ✦ · ˚\n"));
26
+ const steps = [
27
+ `cd ${projectName}`,
28
+ installCmd,
29
+ 'composer install',
30
+ 'copy .env.example .env',
31
+ 'php artisan key:generate',
32
+ runCmd,
33
+ ]
34
+ .map((cmd, i) => `${chalk_1.default.dim(`${i + 1}.`)} ${chalk_1.default.cyan(cmd)}`)
35
+ .join('\n');
36
+ (0, prompts_1.note)(steps, 'Next steps');
37
+ console.log(chalk_1.default.dim(' built with coffee & passion by ') + chalk_1.default.green.underline('Joshua Tania'));
38
+ console.log(chalk_1.default.dim(' github.com/Shuashuaa/create-v-kit-spa') +
39
+ chalk_1.default.dim(' · ') +
40
+ chalk_1.default.dim('gitlab.com/shuashuaa/create-v-kit-spa') +
41
+ '\n');
67
42
  }
68
43
  function errorMessage(error) {
69
44
  console.error(chalk_1.default.red.inverse(`\n✖ Error creating project. ${error.message}`));
package/dist/prompts.d.ts CHANGED
@@ -1,5 +1,16 @@
1
- export declare let fileNameVariable: string;
2
- export declare function getProjectName(): Promise<string>;
3
- export declare function getBoilerplateChoice(): Promise<number>;
4
- export declare function closeReadline(): void;
1
+ export interface Template {
2
+ id: string;
3
+ label: string;
4
+ hint: string;
5
+ }
6
+ export declare const TEMPLATES: Template[];
7
+ export declare function getProjectName(): Promise<string>;
8
+ export declare function getTemplateChoice(): Promise<string>;
9
+ /**
10
+ * Resolve the installed PHP version, or null if PHP is missing.
11
+ * `shell: true` so the bare name `php` resolves via PATH/PATHEXT on Windows,
12
+ * matching how the interactive shell finds php.exe. Never rejects/throws:
13
+ * a missing binary emits 'error', which we catch and report as null.
14
+ */
15
+ export declare function detectPhp(): Promise<string | null>;
5
16
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AASA,eAAO,IAAI,gBAAgB,QAAK,CAAC;AAEjC,wBACgB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAYhD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC,CAwC5D;AAGD,wBAAgB,aAAa,SAE5B"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAGD,eAAO,MAAM,SAAS,EAAE,QAAQ,EAM/B,CAAC;AAaF,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CActD;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAOzD;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAsBxD"}
package/dist/prompts.js CHANGED
@@ -1,80 +1,98 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.fileNameVariable = void 0;
16
- exports.getProjectName = getProjectName;
17
- exports.getBoilerplateChoice = getBoilerplateChoice;
18
- exports.closeReadline = closeReadline;
19
- const chalk_1 = __importDefault(require("chalk"));
20
- const { spawn } = require('child_process');
21
- const readline_1 = require("readline");
22
- const readline = (0, readline_1.createInterface)({
23
- input: process.stdin,
24
- output: process.stdout
25
- });
26
- exports.fileNameVariable = '';
27
- function getProjectName() {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return new Promise((resolve) => {
30
- // readline.question('? Enter a project name (using default "v-kit-app" if left blank): ', (answer) => {
31
- //   resolve(answer || 'v-kit-app');
32
- // });
33
- let message = `\n${chalk_1.default.bold.cyan('?')} ${chalk_1.default.bold('Enter a project name')} (using default "${chalk_1.default.bold.magentaBright('v-kit-app')}" if left blank): `;
34
- readline.question(message, (answer) => {
35
- exports.fileNameVariable = answer ? answer : 'v-kit-spa';
36
- resolve(answer || 'v-kit-app');
37
- });
38
- });
39
- });
40
- }
41
- function getBoilerplateChoice() {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
44
- //!
45
- const phpProcess = spawn('php', ['-v']);
46
- let version = null;
47
- phpProcess.stdout.on('data', (data) => {
48
- const match = data.toString().match(/PHP (\d+\.\d+\.\d+)/);
49
- if (match) {
50
- version = `v${match[1]}`;
51
- console.log(chalk_1.default.italic('Scanning... your php is:'), chalk_1.default.greenBright(version));
52
- }
53
- else {
54
- console.log(chalk_1.default.redBright(`Php is not installed in your machine`));
55
- }
56
- });
57
- phpProcess.stderr.on('data', (data) => {
58
- console.error(`Php not found: ${data}`);
59
- });
60
- //!!
61
- yield new Promise((resolve) => {
62
- phpProcess.stdout.once('data', () => resolve());
63
- });
64
- //! This will not run before the function above 'resolve'
65
- let message = `\n${chalk_1.default.bold.cyan('?')} ${chalk_1.default.bold('Select your preferred boilerplate:')}\n`;
66
- message += `[1] - ${chalk_1.default.underline('Vue2-Laravel8')} ${chalk_1.default.grey.italic('~ php v7.4')}\n`;
67
- message += `[2] - ${chalk_1.default.underline('Vue3-Laravel8')} ${chalk_1.default.grey.italic('~ php v7.4')}\n`;
68
- message += `[3] - ${chalk_1.default.underline('Vue3-Laravel9')} ${chalk_1.default.grey.italic('~ php v8.0')}\n`;
69
- message += `[4] - ${chalk_1.default.underline('Vue3-Laravel10')} ${chalk_1.default.grey.italic('~ php v8.1')}\n`;
70
- message += `[5] - ${chalk_1.default.underline('Vue3-Laravel11')} ${chalk_1.default.grey.italic('~ php v8.2 - v8.3')}\n`;
71
- message += '=> ';
72
- readline.question(message, (answer) => __awaiter(this, void 0, void 0, function* () {
73
- resolve(parseInt(answer));
74
- }));
75
- }));
76
- });
77
- }
78
- function closeReadline() {
79
- readline.close();
80
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.TEMPLATES = void 0;
16
+ exports.getProjectName = getProjectName;
17
+ exports.getTemplateChoice = getTemplateChoice;
18
+ exports.detectPhp = detectPhp;
19
+ const fs_1 = __importDefault(require("fs"));
20
+ const path_1 = __importDefault(require("path"));
21
+ const prompts_1 = require("@clack/prompts");
22
+ const { spawn } = require('child_process');
23
+ // Single source of truth for the boilerplates. Folder ids map to ./lib/<id>.
24
+ exports.TEMPLATES = [
25
+ { id: '158', label: 'Vue2-Laravel8', hint: 'php 7.4' },
26
+ { id: '159', label: 'Vue3-Laravel8', hint: 'php 7.4' },
27
+ { id: '160', label: 'Vue3-Laravel9', hint: 'php 8.0' },
28
+ { id: '161', label: 'Vue3-Laravel10', hint: 'php 8.1' },
29
+ { id: '162', label: 'Vue3-Laravel11', hint: 'php 8.2 - 8.3' },
30
+ ];
31
+ const DEFAULT_NAME = 'v-kit-app';
32
+ // Characters that are illegal in Windows paths (and a good ban list elsewhere too).
33
+ const INVALID_NAME = /[<>:"/\\|?*\x00-\x1f]/;
34
+ function bail(value) {
35
+ if ((0, prompts_1.isCancel)(value)) {
36
+ (0, prompts_1.cancel)('Cancelled.');
37
+ process.exit(0);
38
+ }
39
+ }
40
+ function getProjectName() {
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ const answer = yield (0, prompts_1.text)({
43
+ message: 'Project name',
44
+ placeholder: DEFAULT_NAME,
45
+ defaultValue: DEFAULT_NAME,
46
+ validate(value) {
47
+ const v = (value !== null && value !== void 0 ? value : '').trim();
48
+ if (!v)
49
+ return; // empty -> default name is used
50
+ if (INVALID_NAME.test(v))
51
+ return 'Name contains invalid path characters.';
52
+ if (fs_1.default.existsSync(path_1.default.join(process.cwd(), v)))
53
+ return `Directory "${v}" already exists.`;
54
+ },
55
+ });
56
+ bail(answer);
57
+ return answer.trim() || DEFAULT_NAME;
58
+ });
59
+ }
60
+ function getTemplateChoice() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ const choice = yield (0, prompts_1.select)({
63
+ message: 'Select your preferred boilerplate',
64
+ options: exports.TEMPLATES.map((t) => ({ value: t.id, label: t.label, hint: t.hint })),
65
+ });
66
+ bail(choice);
67
+ return choice;
68
+ });
69
+ }
70
+ /**
71
+ * Resolve the installed PHP version, or null if PHP is missing.
72
+ * `shell: true` so the bare name `php` resolves via PATH/PATHEXT on Windows,
73
+ * matching how the interactive shell finds php.exe. Never rejects/throws:
74
+ * a missing binary emits 'error', which we catch and report as null.
75
+ */
76
+ function detectPhp() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ return new Promise((resolve) => {
79
+ let output = '';
80
+ let settled = false;
81
+ const finish = (version) => {
82
+ if (settled)
83
+ return;
84
+ settled = true;
85
+ resolve(version);
86
+ };
87
+ const phpProcess = spawn('php', ['-v'], { shell: true });
88
+ phpProcess.stdout.on('data', (data) => {
89
+ output += data.toString();
90
+ });
91
+ phpProcess.on('error', () => finish(null));
92
+ phpProcess.on('close', () => {
93
+ const match = output.match(/PHP (\d+\.\d+\.\d+)/);
94
+ finish(match ? `v${match[1]}` : null);
95
+ });
96
+ });
97
+ });
98
+ }
package/dist/utils.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare function copyProjectStructure(sourcePath: string, destinationPath: string): Promise<void>;
1
+ export declare function copyProjectStructure(sourcePath: string, destinationPath: string): Promise<void>;
2
2
  //# sourceMappingURL=utils.d.ts.map
package/dist/utils.js CHANGED
@@ -1,33 +1,33 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.copyProjectStructure = copyProjectStructure;
16
- const fs_1 = __importDefault(require("fs"));
17
- const path_1 = __importDefault(require("path"));
18
- function copyProjectStructure(sourcePath, destinationPath) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const entries = yield fs_1.default.promises.readdir(sourcePath, { withFileTypes: true });
21
- for (const entry of entries) {
22
- const sourceFile = path_1.default.join(sourcePath, entry.name);
23
- const destinationFile = path_1.default.join(destinationPath, entry.name);
24
- if (entry.isDirectory()) {
25
- yield fs_1.default.promises.mkdir(destinationFile);
26
- yield copyProjectStructure(sourceFile, destinationFile);
27
- }
28
- else {
29
- yield fs_1.default.promises.copyFile(sourceFile, destinationFile);
30
- }
31
- }
32
- });
33
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.copyProjectStructure = copyProjectStructure;
16
+ const fs_1 = __importDefault(require("fs"));
17
+ const path_1 = __importDefault(require("path"));
18
+ function copyProjectStructure(sourcePath, destinationPath) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ const entries = yield fs_1.default.promises.readdir(sourcePath, { withFileTypes: true });
21
+ for (const entry of entries) {
22
+ const sourceFile = path_1.default.join(sourcePath, entry.name);
23
+ const destinationFile = path_1.default.join(destinationPath, entry.name);
24
+ if (entry.isDirectory()) {
25
+ yield fs_1.default.promises.mkdir(destinationFile);
26
+ yield copyProjectStructure(sourceFile, destinationFile);
27
+ }
28
+ else {
29
+ yield fs_1.default.promises.copyFile(sourceFile, destinationFile);
30
+ }
31
+ }
32
+ });
33
+ }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=version.d.ts.map
package/dist/version.js CHANGED
@@ -1,20 +1,25 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const chalk_1 = __importDefault(require("chalk"));
7
- const { spawn } = require('child_process');
8
- const phpProcess = spawn('php', ['-v']);
9
- phpProcess.stdout.on('data', (data) => {
10
- const match = data.toString().match(/PHP (\d+\.\d+\.\d+)/);
11
- if (match) {
12
- console.log('Scanning... your php is:', chalk_1.default.greenBright(`v${match[1]}`));
13
- }
14
- else {
15
- console.error('Could not find Php version');
16
- }
17
- });
18
- phpProcess.stderr.on('data', (data) => {
19
- console.error(`Php not found: ${data}`);
20
- });
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const chalk_1 = __importDefault(require("chalk"));
7
+ const { spawn } = require('child_process');
8
+ const phpProcess = spawn('php', ['-v'], { shell: true });
9
+ phpProcess.stdout.on('data', (data) => {
10
+ const match = data.toString().match(/PHP (\d+\.\d+\.\d+)/);
11
+ if (match) {
12
+ console.log('Scanning... your php is:', chalk_1.default.greenBright(`v${match[1]}`));
13
+ }
14
+ else {
15
+ console.error('Could not find Php version');
16
+ }
17
+ });
18
+ phpProcess.stderr.on('data', (data) => {
19
+ console.error(`Php check error: ${data}`);
20
+ });
21
+ // Spawn failure (binary not found) emits 'error', not stderr.
22
+ // Without this, Node throws on the unhandled 'error' event and crashes.
23
+ phpProcess.on('error', () => {
24
+ console.error(chalk_1.default.redBright('Php not found in PATH.'));
25
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-v-kit-spa",
3
- "version": "1.0.12",
3
+ "version": "1.1.1",
4
4
  "main": "dist/index.js",
5
5
  "description": "A simple way to start your Vue-Laravel SPA projects",
6
6
  "repository": "Shuashuaa/v-kit-spa",
@@ -23,16 +23,14 @@
23
23
  "license": "MIT",
24
24
  "homepage": "https://github.com/Shuashuaa/v-kit-spa#readme",
25
25
  "dependencies": {
26
- "ansi-colors": "^4.1.3",
26
+ "@clack/prompts": "^1.5.1",
27
27
  "chalk": "^4.1.2",
28
- "cli-progress": "^3.12.0",
29
28
  "fs": "^0.0.1-security",
30
29
  "path": "^0.12.7",
31
30
  "yargs": "^17.7.2"
32
31
  },
33
32
  "devDependencies": {
34
33
  "@types/yargs": "^17.0.33",
35
- "@types/cli-progress": "^3.11.6",
36
34
  "ts-node": "^10.9.2",
37
35
  "typescript": "^5.6.2"
38
36
  },
package/dist/count.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare function countItems(dirPath: string): Promise<number>;
2
- export declare function getCount(sourcePath: string, templatePath: string): void;
3
- //# sourceMappingURL=count.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../src/count.ts"],"names":[],"mappings":"AAOA,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,mBAgB/C;AAID,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,QAShE"}
package/dist/count.js DELETED
@@ -1,45 +0,0 @@
1
- "use strict";
2
- // counts the items inside the selected boilerplate
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.countItems = countItems;
14
- exports.getCount = getCount;
15
- const fs = require('fs');
16
- const path = require('path');
17
- const progress_1 = require("./progress");
18
- function countItems(dirPath) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- let count = 0;
21
- const files = yield fs.promises.readdir(dirPath);
22
- for (const file of files) {
23
- const filePath = path.join(dirPath, file);
24
- const stat = yield fs.promises.stat(filePath);
25
- if (stat.isDirectory()) {
26
- count += yield countItems(filePath); // Recursive
27
- }
28
- else if (stat.isFile()) {
29
- count++;
30
- }
31
- }
32
- return count;
33
- });
34
- }
35
- // const sourcePath = path.join(__dirname, '../templates', '158');
36
- function getCount(sourcePath, templatePath) {
37
- countItems(sourcePath)
38
- .then((count) => {
39
- // console.log(`There are ${count} items (files and folders) in the folder.`);
40
- (0, progress_1.Progress)(count, templatePath);
41
- })
42
- .catch((err) => {
43
- console.error('Error:', err);
44
- });
45
- }
@@ -1,2 +0,0 @@
1
- export declare function Progress(countVal: number, sourceVal: string): Promise<void>;
2
- //# sourceMappingURL=progress.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["../src/progress.ts"],"names":[],"mappings":"AAOA,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBA0BjE"}
package/dist/progress.js DELETED
@@ -1,38 +0,0 @@
1
- "use strict";
2
- // returns the countVal as a progress bar
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Progress = Progress;
14
- const _progress = require('cli-progress');
15
- const colors = require('ansi-colors');
16
- const messages_1 = require("./messages");
17
- function Progress(countVal, sourceVal) {
18
- return __awaiter(this, void 0, void 0, function* () {
19
- console.log('\n');
20
- const b1 = new _progress.SingleBar({
21
- format: 'Downloading... |' + colors.cyan('{bar}') + '| {percentage}% | {value}/{total} Files | ETA: {eta}s',
22
- barCompleteChar: '\u2588',
23
- barIncompleteChar: '\u2591',
24
- hideCursor: true
25
- });
26
- b1.start(countVal, 0);
27
- let value = 0;
28
- const timer = setInterval(function () {
29
- value++;
30
- b1.update(value);
31
- if (value >= b1.getTotal()) {
32
- clearInterval(timer);
33
- b1.stop();
34
- (0, messages_1.successMessage)(sourceVal);
35
- }
36
- }, 20);
37
- });
38
- }