create-nextop-app 0.0.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.
Files changed (2) hide show
  1. package/dist/index.js +75 -0
  2. package/package.json +38 -0
package/dist/index.js ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const commander_1 = require("commander");
8
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
+ const path_1 = __importDefault(require("path"));
10
+ const chalk_1 = __importDefault(require("chalk"));
11
+ const prompts_1 = __importDefault(require("prompts"));
12
+ const child_process_1 = require("child_process");
13
+ const program = new commander_1.Command();
14
+ function runInstall(projectPath) {
15
+ return new Promise((resolve, reject) => {
16
+ const child = (0, child_process_1.spawn)('npm', ['install'], {
17
+ cwd: projectPath,
18
+ stdio: 'inherit',
19
+ shell: true
20
+ });
21
+ child.on('close', (code) => {
22
+ if (code === 0)
23
+ resolve(true);
24
+ else
25
+ reject(new Error('Bağımlılıklar yüklenirken bir hata oluştu.'));
26
+ });
27
+ });
28
+ }
29
+ program
30
+ .name('create-nextop-app')
31
+ .description('Create a new NextOP app')
32
+ .argument('[project-directory]', 'Project directory')
33
+ .action(async (projectDir) => {
34
+ let targetDir = projectDir;
35
+ if (!targetDir) {
36
+ const response = await (0, prompts_1.default)({
37
+ type: 'text',
38
+ name: 'projectName',
39
+ message: 'Please type a project name',
40
+ initial: 'my-nextop-app',
41
+ validate: value => value.length > 0 ? true : 'Please type a valid name.'
42
+ });
43
+ targetDir = response.projectName;
44
+ }
45
+ if (!targetDir) {
46
+ console.log(chalk_1.default.yellow('\nProcess canceled.'));
47
+ process.exit(0);
48
+ }
49
+ const targetPath = path_1.default.join(process.cwd(), targetDir);
50
+ const templatePath = path_1.default.join(__dirname, '../templates/default');
51
+ console.log(chalk_1.default.blue(`\n${targetDir} creating...\n`));
52
+ try {
53
+ if (fs_extra_1.default.existsSync(targetPath)) {
54
+ console.error(chalk_1.default.red(`Error: ${targetDir} already exist.`));
55
+ process.exit(1);
56
+ }
57
+ console.log(chalk_1.default.gray(`Files creating...`));
58
+ await fs_extra_1.default.copy(templatePath, targetPath);
59
+ const packPath = path_1.default.join(targetPath, 'package.json');
60
+ if (fs_extra_1.default.existsSync(packPath)) {
61
+ const pack = await fs_extra_1.default.readJson(packPath);
62
+ pack.name = targetDir;
63
+ await fs_extra_1.default.writeJson(packPath, pack, { spaces: 2 });
64
+ }
65
+ console.log(chalk_1.default.cyan('\n Installing...'));
66
+ await runInstall(targetPath);
67
+ console.log(chalk_1.default.green(`\n Project created succesfully.`));
68
+ console.log(`\nBaşlamak için:\n cd ${targetDir} \n npm run dev\n`);
69
+ }
70
+ catch (error) {
71
+ console.error(chalk_1.default.red(`\n Error ${error}`));
72
+ process.exit(1);
73
+ }
74
+ });
75
+ program.parse(process.argv);
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "create-nextop-app",
3
+ "version": "0.0.1",
4
+ "description": "NextOP framework starter CLI",
5
+ "main": "./dist/index.js",
6
+ "bin": {
7
+ "create-nextop-app": "./dist/index.js"
8
+ },
9
+ "type": "module",
10
+ "publishConfig": {
11
+ "access": "public"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/FlyingTurkman/nextop-app",
16
+ "directory": "packages/create-nextop-app"
17
+ },
18
+ "scripts": {
19
+ "build": "npx tsc",
20
+ "start": "node dist/index.js"
21
+ },
22
+ "dependencies": {
23
+ "chalk": "^5.0.0",
24
+ "commander": "^11.0.0",
25
+ "fs-extra": "^11.0.0",
26
+ "inquirer": "^9.0.0",
27
+ "path": "^0.12.7",
28
+ "prompts": "^2.4.2",
29
+ "typescript": "^5.9.3"
30
+ },
31
+ "devDependencies": {
32
+ "@types/fs-extra": "^11.0.4",
33
+ "@types/prompts": "^2.4.9"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ]
38
+ }