@rudderjs/cli 4.3.0 → 4.5.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/dist/commands/add.d.ts +42 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +475 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/doctor.d.ts +12 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +83 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/remove.d.ts +24 -0
- package/dist/commands/remove.d.ts.map +1 -0
- package/dist/commands/remove.js +170 -0
- package/dist/commands/remove.js.map +1 -0
- package/dist/doctor/boot-status.d.ts +10 -0
- package/dist/doctor/boot-status.d.ts.map +1 -0
- package/dist/doctor/boot-status.js +15 -0
- package/dist/doctor/boot-status.js.map +1 -0
- package/dist/doctor/built-in/_fs.d.ts +11 -0
- package/dist/doctor/built-in/_fs.d.ts.map +1 -0
- package/dist/doctor/built-in/_fs.js +53 -0
- package/dist/doctor/built-in/_fs.js.map +1 -0
- package/dist/doctor/built-in/deps.d.ts +2 -0
- package/dist/doctor/built-in/deps.d.ts.map +1 -0
- package/dist/doctor/built-in/deps.js +81 -0
- package/dist/doctor/built-in/deps.js.map +1 -0
- package/dist/doctor/built-in/env-vars.d.ts +2 -0
- package/dist/doctor/built-in/env-vars.d.ts.map +1 -0
- package/dist/doctor/built-in/env-vars.js +99 -0
- package/dist/doctor/built-in/env-vars.js.map +1 -0
- package/dist/doctor/built-in/index.d.ts +13 -0
- package/dist/doctor/built-in/index.d.ts.map +1 -0
- package/dist/doctor/built-in/index.js +18 -0
- package/dist/doctor/built-in/index.js.map +1 -0
- package/dist/doctor/built-in/node-version.d.ts +2 -0
- package/dist/doctor/built-in/node-version.d.ts.map +1 -0
- package/dist/doctor/built-in/node-version.js +72 -0
- package/dist/doctor/built-in/node-version.js.map +1 -0
- package/dist/doctor/built-in/package-manager.d.ts +2 -0
- package/dist/doctor/built-in/package-manager.d.ts.map +1 -0
- package/dist/doctor/built-in/package-manager.js +55 -0
- package/dist/doctor/built-in/package-manager.js.map +1 -0
- package/dist/doctor/built-in/runtime.d.ts +2 -0
- package/dist/doctor/built-in/runtime.d.ts.map +1 -0
- package/dist/doctor/built-in/runtime.js +82 -0
- package/dist/doctor/built-in/runtime.js.map +1 -0
- package/dist/doctor/built-in/structure.d.ts +2 -0
- package/dist/doctor/built-in/structure.d.ts.map +1 -0
- package/dist/doctor/built-in/structure.js +93 -0
- package/dist/doctor/built-in/structure.js.map +1 -0
- package/dist/doctor/fixer.d.ts +39 -0
- package/dist/doctor/fixer.d.ts.map +1 -0
- package/dist/doctor/fixer.js +80 -0
- package/dist/doctor/fixer.js.map +1 -0
- package/dist/doctor/load-package-checks.d.ts +2 -0
- package/dist/doctor/load-package-checks.d.ts.map +1 -0
- package/dist/doctor/load-package-checks.js +53 -0
- package/dist/doctor/load-package-checks.js.map +1 -0
- package/dist/doctor/orchestrator.d.ts +34 -0
- package/dist/doctor/orchestrator.d.ts.map +1 -0
- package/dist/doctor/orchestrator.js +65 -0
- package/dist/doctor/orchestrator.js.map +1 -0
- package/dist/doctor/reporter.d.ts +21 -0
- package/dist/doctor/reporter.d.ts.map +1 -0
- package/dist/doctor/reporter.js +151 -0
- package/dist/doctor/reporter.js.map +1 -0
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Command } from 'commander';
|
|
2
|
+
type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
|
|
3
|
+
/** Detect PM from npm_config_user_agent (set by every modern PM). Falls back to pnpm. */
|
|
4
|
+
declare function detectPackageManager(): PackageManager;
|
|
5
|
+
type PackageSpec = {
|
|
6
|
+
/** Short name used in `rudder add <name>`. */
|
|
7
|
+
alias: string;
|
|
8
|
+
/** Full npm package name. */
|
|
9
|
+
npmName: string;
|
|
10
|
+
/** Generates the config file body. Pure — no I/O. */
|
|
11
|
+
config?: {
|
|
12
|
+
key: string;
|
|
13
|
+
template: (ctx: {
|
|
14
|
+
orm: 'prisma' | 'drizzle' | null;
|
|
15
|
+
}) => string;
|
|
16
|
+
};
|
|
17
|
+
/** Other aliases that must already be installed (or selected in the same `add` run). */
|
|
18
|
+
requires?: string[];
|
|
19
|
+
/** When set, the project must use this ORM. */
|
|
20
|
+
requiresOrm?: 'prisma';
|
|
21
|
+
/** One-line post-install hint printed to the user. */
|
|
22
|
+
hint?: string;
|
|
23
|
+
};
|
|
24
|
+
declare function findSpec(name: string): PackageSpec | null;
|
|
25
|
+
declare function detectOrm(cwd: string): 'prisma' | 'drizzle' | null;
|
|
26
|
+
/**
|
|
27
|
+
* Insert a new `import <key> from './<key>.js'` line + a new entry in the
|
|
28
|
+
* `const configs = { ... }` object. Idempotent — bails cleanly if the key is
|
|
29
|
+
* already present or the file shape is too custom to safely edit.
|
|
30
|
+
*
|
|
31
|
+
* Returns `'ok' | 'already-registered' | 'unrecognized-shape'`.
|
|
32
|
+
*/
|
|
33
|
+
export declare function registerConfigKey(indexPath: string, key: string): 'ok' | 'already-registered' | 'unrecognized-shape';
|
|
34
|
+
export declare function addCommand(program: Command): void;
|
|
35
|
+
export declare const _internal: {
|
|
36
|
+
REGISTRY: readonly PackageSpec[];
|
|
37
|
+
findSpec: typeof findSpec;
|
|
38
|
+
detectOrm: typeof detectOrm;
|
|
39
|
+
detectPackageManager: typeof detectPackageManager;
|
|
40
|
+
};
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=add.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.d.ts","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAIxC,KAAK,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAA;AAErD,yFAAyF;AACzF,iBAAS,oBAAoB,IAAI,cAAc,CAS9C;AAsBD,KAAK,WAAW,GAAG;IACjB,8CAA8C;IAC9C,KAAK,EAAK,MAAM,CAAA;IAChB,6BAA6B;IAC7B,OAAO,EAAG,MAAM,CAAA;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAG;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,CAAC,GAAG,EAAE;YAAE,GAAG,EAAE,QAAQ,GAAG,SAAS,GAAG,IAAI,CAAA;SAAE,KAAK,MAAM,CAAA;KAAE,CAAA;IAC1F,wFAAwF;IACxF,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,QAAQ,CAAA;IACtB,sDAAsD;IACtD,IAAI,CAAC,EAAK,MAAM,CAAA;CACjB,CAAA;AA6CD,iBAAS,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAGlD;AAID,iBAAS,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,GAAG,IAAI,CAQ3D;AAYD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,oBAAoB,GAAG,oBAAoB,CAmCpH;AAcD,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA2FjD;AA6QD,eAAO,MAAM,SAAS;;;;;CAA0D,CAAA"}
|
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
/** Detect PM from npm_config_user_agent (set by every modern PM). Falls back to pnpm. */
|
|
5
|
+
function detectPackageManager() {
|
|
6
|
+
const ua = process.env['npm_config_user_agent'] ?? '';
|
|
7
|
+
if (ua.startsWith('pnpm'))
|
|
8
|
+
return 'pnpm';
|
|
9
|
+
if (ua.startsWith('yarn'))
|
|
10
|
+
return 'yarn';
|
|
11
|
+
if (ua.startsWith('bun'))
|
|
12
|
+
return 'bun';
|
|
13
|
+
if (ua.startsWith('npm'))
|
|
14
|
+
return 'npm';
|
|
15
|
+
// If invoked directly via `node bin/rudder.js`, the env var is absent.
|
|
16
|
+
// pnpm-workspace.yaml is the strongest signal for our monorepo / scaffolded apps.
|
|
17
|
+
return 'pnpm';
|
|
18
|
+
}
|
|
19
|
+
function pmAdd(pm, dep) {
|
|
20
|
+
switch (pm) {
|
|
21
|
+
case 'pnpm': return ['add', dep];
|
|
22
|
+
case 'npm': return ['install', dep];
|
|
23
|
+
case 'yarn': return ['add', dep];
|
|
24
|
+
case 'bun': return ['add', dep];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const REGISTRY = [
|
|
28
|
+
// Auth & Security
|
|
29
|
+
{ alias: 'auth', npmName: '@rudderjs/auth', config: { key: 'auth', template: () => CFG_AUTH } },
|
|
30
|
+
{ alias: 'sanctum', npmName: '@rudderjs/sanctum', config: { key: 'sanctum', template: () => CFG_SANCTUM }, requires: ['auth'] },
|
|
31
|
+
{ alias: 'passport', npmName: '@rudderjs/passport', config: { key: 'passport', template: () => CFG_PASSPORT }, requires: ['auth'], requiresOrm: 'prisma', hint: 'OAuth2 ready: /oauth/authorize, /oauth/token — run `rudder passport:keys` then `rudder passport:client <name>`' },
|
|
32
|
+
{ alias: 'socialite', npmName: '@rudderjs/socialite', config: { key: 'socialite', template: () => CFG_SOCIALITE }, hint: 'Set <PROVIDER>_CLIENT_ID and <PROVIDER>_CLIENT_SECRET in .env (e.g. GITHUB_CLIENT_ID).' },
|
|
33
|
+
{ alias: 'crypt', npmName: '@rudderjs/crypt', config: { key: 'crypt', template: () => CFG_CRYPT }, hint: 'Set APP_KEY in .env (32-byte base64) before encrypting anything.' },
|
|
34
|
+
// Infrastructure
|
|
35
|
+
{ alias: 'queue', npmName: '@rudderjs/queue', config: { key: 'queue', template: () => CFG_QUEUE }, hint: 'Background jobs: `import { Bus } from "@rudderjs/queue"; Bus.dispatch(new MyJob())`.' },
|
|
36
|
+
{ alias: 'storage', npmName: '@rudderjs/storage', config: { key: 'storage', template: () => CFG_STORAGE }, hint: 'File uploads: `import { Storage } from "@rudderjs/storage"; Storage.disk().put(...)`.' },
|
|
37
|
+
{ alias: 'scheduler', npmName: '@rudderjs/schedule', hint: 'Schedule tasks in routes/console.ts via `Schedule.command(...)`.' },
|
|
38
|
+
// Communication
|
|
39
|
+
{ alias: 'mail', npmName: '@rudderjs/mail', config: { key: 'mail', template: () => CFG_MAIL }, hint: 'Default mailer is `log` (writes to stdout). Set MAIL_MAILER=smtp + SMTP_* in .env for real delivery.' },
|
|
40
|
+
{ alias: 'notifications', npmName: '@rudderjs/notification', hint: 'Multi-channel notifications: `rudder make:notification Welcome`.' },
|
|
41
|
+
{ alias: 'broadcast', npmName: '@rudderjs/broadcast', hint: 'Real-time channels: define them in routes/channels.ts.' },
|
|
42
|
+
{ alias: 'sync', npmName: '@rudderjs/sync', config: { key: 'sync', template: ({ orm }) => buildSyncConfig(orm) }, hint: 'Collaborative Yjs docs: WebSocket endpoint at /ws-sync.' },
|
|
43
|
+
// i18n
|
|
44
|
+
{ alias: 'localization', npmName: '@rudderjs/localization', config: { key: 'localization', template: () => CFG_LOCALIZATION }, hint: 'i18n: `import { trans } from "@rudderjs/localization"`.' },
|
|
45
|
+
// Developer experience
|
|
46
|
+
{ alias: 'pennant', npmName: '@rudderjs/pennant', config: { key: 'pennant', template: () => CFG_PENNANT }, hint: 'Feature flags: `import { Feature } from "@rudderjs/pennant"`.' },
|
|
47
|
+
{ alias: 'http', npmName: '@rudderjs/http', hint: 'Fluent fetch client: `import { Http } from "@rudderjs/http"`.' },
|
|
48
|
+
{ alias: 'process', npmName: '@rudderjs/process', hint: 'Shell execution: `import { Process } from "@rudderjs/process"`.' },
|
|
49
|
+
{ alias: 'concurrency', npmName: '@rudderjs/concurrency', hint: 'Worker threads: `import { pool } from "@rudderjs/concurrency"`.' },
|
|
50
|
+
{ alias: 'terminal', npmName: '@rudderjs/terminal', hint: 'Rich terminal UI: `rudder make:terminal <Name>`.' },
|
|
51
|
+
// Media
|
|
52
|
+
{ alias: 'image', npmName: '@rudderjs/image', hint: 'Image processing: `import { Image } from "@rudderjs/image"`.' },
|
|
53
|
+
// Observability
|
|
54
|
+
{ alias: 'telescope', npmName: '@rudderjs/telescope', config: { key: 'telescope', template: () => CFG_TELESCOPE }, hint: 'Telescope dashboard: /telescope (requests, queries, jobs, exceptions).' },
|
|
55
|
+
{ alias: 'pulse', npmName: '@rudderjs/pulse', config: { key: 'pulse', template: () => CFG_PULSE }, hint: 'Pulse dashboard: /pulse (throughput, latency, hit rates).' },
|
|
56
|
+
{ alias: 'horizon', npmName: '@rudderjs/horizon', config: { key: 'horizon', template: () => CFG_HORIZON }, hint: 'Horizon dashboard: /horizon (queue lifecycle, workers).' },
|
|
57
|
+
// AI & tooling
|
|
58
|
+
{ alias: 'ai', npmName: '@rudderjs/ai', config: { key: 'ai', template: () => CFG_AI }, hint: 'AI agents: set ANTHROPIC_API_KEY (or OPENAI_API_KEY / GOOGLE_AI_API_KEY) in .env.' },
|
|
59
|
+
{ alias: 'mcp', npmName: '@rudderjs/mcp', hint: 'Model Context Protocol: `rudder make:mcp-server <Name>`.' },
|
|
60
|
+
{ alias: 'boost', npmName: '@rudderjs/boost', hint: 'AI coding DX: `rudder boost:install` to wire your assistant.' },
|
|
61
|
+
];
|
|
62
|
+
function findSpec(name) {
|
|
63
|
+
const normalized = name.startsWith('@rudderjs/') ? name.slice('@rudderjs/'.length) : name;
|
|
64
|
+
return REGISTRY.find(p => p.alias === normalized) ?? null;
|
|
65
|
+
}
|
|
66
|
+
// ── ORM detection ─────────────────────────────────────────────
|
|
67
|
+
function detectOrm(cwd) {
|
|
68
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
69
|
+
if (!existsSync(pkgPath))
|
|
70
|
+
return null;
|
|
71
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
72
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
73
|
+
if ('@rudderjs/orm-prisma' in deps)
|
|
74
|
+
return 'prisma';
|
|
75
|
+
if ('@rudderjs/orm-drizzle' in deps)
|
|
76
|
+
return 'drizzle';
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function isInstalled(cwd, npmName) {
|
|
80
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
81
|
+
if (!existsSync(pkgPath))
|
|
82
|
+
return false;
|
|
83
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
|
|
84
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
85
|
+
return npmName in deps;
|
|
86
|
+
}
|
|
87
|
+
// ── config/index.ts surgical edit ─────────────────────────────
|
|
88
|
+
/**
|
|
89
|
+
* Insert a new `import <key> from './<key>.js'` line + a new entry in the
|
|
90
|
+
* `const configs = { ... }` object. Idempotent — bails cleanly if the key is
|
|
91
|
+
* already present or the file shape is too custom to safely edit.
|
|
92
|
+
*
|
|
93
|
+
* Returns `'ok' | 'already-registered' | 'unrecognized-shape'`.
|
|
94
|
+
*/
|
|
95
|
+
export function registerConfigKey(indexPath, key) {
|
|
96
|
+
const src = readFileSync(indexPath, 'utf8');
|
|
97
|
+
// Already wired? Check both the import and the configs map.
|
|
98
|
+
if (new RegExp(`from '\\./${key}\\.js'`).test(src))
|
|
99
|
+
return 'already-registered';
|
|
100
|
+
// Find the last `import X from './X.js'` line.
|
|
101
|
+
const importRe = /^import\s+\w+\s+from\s+'\.\/(\w+)\.js'\s*$/gm;
|
|
102
|
+
let lastImportEnd = -1;
|
|
103
|
+
let match;
|
|
104
|
+
while ((match = importRe.exec(src)) !== null)
|
|
105
|
+
lastImportEnd = match.index + match[0].length;
|
|
106
|
+
if (lastImportEnd === -1)
|
|
107
|
+
return 'unrecognized-shape';
|
|
108
|
+
// Find `const configs = { ... }` block.
|
|
109
|
+
const configsRe = /const\s+configs\s*=\s*\{([^}]*)\}/;
|
|
110
|
+
const configsMatch = configsRe.exec(src);
|
|
111
|
+
if (!configsMatch)
|
|
112
|
+
return 'unrecognized-shape';
|
|
113
|
+
// Compose the inserts. Use a uniform import format (no fancy column alignment
|
|
114
|
+
// — we don't try to match the user's spacing — but pad to the visual width of
|
|
115
|
+
// the longest existing import so it still reads cleanly).
|
|
116
|
+
const longestKey = Math.max(...[...src.matchAll(importRe)].map(m => m[1].length));
|
|
117
|
+
const padded = key.padEnd(Math.max(longestKey, key.length));
|
|
118
|
+
const newImport = `\nimport ${padded} from './${key}.js'`;
|
|
119
|
+
const existingKeys = configsMatch[1].trim();
|
|
120
|
+
const newKeys = existingKeys
|
|
121
|
+
? `${existingKeys.replace(/,?\s*$/, '')}, ${key}`
|
|
122
|
+
: key;
|
|
123
|
+
const out = src.slice(0, lastImportEnd) + newImport + src.slice(lastImportEnd, configsMatch.index)
|
|
124
|
+
+ `const configs = { ${newKeys} }` + src.slice(configsMatch.index + configsMatch[0].length);
|
|
125
|
+
writeFileSync(indexPath, out);
|
|
126
|
+
return 'ok';
|
|
127
|
+
}
|
|
128
|
+
// ── Child-process runner ──────────────────────────────────────
|
|
129
|
+
function runChild(cmd, args, cwd) {
|
|
130
|
+
return new Promise((resolve) => {
|
|
131
|
+
const child = spawn(cmd, args, { cwd, stdio: 'inherit', shell: false });
|
|
132
|
+
child.on('close', (code) => resolve(code === 0));
|
|
133
|
+
child.on('error', () => resolve(false));
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
// ── Command ───────────────────────────────────────────────────
|
|
137
|
+
export function addCommand(program) {
|
|
138
|
+
program
|
|
139
|
+
.command('add <package>')
|
|
140
|
+
.description('Install a RudderJS package — handles deps, config, and provider discovery')
|
|
141
|
+
.action(async (packageName) => {
|
|
142
|
+
const cwd = process.cwd();
|
|
143
|
+
const spec = findSpec(packageName);
|
|
144
|
+
if (!spec) {
|
|
145
|
+
const valid = REGISTRY.map(p => p.alias).join(', ');
|
|
146
|
+
console.error(`[rudder add] Unknown package "${packageName}".\n Available: ${valid}`);
|
|
147
|
+
process.exit(1);
|
|
148
|
+
}
|
|
149
|
+
// Idempotency — already installed?
|
|
150
|
+
if (isInstalled(cwd, spec.npmName)) {
|
|
151
|
+
console.log(` ${spec.npmName} is already installed.`);
|
|
152
|
+
if (spec.config && existsSync(path.join(cwd, 'config', `${spec.config.key}.ts`))) {
|
|
153
|
+
console.log(` config/${spec.config.key}.ts exists — nothing to do.`);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
// Package installed but config missing — continue and generate it.
|
|
157
|
+
}
|
|
158
|
+
// ORM requirement
|
|
159
|
+
const orm = detectOrm(cwd);
|
|
160
|
+
if (spec.requiresOrm && orm !== spec.requiresOrm) {
|
|
161
|
+
console.error(`[rudder add] ${spec.alias} requires Prisma. Detected: ${orm ?? 'none'}.`);
|
|
162
|
+
console.error(` Add the ORM first: pnpm add @rudderjs/orm @rudderjs/orm-${spec.requiresOrm}`);
|
|
163
|
+
process.exit(1);
|
|
164
|
+
}
|
|
165
|
+
// Dependency requirements
|
|
166
|
+
if (spec.requires?.length) {
|
|
167
|
+
const pkg = JSON.parse(readFileSync(path.join(cwd, 'package.json'), 'utf8'));
|
|
168
|
+
const deps = pkg.dependencies ?? {};
|
|
169
|
+
for (const req of spec.requires) {
|
|
170
|
+
const reqSpec = REGISTRY.find(p => p.alias === req);
|
|
171
|
+
if (reqSpec && !(reqSpec.npmName in deps)) {
|
|
172
|
+
console.error(`[rudder add] ${spec.alias} requires ${req}. Run \`rudder add ${req}\` first.`);
|
|
173
|
+
process.exit(1);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// 1. Install the dependency
|
|
178
|
+
const pm = detectPackageManager();
|
|
179
|
+
if (!isInstalled(cwd, spec.npmName)) {
|
|
180
|
+
console.log(`\n Adding ${spec.npmName}...`);
|
|
181
|
+
const ok = await runChild(pm, pmAdd(pm, spec.npmName), cwd);
|
|
182
|
+
if (!ok) {
|
|
183
|
+
console.error(`[rudder add] ${pm} ${pmAdd(pm, spec.npmName).join(' ')} failed.`);
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// 2. Generate config file (idempotent — skip if exists)
|
|
188
|
+
if (spec.config) {
|
|
189
|
+
const configDir = path.join(cwd, 'config');
|
|
190
|
+
mkdirSync(configDir, { recursive: true });
|
|
191
|
+
const configFile = path.join(configDir, `${spec.config.key}.ts`);
|
|
192
|
+
if (!existsSync(configFile)) {
|
|
193
|
+
const body = spec.config.template({ orm });
|
|
194
|
+
writeFileSync(configFile, body);
|
|
195
|
+
console.log(` Generated config/${spec.config.key}.ts`);
|
|
196
|
+
}
|
|
197
|
+
// 3. Wire into config/index.ts
|
|
198
|
+
const indexFile = path.join(configDir, 'index.ts');
|
|
199
|
+
if (existsSync(indexFile)) {
|
|
200
|
+
const result = registerConfigKey(indexFile, spec.config.key);
|
|
201
|
+
if (result === 'ok') {
|
|
202
|
+
console.log(` Registered "${spec.config.key}" in config/index.ts`);
|
|
203
|
+
}
|
|
204
|
+
else if (result === 'unrecognized-shape') {
|
|
205
|
+
console.warn(` ⚠ Could not auto-wire config/index.ts (custom shape).`);
|
|
206
|
+
console.warn(` Add manually: import ${spec.config.key} from './${spec.config.key}.js'`);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// 4. Refresh provider manifest
|
|
211
|
+
console.log(` Refreshing provider manifest...`);
|
|
212
|
+
const discoverOk = await runChild(pm, [...(pm === 'npm' ? ['exec'] : []), 'rudder', 'providers:discover'], cwd);
|
|
213
|
+
if (!discoverOk) {
|
|
214
|
+
console.warn(` ⚠ providers:discover failed — run \`${pm} rudder providers:discover\` manually.`);
|
|
215
|
+
}
|
|
216
|
+
// 5. Print the post-install hint
|
|
217
|
+
console.log();
|
|
218
|
+
console.log(` ✓ ${spec.alias} is ready.`);
|
|
219
|
+
if (spec.hint)
|
|
220
|
+
console.log(` ${spec.hint}`);
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
// ── Config templates (vendored from create-rudder-app for runtime use) ─────
|
|
224
|
+
//
|
|
225
|
+
// Kept inline here rather than pulled from create-rudder-app via subpath so
|
|
226
|
+
// that @rudderjs/cli stays standalone and doesn't depend on the scaffolder.
|
|
227
|
+
// These are intentionally near-verbatim copies — the scaffolder owns the
|
|
228
|
+
// canonical templates for new-project scaffolding, and this command owns the
|
|
229
|
+
// runtime-add path. When the canonical templates evolve, this file gets
|
|
230
|
+
// updated in lockstep (one PR touches both).
|
|
231
|
+
const CFG_AUTH = `import type { AuthConfig } from '@rudderjs/auth'
|
|
232
|
+
import { User } from '../app/Models/User.js'
|
|
233
|
+
|
|
234
|
+
export default {
|
|
235
|
+
defaults: { guard: 'web' },
|
|
236
|
+
guards: {
|
|
237
|
+
web: { driver: 'session', provider: 'users' },
|
|
238
|
+
},
|
|
239
|
+
providers: {
|
|
240
|
+
users: { driver: 'eloquent', model: User },
|
|
241
|
+
},
|
|
242
|
+
} satisfies AuthConfig
|
|
243
|
+
`;
|
|
244
|
+
const CFG_SANCTUM = `import { Env } from '@rudderjs/support'
|
|
245
|
+
import type { SanctumConfig } from '@rudderjs/sanctum'
|
|
246
|
+
|
|
247
|
+
export default {
|
|
248
|
+
expiration: Env.getNumber('SANCTUM_TOKEN_EXPIRATION_MINUTES', 0),
|
|
249
|
+
prefix: Env.get('SANCTUM_TOKEN_PREFIX', ''),
|
|
250
|
+
|
|
251
|
+
// Default abilities granted on token creation.
|
|
252
|
+
defaultAbilities: ['*'],
|
|
253
|
+
} satisfies SanctumConfig
|
|
254
|
+
`;
|
|
255
|
+
const CFG_PASSPORT = `import { Env } from '@rudderjs/support'
|
|
256
|
+
|
|
257
|
+
export default {
|
|
258
|
+
// Path to the RSA keypair generated by \`rudder passport:keys\`.
|
|
259
|
+
privateKey: Env.get('PASSPORT_PRIVATE_KEY_PATH', 'storage/oauth-private.key'),
|
|
260
|
+
publicKey: Env.get('PASSPORT_PUBLIC_KEY_PATH', 'storage/oauth-public.key'),
|
|
261
|
+
|
|
262
|
+
// Token lifetimes (in seconds).
|
|
263
|
+
accessTokenTtl: Env.getNumber('PASSPORT_ACCESS_TOKEN_TTL', 3600), // 1h
|
|
264
|
+
refreshTokenTtl: Env.getNumber('PASSPORT_REFRESH_TOKEN_TTL', 1209600), // 14d
|
|
265
|
+
}
|
|
266
|
+
`;
|
|
267
|
+
const CFG_SOCIALITE = `import { Env } from '@rudderjs/support'
|
|
268
|
+
|
|
269
|
+
export default {
|
|
270
|
+
github: {
|
|
271
|
+
clientId: Env.get('GITHUB_CLIENT_ID', ''),
|
|
272
|
+
clientSecret: Env.get('GITHUB_CLIENT_SECRET', ''),
|
|
273
|
+
redirectUri: Env.get('GITHUB_REDIRECT_URI', 'http://localhost:3000/auth/github/callback'),
|
|
274
|
+
},
|
|
275
|
+
google: {
|
|
276
|
+
clientId: Env.get('GOOGLE_CLIENT_ID', ''),
|
|
277
|
+
clientSecret: Env.get('GOOGLE_CLIENT_SECRET', ''),
|
|
278
|
+
redirectUri: Env.get('GOOGLE_REDIRECT_URI', 'http://localhost:3000/auth/google/callback'),
|
|
279
|
+
},
|
|
280
|
+
}
|
|
281
|
+
`;
|
|
282
|
+
const CFG_CRYPT = `import { Env } from '@rudderjs/support'
|
|
283
|
+
|
|
284
|
+
export default {
|
|
285
|
+
// 32-byte base64 key. Generate with: openssl rand -base64 32
|
|
286
|
+
// Stored in .env as APP_KEY — never commit it.
|
|
287
|
+
key: Env.get('APP_KEY', ''),
|
|
288
|
+
cipher: Env.get('APP_CIPHER', 'aes-256-cbc'),
|
|
289
|
+
}
|
|
290
|
+
`;
|
|
291
|
+
const CFG_QUEUE = `import { Env, isWebContainer } from '@rudderjs/support'
|
|
292
|
+
import type { QueueConfig } from '@rudderjs/queue'
|
|
293
|
+
|
|
294
|
+
// In WebContainer, BullMQ (Redis over raw TCP) doesn't work — fall back to
|
|
295
|
+
// the in-process \`sync\` driver.
|
|
296
|
+
const defaultConnection = isWebContainer() ? 'sync' : Env.get('QUEUE_CONNECTION', 'sync')
|
|
297
|
+
|
|
298
|
+
export default {
|
|
299
|
+
default: defaultConnection,
|
|
300
|
+
|
|
301
|
+
connections: {
|
|
302
|
+
sync: {
|
|
303
|
+
driver: 'sync',
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
inngest: {
|
|
307
|
+
driver: 'inngest',
|
|
308
|
+
appId: Env.get('INNGEST_APP_ID', 'my-app'),
|
|
309
|
+
eventKey: Env.get('INNGEST_EVENT_KEY', ''),
|
|
310
|
+
signingKey: Env.get('INNGEST_SIGNING_KEY', ''),
|
|
311
|
+
jobs: [],
|
|
312
|
+
},
|
|
313
|
+
},
|
|
314
|
+
} satisfies QueueConfig
|
|
315
|
+
`;
|
|
316
|
+
const CFG_STORAGE = `import { Env } from '@rudderjs/support'
|
|
317
|
+
import type { StorageConfig } from '@rudderjs/storage'
|
|
318
|
+
|
|
319
|
+
export default {
|
|
320
|
+
default: Env.get('STORAGE_DISK', 'local'),
|
|
321
|
+
|
|
322
|
+
disks: {
|
|
323
|
+
local: {
|
|
324
|
+
driver: 'local',
|
|
325
|
+
root: Env.get('STORAGE_LOCAL_ROOT', 'storage/app'),
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
s3: {
|
|
329
|
+
driver: 's3',
|
|
330
|
+
key: Env.get('AWS_ACCESS_KEY_ID', ''),
|
|
331
|
+
secret: Env.get('AWS_SECRET_ACCESS_KEY', ''),
|
|
332
|
+
region: Env.get('AWS_DEFAULT_REGION', 'us-east-1'),
|
|
333
|
+
bucket: Env.get('AWS_BUCKET', ''),
|
|
334
|
+
endpoint: Env.get('AWS_ENDPOINT', ''),
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
} satisfies StorageConfig
|
|
338
|
+
`;
|
|
339
|
+
const CFG_MAIL = `import { Env, isWebContainer } from '@rudderjs/support'
|
|
340
|
+
|
|
341
|
+
// In WebContainer, raw SMTP (TCP) doesn't work — fall back to the log driver
|
|
342
|
+
// (writes the rendered email to stdout instead of sending).
|
|
343
|
+
const defaultMailer = isWebContainer() ? 'log' : Env.get('MAIL_MAILER', 'log')
|
|
344
|
+
|
|
345
|
+
export default {
|
|
346
|
+
default: defaultMailer,
|
|
347
|
+
|
|
348
|
+
from: {
|
|
349
|
+
address: Env.get('MAIL_FROM_ADDRESS', 'hello@example.com'),
|
|
350
|
+
name: Env.get('MAIL_FROM_NAME', 'RudderJS'),
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
mailers: {
|
|
354
|
+
log: {
|
|
355
|
+
driver: 'log',
|
|
356
|
+
},
|
|
357
|
+
|
|
358
|
+
smtp: {
|
|
359
|
+
driver: 'smtp',
|
|
360
|
+
host: Env.get('MAIL_HOST', 'localhost'),
|
|
361
|
+
port: Env.getNumber('MAIL_PORT', 587),
|
|
362
|
+
username: Env.get('MAIL_USERNAME', ''),
|
|
363
|
+
password: Env.get('MAIL_PASSWORD', ''),
|
|
364
|
+
encryption: Env.get('MAIL_ENCRYPTION', 'tls'),
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
}
|
|
368
|
+
`;
|
|
369
|
+
function buildSyncConfig(orm) {
|
|
370
|
+
const persistenceImport = orm === 'prisma' ? "\nimport { syncPrisma } from '@rudderjs/sync'" : '';
|
|
371
|
+
const persistenceLine = orm === 'prisma'
|
|
372
|
+
? '\n // Server-side persistence — Y.Docs survive server restarts\n persistence: syncPrisma(),\n'
|
|
373
|
+
: '';
|
|
374
|
+
return `import { Env } from '@rudderjs/support'${persistenceImport}
|
|
375
|
+
import type { SyncConfig } from '@rudderjs/sync'
|
|
376
|
+
|
|
377
|
+
export default {
|
|
378
|
+
path: Env.get('SYNC_PATH', '/ws-sync'),
|
|
379
|
+
${persistenceLine}
|
|
380
|
+
// Client-side providers
|
|
381
|
+
providers: ['websocket', 'indexeddb'],
|
|
382
|
+
} satisfies SyncConfig
|
|
383
|
+
`;
|
|
384
|
+
}
|
|
385
|
+
const CFG_LOCALIZATION = `import { Env } from '@rudderjs/support'
|
|
386
|
+
|
|
387
|
+
export default {
|
|
388
|
+
locale: Env.get('APP_LOCALE', 'en'),
|
|
389
|
+
fallbackLocale: Env.get('APP_FALLBACK_LOCALE', 'en'),
|
|
390
|
+
|
|
391
|
+
// Path to translation files (relative to project root).
|
|
392
|
+
path: 'lang',
|
|
393
|
+
}
|
|
394
|
+
`;
|
|
395
|
+
const CFG_PENNANT = `import { Env } from '@rudderjs/support'
|
|
396
|
+
import type { PennantConfig } from '@rudderjs/pennant'
|
|
397
|
+
|
|
398
|
+
export default {
|
|
399
|
+
default: Env.get('PENNANT_STORE', 'array'),
|
|
400
|
+
|
|
401
|
+
stores: {
|
|
402
|
+
array: { driver: 'array' },
|
|
403
|
+
database: { driver: 'database', table: 'feature_flags' },
|
|
404
|
+
},
|
|
405
|
+
} satisfies PennantConfig
|
|
406
|
+
`;
|
|
407
|
+
const CFG_TELESCOPE = `import { Env } from '@rudderjs/support'
|
|
408
|
+
import type { TelescopeConfig } from '@rudderjs/telescope'
|
|
409
|
+
|
|
410
|
+
export default {
|
|
411
|
+
enabled: Env.getBool('TELESCOPE_ENABLED', true),
|
|
412
|
+
path: Env.get('TELESCOPE_PATH', '/telescope'),
|
|
413
|
+
|
|
414
|
+
storage: {
|
|
415
|
+
driver: Env.get('TELESCOPE_STORAGE', 'memory'),
|
|
416
|
+
},
|
|
417
|
+
} satisfies TelescopeConfig
|
|
418
|
+
`;
|
|
419
|
+
const CFG_PULSE = `import { Env } from '@rudderjs/support'
|
|
420
|
+
import type { PulseConfig } from '@rudderjs/pulse'
|
|
421
|
+
|
|
422
|
+
export default {
|
|
423
|
+
enabled: Env.getBool('PULSE_ENABLED', true),
|
|
424
|
+
path: Env.get('PULSE_PATH', '/pulse'),
|
|
425
|
+
|
|
426
|
+
storage: {
|
|
427
|
+
driver: Env.get('PULSE_STORAGE', 'memory'),
|
|
428
|
+
},
|
|
429
|
+
} satisfies PulseConfig
|
|
430
|
+
`;
|
|
431
|
+
const CFG_HORIZON = `import { Env } from '@rudderjs/support'
|
|
432
|
+
import type { HorizonConfig } from '@rudderjs/horizon'
|
|
433
|
+
|
|
434
|
+
export default {
|
|
435
|
+
enabled: Env.getBool('HORIZON_ENABLED', true),
|
|
436
|
+
path: Env.get('HORIZON_PATH', '/horizon'),
|
|
437
|
+
|
|
438
|
+
storage: {
|
|
439
|
+
driver: Env.get('HORIZON_STORAGE', 'memory'),
|
|
440
|
+
},
|
|
441
|
+
} satisfies HorizonConfig
|
|
442
|
+
`;
|
|
443
|
+
const CFG_AI = `import { Env } from '@rudderjs/support'
|
|
444
|
+
import type { AiConfig } from '@rudderjs/ai'
|
|
445
|
+
|
|
446
|
+
export default {
|
|
447
|
+
default: Env.get('AI_MODEL', 'anthropic/claude-sonnet-4-5'),
|
|
448
|
+
|
|
449
|
+
providers: {
|
|
450
|
+
anthropic: {
|
|
451
|
+
driver: 'anthropic',
|
|
452
|
+
apiKey: Env.get('ANTHROPIC_API_KEY', ''),
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
openai: {
|
|
456
|
+
driver: 'openai',
|
|
457
|
+
apiKey: Env.get('OPENAI_API_KEY', ''),
|
|
458
|
+
},
|
|
459
|
+
|
|
460
|
+
google: {
|
|
461
|
+
driver: 'google',
|
|
462
|
+
apiKey: Env.get('GOOGLE_AI_API_KEY', ''),
|
|
463
|
+
},
|
|
464
|
+
|
|
465
|
+
ollama: {
|
|
466
|
+
driver: 'ollama',
|
|
467
|
+
baseUrl: Env.get('OLLAMA_BASE_URL', 'http://localhost:11434'),
|
|
468
|
+
},
|
|
469
|
+
},
|
|
470
|
+
} satisfies AiConfig
|
|
471
|
+
`;
|
|
472
|
+
// ── Test exports ──────────────────────────────────────────────
|
|
473
|
+
// (not part of the runtime API, but tests import these directly)
|
|
474
|
+
export const _internal = { REGISTRY, findSpec, detectOrm, detectPackageManager };
|
|
475
|
+
//# sourceMappingURL=add.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"add.js","sourceRoot":"","sources":["../../src/commands/add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAC5E,OAAO,IAAI,MAAM,WAAW,CAAA;AAC5B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAO1C,yFAAyF;AACzF,SAAS,oBAAoB;IAC3B,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,IAAI,EAAE,CAAA;IACrD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IACxC,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAA;IACxC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;QAAG,OAAO,KAAK,CAAA;IACvC,IAAI,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;QAAG,OAAO,KAAK,CAAA;IACvC,uEAAuE;IACvE,kFAAkF;IAClF,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,KAAK,CAAC,EAAkB,EAAE,GAAW;IAC5C,QAAQ,EAAE,EAAE,CAAC;QACX,KAAK,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAChC,KAAK,KAAK,CAAC,CAAE,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QACpC,KAAK,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;QAChC,KAAK,KAAK,CAAC,CAAE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAClC,CAAC;AACH,CAAC;AA4BD,MAAM,QAAQ,GAA+B;IAC3C,kBAA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|
3
|
+
/**
|
|
4
|
+
* Inject the CLI's bootApp so the doctor command can boot the app under
|
|
5
|
+
* `--deep`. Passed by reference rather than imported because the CLI's
|
|
6
|
+
* bootApp suppresses console output (provider chatter is noise here too)
|
|
7
|
+
* and the doctor command shouldn't reimplement that.
|
|
8
|
+
*/
|
|
9
|
+
bootApp: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare function doctorCommand(program: CommanderCommand, deps: DoctorCommandDeps): void;
|
|
12
|
+
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAQ5D,MAAM,WAAW,iBAAiB;IAChC;;;;;OAKG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAC7B;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI,CAmFtF"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { runChecks } from '../doctor/orchestrator.js';
|
|
2
|
+
import { renderReport, renderFixReport, exitCodeFor } from '../doctor/reporter.js';
|
|
3
|
+
import { loadPackageChecks } from '../doctor/load-package-checks.js';
|
|
4
|
+
import { loadBuiltInChecks } from '../doctor/built-in/index.js';
|
|
5
|
+
import { setBootStatus } from '../doctor/boot-status.js';
|
|
6
|
+
import { applyFixes } from '../doctor/fixer.js';
|
|
7
|
+
export function doctorCommand(program, deps) {
|
|
8
|
+
program
|
|
9
|
+
.command('doctor')
|
|
10
|
+
.description('Diagnose common setup issues in a RudderJS app')
|
|
11
|
+
.option('--deep', 'Also run checks that require booting the app (DB connect, port, …)')
|
|
12
|
+
.option('--fix', 'Auto-apply safe fixes for any failures that declare a fixer')
|
|
13
|
+
.option('--yes', 'Skip fix-mode prompts and apply every fixable failure')
|
|
14
|
+
.option('--verbose', 'Show detail block under each check (not just failures)')
|
|
15
|
+
.option('--json', 'Reserved for a future machine-readable output mode')
|
|
16
|
+
.option('--only <substring>', 'Only run checks whose id contains <substring>')
|
|
17
|
+
.action(async (opts) => {
|
|
18
|
+
if (opts.json) {
|
|
19
|
+
console.error('rudder doctor: --json is reserved for a future release (v1 has no JSON output).');
|
|
20
|
+
process.exit(2);
|
|
21
|
+
}
|
|
22
|
+
// Built-in CLI-owned checks (env, structure, deps, runtime) — registered
|
|
23
|
+
// eagerly via side-effect imports so they're present even if no framework
|
|
24
|
+
// package contributed any.
|
|
25
|
+
loadBuiltInChecks();
|
|
26
|
+
// Lazy-load package-contributed checks.
|
|
27
|
+
await loadPackageChecks();
|
|
28
|
+
// --deep boots the app once so runtime checks can interrogate the live
|
|
29
|
+
// DI container (DB client, queue connection, mail transport, etc.).
|
|
30
|
+
// Boot failure is captured as a check result, not a crash — the rest
|
|
31
|
+
// of the runtime suite then short-circuits to skipped, but the user
|
|
32
|
+
// still sees the boot error verbatim with the failing provider.
|
|
33
|
+
if (opts.deep) {
|
|
34
|
+
const t0 = performance.now();
|
|
35
|
+
try {
|
|
36
|
+
await deps.bootApp();
|
|
37
|
+
setBootStatus({ ok: true, durationMs: performance.now() - t0 });
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
setBootStatus({
|
|
41
|
+
ok: false,
|
|
42
|
+
error: e instanceof Error ? `${e.message}\n${e.stack ?? ''}` : String(e),
|
|
43
|
+
durationMs: performance.now() - t0,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
const runOpts = {};
|
|
48
|
+
if (opts.deep)
|
|
49
|
+
runOpts.deep = true;
|
|
50
|
+
if (opts.only !== undefined)
|
|
51
|
+
runOpts.filter = opts.only;
|
|
52
|
+
const reportOpts = {};
|
|
53
|
+
if (opts.verbose)
|
|
54
|
+
reportOpts.verbose = true;
|
|
55
|
+
// First pass — surface every failure to the user before touching anything.
|
|
56
|
+
const result = await runChecks(runOpts);
|
|
57
|
+
console.log(renderReport(result, reportOpts));
|
|
58
|
+
if (!opts.fix) {
|
|
59
|
+
process.exit(exitCodeFor(result));
|
|
60
|
+
}
|
|
61
|
+
// ── --fix path ──────────────────────────────────────
|
|
62
|
+
// Only fixable checks (warn/error with a fixer) are eligible. Prompt
|
|
63
|
+
// each unless --yes; never modify .env or package.json — fixers are
|
|
64
|
+
// idempotent regenerate-style operations only.
|
|
65
|
+
const fixOpts = {};
|
|
66
|
+
if (opts.yes)
|
|
67
|
+
fixOpts.yes = true;
|
|
68
|
+
const fixResult = await applyFixes(result.outcomes, fixOpts);
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log(renderFixReport(fixResult, reportOpts));
|
|
71
|
+
// Second pass — confirm the fixers actually resolved the issues so
|
|
72
|
+
// the user doesn't have to eyeball it. Same runOpts so deep/only flags
|
|
73
|
+
// carry through.
|
|
74
|
+
if (fixResult.applied > 0) {
|
|
75
|
+
console.log('');
|
|
76
|
+
const second = await runChecks(runOpts);
|
|
77
|
+
console.log(renderReport(second, reportOpts));
|
|
78
|
+
process.exit(exitCodeFor(second));
|
|
79
|
+
}
|
|
80
|
+
process.exit(exitCodeFor(result));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=doctor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AAC/D,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B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