@galaxy-stack/orbit-cli 0.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.
- package/README.md +145 -0
- package/dist/commands/build.d.ts +6 -0
- package/dist/commands/dev.d.ts +13 -0
- package/dist/commands/generate.d.ts +9 -0
- package/dist/commands/migrate/index.d.ts +2 -0
- package/dist/commands/migrate/templates.d.ts +40 -0
- package/dist/commands/migrate/transformers.d.ts +13 -0
- package/dist/commands/new.d.ts +5 -0
- package/dist/commands/test.d.ts +6 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6097 -0
- package/dist/templates/index.d.ts +34 -0
- package/dist/utils/ast-utils.d.ts +6 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# orbit
|
|
2
|
+
|
|
3
|
+
## Mô tả
|
|
4
|
+
CLI tool cho Orbit framework để scaffolding projects và generate components.
|
|
5
|
+
|
|
6
|
+
## Cài đặt
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
bun add -g orbit
|
|
10
|
+
# hoặc
|
|
11
|
+
npx orbit
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Commands
|
|
15
|
+
|
|
16
|
+
### 1. Tạo Project mới
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
orbit new my-app
|
|
20
|
+
orbit new my-app --template api
|
|
21
|
+
orbit new my-app --template graphql
|
|
22
|
+
orbit new my-app --template microservice
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### 2. Generate Components
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
# Controller
|
|
29
|
+
orbit generate controller user
|
|
30
|
+
orbit g co user
|
|
31
|
+
|
|
32
|
+
# Service
|
|
33
|
+
orbit generate service user
|
|
34
|
+
orbit g s user
|
|
35
|
+
|
|
36
|
+
# Module
|
|
37
|
+
orbit generate module user
|
|
38
|
+
orbit g mo user
|
|
39
|
+
|
|
40
|
+
# Guard
|
|
41
|
+
orbit generate guard auth
|
|
42
|
+
orbit g gu auth
|
|
43
|
+
|
|
44
|
+
# Pipe
|
|
45
|
+
orbit generate pipe validation
|
|
46
|
+
orbit g pi validation
|
|
47
|
+
|
|
48
|
+
# Interceptor
|
|
49
|
+
orbit generate interceptor logging
|
|
50
|
+
orbit g in logging
|
|
51
|
+
|
|
52
|
+
# Middleware
|
|
53
|
+
orbit generate middleware cors
|
|
54
|
+
orbit g mi cors
|
|
55
|
+
|
|
56
|
+
# Filter
|
|
57
|
+
orbit generate filter http-exception
|
|
58
|
+
orbit g f http-exception
|
|
59
|
+
|
|
60
|
+
# Resource (CRUD)
|
|
61
|
+
orbit generate resource user
|
|
62
|
+
orbit g res user
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### 3. Development Server
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
orbit dev
|
|
69
|
+
orbit dev --port 3000
|
|
70
|
+
orbit dev --watch
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### 4. Build
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
orbit build
|
|
77
|
+
orbit build --minify
|
|
78
|
+
orbit build --target bun
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 5. Test
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
orbit test
|
|
85
|
+
orbit test --watch
|
|
86
|
+
orbit test --coverage
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Auto-import
|
|
90
|
+
|
|
91
|
+
CLI tự động update module imports khi generate:
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
// Trước
|
|
95
|
+
@Module({
|
|
96
|
+
controllers: [],
|
|
97
|
+
providers: [],
|
|
98
|
+
})
|
|
99
|
+
class AppModule {}
|
|
100
|
+
|
|
101
|
+
// Sau generate controller user
|
|
102
|
+
@Module({
|
|
103
|
+
controllers: [UserController], // Auto-imported
|
|
104
|
+
providers: [],
|
|
105
|
+
})
|
|
106
|
+
class AppModule {}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Project Structure
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
my-app/
|
|
113
|
+
├── src/
|
|
114
|
+
│ ├── main.ts
|
|
115
|
+
│ ├── app.module.ts
|
|
116
|
+
│ ├── app.controller.ts
|
|
117
|
+
│ ├── app.service.ts
|
|
118
|
+
│ └── users/
|
|
119
|
+
│ ├── users.module.ts
|
|
120
|
+
│ ├── users.controller.ts
|
|
121
|
+
│ ├── users.service.ts
|
|
122
|
+
│ └── dto/
|
|
123
|
+
│ └── create-user.dto.ts
|
|
124
|
+
├── test/
|
|
125
|
+
│ └── app.e2e-spec.ts
|
|
126
|
+
├── package.json
|
|
127
|
+
├── tsconfig.json
|
|
128
|
+
└── bunfig.toml
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Options
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Generate với spec file
|
|
135
|
+
orbit g co user --spec
|
|
136
|
+
|
|
137
|
+
# Generate không có spec
|
|
138
|
+
orbit g co user --no-spec
|
|
139
|
+
|
|
140
|
+
# Dry run (không tạo file)
|
|
141
|
+
orbit g co user --dry-run
|
|
142
|
+
|
|
143
|
+
# Flat structure (không tạo folder)
|
|
144
|
+
orbit g co user --flat
|
|
145
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Transpiler } from 'bun';
|
|
2
|
+
export interface DevOptions {
|
|
3
|
+
port?: string;
|
|
4
|
+
entry?: string;
|
|
5
|
+
transpile?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const transpiler: Transpiler;
|
|
8
|
+
declare function transpileFile(filePath: string): Promise<{
|
|
9
|
+
code: string;
|
|
10
|
+
time: number;
|
|
11
|
+
} | null>;
|
|
12
|
+
export declare function devCommand(options: DevOptions): Promise<void>;
|
|
13
|
+
export { transpiler, transpileFile };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface GenerateOptions {
|
|
2
|
+
path?: string;
|
|
3
|
+
flat?: boolean;
|
|
4
|
+
spec?: boolean;
|
|
5
|
+
dryRun?: boolean;
|
|
6
|
+
skipImport?: boolean;
|
|
7
|
+
module?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function generateCommand(schematic: string, name: string, options: GenerateOptions): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const mainTsTemplate = "import 'reflect-metadata';\nimport { BunFactory } from '@galaxy-stack/orbit-core';\nimport { AppModule } from './app.module';\n\nasync function bootstrap() {\n const app = await BunFactory.create(AppModule);\n \n // Enable CORS if needed\n // app.use(new CorsMiddleware());\n \n // Global prefix\n // app.setGlobalPrefix('api');\n \n const port = process.env.PORT || 3000;\n await app.listen(port);\n \n console.log(`\uD83D\uDE80 Server running at http://localhost:${port}`);\n}\n\nbootstrap();\n";
|
|
2
|
+
export declare const appModuleTemplate = "import { Module } from '@galaxy-stack/orbit-core';\nimport { ConfigModule } from '@galaxy-stack/orbit-config';\nimport { AppController } from './app.controller';\nimport { AppService } from './app.service';\n\n@Module({\n imports: [\n ConfigModule.forRoot({\n isGlobal: true,\n }),\n ],\n controllers: [AppController],\n providers: [AppService],\n})\nexport class AppModule {}\n";
|
|
3
|
+
export declare const packageJsonUpdates: {
|
|
4
|
+
dependencies: {
|
|
5
|
+
'@galaxy-stack/orbit-core': string;
|
|
6
|
+
'@galaxy-stack/orbit-common': string;
|
|
7
|
+
'@galaxy-stack/orbit-config': string;
|
|
8
|
+
'reflect-metadata': string;
|
|
9
|
+
};
|
|
10
|
+
devDependencies: {
|
|
11
|
+
'@galaxy-stack/orbit-testing': string;
|
|
12
|
+
orbit: string;
|
|
13
|
+
'@types/bun': string;
|
|
14
|
+
};
|
|
15
|
+
scripts: {
|
|
16
|
+
dev: string;
|
|
17
|
+
build: string;
|
|
18
|
+
start: string;
|
|
19
|
+
test: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare const tsconfigUpdates: {
|
|
23
|
+
compilerOptions: {
|
|
24
|
+
target: string;
|
|
25
|
+
module: string;
|
|
26
|
+
moduleResolution: string;
|
|
27
|
+
experimentalDecorators: boolean;
|
|
28
|
+
emitDecoratorMetadata: boolean;
|
|
29
|
+
strict: boolean;
|
|
30
|
+
skipLibCheck: boolean;
|
|
31
|
+
esModuleInterop: boolean;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare function generateMigrationGuide(analysis: {
|
|
35
|
+
hasTypeOrm: boolean;
|
|
36
|
+
hasMongoose: boolean;
|
|
37
|
+
hasPassport: boolean;
|
|
38
|
+
hasBcrypt: boolean;
|
|
39
|
+
hasClassValidator: boolean;
|
|
40
|
+
}): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface TransformResult {
|
|
2
|
+
code: string;
|
|
3
|
+
changes: string[];
|
|
4
|
+
warnings: string[];
|
|
5
|
+
}
|
|
6
|
+
export declare function transformImports(code: string): TransformResult;
|
|
7
|
+
export declare function transformFactoryMethods(code: string): TransformResult;
|
|
8
|
+
export declare function transformPlatformAdapters(code: string): TransformResult;
|
|
9
|
+
export declare function transformTypeOrmToDb(code: string): TransformResult;
|
|
10
|
+
export declare function transformPassportToAuth(code: string): TransformResult;
|
|
11
|
+
export declare function transformBcryptToBun(code: string): TransformResult;
|
|
12
|
+
export declare function transformClassValidator(code: string): TransformResult;
|
|
13
|
+
export declare function transformAll(code: string): TransformResult;
|
package/dist/index.d.ts
ADDED