@avleon/cli 0.0.46 → 0.4.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 (89) hide show
  1. package/LICENSE +21 -0
  2. package/dist/bin.d.ts +2 -0
  3. package/dist/bin.js +10 -0
  4. package/dist/commands/build.d.ts +11 -0
  5. package/dist/commands/build.js +65 -0
  6. package/dist/commands/doctor.d.ts +10 -0
  7. package/dist/commands/doctor.js +96 -0
  8. package/dist/commands/new.d.ts +19 -0
  9. package/dist/commands/new.js +306 -0
  10. package/dist/commands/route-list.d.ts +19 -0
  11. package/dist/commands/route-list.js +160 -0
  12. package/dist/commands/serve.d.ts +17 -0
  13. package/dist/commands/serve.js +238 -0
  14. package/dist/commands/start.d.ts +10 -0
  15. package/dist/commands/start.js +43 -0
  16. package/dist/compiler.d.ts +24 -0
  17. package/dist/compiler.js +83 -0
  18. package/dist/errors.d.ts +8 -0
  19. package/dist/errors.js +16 -0
  20. package/dist/generators/make.d.ts +24 -0
  21. package/dist/generators/make.js +157 -0
  22. package/dist/index.d.ts +17 -0
  23. package/dist/index.js +40 -15
  24. package/dist/program.d.ts +22 -0
  25. package/dist/program.js +178 -0
  26. package/dist/utils/entry.d.ts +15 -0
  27. package/dist/utils/entry.js +55 -0
  28. package/dist/utils/env-types.d.ts +8 -0
  29. package/dist/utils/env-types.js +19 -0
  30. package/dist/utils/log.d.ts +25 -0
  31. package/dist/utils/log.js +39 -0
  32. package/dist/utils/names.d.ts +27 -0
  33. package/dist/utils/names.js +58 -0
  34. package/dist/utils/process.d.ts +18 -0
  35. package/dist/utils/process.js +84 -0
  36. package/dist/utils/project.d.ts +17 -0
  37. package/dist/utils/project.js +91 -0
  38. package/dist/utils/stubs.d.ts +15 -0
  39. package/dist/utils/stubs.js +52 -0
  40. package/dist/utils/tsconfig.d.ts +13 -0
  41. package/dist/utils/tsconfig.js +102 -0
  42. package/package.json +63 -62
  43. package/readme.md +155 -66
  44. package/stubs/config/config.stub +9 -0
  45. package/stubs/controllers/basic-controller.stub +9 -12
  46. package/stubs/controllers/resource-controller.stub +45 -0
  47. package/stubs/controllers/rest-controller.stub +29 -34
  48. package/stubs/dtos/dto.stub +11 -0
  49. package/stubs/middlewares/middleware.stub +9 -0
  50. package/stubs/models/basic-model.stub +4 -6
  51. package/stubs/models/entity-model.stub +16 -23
  52. package/stubs/project/app-minimal.stub +7 -0
  53. package/stubs/project/app.stub +8 -0
  54. package/stubs/project/env.stub +3 -0
  55. package/stubs/project/gitignore.stub +5 -0
  56. package/stubs/project/home.controller.spec.stub +19 -0
  57. package/stubs/project/home.controller.stub +12 -0
  58. package/stubs/project/home.service.stub +8 -0
  59. package/stubs/project/openapi.config.stub +15 -0
  60. package/stubs/project/readme.stub +26 -0
  61. package/stubs/project/serve.stub +10 -0
  62. package/stubs/project/tsconfig.build.stub +4 -0
  63. package/stubs/project/tsconfig.stub +18 -0
  64. package/stubs/project/vitest-e2e.config.stub +10 -0
  65. package/stubs/project/vitest.config.stub +17 -0
  66. package/stubs/services/basic-service.stub +8 -9
  67. package/stubs/services/orm-rest-service.stub +61 -73
  68. package/stubs/services/rest-service.stub +34 -71
  69. package/dist/av-cli.js +0 -60
  70. package/dist/avcli.js +0 -26
  71. package/dist/cli.interface.js +0 -2
  72. package/dist/cli.js +0 -358
  73. package/dist/commands.js +0 -55
  74. package/dist/controller.js +0 -92
  75. package/dist/create.js +0 -498
  76. package/dist/helpers/file-helper.js +0 -30
  77. package/dist/helpers/path-helper.js +0 -21
  78. package/dist/paths.js +0 -32
  79. package/dist/scripts/serve.js +0 -290
  80. package/dist/serve.js +0 -311
  81. package/dist/service.js +0 -73
  82. package/stubs/app/app-controller.stub +0 -11
  83. package/stubs/app/app-minimal.stub +0 -17
  84. package/stubs/app/app-withdb.stub +0 -0
  85. package/stubs/basic-controller.stub +0 -7
  86. package/stubs/config.stub +0 -11
  87. package/stubs/controllers/orm-rest-controller.stub +0 -52
  88. package/stubs/model.stub +0 -0
  89. package/stubs/serve.stub +0 -10
