mvc-beckend-cli 1.2.0 → 1.3.2

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,30 +1,28 @@
1
- import { mkdir, writeFile } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { DATA_CONTROLLERS, DATA_MODELS, DATA_SERVICES } from '../data/data.actions.ts';
4
-
5
- export const init_base_folders = async (name: string) => {
6
- try {
7
- await mkdir(`${name}`, { recursive: true });
8
- await mkdir(`${name}/controllers`, { recursive: true });
9
- await mkdir(`${name}/models`, { recursive: true });
10
- await mkdir(`${name}/services`, { recursive: true });
11
-
12
- console.log(` Structure MVC for project "${name}" successfully created!`);
13
- } catch (error) {
14
- console.error('Ошибка при создании папок:', error);
15
- }
16
- }
17
-
18
- export const create_files_struct = async (structPath: string = 'app', structName: string) => {
19
- try {
20
- const controllerPath = join(structPath, 'controllers', `${structName}.controller.ts`);
21
- const servicesPath = join(structPath, 'services', `${structName}.service.ts`);
22
- const modelsPath = join(structPath, 'models', `${structName}.models.ts`);
23
-
24
- await writeFile(controllerPath, DATA_CONTROLLERS(structName), 'utf-8')
25
- await writeFile(servicesPath, DATA_SERVICES(structName), 'utf-8')
26
- await writeFile(modelsPath, DATA_MODELS(structName), 'utf-8')
27
- } catch (error) {
28
- console.log('Ошибка при генерации файлов:', error);
29
- }
30
- }
1
+ import { mkdir, writeFile } from 'node:fs/promises';
2
+ import { join } from 'node:path';
3
+ import { DATA_CONTROLLERS, DATA_MODELS, DATA_SERVICES } from '../data/data.actions.js';
4
+ export const init_base_folders = async (name) => {
5
+ try {
6
+ await mkdir(`${name}`, { recursive: true });
7
+ await mkdir(`${name}/controllers`, { recursive: true });
8
+ await mkdir(`${name}/models`, { recursive: true });
9
+ await mkdir(`${name}/services`, { recursive: true });
10
+ console.log(` Structure MVC for project "${name}" successfully created!`);
11
+ }
12
+ catch (error) {
13
+ console.error('Ошибка при создании папок:', error);
14
+ }
15
+ };
16
+ export const create_files_struct = async (structPath = 'app', structName) => {
17
+ try {
18
+ const controllerPath = join(structPath, 'controllers', `${structName}.controller.ts`);
19
+ const servicesPath = join(structPath, 'services', `${structName}.service.ts`);
20
+ const modelsPath = join(structPath, 'models', `${structName}.models.ts`);
21
+ await writeFile(controllerPath, DATA_CONTROLLERS(structName), 'utf-8');
22
+ await writeFile(servicesPath, DATA_SERVICES(structName), 'utf-8');
23
+ await writeFile(modelsPath, DATA_MODELS(structName), 'utf-8');
24
+ }
25
+ catch (error) {
26
+ console.log('Ошибка при генерации файлов:', error);
27
+ }
28
+ };
@@ -1,4 +1,4 @@
1
- export const DATA_CONTROLLERS = (controllerName: string) => {
1
+ export const DATA_CONTROLLERS = (controllerName) => {
2
2
  return `import { Router } from "express";
3
3
 
4
4
  const router = Router();
@@ -8,17 +8,15 @@ router.post('/${controllerName}', );
8
8
  router.patch('/${controllerName}', );
9
9
  router.delete('/${controllerName}', );
10
10
 
11
- export default router;`;
12
- }
13
-
14
- export const DATA_SERVICES = (serviceName: string) => {
11
+ export default router;`;
12
+ };
13
+ export const DATA_SERVICES = (serviceName) => {
15
14
  return `import pkg from 'express';
16
15
 
17
16
  const { request, response } = pkg;
18
17
 
19
- export const ${serviceName}Service = {}`;
20
- }
21
-
22
- export const DATA_MODELS = (modelName: string) => {
23
- return `export const ${modelName}Model = {}`;
24
- }
18
+ export const ${serviceName}Service = {}`;
19
+ };
20
+ export const DATA_MODELS = (modelName) => {
21
+ return `export const ${modelName}Model = {}`;
22
+ };
@@ -1,24 +1,18 @@
1
1
  #!/usr/bin/env node
2
-
3
- import { program } from 'commander';
4
- import { create_files_struct, init_base_folders } from './actions/actions.js';
5
-
6
- program
7
- .version('1.0.0')
8
- .description('CLI для бэкенд проектов MVC')
9
-
10
- program
11
- .command('init')
12
- .argument('<name>', 'Название корневой папки проекта')
13
- .action(init_base_folders);
14
-
15
- program
16
- .command('struct')
17
- .argument('<structPath>', 'Путь до папок структур')
18
- .argument('<nameSctructure>', 'Название структуры генераторов')
19
- .action((structPath, nameSctructure) => {
20
- nameSctructure(structPath, nameSctructure);
21
- })
22
-
23
-
24
- program.parse(process.argv);
2
+ import { program } from 'commander';
3
+ import { create_files_struct, init_base_folders } from './actions/actions.js';
4
+ program
5
+ .version('1.0.0')
6
+ .description('CLI для бэкенд проектов MVC');
7
+ program
8
+ .command('init')
9
+ .argument('<name>', 'Название корневой папки проекта')
10
+ .action(init_base_folders);
11
+ program
12
+ .command('struct')
13
+ .argument('<structPath>', 'Путь до папок структур')
14
+ .argument('<nameSctructure>', 'Название структуры генераторов')
15
+ .action((structPath, nameSctructure) => {
16
+ create_files_struct(structPath, nameSctructure);
17
+ });
18
+ program.parse(process.argv);
package/package.json CHANGED
@@ -1,13 +1,16 @@
1
1
  {
2
2
  "name": "mvc-beckend-cli",
3
3
  "description": "CLI для быстрой генерации бэкенд проектов на архитектуре MVC",
4
- "version": "1.2.0",
4
+ "version": "1.3.2",
5
5
  "license": "MIT",
6
6
  "author": "Turbo_MaKsIk12",
7
7
  "type": "module",
8
8
  "bin": {
9
- "mvc-cli": "index.js"
9
+ "mvc-cli": "./dist/index.js"
10
10
  },
11
+ "files": [
12
+ "dist"
13
+ ],
11
14
  "keywords": [
12
15
  "cli",
13
16
  "mvc",
@@ -19,6 +22,7 @@
19
22
  "commander": "^15.0.0"
20
23
  },
21
24
  "devDependencies": {
22
- "@types/node": "^26.1.1"
25
+ "@types/node": "^26.1.1",
26
+ "typescript": "^7.0.2"
23
27
  }
24
28
  }