create-v-kit-spa 1.0.10 → 1.1.0

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 (55) hide show
  1. package/README.md +4 -1
  2. package/dist/commands.d.ts +1 -1
  3. package/dist/commands.js +80 -67
  4. package/dist/index.d.ts +2 -2
  5. package/dist/index.js +3 -3
  6. package/dist/messages.d.ts +2 -2
  7. package/dist/messages.d.ts.map +1 -1
  8. package/dist/messages.js +39 -69
  9. package/dist/prompts.d.ts +15 -3
  10. package/dist/prompts.d.ts.map +1 -1
  11. package/dist/prompts.js +98 -77
  12. package/dist/utils.d.ts +1 -1
  13. package/dist/utils.js +33 -33
  14. package/dist/version.d.ts +1 -1
  15. package/dist/version.js +25 -20
  16. package/lib/162/.env.example +1 -7
  17. package/lib/162/README.md +0 -19
  18. package/lib/162/app/Http/Controllers/MainController.php +12 -0
  19. package/lib/162/composer.json +3 -7
  20. package/lib/162/composer.lock +579 -1140
  21. package/lib/162/config/cache.php +4 -3
  22. package/lib/162/config/database.php +5 -2
  23. package/lib/162/config/filesystems.php +3 -2
  24. package/lib/162/config/logging.php +1 -1
  25. package/lib/162/config/mail.php +15 -2
  26. package/lib/162/config/queue.php +4 -4
  27. package/lib/162/config/services.php +4 -0
  28. package/lib/162/config/session.php +0 -1
  29. package/lib/162/package.json +1 -9
  30. package/lib/162/public/.htaccess +6 -8
  31. package/lib/162/resources/js/app.js +10 -10
  32. package/lib/162/resources/js/components/About.vue +4 -4
  33. package/lib/162/resources/js/components/Home.vue +11 -11
  34. package/lib/162/resources/js/components/pages/About.vue +5 -0
  35. package/lib/162/resources/js/components/pages/Error.vue +5 -0
  36. package/lib/162/resources/js/components/pages/Home.vue +21 -0
  37. package/lib/162/resources/js/components/templates/App.vue +86 -0
  38. package/lib/162/resources/js/failOver.js +8 -8
  39. package/lib/162/resources/js/mainStore.js +20 -0
  40. package/lib/162/resources/js/router.js +40 -24
  41. package/lib/162/resources/js/store.js +18 -18
  42. package/lib/162/resources/js/templates/App.vue +65 -65
  43. package/lib/162/resources/js/views/HomeView.vue +7 -7
  44. package/lib/162/resources/views/layouts/app.blade.php +13 -14
  45. package/lib/162/resources/views/welcome.blade.php +2 -2
  46. package/lib/162/routes/web.php +2 -3
  47. package/lib/162/vite.config.js +1 -1
  48. package/package.json +2 -4
  49. package/dist/count.d.ts +0 -3
  50. package/dist/count.d.ts.map +0 -1
  51. package/dist/count.js +0 -44
  52. package/dist/progress.d.ts +0 -2
  53. package/dist/progress.d.ts.map +0 -1
  54. package/dist/progress.js +0 -37
  55. package/lib/162/package-lock.json +0 -1330
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  <br>
2
2
 
3
+
3
4
  <div align="center">
4
5
  <img src="https://gitlab.com/shuashuaa/v-kit-app/-/raw/main/@shuashuaa-v-kit.png?ref_type=heads" width="300" />
5
6
  </div>
@@ -25,6 +26,8 @@ vite/webpack, vuetify and pinia. up-to-date, ready for local-deployment and full
25
26
  <!-- <a href="https://www.npmjs.com/package/create-v-kit-spa"><img src="https://img.shields.io/npm/v/create-v-kit-spa?color=c95f8b&amp;label=" alt="NPM version"></a>
26
27
  <a href="https://www.npmjs.com/package/create-v-kit-spa"><img src="https://img.shields.io/npm/dw/create-v-kit-spa?style=flat-square" alt="NPM downloads"></a>
27
28
  <a href="https://github.com/shuashuaa/v-kit/blob/main/LICENSE"><img src="https://img.shields.io/npm/v/create-v-kit-spa?style=flat-square" alt="License"></a> -->