package/dist/create.js DELETED
@@ -1,498 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.createApplication = createApplication;
40
- const fs_extra_1 = __importDefault(require("fs-extra"));
41
- const paths_1 = require("./paths");
42
- const prettier = __importStar(require("prettier"));
43
- const path_1 = __importDefault(require("path"));
44
- const os_1 = __importDefault(require("os"));
45
- const inquirer_1 = __importDefault(require("inquirer"));
46
- const child_process_1 = require("child_process");
47
- const lodash_1 = require("lodash");
48
- // ─── Colors ───────────────────────────────────────────────────────────────────
49
- const C = {
50
- reset: '\x1b[0m',
51
- dim: '\x1b[90m',
52
- bold: '\x1b[1m',
53
- cyan: '\x1b[36m',
54
- green: '\x1b[32m',
55
- yellow: '\x1b[33m',
56
- red: '\x1b[31m',
57
- white: '\x1b[37m',
58
- };
59
- const icon = {
60
- success: `${C.green}✔${C.reset}`,
61
- error: `${C.red}✖${C.reset}`,
62
- warn: `${C.yellow}⚠${C.reset}`,
63
- arrow: `${C.dim}→${C.reset}`,
64
- };
65
- function step(label, detail) {
66
- const pad = label.padEnd(30, ' ');
67
- console.log(` ${icon.arrow} ${C.white}${pad}${C.reset}${detail ? C.dim + detail + C.reset : ''}`);
68
- }
69
- function success(msg) {
70
- console.log(` ${icon.success} ${C.green}${msg}${C.reset}`);
71
- }
72
- function fail(msg) {
73
- console.log(` ${icon.error} ${C.red}${msg}${C.reset}`);
74
- }
75
- function section(title) {
76
- console.log(`\n${C.bold}${C.cyan} ${title}${C.reset}`);
77
- console.log(` ${'─'.repeat(40)}`);
78
- }
79
- // ─── Version resolver ─────────────────────────────────────────────────────────
80
- function resolveDepVersion(pkgName, fallback = 'latest') {
81
- try {
82
- const pkgJsonPath = require.resolve(`${pkgName}/package.json`);
83
- const pkg = JSON.parse(fs_extra_1.default.readFileSync(pkgJsonPath, 'utf8'));
84
- return `^${pkg.version}`;
85
- }
86
- catch {
87
- return fallback;
88
- }
89
- }
90
- function getAvleonVersions() {
91
- try {
92
- // Read CLI's own package.json (this file lives inside @avleon/cli)
93
- const cliPkgPath = path_1.default.resolve(__dirname, '../../package.json');
94
- const cliPkg = JSON.parse(fs_extra_1.default.readFileSync(cliPkgPath, 'utf8'));
95
- // Core version — resolve from installed node_modules
96
- const corePkgPath = require.resolve('@avleon/core/package.json');
97
- const corePkg = JSON.parse(fs_extra_1.default.readFileSync(corePkgPath, 'utf8'));
98
- return {
99
- core: `^${corePkg.version}`,
100
- cli: `^${cliPkg.version}`,
101
- };
102
- }
103
- catch {
104
- return { core: 'latest', cli: 'latest' };
105
- }
106
- }
107
- // ─── Banner ───────────────────────────────────────────────────────────────────
108
- function banner(fname) {
109
- const { core } = getAvleonVersions();
110
- console.clear();
111
- console.log();
112
- console.log(`${C.bold}${C.cyan} ╔═══════════════════════════════════════╗${C.reset}`);
113
- console.log(`${C.bold}${C.cyan} ║ AVLEON APPLICATION CLI ║${C.reset}`);
114
- console.log(`${C.bold}${C.cyan} ╚═══════════════════════════════════════╝${C.reset}`);
115
- console.log();
116
- console.log(` ${C.dim}Creating project :${C.reset} ${C.bold}${C.white}${fname}${C.reset}`);
117
- console.log(` ${C.dim}Avleon version :${C.reset} ${C.bold}${C.cyan}${core}${C.reset}`);
118
- console.log();
119
- }
120
- // ─── Shell ────────────────────────────────────────────────────────────────────
121
- const getShell = () => os_1.default.platform() === 'win32'
122
- ? process.env.ComSpec || 'cmd.exe'
123
- : process.env.SHELL || '/bin/sh';
124
- // ─── Prompts ──────────────────────────────────────────────────────────────────
125
- async function askForPackageManager() {
126
- const { packageManager } = await inquirer_1.default.prompt([
127
- {
128
- type: 'list',
129
- name: 'packageManager',
130
- message: 'Package manager:',
131
- choices: [
132
- { name: 'npm', value: 'npm' },
133
- { name: 'yarn', value: 'yarn' },
134
- { name: 'pnpm (recommended)', value: 'pnpm' },
135
- ],
136
- default: 'npm',
137
- },
138
- ]);
139
- return packageManager;
140
- }
141
- async function askForFeatures() {
142
- const { features } = await inquirer_1.default.prompt([
143
- {
144
- type: 'checkbox',
145
- name: 'features',
146
- message: 'Select features to include:',
147
- choices: [
148
- { name: 'OpenAPI / Swagger docs', value: 'openapi', checked: true },
149
- { name: 'CORS support', value: 'cors', checked: false },
150
- { name: 'TypeORM database', value: 'typeorm', checked: false },
151
- { name: 'Scalar UI (replaces Swagger UI)', value: 'scalar', checked: false },
152
- ],
153
- },
154
- ]);
155
- return features;
156
- }
157
- // ─── Installer ────────────────────────────────────────────────────────────────
158
- async function installDependencies(pm, cwd) {
159
- return new Promise((resolve, reject) => {
160
- const child = (0, child_process_1.spawn)(pm, ['install'], {
161
- cwd,
162
- shell: getShell(),
163
- stdio: 'inherit',
164
- });
165
- child.on('exit', (code) => {
166
- code === 0
167
- ? resolve()
168
- : reject(new Error(`Install failed with exit code ${code}`));
169
- });
170
- child.on('error', reject);
171
- });
172
- }
173
- // ─── Format helper ────────────────────────────────────────────────────────────
174
- async function fmt(source, parser = 'typescript') {
175
- return prettier.format(source, {
176
- singleQuote: true,
177
- singleAttributePerLine: true,
178
- parser,
179
- });
180
- }
181
- // ─── File writer ──────────────────────────────────────────────────────────────
182
- async function writeFile(filePath, content, label) {
183
- await fs_extra_1.default.ensureDir(path_1.default.dirname(filePath));
184
- await fs_extra_1.default.writeFile(filePath, content);
185
- if (label)
186
- step(label, path_1.default.relative(process.cwd(), filePath));
187
- }
188
- // ─── Templates ────────────────────────────────────────────────────────────────
189
- function homeServiceTemplate() {
190
- return `
191
- import { AppService } from '@avleon/core';
192
-
193
- @AppService
194
- export class HomeService {
195
- sayHello() {
196
- return { message: 'Hello World!' };
197
- }
198
- }
199
- `;
200
- }
201
- function homeControllerTemplate() {
202
- return `
203
- import { ApiController, Get } from '@avleon/core';
204
- import { HomeService } from '../services/home.service';
205
-
206
- @ApiController('/')
207
- export class HomeController {
208
- constructor(private readonly homeService: HomeService) {}
209
-
210
- @Get()
211
- sayHello() {
212
- return this.homeService.sayHello();
213
- }
214
- }
215
- `;
216
- }
217
- function homeControllerTestTemplate() {
218
- return `
219
- import { AvleonTest } from '@avleon/core';
220
- import { HomeController } from './home.controller';
221
-
222
- describe('HomeController', () => {
223
- let controller!: HomeController;
224
-
225
- beforeAll(() => {
226
- controller = AvleonTest.getController(HomeController);
227
- });
228
-
229
- it('should be defined', () => {
230
- expect(controller).toBeDefined();
231
- });
232
-
233
- it('should have sayHello method', () => {
234
- expect(typeof controller.sayHello).toBe('function');
235
- });
236
-
237
- it('should return hello message', () => {
238
- expect(controller.sayHello()).toEqual({ message: 'Hello World!' });
239
- });
240
- });
241
- `;
242
- }
243
- function openApiConfigTemplate(fname, useScalar) {
244
- return `
245
- import { AppConfig, Environment, IConfig } from '@avleon/core';
246
-
247
- @AppConfig
248
- export class OpenApiConfig implements IConfig {
249
- config(env: Environment) {
250
- return {
251
- info: {
252
- title: '${(0, lodash_1.capitalize)(fname)} API',
253
- version: '0.0.1',
254
- description: 'API documentation for ${(0, lodash_1.capitalize)(fname)}',
255
- },
256
- ${useScalar ? "provider: 'scalar'," : ''}
257
- routePrefix: '/docs',
258
- };
259
- }
260
- }
261
- `;
262
- }
263
- function appTemplate(features) {
264
- const hasOpenApi = features.includes('openapi');
265
- const hasCors = features.includes('cors');
266
- const hasTypeorm = features.includes('typeorm');
267
- const imports = [`import { Avleon } from '@avleon/core';`];
268
- imports.push(`import { HomeController } from './controllers/home.controller';`);
269
- if (hasOpenApi) {
270
- imports.push(`import { OpenApiConfig } from './config/openapi.config';`);
271
- }
272
- const body = [`const app = Avleon.createApplication();`, ''];
273
- if (hasCors) {
274
- body.push(`app.useCors({ origin: '*' });`);
275
- }
276
- if (hasOpenApi) {
277
- body.push(`if (app.isDevelopment()) {`);
278
- body.push(` app.useOpenApi(OpenApiConfig);`);
279
- body.push(`}`);
280
- body.push('');
281
- }
282
- if (hasTypeorm) {
283
- body.push(`// TODO: configure datasource in src/config/database.config.ts`);
284
- body.push(`// app.useDatasource(AppDataSource);`);
285
- body.push('');
286
- }
287
- body.push(`app.useControllers([HomeController]);`);
288
- body.push('');
289
- body.push(`export default app;`);
290
- return `${imports.join('\n')}\n\n${body.join('\n')}\n`;
291
- }
292
- function serveTemplate() {
293
- return `
294
- import app from './app';
295
-
296
- async function start() {
297
- await app.run(); // default port: 4000
298
- }
299
-
300
- start();
301
- `;
302
- }
303
- function packageJsonTemplate(fname, features) {
304
- // ✅ Always resolve current installed versions at generation time
305
- const { core, cli } = getAvleonVersions();
306
- const deps = {
307
- '@avleon/core': core,
308
- '@avleon/cli': cli,
309
- 'class-transformer': resolveDepVersion('class-transformer', '^0.5.1'),
310
- 'class-validator': resolveDepVersion('class-validator', '^0.14.1'),
311
- 'rimraf': resolveDepVersion('rimraf', '^6.0.1'),
312
- 'reflect-metadata': resolveDepVersion('reflect-metadata', '^0.2.2'),
313
- };
314
- if (features.includes('cors')) {
315
- deps['@fastify/cors'] = resolveDepVersion('@fastify/cors', '^10.0.0');
316
- }
317
- if (features.includes('typeorm')) {
318
- deps['typeorm'] = resolveDepVersion('typeorm', '^0.3.20');
319
- deps['pg'] = resolveDepVersion('pg', '^8.11.0');
320
- }
321
- if (features.includes('scalar')) {
322
- deps['@scalar/fastify-api-reference'] = resolveDepVersion('@scalar/fastify-api-reference', '^1.0.0');
323
- }
324
- const devDeps = {
325
- '@types/jest': resolveDepVersion('@types/jest', '^29.5.14'),
326
- '@types/node': resolveDepVersion('@types/node', '^24.0.3'),
327
- 'jest': resolveDepVersion('jest', '^29.7.0'),
328
- 'ts-jest': resolveDepVersion('ts-jest', '^29.2.6'),
329
- 'typescript': resolveDepVersion('typescript', '^5.7.2'),
330
- };
331
- return JSON.stringify({
332
- name: (0, lodash_1.kebabCase)(fname),
333
- version: '0.0.1',
334
- description: `${(0, lodash_1.capitalize)(fname)} API built with Avleon`,
335
- main: 'dist/serve.js',
336
- scripts: {
337
- 'start:dev': 'avleon serve',
338
- 'clean': 'rimraf ./dist',
339
- 'build': 'npm run clean && tsc --project ./tsconfig.build.json',
340
- 'start': 'node ./dist/serve.js',
341
- 'test': 'jest',
342
- 'test:watch': 'jest --watch',
343
- 'test:cov': 'jest --coverage',
344
- 'test:e2e': 'jest --config ./test/e2e-spec.json',
345
- },
346
- keywords: ['avleon', 'nodejs', 'typescript'],
347
- license: 'ISC',
348
- dependencies: deps,
349
- devDependencies: devDeps,
350
- jest: {
351
- preset: 'ts-jest',
352
- rootDir: 'src',
353
- testRegex: '.*.spec.ts$',
354
- collectCoverageFrom: ['**/*.(t|j)s'],
355
- coverageDirectory: '../coverage',
356
- testEnvironment: 'node',
357
- },
358
- }, null, 2);
359
- }
360
- function tsconfigTemplate() {
361
- return JSON.stringify({
362
- compilerOptions: {
363
- target: 'ES2017',
364
- module: 'CommonJS',
365
- moduleResolution: 'node',
366
- experimentalDecorators: true,
367
- emitDecoratorMetadata: true,
368
- outDir: './dist',
369
- esModuleInterop: true,
370
- allowSyntheticDefaultImports: true,
371
- forceConsistentCasingInFileNames: true,
372
- skipLibCheck: true,
373
- strict: false,
374
- },
375
- include: ['src/**/*'],
376
- exclude: ['node_modules', 'dist'],
377
- }, null, 2);
378
- }
379
- function tsconfigBuildTemplate() {
380
- return JSON.stringify({
381
- extends: './tsconfig.json',
382
- exclude: ['node_modules', 'coverage', 'test', 'dist', '**/*spec.ts'],
383
- }, null, 2);
384
- }
385
- function e2eConfigTemplate() {
386
- return JSON.stringify({
387
- moduleFileExtensions: ['js', 'json', 'ts'],
388
- rootDir: '.',
389
- testEnvironment: 'node',
390
- testRegex: '.e2e-spec.ts$',
391
- transform: { '^.+\\.(t|j)s$': 'ts-jest' },
392
- }, null, 2);
393
- }
394
- function gitignoreTemplate() {
395
- return `node_modules/\ndist/\n.env\n.env.local\ncoverage/\n`;
396
- }
397
- function envTemplate() {
398
- return `NODE_ENV=development\nPORT=4000\n`;
399
- }
400
- function readmeTemplate(fname, pm) {
401
- const runCmd = pm === 'npm' ? 'npm run start:dev' : `${pm} start:dev`;
402
- return `# ${(0, lodash_1.capitalize)(fname)}
403
-
404
- Built with [Avleon](https://github.com/xtareq/avleon).
405
-
406
- ## Getting Started
407
-
408
- \`\`\`bash
409
- ${runCmd}
410
- \`\`\`
411
-
412
- ## Scripts
413
-
414
- | Script | Description |
415
- |--------|-------------|
416
- | \`start:dev\` | Start development server with hot reload |
417
- | \`build\` | Compile TypeScript to JavaScript |
418
- | \`start\` | Start production server |
419
- | \`test\` | Run unit tests |
420
-
421
- ## Project Structure
422
-
423
- \`\`\`
424
- src/
425
- ├── controllers/ # Route controllers
426
- ├── services/ # Business logic
427
- ├── config/ # App configuration
428
- ├── app.ts # App setup
429
- └── serve.ts # Entry point
430
- \`\`\`
431
- `;
432
- }
433
- // ─── Main ─────────────────────────────────────────────────────────────────────
434
- async function createApplication(fname, flags = {}) {
435
- const appPaths = (0, paths_1.appPaths)(fname);
436
- banner(fname);
437
- // ── Prompts ───────────────────────────────────────────────────────────────
438
- const pm = await askForPackageManager();
439
- const features = await askForFeatures();
440
- const useScalar = features.includes('scalar');
441
- // ── Directories ───────────────────────────────────────────────────────────
442
- section('Scaffolding project structure');
443
- const dirs = [
444
- appPaths.root + '/src',
445
- appPaths.root + '/src/controllers',
446
- appPaths.root + '/src/config',
447
- appPaths.root + '/src/services',
448
- appPaths.root + '/test',
449
- appPaths.root + '/public',
450
- ];
451
- for (const dir of dirs) {
452
- await fs_extra_1.default.ensureDir(dir);
453
- step('Created directory', path_1.default.relative(process.cwd(), dir));
454
- }
455
- // ── Source files ──────────────────────────────────────────────────────────
456
- section('Generating source files');
457
- await writeFile(path_1.default.join(appPaths.services, 'home.service.ts'), await fmt(homeServiceTemplate()), 'HomeService');
458
- await writeFile(path_1.default.join(appPaths.controllers, 'home.controller.ts'), await fmt(homeControllerTemplate()), 'HomeController');
459
- await writeFile(path_1.default.join(appPaths.controllers, 'home.controller.spec.ts'), await fmt(homeControllerTestTemplate()), 'HomeController spec');
460
- if (features.includes('openapi')) {
461
- await writeFile(path_1.default.join(appPaths.configs, 'openapi.config.ts'), await fmt(openApiConfigTemplate(fname, useScalar)), 'OpenApiConfig');
462
- }
463
- await writeFile(path_1.default.join(appPaths.src, 'app.ts'), await fmt(appTemplate(features)), 'app.ts');
464
- await writeFile(path_1.default.join(appPaths.src, 'serve.ts'), await fmt(serveTemplate()), 'serve.ts');
465
- // ── Config files ──────────────────────────────────────────────────────────
466
- section('Generating config files');
467
- await writeFile(path_1.default.join(appPaths.root, 'package.json'), await fmt(packageJsonTemplate(fname, features), 'json'), 'package.json');
468
- await writeFile(path_1.default.join(appPaths.root, 'tsconfig.json'), await fmt(tsconfigTemplate(), 'json'), 'tsconfig.json');
469
- await writeFile(path_1.default.join(appPaths.root, 'tsconfig.build.json'), await fmt(tsconfigBuildTemplate(), 'json'), 'tsconfig.build.json');
470
- await writeFile(path_1.default.join(appPaths.root, 'test/e2e-spec.json'), await fmt(e2eConfigTemplate(), 'json'), 'e2e-spec.json');
471
- await writeFile(path_1.default.join(appPaths.root, '.gitignore'), gitignoreTemplate(), '.gitignore');
472
- await writeFile(path_1.default.join(appPaths.root, '.env'), envTemplate(), '.env');
473
- await writeFile(path_1.default.join(appPaths.root, 'README.md'), readmeTemplate(fname, pm), 'README.md');
474
- // ── Install ───────────────────────────────────────────────────────────────
475
- section('Installing dependencies');
476
- try {
477
- await installDependencies(pm, appPaths.root);
478
- success('Dependencies installed');
479
- }
480
- catch (error) {
481
- fail(`Installation failed: ${error instanceof Error ? error.message : error}`);
482
- console.log(`\n ${C.yellow}Install manually:${C.reset}`);
483
- console.log(` ${C.dim}cd ${fname} && ${pm} install${C.reset}\n`);
484
- }
485
- // ── Done ──────────────────────────────────────────────────────────────────
486
- const runCmd = pm === 'npm' ? 'npm run start:dev' : `${pm} start:dev`;
487
- console.log();
488
- console.log(`${C.bold}${C.green} ✔ Project created successfully!${C.reset}`);
489
- console.log();
490
- console.log(` ${C.dim}Next steps:${C.reset}`);
491
- console.log(` ${C.cyan} cd ${fname}${C.reset}`);
492
- console.log(` ${C.cyan} ${runCmd}${C.reset}`);
493
- if (features.includes('openapi')) {
494
- console.log();
495
- console.log(` ${C.dim}API docs:${C.reset} ${C.white}http://localhost:4000/docs${C.reset}`);
496
- }
497
- console.log();
498
- }
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fh = void 0;
4
- exports.getLastPart = getLastPart;
5
- exports.getFilePathWithoutName = getFilePathWithoutName;
6
- exports.resolveNames = resolveNames;
7
- const filenameFromPath = (fpath) => fpath.split('/')[fpath.split('/').length - 1];
8
- function getLastPart(str, separator) {
9
- if (!str.includes(separator))
10
- return str;
11
- const parts = str.split(separator);
12
- return parts.at(-1);
13
- }
14
- function getFilePathWithoutName(fpath) {
15
- const parts = fpath.split("/");
16
- if (parts.length < 2) {
17
- return "";
18
- }
19
- parts.splice(parts.length - 1, 1);
20
- return parts.join("/");
21
- }
22
- function resolveNames(name, exclude) {
23
- const parsedName = name.replace(exclude, '');
24
- return {
25
- className: parsedName.charAt(0).toUpperCase() + name.slice(1),
26
- fileName: parsedName.toLowerCase(),
27
- varName: parsedName.toLowerCase(),
28
- };
29
- }
30
- exports.fh = { filenameFromPath };
@@ -1,21 +0,0 @@
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.pathHelper = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- // export const __filename = fileURLToPath(process.argv[1])
9
- // export const __dirname = path.dirname(__filename)
10
- /* */
11
- exports.pathHelper = {
12
- appSoucePath(p) {
13
- return path_1.default.join(process.cwd(), p ? './src/' + p : './src/');
14
- },
15
- appTestPath(p) {
16
- return path_1.default.join(process.cwd(), p ? './test/' + p : './test/');
17
- },
18
- stubPath(p) {
19
- return path_1.default.join(__dirname, p ? '../../stubs/' + p : '../../stubs/');
20
- },
21
- };
package/dist/paths.js DELETED
@@ -1,32 +0,0 @@
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.appPaths = exports.appPathsMinimal = void 0;
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const appPathsMinimal = (rootPath) => {
9
- const root = rootPath ? rootPath : node_path_1.default.join(process.cwd(), "./");
10
- return {
11
- root: root,
12
- src: node_path_1.default.join(root, "src"),
13
- public: node_path_1.default.join(root, "public"),
14
- test: node_path_1.default.join(root, "test"),
15
- };
16
- };
17
- exports.appPathsMinimal = appPathsMinimal;
18
- const appPaths = (rootPath) => {
19
- const root = rootPath ? rootPath : node_path_1.default.join(process.cwd(), "./");
20
- return {
21
- root: root,
22
- src: node_path_1.default.join(root, "src"),
23
- public: node_path_1.default.join(root, "public"),
24
- test: node_path_1.default.join(root, "test"),
25
- controllers: node_path_1.default.join(root, "src/controllers"),
26
- models: node_path_1.default.join(root, "src/models"),
27
- services: node_path_1.default.join(root, "src/services"),
28
- dtos: node_path_1.default.join(root, "src/dtos"),
29
- configs: node_path_1.default.join(root, "src/config")
30
- };
31
- };
32
- exports.appPaths = appPaths;