@xeno-js/cli 0.1.2 → 0.1.4
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.
- package/LICENSE +18 -12
- package/README.md +461 -236
- package/dist/index.js +1018 -688
- package/dist/index.js.map +1 -1
- package/package.json +91 -66
- package/.github/.copilot-instruction.md +0 -73
- package/.github/agents/git-operator.agent.md +0 -86
- package/.github/agents/unit-tester.agent.md +0 -68
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.husky/pre-push +0 -1
- package/.prettierignore +0 -7
- package/.prettierrc.json +0 -37
- package/commitlint.config.cjs +0 -39
- package/eslint.config.mjs +0 -306
- package/lint-staged.config.mjs +0 -5
- package/logo/logo.png +0 -0
- package/src/domain/contracts/icommand-cli.contracts.ts +0 -13
- package/src/domain/contracts/icommand-runner.contracts.ts +0 -3
- package/src/domain/contracts/idispatch.contracts.ts +0 -3
- package/src/domain/contracts/ifile-service.contracts.ts +0 -3
- package/src/domain/contracts/igenerator.contracts.ts +0 -5
- package/src/domain/contracts/index.ts +0 -6
- package/src/domain/contracts/iscaffold-strategy.contracts.ts +0 -7
- package/src/domain/index.ts +0 -1
- package/src/index.ts +0 -30
- package/src/infrastructure/bootstrap/bootstrapper.ts +0 -30
- package/src/infrastructure/bootstrap/index.ts +0 -1
- package/src/infrastructure/builder/builder.test.ts +0 -36
- package/src/infrastructure/builder/builder.ts +0 -15
- package/src/infrastructure/builder/index.ts +0 -1
- package/src/infrastructure/command_launcher/command.utils.ts +0 -31
- package/src/infrastructure/command_launcher/index.ts +0 -0
- package/src/infrastructure/commands/command-runner.service.ts +0 -36
- package/src/infrastructure/commands/generate.command.ts +0 -55
- package/src/infrastructure/commands/help.command.ts +0 -63
- package/src/infrastructure/commands/index.ts +0 -4
- package/src/infrastructure/commands/new-project.command.ts +0 -47
- package/src/infrastructure/dispatcher/dispatcher.ts +0 -45
- package/src/infrastructure/dispatcher/index.ts +0 -1
- package/src/infrastructure/file/file.service.ts +0 -14
- package/src/infrastructure/file/index.ts +0 -1
- package/src/infrastructure/generators/core/bootstrap.generator.ts +0 -118
- package/src/infrastructure/generators/core/command/cqrs.generator.ts +0 -63
- package/src/infrastructure/generators/core/command/generate-command.generator.ts +0 -191
- package/src/infrastructure/generators/core/command/generate-query.generator.ts +0 -150
- package/src/infrastructure/generators/core/drizzle-sql-lite.generator.ts +0 -76
- package/src/infrastructure/generators/core/drizzle.generator.ts +0 -86
- package/src/infrastructure/generators/core/env.generator.ts +0 -69
- package/src/infrastructure/generators/core/index.ts +0 -9
- package/src/infrastructure/generators/core/main.generator.ts +0 -41
- package/src/infrastructure/generators/core/packagejson.generator.ts +0 -70
- package/src/infrastructure/generators/core/readme.generator.ts +0 -427
- package/src/infrastructure/generators/core/registry.generator.ts +0 -40
- package/src/infrastructure/generators/core/tsconfig.generator.ts +0 -39
- package/src/infrastructure/generators/gitignore.generator.ts +0 -60
- package/src/infrastructure/generators/vue/app-vue.generator.ts +0 -21
- package/src/infrastructure/generators/vue/bootstrap-ts.generator.ts +0 -60
- package/src/infrastructure/generators/vue/command_query/cqrs.generator.ts +0 -36
- package/src/infrastructure/generators/vue/command_query/generate-command-vue.generator.ts +0 -153
- package/src/infrastructure/generators/vue/command_query/generate-query-vue.generator.ts +0 -161
- package/src/infrastructure/generators/vue/env.generator.ts +0 -39
- package/src/infrastructure/generators/vue/index-html.generator.ts +0 -24
- package/src/infrastructure/generators/vue/index.ts +0 -12
- package/src/infrastructure/generators/vue/main.generator.ts +0 -41
- package/src/infrastructure/generators/vue/packagejson.generator.ts +0 -50
- package/src/infrastructure/generators/vue/readme.generator.ts +0 -389
- package/src/infrastructure/generators/vue/registry-ts.generator.ts +0 -26
- package/src/infrastructure/generators/vue/router.generator.ts +0 -35
- package/src/infrastructure/generators/vue/tailwind.generator.ts +0 -17
- package/src/infrastructure/generators/vue/tsconfig.generator.ts +0 -38
- package/src/infrastructure/generators/vue/use-app.generator.ts +0 -38
- package/src/infrastructure/generators/vue/vite-config.generator.ts +0 -35
- package/src/infrastructure/index.ts +0 -5
- package/src/infrastructure/strategies/core-scaffold.strategy.ts +0 -100
- package/src/infrastructure/strategies/index.ts +0 -2
- package/src/infrastructure/strategies/vue-scaffold.strategy.ts +0 -79
- package/src/shared/constants/command.constants.ts +0 -18
- package/src/shared/constants/core.constants.ts +0 -7
- package/src/shared/constants/index.ts +0 -2
- package/src/shared/index.ts +0 -3
- package/src/shared/types/common.types.ts +0 -68
- package/src/shared/types/index.ts +0 -1
- package/src/shared/utils/guards.utils.ts +0 -334
- package/src/shared/utils/index.ts +0 -2
- package/src/shared/utils/string.utils.ts +0 -60
- package/tsconfig.json +0 -15
- package/tsup.config.ts +0 -13
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type { IFileService } from '../../../../domain'
|
|
4
|
-
|
|
5
|
-
export class GenerateQueryCoreGenerator {
|
|
6
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
7
|
-
|
|
8
|
-
public async generate(
|
|
9
|
-
pascalName: string,
|
|
10
|
-
lowerName: string,
|
|
11
|
-
tokenPrefix: string,
|
|
12
|
-
componentDir: string,
|
|
13
|
-
hasZod: boolean,
|
|
14
|
-
): Promise<void> {
|
|
15
|
-
const queryContent = `import { BaseQuery } from '@xeno-js/core';
|
|
16
|
-
|
|
17
|
-
/*
|
|
18
|
-
* ⚠️ WARNING: ACTION REQUIRED ⚠️
|
|
19
|
-
* Please replace <any> with your specific payload and response types.
|
|
20
|
-
*/
|
|
21
|
-
export class ${pascalName}Query extends BaseQuery<any> {
|
|
22
|
-
constructor(public readonly payload: any) {
|
|
23
|
-
super(
|
|
24
|
-
'${tokenPrefix}_QUERY_HANDLER',
|
|
25
|
-
// Default cache options:
|
|
26
|
-
{
|
|
27
|
-
ttl: 60,
|
|
28
|
-
cacheKey: \`${lowerName}:\${JSON.stringify(payload)}\`,
|
|
29
|
-
bypassCache: false,
|
|
30
|
-
consistentRead: false
|
|
31
|
-
isUserScoped: false,
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
`
|
|
37
|
-
await this._fileService.writeFileRecursive(
|
|
38
|
-
path.join(componentDir, `${lowerName}.query.ts`),
|
|
39
|
-
queryContent,
|
|
40
|
-
)
|
|
41
|
-
|
|
42
|
-
// 2. Handler
|
|
43
|
-
const handlerContent = `import type { IFactory, ResultType, UserContext } from '@xeno-js/core';
|
|
44
|
-
import { AppError, BaseHandler, Result } from '@xeno-js/core';
|
|
45
|
-
import { ${pascalName}Query } from './${lowerName}.query';
|
|
46
|
-
|
|
47
|
-
/*
|
|
48
|
-
* ⚠️ WARNING: ACTION REQUIRED ⚠️
|
|
49
|
-
* Please replace <any> with your specific response type.
|
|
50
|
-
*/
|
|
51
|
-
export class ${pascalName}Handler extends BaseHandler<${pascalName}Query, any> {
|
|
52
|
-
constructor(
|
|
53
|
-
identityFactory: IFactory<void, UserContext>
|
|
54
|
-
// TODO: Inject your ReadDao or DataSource here
|
|
55
|
-
) {
|
|
56
|
-
super(identityFactory);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public async executeAsync(request: ${pascalName}Query, singal: AbortSignal): Promise<ResultType<any>> {
|
|
60
|
-
// TODO: Implement your query logic here
|
|
61
|
-
|
|
62
|
-
return Result.ok();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
`
|
|
66
|
-
await this._fileService.writeFileRecursive(
|
|
67
|
-
path.join(componentDir, `${lowerName}.handler.ts`),
|
|
68
|
-
handlerContent,
|
|
69
|
-
)
|
|
70
|
-
|
|
71
|
-
// 3. Controller
|
|
72
|
-
const controllerContent = `import type { IContextAccessor, IMediator, RequestContext, ResponseDto } from '@xeno-js/core';
|
|
73
|
-
import { BaseController } from '@xeno-js/core';
|
|
74
|
-
import { ${pascalName}Query } from './${lowerName}.query';
|
|
75
|
-
|
|
76
|
-
/*
|
|
77
|
-
* ⚠️ WARNING: ACTION REQUIRED ⚠️
|
|
78
|
-
* Please replace <any, any> with your specific request and response types.
|
|
79
|
-
*/
|
|
80
|
-
export class ${pascalName}Controller extends BaseController<any, any> {
|
|
81
|
-
constructor(
|
|
82
|
-
requestContext: IContextAccessor<RequestContext>,
|
|
83
|
-
mediator: IMediator,
|
|
84
|
-
) {
|
|
85
|
-
super(requestContext, mediator);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
public async handle(request: any): Promise<ResponseDto<any>> {
|
|
89
|
-
const query = new ${pascalName}Query(request);
|
|
90
|
-
const result = await this._query(query);
|
|
91
|
-
|
|
92
|
-
if (!result.isOk()) {
|
|
93
|
-
return this.fail(result.getErrorOrThrow(), 'Error during ${pascalName} operation');
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return this.ok(result.getValueOrThrow());
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
`
|
|
100
|
-
await this._fileService.writeFileRecursive(
|
|
101
|
-
path.join(componentDir, `${lowerName}.controller.ts`),
|
|
102
|
-
controllerContent,
|
|
103
|
-
)
|
|
104
|
-
|
|
105
|
-
// 4. Schema Zod
|
|
106
|
-
if (hasZod) {
|
|
107
|
-
const zodContent = `import { z } from 'zod';
|
|
108
|
-
import { ZodUtils } from '@xeno-js/core';
|
|
109
|
-
|
|
110
|
-
/*
|
|
111
|
-
* ⚠️ WARNING: ACTION REQUIRED ⚠️
|
|
112
|
-
* Define the actual Zod validation schema for your query payload.
|
|
113
|
-
*/
|
|
114
|
-
export const ${pascalName}Schema = ZodUtils.createQuerySchema({
|
|
115
|
-
payload: z.any() // TODO: Update with strict validation
|
|
116
|
-
});
|
|
117
|
-
`
|
|
118
|
-
await this._fileService.writeFileRecursive(
|
|
119
|
-
path.join(componentDir, `${lowerName}.schema-zod.ts`),
|
|
120
|
-
zodContent,
|
|
121
|
-
)
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// 5. Module
|
|
125
|
-
const moduleContent = `import type { IServiceContainer, IConfigurationService } from '@xeno-js/core';
|
|
126
|
-
import { TOKENS } from '@xeno-js/core';
|
|
127
|
-
import { ${pascalName}Controller } from './${lowerName}.controller';
|
|
128
|
-
import { ${pascalName}Handler } from './${lowerName}.handler';
|
|
129
|
-
|
|
130
|
-
export const ${pascalName}Module = Object.freeze({
|
|
131
|
-
register(opts: IServiceContainer<any>, _config: IConfigurationService): void {
|
|
132
|
-
opts.addTransient('${tokenPrefix}_QUERY_CONTROLLER', (c) => new ${pascalName}Controller(c.resolve(TOKENS.REQUEST_CONTEXT), c.resolve(TOKENS.MEDIATOR)));
|
|
133
|
-
opts.addScoped('${tokenPrefix}_QUERY_HANDLER', (c) => new ${pascalName}Handler(c.resolve(TOKENS.USER_CONTEXT_FACTORY)));
|
|
134
|
-
|
|
135
|
-
/*
|
|
136
|
-
* ⚠️ WARNING: ACTION REQUIRED ⚠️
|
|
137
|
-
* Please copy and paste the following tokens to your MyRegistry interface (usually in src/registry.ts):
|
|
138
|
-
*
|
|
139
|
-
* ${tokenPrefix}_QUERY_CONTROLLER: IController<any, any>;
|
|
140
|
-
* ${tokenPrefix}_QUERY_HANDLER: IHandler<${pascalName}Query, any>;
|
|
141
|
-
*/
|
|
142
|
-
}
|
|
143
|
-
} as const);
|
|
144
|
-
`
|
|
145
|
-
await this._fileService.writeFileRecursive(
|
|
146
|
-
path.join(componentDir, `${lowerName}.module.ts`),
|
|
147
|
-
moduleContent,
|
|
148
|
-
)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type { IFileService, IGenerator } from '../../../domain'
|
|
4
|
-
import { type CoreOptions } from '../../../shared'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @class DrizzleSqlLiteGenerator
|
|
8
|
-
* @description Generates a Drizzle configuration file (drizzle.config.ts) and a
|
|
9
|
-
* SQLite schema example (src/infrastructure/db/sqlite-schema.ts) when the user
|
|
10
|
-
* opts to use SQLite/libSQL instead of Postgres.
|
|
11
|
-
*/
|
|
12
|
-
export class DrizzleSqlLiteGenerator implements IGenerator<CoreOptions> {
|
|
13
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
14
|
-
|
|
15
|
-
async generate(projectPath: string, _options: CoreOptions): Promise<void> {
|
|
16
|
-
const configContent = this.composeDrizzleConfig()
|
|
17
|
-
const filePath = path.join(projectPath, 'drizzle.config.ts')
|
|
18
|
-
await this._fileService.writeFileRecursive(filePath, configContent)
|
|
19
|
-
|
|
20
|
-
const schemaPath = path.join(projectPath, 'src', 'schema.ts')
|
|
21
|
-
const schemaContent = this.composeSchema()
|
|
22
|
-
await this._fileService.writeFileRecursive(schemaPath, schemaContent)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private composeDrizzleConfig(): string {
|
|
26
|
-
return `import 'dotenv/config';
|
|
27
|
-
import { defineConfig } from 'drizzle-kit';
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Drizzle Kit configuration for SQLite / libSQL.
|
|
31
|
-
* Uses environment variable SQLITE_DATABASE_URL to locate the database.
|
|
32
|
-
*/
|
|
33
|
-
export default defineConfig({
|
|
34
|
-
schema: './src/schema.ts',
|
|
35
|
-
out: './drizzle',
|
|
36
|
-
dialect: 'sqlite',
|
|
37
|
-
dbCredentials: {
|
|
38
|
-
url: process.env.SQLITE_DATABASE_URL!,
|
|
39
|
-
},
|
|
40
|
-
verbose: true,
|
|
41
|
-
strict: true,
|
|
42
|
-
});
|
|
43
|
-
`
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
private composeSchema(): string {
|
|
47
|
-
return `import { sqliteTable, integer, text } from 'drizzle-orm/sqlite-core';
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Example SQLite schema using Drizzle's libsql primitives.
|
|
51
|
-
* Place your application tables here (this file is scaffolded by the CLI when
|
|
52
|
-
* the user opts into SQLite support).
|
|
53
|
-
*/
|
|
54
|
-
export const usersTable = sqliteTable('users', {
|
|
55
|
-
id: integer('id').primaryKey().notNull(),
|
|
56
|
-
name: text('name').notNull(),
|
|
57
|
-
description: text('description'),
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Types inferred from the schema.
|
|
62
|
-
* - UserDto: Represents the shape of the data retrieved from the database ($inferSelect).
|
|
63
|
-
* - NewUserDto: Represents the shape of the data required to insert a new record ($inferInsert).
|
|
64
|
-
*/
|
|
65
|
-
export type UserDto = typeof usersTable.$inferSelect;
|
|
66
|
-
export type NewUserDto = typeof usersTable.$inferInsert;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Centralized Database Schema dictionary.
|
|
70
|
-
*/
|
|
71
|
-
export type SqliteSchema = {
|
|
72
|
-
users: typeof usersTable;
|
|
73
|
-
};
|
|
74
|
-
`
|
|
75
|
-
}
|
|
76
|
-
}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type { IFileService, IGenerator } from '../../../domain'
|
|
4
|
-
import { type CoreOptions } from '../../../shared'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @class DrizzleGenerator
|
|
8
|
-
* @description Generates the Drizzle configuration file (drizzle.config.ts) and a basic schema file (src/schema.ts) for database scaffolding.
|
|
9
|
-
* The generator is only invoked if the user has opted to include database support in their project.
|
|
10
|
-
*
|
|
11
|
-
* @author Xeno
|
|
12
|
-
* @version 1.0.0
|
|
13
|
-
* @license ISC
|
|
14
|
-
* @since 2025-09-30
|
|
15
|
-
* @link https://github.com/xeno-js/xeno-js
|
|
16
|
-
*/
|
|
17
|
-
export class DrizzleGenerator implements IGenerator<CoreOptions> {
|
|
18
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
19
|
-
|
|
20
|
-
async generate(projectPath: string, _options: CoreOptions): Promise<void> {
|
|
21
|
-
const configContent = this.composeDrizzleConfig()
|
|
22
|
-
const filePath = path.join(projectPath, 'drizzle.config.ts')
|
|
23
|
-
await this._fileService.writeFileRecursive(filePath, configContent)
|
|
24
|
-
|
|
25
|
-
const schemaContent = this.composeSchema()
|
|
26
|
-
await this._fileService.writeFileRecursive(
|
|
27
|
-
path.join(projectPath, 'src', 'schema.ts'),
|
|
28
|
-
schemaContent,
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
private composeDrizzleConfig(): string {
|
|
33
|
-
return `import 'dotenv/config';
|
|
34
|
-
import { defineConfig } from 'drizzle-kit';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Drizzle Kit configuration file.
|
|
38
|
-
* Defines the schema location, migration output directory, and database connection.
|
|
39
|
-
*/
|
|
40
|
-
export default defineConfig({
|
|
41
|
-
schema: './src/schema.ts',
|
|
42
|
-
out: './drizzle',
|
|
43
|
-
dialect: 'postgresql',
|
|
44
|
-
dbCredentials: {
|
|
45
|
-
url: process.env.DATABASE_URL!,
|
|
46
|
-
},
|
|
47
|
-
verbose: true,
|
|
48
|
-
strict: true,
|
|
49
|
-
});
|
|
50
|
-
`
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
private composeSchema(): string {
|
|
54
|
-
return `import { boolean, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* @description Define your database tables here.
|
|
58
|
-
* The 'usersTable' serves as a baseline example.
|
|
59
|
-
* You can add more tables, relations, and indexes according to your domain requirements.
|
|
60
|
-
*/
|
|
61
|
-
export const usersTable = pgTable('users', {
|
|
62
|
-
id: serial('id').primaryKey(),
|
|
63
|
-
name: text('name').notNull(),
|
|
64
|
-
email: text('email').notNull().unique(),
|
|
65
|
-
isDeleted: boolean('is_deleted').notNull().default(false),
|
|
66
|
-
deletedAt: timestamp('deleted_at'),
|
|
67
|
-
createdAt: timestamp('created_at').defaultNow(),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Types inferred from the schema.
|
|
72
|
-
* - UserDto: Represents the shape of the data retrieved from the database ($inferSelect).
|
|
73
|
-
* - NewUserDto: Represents the shape of the data required to insert a new record ($inferInsert).
|
|
74
|
-
*/
|
|
75
|
-
export type UserDto = typeof usersTable.$inferSelect;
|
|
76
|
-
export type NewUserDto = typeof usersTable.$inferInsert;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Centralized Database Schema dictionary.
|
|
80
|
-
*/
|
|
81
|
-
export type DbSchema = {
|
|
82
|
-
users: typeof usersTable;
|
|
83
|
-
};
|
|
84
|
-
`
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import { type IFileService, type IGenerator } from '../../../domain'
|
|
4
|
-
import { CORE_CONSTANTS, type CoreOptions } from '../../../shared'
|
|
5
|
-
|
|
6
|
-
export class EnvGenerator implements IGenerator<CoreOptions> {
|
|
7
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
8
|
-
|
|
9
|
-
public async generate(projectPath: string, options: CoreOptions): Promise<void> {
|
|
10
|
-
let content = `# ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
-
# Xeno APPLICATION ENVIRONMENT VARIABLES
|
|
12
|
-
# ─────────────────────────────────────────────────────────────────────────────
|
|
13
|
-
NODE_ENV=development
|
|
14
|
-
`
|
|
15
|
-
|
|
16
|
-
// Configurazione Database
|
|
17
|
-
if (options.database !== CORE_CONSTANTS.NONE) {
|
|
18
|
-
if (options.database === CORE_CONSTANTS.DRIZZLE) {
|
|
19
|
-
content += `\n# --- Database (PostgreSQL) ---
|
|
20
|
-
DATABASE_URL=postgres://postgres:password@localhost:5432/xeno_db
|
|
21
|
-
`
|
|
22
|
-
} else if (options.database === CORE_CONSTANTS.SQL_LITE) {
|
|
23
|
-
content += `\n# --- Database (SQLite) ---
|
|
24
|
-
SQLITE_DATABASE_URL=file:./dev.sqlite
|
|
25
|
-
`
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (options.axios) {
|
|
30
|
-
content += `\n# --- Axios ---
|
|
31
|
-
BASE_URL=
|
|
32
|
-
`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Configurazione Redis (Caching, Idempotenza, Concorrenza)
|
|
36
|
-
if (options.redis) {
|
|
37
|
-
content += `\n# --- Cache (Redis) ---
|
|
38
|
-
REDIS_HOST=localhost
|
|
39
|
-
REDIS_PORT=6379
|
|
40
|
-
REDIS_PASSWORD=
|
|
41
|
-
REDIS_USERNAME=
|
|
42
|
-
REDIS_TLS=false
|
|
43
|
-
`
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Configurazione Supabase (Autenticazione)
|
|
47
|
-
if (options.supabase) {
|
|
48
|
-
content += `\n# --- Authentication (Supabase) ---
|
|
49
|
-
SUPABASE_URL=https://your-project.supabase.co
|
|
50
|
-
SUPABASE_KEY=your-anon-key
|
|
51
|
-
`
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Configurazione Logging & Observability
|
|
55
|
-
if (options.sentry) {
|
|
56
|
-
content += `\n# --- Error Tracking (Sentry) ---
|
|
57
|
-
SENTRY_DSN=https://your-sentry-dsn@o0.ingest.sentry.io/0
|
|
58
|
-
SENTRY_ENVIRONMENT=development
|
|
59
|
-
`
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Creiamo sia il file effettivo che il file di esempio
|
|
63
|
-
const envPath = path.join(projectPath, '.env')
|
|
64
|
-
const envExamplePath = path.join(projectPath, '.env.example')
|
|
65
|
-
|
|
66
|
-
await this._fileService.writeFileRecursive(envPath, content)
|
|
67
|
-
await this._fileService.writeFileRecursive(envExamplePath, content)
|
|
68
|
-
}
|
|
69
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from './bootstrap.generator'
|
|
2
|
-
export * from './drizzle.generator'
|
|
3
|
-
export * from './drizzle-sql-lite.generator'
|
|
4
|
-
export * from './env.generator'
|
|
5
|
-
export * from './main.generator'
|
|
6
|
-
export * from './packagejson.generator'
|
|
7
|
-
export * from './readme.generator'
|
|
8
|
-
export * from './registry.generator'
|
|
9
|
-
export * from './tsconfig.generator'
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type { IFileService, IGenerator } from '../../../domain'
|
|
4
|
-
import { type CoreOptions } from '../../../shared'
|
|
5
|
-
|
|
6
|
-
export class MainGenerator implements IGenerator<CoreOptions> {
|
|
7
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
8
|
-
|
|
9
|
-
public async generate(projectPath: string, options: CoreOptions): Promise<void> {
|
|
10
|
-
const content = `import 'dotenv/config';
|
|
11
|
-
import { bootstrap } from './bootstrap';
|
|
12
|
-
import { TOKENS } from '@xeno-js/core';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Main Application Entry Point
|
|
16
|
-
*/
|
|
17
|
-
async function main() {
|
|
18
|
-
try {
|
|
19
|
-
console.info('⏳ Bootstrapping ${options.targetDir} application...');
|
|
20
|
-
|
|
21
|
-
// Initialize the dependency injection container and infrastructure modules
|
|
22
|
-
const container = await bootstrap();
|
|
23
|
-
|
|
24
|
-
const logger = container.resolve(TOKENS.LOGGER)
|
|
25
|
-
logger.info('✅ Application started successfully!');
|
|
26
|
-
|
|
27
|
-
// TODO: Implement your logic here
|
|
28
|
-
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error('❌ Critical error during startup:', error);
|
|
31
|
-
process.exit(1);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
main();
|
|
36
|
-
`
|
|
37
|
-
|
|
38
|
-
const filePath = path.join(projectPath, 'src', 'main.ts')
|
|
39
|
-
await this._fileService.writeFileRecursive(filePath, content)
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import path from 'node:path'
|
|
2
|
-
|
|
3
|
-
import type { IFileService, IGenerator } from '../../../domain'
|
|
4
|
-
import { CORE_CONSTANTS, type CoreOptions } from '../../../shared'
|
|
5
|
-
|
|
6
|
-
export class PackageJsonCoreGenerator implements IGenerator<CoreOptions> {
|
|
7
|
-
constructor(private readonly _fileService: IFileService) {}
|
|
8
|
-
|
|
9
|
-
public async generate(projectPath: string, options: CoreOptions): Promise<void> {
|
|
10
|
-
const packageJson = {
|
|
11
|
-
name: options.targetDir,
|
|
12
|
-
version: '1.0.0',
|
|
13
|
-
private: true,
|
|
14
|
-
main: './dist/index.js',
|
|
15
|
-
module: './dist/index.js',
|
|
16
|
-
types: './dist/index.d.ts',
|
|
17
|
-
scripts: {
|
|
18
|
-
start: 'tsx src/main.ts',
|
|
19
|
-
build: 'tsc --project tsconfig.json',
|
|
20
|
-
g: 'xeno-js generate',
|
|
21
|
-
} as Record<string, string>,
|
|
22
|
-
dependencies: {
|
|
23
|
-
'@xeno-js/core': 'latest',
|
|
24
|
-
'dotenv': '^16.4.5',
|
|
25
|
-
} as Record<string, string>,
|
|
26
|
-
devDependencies: {
|
|
27
|
-
'@types/node': '^20.0.0',
|
|
28
|
-
'tsx': '^4.7.0',
|
|
29
|
-
'typescript': '^5.4.0',
|
|
30
|
-
} as Record<string, string>,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Database & ORM
|
|
34
|
-
if (options.database !== CORE_CONSTANTS.NONE) {
|
|
35
|
-
if (options.database === CORE_CONSTANTS.DRIZZLE) {
|
|
36
|
-
packageJson.dependencies['drizzle-orm'] = '^0.45.2'
|
|
37
|
-
packageJson.dependencies['pg'] = '^8.22.0'
|
|
38
|
-
packageJson.dependencies['postgres'] = '^3.4.9'
|
|
39
|
-
packageJson.devDependencies['@types/pg'] = '^8.11.0'
|
|
40
|
-
packageJson.devDependencies['drizzle-kit'] = '^0.31.10'
|
|
41
|
-
packageJson.scripts['db:migrate'] = 'drizzle-kit migrate'
|
|
42
|
-
} else if (options.database === CORE_CONSTANTS.SQL_LITE) {
|
|
43
|
-
packageJson.dependencies['drizzle-orm'] = '^0.45.2'
|
|
44
|
-
packageJson.dependencies['@libsql/client'] = '^0.14.0'
|
|
45
|
-
packageJson.devDependencies['drizzle-kit'] = '^0.31.10'
|
|
46
|
-
}
|
|
47
|
-
packageJson.scripts['db:generate'] = 'drizzle-kit generate'
|
|
48
|
-
packageJson.scripts['db:push'] = 'drizzle-kit push'
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// HTTP / External Calls
|
|
52
|
-
if (options.axios) packageJson.dependencies['axios'] = '^1.16.1'
|
|
53
|
-
if (options.cockatiel) packageJson.dependencies['cockatiel'] = '^4.0.0'
|
|
54
|
-
|
|
55
|
-
// Logging & Observability
|
|
56
|
-
if (options.pino) {
|
|
57
|
-
packageJson.dependencies['pino'] = '^10.3.1'
|
|
58
|
-
packageJson.devDependencies['pino-pretty'] = '^11.2.2'
|
|
59
|
-
}
|
|
60
|
-
if (options.sentry) packageJson.dependencies['@sentry/node'] = '^7.64.0'
|
|
61
|
-
|
|
62
|
-
// Services
|
|
63
|
-
if (options.redis) packageJson.dependencies['ioredis'] = '^5.3.1'
|
|
64
|
-
if (options.supabase) packageJson.dependencies['@supabase/supabase-js'] = '^2.35.0'
|
|
65
|
-
if (options.zod) packageJson.dependencies['zod'] = '^4.4.3'
|
|
66
|
-
|
|
67
|
-
const filePath = path.join(projectPath, 'package.json')
|
|
68
|
-
await this._fileService.writeFileRecursive(filePath, JSON.stringify(packageJson, null, 2))
|
|
69
|
-
}
|
|
70
|
-
}
|