29
+
30
+ [![ci-test](https://github.com/Shuashuaa/create-v-kit-spa/actions/workflows/ci.yml/badge.svg)](https://github.com/Shuashuaa/create-v-kit-spa/actions/workflows/ci.yml)
28
31
  <a href="https://github.com/shuashuaa/v-kit/blob/main/LICENSE"><img src="https://img.shields.io/npm/v/create-v-kit-spa?style=flat-square&logo=npm&color=ffe963" alt="VERSION"></a>
29
32
  <a href="https://www.npmjs.com/package/create-v-kit-spa"><img src="https://img.shields.io/npm/dw/create-v-kit-spa?style=flat-square&logo=npm&color=ffe963" alt="NPM DOWNLOADS"></a>
30
33
  <a href="https://github.com/shuashuaa/v-kit/blob/main/LICENSE"><img src="https://img.shields.io/bundlejs/size/create-v-kit-spa?style=flat-square&logo=npm&color=ffe963" alt="MINIFIED SIZE"></a>
@@ -67,7 +70,7 @@ https://windows.php.net/downloads/releases/archives/php-8.0.9-Win32-vs16-x64.zip
67
70
 
68
71
  # Reference Table (❗ PHP Version is Important ❗)
69
72
 
70
- ### Mono Repo
73
+ ### Monolith Repo
71
74
  > frontend and backend are in a single folder, united via configuration.
72
75
 
73
76
  | Version & Type | Features | Prerequisite |
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=commands.d.ts.map
package/dist/commands.js CHANGED
@@ -1,67 +1,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
- const path_1 = __importDefault(require("path"));
16
- const fs_1 = __importDefault(require("fs"));
17
- const utils_1 = require("./utils");
18
- const prompts_1 = require("./prompts");
19
- const messages_1 = require("./messages");
20
- const count_1 = require("./count");
21
- const yargs_1 = __importDefault(require("yargs"));
22
- function createProject() {
23
- 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
- const boilerplateChoice = yield (0, prompts_1.getBoilerplateChoice)();
30
- const templatePath = getTemplatePath(boilerplateChoice);
31
- if (!templatePath) {
32
- (0, messages_1.errorMessage)(new Error('\n✖ Invalid boilerplate choice.'));
33
- (0, prompts_1.closeReadline)();
34
- return;
35
- }
36
- const sourcePath = path_1.default.join(__dirname, '../lib', templatePath);
37
- const destinationPath = path_1.default.join(process.cwd(), projectName);
38
- try {
39
- yield fs_1.default.promises.mkdir(destinationPath);
40
- yield (0, utils_1.copyProjectStructure)(sourcePath, destinationPath);
41
- (0, count_1.getCount)(sourcePath, templatePath);
42
- }
43
- catch (error) {
44
- (0, messages_1.errorMessage)(error);
45
- }
46
- finally {
47
- (0, prompts_1.closeReadline)();
48
- }
49
- });
50
- }
51
- function getTemplatePath(boilerplateChoice) {
52
- switch (boilerplateChoice) {
53
- case 1:
54
- return '158';
55
- case 2:
56
- return '159';
57
- case 3:
58
- return '160';
59
- case 4:
60
- return '161';
61
- case 5:
62
- return '162';
63
- default:
64
- return null;
65
- }
66
- }
67
- createProject();
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
+ const path_1 = __importDefault(require("path"));
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");
21
+ const utils_1 = require("./utils");
22
+ const prompts_2 = require("./prompts");
23
+ const messages_1 = require("./messages");
24
+ function createProject() {
25
+ return __awaiter(this, void 0, void 0, function* () {
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)();
38
+ const destinationPath = path_1.default.join(process.cwd(), projectName);
39
+ if (fs_1.default.existsSync(destinationPath)) {
40
+ (0, messages_1.errorMessage)(new Error(`The directory "${projectName}" already exists.`));
41
+ process.exit(1);
42
+ }
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);
55
+ }
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`);
62
+ try {
63
+ yield fs_1.default.promises.mkdir(destinationPath);
64
+ yield (0, utils_1.copyProjectStructure)(sourcePath, destinationPath);
65
+ copySpinner.stop(`Created ${chalk_1.default.cyan(projectName)} (${template.label})`);
66
+ }
67
+ catch (error) {
68
+ copySpinner.stop('Failed to create project');
69
+ (0, messages_1.errorMessage)(error);
70
+ process.exit(1);
71
+ }
72
+ (0, messages_1.successMessage)(template.id, projectName);
73
+ (0, prompts_1.outro)(chalk_1.default.green(`${template.label} boilerplate ready 🎉`));
74
+ });
75
+ }
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":"AAEA,wBAAsB,cAAc,CAAC,SAAS,EAAE,MAAM,iBAsCrD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAExC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,QA0BpE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,QAExC"}
package/dist/messages.js CHANGED
@@ -1,69 +1,39 @@
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.successMessage = successMessage;
16
- exports.errorMessage = errorMessage;
17
- const chalk_1 = __importDefault(require("chalk"));
18
- function successMessage(sourceVal) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- // console.log(sourceVal)
21
- let tempVal = '';
22
- if (sourceVal == '158') {
23
- tempVal = 'Vue2-Laravel8';
24
- }
25
- else if (sourceVal == '159') {
26
- tempVal = 'Vue3-Laravel8';
27
- }
28
- else if (sourceVal == '160') {
29
- tempVal = 'Vue3-Laravel9';
30
- }
31
- else if (sourceVal == '161') {
32
- tempVal = 'Vue3-Laravel10';
33
- }
34
- else if (sourceVal == '162') {
35
- tempVal = 'Vue3-Laravel11';
36
- }
37
- console.log(chalk_1.default.green(`\n✔ ${tempVal} boilerplate is successfully downloaded!. \n`));
38
- setTimeout(() => {
39
- console.log(chalk_1.default.yellow.bold("              *       ˜"));
40
- console.log(chalk_1.default.cyan.bold("        ˜                  |"));
41
- console.log(chalk_1.default.red.bold("    ()    .-.,='``'=.    - o -"));
42
- console.log(chalk_1.default.yellow.bold("          '=/_       〵    |"));
43
- console.log(chalk_1.default.cyanBright.bold("       *   |  '=._     )"));
44
- console.log(chalk_1.default.yellow.bold("           \\      `=../`,        '"));
45
- console.log(chalk_1.default.redBright.bold("         .   '=.__.=' `='      *"));
46
- console.log(chalk_1.default.yellow.bold("˜                         +"));
47
- console.log(chalk_1.default.cyanBright.bold("     O      *        '       .\n"));
48
- }, 300);
49
- setTimeout(() => {
50
- 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')));
51
- }, 800);
52
- setTimeout(() => {
53
- if (sourceVal == "158" || sourceVal == "159") {
54
- console.log(chalk_1.default.bgBlack('Locate Project:'), chalk_1.default.cyanBright('cd project_name,'));
55
- 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'));
56
- console.log(chalk_1.default.bgBlack('Run Project:'), chalk_1.default.cyanBright('npm run artisan-watch') + '.\n');
57
- }
58
- else if (sourceVal == "160" || sourceVal == "161" || sourceVal == "162") {
59
- console.log(chalk_1.default.bgBlack('Locate Project:'), chalk_1.default.cyanBright('cd project_name,'));
60
- 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'));
61
- console.log(chalk_1.default.bgBlack('Run Project:'), chalk_1.default.cyanBright('npm run artisan-dev') + '.\n');
62
- }
63
- console.log(chalk_1.default.bgBlack('Visit:'), chalk_1.default.bold('http://127.0.0.1:8000\n'));
64
- }, 500);
65
- });
66
- }
67
- function errorMessage(error) {
68
- console.error(chalk_1.default.red.inverse(`\n✖ Error creating project. ${error.message}`));
69
- }
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
+ exports.successMessage = successMessage;
7
+ exports.errorMessage = errorMessage;
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const prompts_1 = require("./prompts");
10
+ // Templates whose install hint uses npm; the rest use yarn.
11
+ const NPM_TEMPLATES = ['158', '159'];
12
+ function successMessage(sourceVal, projectName) {
13
+ var _a, _b;
14
+ const label = (_b = (_a = prompts_1.TEMPLATES.find((t) => t.id === sourceVal)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : sourceVal;
15
+ console.log(chalk_1.default.green(`\n✔ ${label} boilerplate is successfully downloaded!\n`));
16
+ console.log(chalk_1.default.yellow.bold(" * ˜"));
17
+ console.log(chalk_1.default.cyan.bold(" ˜ |"));
18
+ console.log(chalk_1.default.red.bold(" () .-.,='``'=. - o -"));
19
+ console.log(chalk_1.default.yellow.bold(" '=/_ 〵 |"));
20
+ console.log(chalk_1.default.cyanBright.bold(" * | '=._ )"));
21
+ console.log(chalk_1.default.yellow.bold(" \\ `=../`, '"));
22
+ console.log(chalk_1.default.redBright.bold(" . '=.__.=' `=' *"));
23
+ console.log(chalk_1.default.yellow.bold("˜ +"));
24
+ console.log(chalk_1.default.cyanBright.bold(" O * ' .\n"));
25
+ console.log(chalk_1.default.bgBlack('Locate Project:'), chalk_1.default.cyanBright(`cd ${projectName},`));
26
+ if (NPM_TEMPLATES.includes(sourceVal)) {
27
+ 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'));
28
+ console.log(chalk_1.default.bgBlack('Run Project:'), chalk_1.default.cyanBright('npm run artisan-watch') + '.\n');
29
+ }
30
+ else {
31
+ 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'));
32
+ console.log(chalk_1.default.bgBlack('Run Project:'), chalk_1.default.cyanBright('npm run artisan-dev') + '.\n');
33
+ }
34
+ console.log(chalk_1.default.bgBlack('Visit:'), chalk_1.default.bold('http://127.0.0.1:8000\n'));
35
+ 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')));
36
+ }
37
+ function errorMessage(error) {
38
+ console.error(chalk_1.default.red.inverse(`\n✖ Error creating project. ${error.message}`));
39
+ }
package/dist/prompts.d.ts CHANGED
@@ -1,4 +1,16 @@
1
- export declare function getProjectName(): Promise<string>;
2
- export declare function getBoilerplateChoice(): Promise<number>;
3
- 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>;
4
16
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AASA,wBACgB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAWhD;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,77 +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.getProjectName = getProjectName;
16
- exports.getBoilerplateChoice = getBoilerplateChoice;
17
- exports.closeReadline = closeReadline;
18
- const chalk_1 = __importDefault(require("chalk"));
19
- const { spawn } = require('child_process');
20
- const readline_1 = require("readline");
21
- const readline = (0, readline_1.createInterface)({
22
- input: process.stdin,
23
- output: process.stdout
24
- });
25
- function getProjectName() {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- return new Promise((resolve) => {
28
- // readline.question('? Enter a project name (using default "v-kit-app" if left blank): ', (answer) => {
29
- //   resolve(answer || 'v-kit-app');
30
- // });
31
- 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): `;
32
- readline.question(message, (answer) => {
33
- resolve(answer || 'v-kit-app');
34
- });
35
- });
36
- });
37
- }
38
- function getBoilerplateChoice() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
41
- //!
42
- const phpProcess = spawn('php', ['-v']);
43
- let version = null;
44
- phpProcess.stdout.on('data', (data) => {
45
- const match = data.toString().match(/PHP (\d+\.\d+\.\d+)/);
46
- if (match) {
47
- version = `v${match[1]}`;
48
- console.log(chalk_1.default.italic('Scanning... your php is:'), chalk_1.default.greenBright(version));
49
- }
50
- else {
51
- console.log(chalk_1.default.redBright(`Php is not installed in your machine`));
52
- }
53
- });
54
- phpProcess.stderr.on('data', (data) => {
55
- console.error(`Php not found: ${data}`);
56
- });
57
- //!!
58
- yield new Promise((resolve) => {
59
- phpProcess.stdout.once('data', () => resolve());
60
- });
61
- //! This will not run before the function above 'resolve'
62
- let message = `\n${chalk_1.default.bold.cyan('?')} ${chalk_1.default.bold('Select your preferred boilerplate:')}\n`;
63
- message += `[1] - ${chalk_1.default.underline('Vue2-Laravel8')} ${chalk_1.default.grey.italic('~ php v7.4')}\n`;
64
- message += `[2] - ${chalk_1.default.underline('Vue3-Laravel8')} ${chalk_1.default.grey.italic('~ php v7.4')}\n`;
65
- message += `[3] - ${chalk_1.default.underline('Vue3-Laravel9')} ${chalk_1.default.grey.italic('~ php v8.0')}\n`;
66
- message += `[4] - ${chalk_1.default.underline('Vue3-Laravel10')} ${chalk_1.default.grey.italic('~ php v8.1')}\n`;
67
- message += `[5] - ${chalk_1.default.underline('Vue3-Laravel11')} ${chalk_1.default.grey.italic('~ php v8.2 - v8.3')}\n`;
68
- message += '=> ';
69
- readline.question(message, (answer) => __awaiter(this, void 0, void 0, function* () {
70
- resolve(parseInt(answer));
71
- }));
72
- }));
73
- });
74
- }
75
- function closeReadline() {
76
- readline.close();
77
- }
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