@strav/cli 0.4.30 → 1.0.0-alpha.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/package.json +17 -41
- package/src/binder.ts +88 -0
- package/src/command.ts +297 -0
- package/src/config_list.ts +42 -0
- package/src/config_show.ts +50 -0
- package/src/console_provider.ts +46 -0
- package/src/exit_codes.ts +26 -0
- package/src/index.ts +60 -2
- package/src/key_generate.ts +66 -0
- package/src/make/index.ts +17 -0
- package/src/make/make_command_file.ts +27 -0
- package/src/make/make_controller.ts +24 -0
- package/src/make/make_factory.ts +25 -0
- package/src/make/make_job.ts +25 -0
- package/src/make/make_mail.ts +27 -0
- package/src/make/make_middleware.ts +23 -0
- package/src/make/make_migration.ts +48 -0
- package/src/make/make_model.ts +91 -0
- package/src/make/make_notification.ts +23 -0
- package/src/make/make_policy.ts +24 -0
- package/src/make/make_provider.ts +29 -0
- package/src/make/make_repository.ts +30 -0
- package/src/make/make_request.ts +24 -0
- package/src/make/make_seeder.ts +23 -0
- package/src/make/make_test.ts +22 -0
- package/src/make_command.ts +69 -0
- package/src/run_cli.ts +121 -0
- package/src/scaffold_console_provider.ts +45 -0
- package/src/signature.ts +171 -0
- package/src/subset_boot.ts +51 -0
- package/src/util_console_provider.ts +18 -0
- package/src/cli/bootstrap.ts +0 -77
- package/src/cli/command_loader.ts +0 -180
- package/src/cli/index.ts +0 -3
- package/src/cli/strav.ts +0 -13
- package/src/commands/db_seed.ts +0 -77
- package/src/commands/db_setup_roles.ts +0 -101
- package/src/commands/generate_api.ts +0 -93
- package/src/commands/generate_key.ts +0 -47
- package/src/commands/generate_models.ts +0 -49
- package/src/commands/generate_seeder.ts +0 -68
- package/src/commands/migration_compare.ts +0 -167
- package/src/commands/migration_fresh.ts +0 -148
- package/src/commands/migration_generate.ts +0 -84
- package/src/commands/migration_rollback.ts +0 -54
- package/src/commands/migration_run.ts +0 -45
- package/src/commands/package_install.ts +0 -161
- package/src/commands/queue_flush.ts +0 -35
- package/src/commands/queue_retry.ts +0 -34
- package/src/commands/queue_work.ts +0 -101
- package/src/commands/scheduler_work.ts +0 -46
- package/src/commands/tenant_create.ts +0 -35
- package/src/commands/tenant_delete.ts +0 -64
- package/src/commands/tenant_list.ts +0 -39
- package/src/config/loader.ts +0 -50
- package/src/generators/api_generator.ts +0 -1035
- package/src/generators/config.ts +0 -113
- package/src/generators/doc_generator.ts +0 -996
- package/src/generators/index.ts +0 -11
- package/src/generators/model_generator.ts +0 -596
- package/src/generators/route_generator.ts +0 -187
- package/src/generators/test_generator.ts +0 -1667
- package/tsconfig.json +0 -5
package/src/generators/config.ts
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs'
|
|
2
|
-
import { resolve, relative } from 'node:path'
|
|
3
|
-
import type { GeneratedFile } from './model_generator.ts'
|
|
4
|
-
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Types
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
|
|
9
|
-
export interface GeneratorPaths {
|
|
10
|
-
models: string
|
|
11
|
-
enums: string
|
|
12
|
-
controllers: string
|
|
13
|
-
services: string
|
|
14
|
-
events: string
|
|
15
|
-
validators: string
|
|
16
|
-
policies: string
|
|
17
|
-
resources: string
|
|
18
|
-
routes: string
|
|
19
|
-
tests: string
|
|
20
|
-
docs: string
|
|
21
|
-
// Database paths
|
|
22
|
-
schemas: string
|
|
23
|
-
migrations: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface GeneratorConfig {
|
|
27
|
-
paths?: Partial<GeneratorPaths>
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ---------------------------------------------------------------------------
|
|
31
|
-
// Defaults
|
|
32
|
-
// ---------------------------------------------------------------------------
|
|
33
|
-
|
|
34
|
-
const DEFAULT_PATHS: GeneratorPaths = {
|
|
35
|
-
models: 'app/models',
|
|
36
|
-
enums: 'app/enums',
|
|
37
|
-
controllers: 'app/http/controllers',
|
|
38
|
-
services: 'app/services',
|
|
39
|
-
events: 'app/events',
|
|
40
|
-
validators: 'app/validators',
|
|
41
|
-
policies: 'app/policies',
|
|
42
|
-
resources: 'app/resources',
|
|
43
|
-
routes: 'start',
|
|
44
|
-
tests: 'tests/api',
|
|
45
|
-
docs: 'public/_docs',
|
|
46
|
-
schemas: 'database/schemas',
|
|
47
|
-
migrations: 'database/migrations',
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// ---------------------------------------------------------------------------
|
|
51
|
-
// Helpers
|
|
52
|
-
// ---------------------------------------------------------------------------
|
|
53
|
-
|
|
54
|
-
/** Merge user config with defaults, returning fully resolved paths. */
|
|
55
|
-
export function resolvePaths(config?: GeneratorConfig): GeneratorPaths {
|
|
56
|
-
return config?.paths ? { ...DEFAULT_PATHS, ...config.paths } : { ...DEFAULT_PATHS }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Compute a relative import path from a file inside `fromDir` to a file
|
|
61
|
-
* inside `toDir`. Returns a path suitable for ES import statements
|
|
62
|
-
* (e.g. `'../../services'`, `'../enums'`).
|
|
63
|
-
*/
|
|
64
|
-
export function relativeImport(fromDir: string, toDir: string): string {
|
|
65
|
-
let rel = relative(fromDir, toDir)
|
|
66
|
-
rel = rel.split('\\').join('/')
|
|
67
|
-
return rel.startsWith('.') ? rel : './' + rel
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface WriteResult {
|
|
71
|
-
written: GeneratedFile[]
|
|
72
|
-
skipped: GeneratedFile[]
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Format generated files with Prettier and write them to disk.
|
|
77
|
-
* Falls back to writing unformatted content if Prettier is not installed.
|
|
78
|
-
*
|
|
79
|
-
* Skips files that already exist unless `force` is true. Returns the
|
|
80
|
-
* partition of written and skipped files so callers can report them.
|
|
81
|
-
*/
|
|
82
|
-
export async function formatAndWrite(
|
|
83
|
-
files: GeneratedFile[],
|
|
84
|
-
options: { force?: boolean } = {}
|
|
85
|
-
): Promise<WriteResult> {
|
|
86
|
-
let prettier: typeof import('prettier') | null = null
|
|
87
|
-
try {
|
|
88
|
-
prettier = await import('prettier')
|
|
89
|
-
} catch {
|
|
90
|
-
// Prettier not installed — write unformatted
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const written: GeneratedFile[] = []
|
|
94
|
-
const skipped: GeneratedFile[] = []
|
|
95
|
-
|
|
96
|
-
for (const file of files) {
|
|
97
|
-
if (existsSync(file.path) && !options.force) {
|
|
98
|
-
skipped.push(file)
|
|
99
|
-
continue
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let content = file.content
|
|
103
|
-
if (prettier) {
|
|
104
|
-
const filePath = resolve(file.path)
|
|
105
|
-
const prettierOpts = await prettier.resolveConfig(filePath)
|
|
106
|
-
content = await prettier.format(content, { ...prettierOpts, filepath: filePath })
|
|
107
|
-
}
|
|
108
|
-
await Bun.write(file.path, content)
|
|
109
|
-
written.push(file)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return { written, skipped }
|
|
113
|
-
}
|