nucleus-core-ts 0.9.992 → 0.9.993

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/bin/cli.ts CHANGED
@@ -1,131 +1,131 @@
1
- #!/usr/bin/env bun
2
-
3
- /**
4
- * Nucleus CLI — the single front door to nucleus-core-ts.
5
- *
6
- * nucleus init scaffold a new project (interactive)
7
- * nucleus dev … run locally (up | down | run)
8
- * nucleus add … extend an existing project (entity | feature | oauth)
9
- * nucleus validate validate config.json against the schema
10
- * nucleus doctor check the local environment (bun, postgres, redis, …)
11
- * nucleus generate generate the Drizzle schema from config.json
12
- */
13
-
14
- import { spawn } from 'node:child_process'
15
- import { dirname, join } from 'node:path'
16
- import { fileURLToPath } from 'node:url'
17
- import { banner, c, log } from './lib/ui'
18
- import { doctorCommand } from './lib/commands/doctor'
19
- import { validateCommand } from './lib/commands/validate'
20
- import { initCommand } from './lib/commands/init'
21
- import { devCommand } from './lib/commands/dev'
22
- import { addCommand } from './lib/commands/add'
23
-
24
- const here = dirname(fileURLToPath(import.meta.url))
25
- const rootDir = join(here, '..')
26
-
27
- const argv = process.argv.slice(2)
28
- const firstArg = argv[0] ?? ''
29
- const looksLikeFile = firstArg.endsWith('.json') || firstArg.startsWith('./') || firstArg.startsWith('/')
30
- const command = looksLikeFile ? 'generate' : firstArg
31
-
32
- async function pkgVersion(): Promise<string> {
33
- try {
34
- return (JSON.parse(await Bun.file(join(rootDir, 'package.json')).text()) as { version: string }).version
35
- } catch {
36
- return '?'
37
- }
38
- }
39
-
40
- function showHelp(version: string) {
41
- banner(`Nucleus CLI v${version}`, 'nucleus-core-ts — config-driven backend framework')
42
- log(`
43
- ${c.bold('Usage')} ${c.cyan('nucleus')} ${c.dim('<command> [options]')}
44
-
45
- ${c.bold('Create & evolve')}
46
- ${c.cyan('init')} ${c.dim('[--preset <p>] [-o <dir>] [-y]')} build a config + scaffold a runnable backend (zero-to-running)
47
- ${c.cyan('add')} ${c.dim('entity | feature <n> | oauth <p>')} extend this project's config in place (+ regenerate)
48
- ${c.cyan('scaffold')} full-project scaffold (backend+frontend+k8s+pipelines) from a config.json
49
- ${c.cyan('generate')} ${c.dim('<config.json> <outDir>')} generate the Drizzle schema + relations from config
50
- ${c.cyan('validate')} ${c.dim('[config.json]')} validate a config against the JSON-Schema + cross-field rules
51
-
52
- ${c.bold('Local dev')}
53
- ${c.cyan('dev')} ${c.dim('[up | down]')} run the app; ${c.dim('up')} starts Postgres+Redis, ${c.dim('down')} stops them
54
- ${c.cyan('doctor')} check the local environment can run a Nucleus project
55
-
56
- ${c.bold('Maintenance')}
57
- ${c.cyan('audit:purge-noise')} ${c.dim('[--execute]')} delete historical low-signal audit_logs rows (dry-run by default)
58
- ${c.cyan('help')}${c.dim(', ')}${c.cyan('--version')} this help / the installed version
59
-
60
- ${c.dim('init = preset → runnable backend · scaffold (= new) = full project · Aliases: generate = gen, validate = check')}
61
- `)
62
- }
63
-
64
- function runScript(scriptRelPath: string, args: string[]): Promise<never> {
65
- return new Promise<never>(() => {
66
- const proc = spawn('bun', ['run', join(rootDir, scriptRelPath), ...args], { cwd: process.cwd(), stdio: 'inherit' })
67
- proc.on('close', (code) => process.exit(code ?? 1))
68
- })
69
- }
70
-
71
- switch (command) {
72
- case 'init':
73
- process.exit(await initCommand(argv.slice(1)))
74
- break
75
-
76
- case 'dev':
77
- process.exit(await devCommand(argv.slice(1)))
78
- break
79
-
80
- case 'add':
81
- process.exit(await addCommand(argv.slice(1)))
82
- break
83
-
84
- case 'scaffold':
85
- case 'new': {
86
- // Full-project scaffold (backend + frontend + k8s + pipelines) from an
87
- // existing config.json. `init` is the leaner, config-building local-dev path.
88
- const { scaffold } = await import(join(rootDir, 'infra', 'scripts', 'generate-project.ts'))
89
- await scaffold(join(rootDir, 'infra'))
90
- break
91
- }
92
-
93
- case 'generate':
94
- case 'gen': {
95
- const genArgs = looksLikeFile ? argv : argv.slice(1)
96
- await runScript(join('scripts', 'generate-schema.ts'), genArgs)
97
- break
98
- }
99
-
100
- case 'validate':
101
- case 'check':
102
- process.exit(await validateCommand(argv.slice(1)))
103
- break
104
-
105
- case 'doctor':
106
- process.exit(await doctorCommand())
107
- break
108
-
109
- case 'audit:purge-noise':
110
- case 'audit-purge-noise':
111
- await runScript(join('scripts', 'audit-purge-noise.ts'), argv.slice(1))
112
- break
113
-
114
- case '--version':
115
- case '-v':
116
- log(await pkgVersion())
117
- break
118
-
119
- case 'help':
120
- case '--help':
121
- case '-h':
122
- case '':
123
- case undefined:
124
- showHelp(await pkgVersion())
125
- break
126
-
127
- default:
128
- log(`${c.red('Unknown command:')} ${command}\n`)
129
- showHelp(await pkgVersion())
130
- process.exit(1)
131
- }
1
+ #!/usr/bin/env bun
2
+
3
+ /**
4
+ * Nucleus CLI — the single front door to nucleus-core-ts.
5
+ *
6
+ * nucleus init scaffold a new project (interactive)
7
+ * nucleus dev … run locally (up | down | run)
8
+ * nucleus add … extend an existing project (entity | feature | oauth)
9
+ * nucleus validate validate config.json against the schema
10
+ * nucleus doctor check the local environment (bun, postgres, redis, …)
11
+ * nucleus generate generate the Drizzle schema from config.json
12
+ */
13
+
14
+ import { spawn } from 'node:child_process'
15
+ import { dirname, join } from 'node:path'
16
+ import { fileURLToPath } from 'node:url'
17
+ import { banner, c, log } from './lib/ui'
18
+ import { doctorCommand } from './lib/commands/doctor'
19
+ import { validateCommand } from './lib/commands/validate'
20
+ import { initCommand } from './lib/commands/init'
21
+ import { devCommand } from './lib/commands/dev'
22
+ import { addCommand } from './lib/commands/add'
23
+
24
+ const here = dirname(fileURLToPath(import.meta.url))
25
+ const rootDir = join(here, '..')
26
+
27
+ const argv = process.argv.slice(2)
28
+ const firstArg = argv[0] ?? ''
29
+ const looksLikeFile = firstArg.endsWith('.json') || firstArg.startsWith('./') || firstArg.startsWith('/')
30
+ const command = looksLikeFile ? 'generate' : firstArg
31
+
32
+ async function pkgVersion(): Promise<string> {
33
+ try {
34
+ return (JSON.parse(await Bun.file(join(rootDir, 'package.json')).text()) as { version: string }).version
35
+ } catch {
36
+ return '?'
37
+ }
38
+ }
39
+
40
+ function showHelp(version: string) {
41
+ banner(`Nucleus CLI v${version}`, 'nucleus-core-ts — config-driven backend framework')
42
+ log(`
43
+ ${c.bold('Usage')} ${c.cyan('nucleus')} ${c.dim('<command> [options]')}
44
+
45
+ ${c.bold('Create & evolve')}
46
+ ${c.cyan('init')} ${c.dim('[--preset <p>] [-o <dir>] [-y]')} build a config + scaffold a runnable backend (zero-to-running)
47
+ ${c.cyan('add')} ${c.dim('entity | feature <n> | oauth <p>')} extend this project's config in place (+ regenerate)
48
+ ${c.cyan('scaffold')} full-project scaffold (backend+frontend+k8s+pipelines) from a config.json
49
+ ${c.cyan('generate')} ${c.dim('<config.json> <outDir>')} generate the Drizzle schema + relations from config
50
+ ${c.cyan('validate')} ${c.dim('[config.json]')} validate a config against the JSON-Schema + cross-field rules
51
+
52
+ ${c.bold('Local dev')}
53
+ ${c.cyan('dev')} ${c.dim('[up | down]')} run the app; ${c.dim('up')} starts Postgres+Redis, ${c.dim('down')} stops them
54
+ ${c.cyan('doctor')} check the local environment can run a Nucleus project
55
+
56
+ ${c.bold('Maintenance')}
57
+ ${c.cyan('audit:purge-noise')} ${c.dim('[--execute]')} delete historical low-signal audit_logs rows (dry-run by default)
58
+ ${c.cyan('help')}${c.dim(', ')}${c.cyan('--version')} this help / the installed version
59
+
60
+ ${c.dim('init = preset → runnable backend · scaffold (= new) = full project · Aliases: generate = gen, validate = check')}
61
+ `)
62
+ }
63
+
64
+ function runScript(scriptRelPath: string, args: string[]): Promise<never> {
65
+ return new Promise<never>(() => {
66
+ const proc = spawn('bun', ['run', join(rootDir, scriptRelPath), ...args], { cwd: process.cwd(), stdio: 'inherit' })
67
+ proc.on('close', (code) => process.exit(code ?? 1))
68
+ })
69
+ }
70
+
71
+ switch (command) {
72
+ case 'init':
73
+ process.exit(await initCommand(argv.slice(1)))
74
+ break
75
+
76
+ case 'dev':
77
+ process.exit(await devCommand(argv.slice(1)))
78
+ break
79
+
80
+ case 'add':
81
+ process.exit(await addCommand(argv.slice(1)))
82
+ break
83
+
84
+ case 'scaffold':
85
+ case 'new': {
86
+ // Full-project scaffold (backend + frontend + k8s + pipelines) from an
87
+ // existing config.json. `init` is the leaner, config-building local-dev path.
88
+ const { scaffold } = await import(join(rootDir, 'infra', 'scripts', 'generate-project.ts'))
89
+ await scaffold(join(rootDir, 'infra'))
90
+ break
91
+ }
92
+
93
+ case 'generate':
94
+ case 'gen': {
95
+ const genArgs = looksLikeFile ? argv : argv.slice(1)
96
+ await runScript(join('scripts', 'generate-schema.ts'), genArgs)
97
+ break
98
+ }
99
+
100
+ case 'validate':
101
+ case 'check':
102
+ process.exit(await validateCommand(argv.slice(1)))
103
+ break
104
+
105
+ case 'doctor':
106
+ process.exit(await doctorCommand())
107
+ break
108
+
109
+ case 'audit:purge-noise':
110
+ case 'audit-purge-noise':
111
+ await runScript(join('scripts', 'audit-purge-noise.ts'), argv.slice(1))
112
+ break
113
+
114
+ case '--version':
115
+ case '-v':
116
+ log(await pkgVersion())
117
+ break
118
+
119
+ case 'help':
120
+ case '--help':
121
+ case '-h':
122
+ case '':
123
+ case undefined:
124
+ showHelp(await pkgVersion())
125
+ break
126
+
127
+ default:
128
+ log(`${c.red('Unknown command:')} ${command}\n`)
129
+ showHelp(await pkgVersion())
130
+ process.exit(1)
131
+ }
package/dist/.build-ok CHANGED
@@ -1 +1 @@
1
- 0.9.992
1
+ 0.9.993