@atlasauth/cli 0.5.0 → 0.7.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/CHANGELOG.md +15 -0
- package/README.md +5 -0
- package/dist/args.d.ts +39 -0
- package/dist/args.js +17 -0
- package/dist/args.js.map +1 -1
- package/dist/commands/actions-gallery.d.ts +8 -0
- package/dist/commands/actions-gallery.js +197 -0
- package/dist/commands/actions-gallery.js.map +1 -0
- package/dist/commands/actions.d.ts +2 -0
- package/dist/commands/actions.js +17 -2
- package/dist/commands/actions.js.map +1 -1
- package/dist/commands/import.d.ts +3 -0
- package/dist/commands/import.js +116 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/info.d.ts +75 -0
- package/dist/commands/info.js +362 -0
- package/dist/commands/info.js.map +1 -0
- package/dist/commands/mcp.d.ts +38 -0
- package/dist/commands/mcp.js +108 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/migrate.d.ts +12 -0
- package/dist/commands/migrate.js +65 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/commands/referrals.d.ts +6 -6
- package/dist/commands/referrals.js +28 -28
- package/dist/context.d.ts +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.js +111 -7
- package/dist/help.js.map +1 -1
- package/dist/import/csv.d.ts +6 -0
- package/dist/import/csv.js +63 -0
- package/dist/import/csv.js.map +1 -0
- package/dist/import/vendors.d.ts +57 -0
- package/dist/import/vendors.js +568 -0
- package/dist/import/vendors.js.map +1 -0
- package/dist/run.js +8 -0
- package/dist/run.js.map +1 -1
- package/package.json +4 -3
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { ParsedArgs } from '../args';
|
|
2
|
+
import type { RunContext } from '../context';
|
|
3
|
+
export interface InfoPackage {
|
|
4
|
+
name: string;
|
|
5
|
+
wanted: string;
|
|
6
|
+
installed: string | null;
|
|
7
|
+
latest: string | null;
|
|
8
|
+
update_available: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface InfoReport {
|
|
11
|
+
object: 'atlas_info';
|
|
12
|
+
generated_at: string;
|
|
13
|
+
cli: {
|
|
14
|
+
version: string;
|
|
15
|
+
latest: string | null;
|
|
16
|
+
update_available: boolean;
|
|
17
|
+
};
|
|
18
|
+
runtime: {
|
|
19
|
+
node: string;
|
|
20
|
+
platform: string;
|
|
21
|
+
arch: string;
|
|
22
|
+
};
|
|
23
|
+
project: {
|
|
24
|
+
path: string;
|
|
25
|
+
name: string | null;
|
|
26
|
+
framework: {
|
|
27
|
+
name: string;
|
|
28
|
+
package: string;
|
|
29
|
+
version: string | null;
|
|
30
|
+
} | null;
|
|
31
|
+
packages: InfoPackage[];
|
|
32
|
+
};
|
|
33
|
+
instance: {
|
|
34
|
+
configured: boolean;
|
|
35
|
+
api_url: string | null;
|
|
36
|
+
key_source: string | null;
|
|
37
|
+
secret_key_prefix: string | null;
|
|
38
|
+
instance_id: string | null;
|
|
39
|
+
environment: string | null;
|
|
40
|
+
frontend_api_host: string | null;
|
|
41
|
+
publishable_key_prefix: string | null;
|
|
42
|
+
publishable_key_source: string | null;
|
|
43
|
+
publishable_key_matches_instance: boolean | null;
|
|
44
|
+
error: string | null;
|
|
45
|
+
};
|
|
46
|
+
api: {
|
|
47
|
+
reachable: boolean;
|
|
48
|
+
health_status: number | null;
|
|
49
|
+
health_latency_ms: number | null;
|
|
50
|
+
instance_latency_ms: number | null;
|
|
51
|
+
error: string | null;
|
|
52
|
+
};
|
|
53
|
+
preflight: {
|
|
54
|
+
ran: boolean;
|
|
55
|
+
ok: boolean | null;
|
|
56
|
+
errors: number;
|
|
57
|
+
warnings: number;
|
|
58
|
+
info: number;
|
|
59
|
+
findings: Array<{
|
|
60
|
+
severity: string;
|
|
61
|
+
code: string;
|
|
62
|
+
}>;
|
|
63
|
+
error: string | null;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/** `sk_live_abc…` → `sk_live_`; anything else → its first 3 chars. */
|
|
67
|
+
export declare function keyPrefix(key: string): string;
|
|
68
|
+
/** Mask anything that looks like an Atlas (or other bearer) secret in free text. */
|
|
69
|
+
export declare function redactSecrets(text: string): string;
|
|
70
|
+
/** Dotted-number compare that tolerates prerelease tags (`1.2.0-rc.1` < `1.2.0`). */
|
|
71
|
+
export declare function compareVersions(a: string, b: string): number;
|
|
72
|
+
export declare function info(ctx: RunContext, args: ParsedArgs): Promise<number>;
|
|
73
|
+
export declare function collectInfo(ctx: RunContext, args: ParsedArgs): Promise<InfoReport>;
|
|
74
|
+
/** The human block: aligned, copyable, nothing secret. */
|
|
75
|
+
export declare function renderInfo(r: InfoReport): string[];
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.keyPrefix = keyPrefix;
|
|
4
|
+
exports.redactSecrets = redactSecrets;
|
|
5
|
+
exports.compareVersions = compareVersions;
|
|
6
|
+
exports.info = info;
|
|
7
|
+
exports.collectInfo = collectInfo;
|
|
8
|
+
exports.renderInfo = renderInfo;
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const backend_1 = require("@atlasauth/backend");
|
|
11
|
+
const project_1 = require("../project");
|
|
12
|
+
const secrets_1 = require("../secrets");
|
|
13
|
+
const version_1 = require("../version");
|
|
14
|
+
const project_commands_1 = require("./project-commands");
|
|
15
|
+
const shared_1 = require("./shared");
|
|
16
|
+
/**
|
|
17
|
+
* `atlas info` — the environment in one copyable block, for support tickets and
|
|
18
|
+
* "works on my machine" debugging:
|
|
19
|
+
*
|
|
20
|
+
* - CLI, Node and OS versions;
|
|
21
|
+
* - the detected framework and every Atlas SDK package in the project, with the
|
|
22
|
+
* installed version and "update available" from the npm registry;
|
|
23
|
+
* - the configured instance — key PREFIXES only (`sk_live_`, `pk_test_`), never a
|
|
24
|
+
* key — whether the app's publishable key belongs to that instance, the API
|
|
25
|
+
* URL, reachability and latency;
|
|
26
|
+
* - the instance's preflight summary.
|
|
27
|
+
*
|
|
28
|
+
* Every network step is best-effort with a short timeout: `atlas info` reports a
|
|
29
|
+
* failure as data instead of failing, because it is what you run when things are
|
|
30
|
+
* broken. A final redaction pass masks anything shaped like a secret.
|
|
31
|
+
*/
|
|
32
|
+
const NPM_REGISTRY = 'https://registry.npmjs.org';
|
|
33
|
+
const TIMEOUT_MS = 5_000;
|
|
34
|
+
/** Frameworks, in detection priority (the first one present wins as "framework"). */
|
|
35
|
+
const FRAMEWORKS = [
|
|
36
|
+
['next', 'Next.js'],
|
|
37
|
+
['@remix-run/react', 'Remix'],
|
|
38
|
+
['@react-router/dev', 'React Router'],
|
|
39
|
+
['@tanstack/react-start', 'TanStack Start'],
|
|
40
|
+
['nuxt', 'Nuxt'],
|
|
41
|
+
['@sveltejs/kit', 'SvelteKit'],
|
|
42
|
+
['astro', 'Astro'],
|
|
43
|
+
['gatsby', 'Gatsby'],
|
|
44
|
+
['@builder.io/qwik-city', 'Qwik City'],
|
|
45
|
+
['@angular/core', 'Angular'],
|
|
46
|
+
['expo', 'Expo'],
|
|
47
|
+
['react-native', 'React Native'],
|
|
48
|
+
['electron', 'Electron'],
|
|
49
|
+
['@nestjs/core', 'NestJS'],
|
|
50
|
+
['hono', 'Hono'],
|
|
51
|
+
['fastify', 'Fastify'],
|
|
52
|
+
['express', 'Express'],
|
|
53
|
+
['solid-js', 'Solid'],
|
|
54
|
+
['vue', 'Vue'],
|
|
55
|
+
['vite', 'Vite'],
|
|
56
|
+
['react', 'React'],
|
|
57
|
+
];
|
|
58
|
+
const PUBLISHABLE_ENV = ['ATLAS_PUBLISHABLE_KEY', 'NEXT_PUBLIC_ATLAS_PUBLISHABLE_KEY', 'VITE_ATLAS_PUBLISHABLE_KEY', 'REACT_APP_ATLAS_PUBLISHABLE_KEY', 'PUBLIC_ATLAS_PUBLISHABLE_KEY', 'EXPO_PUBLIC_ATLAS_PUBLISHABLE_KEY'];
|
|
59
|
+
const ENV_FILES = ['.env', '.env.local', '.env.development', '.env.development.local'];
|
|
60
|
+
/** `sk_live_abc…` → `sk_live_`; anything else → its first 3 chars. */
|
|
61
|
+
function keyPrefix(key) {
|
|
62
|
+
const m = /^([a-z]+_(?:live|test)_)/.exec(key) ?? /^([a-z]+_)/.exec(key);
|
|
63
|
+
return m ? m[1] : `${key.slice(0, 3)}…`;
|
|
64
|
+
}
|
|
65
|
+
/** Mask anything that looks like an Atlas (or other bearer) secret in free text. */
|
|
66
|
+
function redactSecrets(text) {
|
|
67
|
+
return text.replace(/\b((?:sk|psk|rk|whsec|ak|fck|cft)_(?:(?:live|test)_)?)[A-Za-z0-9_-]{6,}/g, '$1[redacted]');
|
|
68
|
+
}
|
|
69
|
+
/** Dotted-number compare that tolerates prerelease tags (`1.2.0-rc.1` < `1.2.0`). */
|
|
70
|
+
function compareVersions(a, b) {
|
|
71
|
+
const parse = (v) => {
|
|
72
|
+
const [core = '', pre] = v.replace(/^[^\d]*/, '').split('-', 2);
|
|
73
|
+
return { nums: core.split('.').map((n) => Number.parseInt(n, 10) || 0), pre };
|
|
74
|
+
};
|
|
75
|
+
const x = parse(a);
|
|
76
|
+
const y = parse(b);
|
|
77
|
+
for (let i = 0; i < Math.max(x.nums.length, y.nums.length); i++) {
|
|
78
|
+
const d = (x.nums[i] ?? 0) - (y.nums[i] ?? 0);
|
|
79
|
+
if (d !== 0)
|
|
80
|
+
return d > 0 ? 1 : -1;
|
|
81
|
+
}
|
|
82
|
+
if (x.pre && !y.pre)
|
|
83
|
+
return -1;
|
|
84
|
+
if (!x.pre && y.pre)
|
|
85
|
+
return 1;
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
function isAtlasPackage(name) {
|
|
89
|
+
return name.startsWith('@atlasauth/') || name === 'gatsby-plugin-atlasauth';
|
|
90
|
+
}
|
|
91
|
+
function errorText(err) {
|
|
92
|
+
if (err instanceof backend_1.AtlasApiError)
|
|
93
|
+
return `HTTP ${err.status}${err.code ? ` ${err.code}` : ''}: ${err.message}`;
|
|
94
|
+
if (err instanceof Error)
|
|
95
|
+
return err.name === 'AbortError' || err.name === 'TimeoutError' ? `timed out after ${TIMEOUT_MS} ms` : err.message;
|
|
96
|
+
return String(err);
|
|
97
|
+
}
|
|
98
|
+
async function withTimeout(run) {
|
|
99
|
+
const controller = new AbortController();
|
|
100
|
+
let timer;
|
|
101
|
+
const expired = new Promise((_, reject) => {
|
|
102
|
+
timer = setTimeout(() => {
|
|
103
|
+
controller.abort();
|
|
104
|
+
const err = new Error(`timed out after ${TIMEOUT_MS} ms`);
|
|
105
|
+
err.name = 'TimeoutError';
|
|
106
|
+
reject(err);
|
|
107
|
+
}, TIMEOUT_MS);
|
|
108
|
+
});
|
|
109
|
+
try {
|
|
110
|
+
return await Promise.race([run(controller.signal), expired]);
|
|
111
|
+
}
|
|
112
|
+
finally {
|
|
113
|
+
clearTimeout(timer);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function info(ctx, args) {
|
|
117
|
+
const report = await collectInfo(ctx, args);
|
|
118
|
+
if ((0, shared_1.wantsJson)(args.values)) {
|
|
119
|
+
// Redact the serialized form too: belt and braces over every free-text field.
|
|
120
|
+
ctx.io.out(redactSecrets(JSON.stringify(report, null, 2)));
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
for (const line of renderInfo(report))
|
|
124
|
+
ctx.io.out(redactSecrets(line));
|
|
125
|
+
return 0;
|
|
126
|
+
}
|
|
127
|
+
async function collectInfo(ctx, args) {
|
|
128
|
+
const fetchImpl = ctx.fetch ?? globalThis.fetch;
|
|
129
|
+
const projectDir = (0, node_path_1.resolve)(args.positionals[1] ?? process.cwd());
|
|
130
|
+
const readJson = (path) => {
|
|
131
|
+
try {
|
|
132
|
+
return JSON.parse(ctx.readFile(path));
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const pkg = readJson((0, node_path_1.join)(projectDir, 'package.json'));
|
|
139
|
+
const deps = {
|
|
140
|
+
...(pkg?.dependencies ?? {}),
|
|
141
|
+
...(pkg?.devDependencies ?? {}),
|
|
142
|
+
};
|
|
143
|
+
const installedVersion = (name) => {
|
|
144
|
+
const v = readJson((0, node_path_1.join)(projectDir, 'node_modules', ...name.split('/'), 'package.json'))?.version;
|
|
145
|
+
return typeof v === 'string' ? v : null;
|
|
146
|
+
};
|
|
147
|
+
const latestOf = async (name) => {
|
|
148
|
+
if (typeof fetchImpl !== 'function')
|
|
149
|
+
return null;
|
|
150
|
+
try {
|
|
151
|
+
return await withTimeout(async (signal) => {
|
|
152
|
+
const res = await fetchImpl(`${NPM_REGISTRY}/${name.replace('/', '%2F')}/latest`, {
|
|
153
|
+
headers: { accept: 'application/json' },
|
|
154
|
+
signal,
|
|
155
|
+
});
|
|
156
|
+
if (!res.ok)
|
|
157
|
+
return null;
|
|
158
|
+
const body = (await res.json());
|
|
159
|
+
return typeof body.version === 'string' ? body.version : null;
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
const atlasNames = Object.keys(deps).filter(isAtlasPackage).sort();
|
|
167
|
+
const cliVersion = (0, version_1.getVersion)();
|
|
168
|
+
const [cliLatest, ...latest] = await Promise.all([latestOf('@atlasauth/cli'), ...atlasNames.map(latestOf)]);
|
|
169
|
+
const packages = atlasNames.map((name, i) => {
|
|
170
|
+
const installed = installedVersion(name);
|
|
171
|
+
const newest = latest[i] ?? null;
|
|
172
|
+
const current = installed ?? deps[name];
|
|
173
|
+
return {
|
|
174
|
+
name,
|
|
175
|
+
wanted: deps[name],
|
|
176
|
+
installed,
|
|
177
|
+
latest: newest,
|
|
178
|
+
update_available: Boolean(newest && /\d/.test(current) && compareVersions(current, newest) < 0),
|
|
179
|
+
};
|
|
180
|
+
});
|
|
181
|
+
const fw = FRAMEWORKS.find(([name]) => deps[name] !== undefined);
|
|
182
|
+
const framework = fw ? { name: fw[1], package: fw[0], version: installedVersion(fw[0]) ?? deps[fw[0]] ?? null } : null;
|
|
183
|
+
// Publishable key: the process env first, then the project's .env files.
|
|
184
|
+
let publishable = null;
|
|
185
|
+
for (const name of PUBLISHABLE_ENV) {
|
|
186
|
+
const v = ctx.env[name]?.trim();
|
|
187
|
+
if (v) {
|
|
188
|
+
publishable = { key: v, source: `env ${name}` };
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (!publishable) {
|
|
193
|
+
outer: for (const file of ENV_FILES) {
|
|
194
|
+
const vars = (0, secrets_1.readEnvFile)((0, node_path_1.join)(projectDir, file));
|
|
195
|
+
for (const name of PUBLISHABLE_ENV) {
|
|
196
|
+
const v = vars?.[name]?.trim();
|
|
197
|
+
if (v) {
|
|
198
|
+
publishable = { key: v, source: `${file} ${name}` };
|
|
199
|
+
break outer;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const report = {
|
|
205
|
+
object: 'atlas_info',
|
|
206
|
+
generated_at: new Date().toISOString(),
|
|
207
|
+
cli: {
|
|
208
|
+
version: cliVersion,
|
|
209
|
+
latest: cliLatest ?? null,
|
|
210
|
+
update_available: Boolean(cliLatest && compareVersions(cliVersion, cliLatest) < 0),
|
|
211
|
+
},
|
|
212
|
+
runtime: { node: process.version, platform: process.platform, arch: process.arch },
|
|
213
|
+
project: { path: projectDir, name: typeof pkg?.name === 'string' ? pkg.name : null, framework, packages },
|
|
214
|
+
instance: {
|
|
215
|
+
configured: false,
|
|
216
|
+
api_url: null,
|
|
217
|
+
key_source: null,
|
|
218
|
+
secret_key_prefix: null,
|
|
219
|
+
instance_id: null,
|
|
220
|
+
environment: null,
|
|
221
|
+
frontend_api_host: null,
|
|
222
|
+
publishable_key_prefix: publishable ? keyPrefix(publishable.key) : null,
|
|
223
|
+
publishable_key_source: publishable?.source ?? null,
|
|
224
|
+
publishable_key_matches_instance: null,
|
|
225
|
+
error: null,
|
|
226
|
+
},
|
|
227
|
+
api: { reachable: false, health_status: null, health_latency_ms: null, instance_latency_ms: null, error: null },
|
|
228
|
+
preflight: { ran: false, ok: null, errors: 0, warnings: 0, info: 0, findings: [], error: null },
|
|
229
|
+
};
|
|
230
|
+
let cred = null;
|
|
231
|
+
try {
|
|
232
|
+
const resolved = (0, project_commands_1.instanceCredential)(ctx, args);
|
|
233
|
+
cred = { secretKey: resolved.secretKey, apiUrl: resolved.apiUrl };
|
|
234
|
+
report.instance.configured = true;
|
|
235
|
+
report.instance.api_url = resolved.apiUrl;
|
|
236
|
+
report.instance.secret_key_prefix = keyPrefix(resolved.secretKey);
|
|
237
|
+
report.instance.key_source = resolved.instance
|
|
238
|
+
? 'project manifest'
|
|
239
|
+
: ctx.env.ATLAS_SECRET_KEY?.trim()
|
|
240
|
+
? 'env ATLAS_SECRET_KEY'
|
|
241
|
+
: 'stored profile';
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
report.instance.error = errorText(err);
|
|
245
|
+
report.instance.api_url = ctx.env.ATLAS_API_URL?.trim() || null;
|
|
246
|
+
}
|
|
247
|
+
// Reachability: the unauthenticated health endpoint, timed.
|
|
248
|
+
const apiUrl = (report.instance.api_url ?? 'https://atlasauth.net').replace(/\/+$/, '');
|
|
249
|
+
if (!report.instance.api_url)
|
|
250
|
+
report.instance.api_url = apiUrl;
|
|
251
|
+
if (typeof fetchImpl === 'function') {
|
|
252
|
+
const started = Date.now();
|
|
253
|
+
try {
|
|
254
|
+
const res = await withTimeout((signal) => fetchImpl(`${apiUrl}/v1/health`, { signal }));
|
|
255
|
+
report.api.health_status = res.status;
|
|
256
|
+
report.api.health_latency_ms = Date.now() - started;
|
|
257
|
+
report.api.reachable = res.status < 500;
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
report.api.error = errorText(err);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (cred) {
|
|
264
|
+
const http = (0, project_1.httpFor)(ctx, cred);
|
|
265
|
+
const started = Date.now();
|
|
266
|
+
try {
|
|
267
|
+
const inst = await withTimeout(() => http.get('/v1/instance'));
|
|
268
|
+
report.api.instance_latency_ms = Date.now() - started;
|
|
269
|
+
report.api.reachable = true;
|
|
270
|
+
report.instance.instance_id = inst.id ?? null;
|
|
271
|
+
report.instance.environment = inst.environment ?? null;
|
|
272
|
+
report.instance.frontend_api_host = inst.frontend_api_host ?? null;
|
|
273
|
+
if (publishable) {
|
|
274
|
+
report.instance.publishable_key_matches_instance = inst.publishable_key
|
|
275
|
+
? inst.publishable_key === publishable.key
|
|
276
|
+
: (0, backend_1.instanceIdFromPublishableKey)(publishable.key) === inst.id;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
catch (err) {
|
|
280
|
+
report.instance.error = errorText(err);
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
const pre = await withTimeout(() => http.get('/v1/instance/preflight'));
|
|
284
|
+
const findings = pre.findings ?? [];
|
|
285
|
+
report.preflight = {
|
|
286
|
+
ran: true,
|
|
287
|
+
ok: pre.ok ?? null,
|
|
288
|
+
errors: findings.filter((f) => f.severity === 'error').length,
|
|
289
|
+
warnings: findings.filter((f) => f.severity === 'warning').length,
|
|
290
|
+
info: findings.filter((f) => f.severity === 'info').length,
|
|
291
|
+
findings: findings.map((f) => ({ severity: f.severity, code: f.code })),
|
|
292
|
+
error: null,
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
report.preflight.error = errorText(err);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
return report;
|
|
300
|
+
}
|
|
301
|
+
/** The human block: aligned, copyable, nothing secret. */
|
|
302
|
+
function renderInfo(r) {
|
|
303
|
+
const lines = [];
|
|
304
|
+
const row = (label, value) => lines.push(` ${label.padEnd(22)}${value}`);
|
|
305
|
+
const upd = (u, latest) => (u && latest ? ` (update available: ${latest})` : '');
|
|
306
|
+
lines.push('Atlas environment (safe to paste into a support ticket: no secrets)');
|
|
307
|
+
lines.push('');
|
|
308
|
+
lines.push('System');
|
|
309
|
+
row('atlas CLI', `${r.cli.version}${upd(r.cli.update_available, r.cli.latest)}`);
|
|
310
|
+
row('Node.js', r.runtime.node);
|
|
311
|
+
row('OS', `${r.runtime.platform} ${r.runtime.arch}`);
|
|
312
|
+
lines.push('');
|
|
313
|
+
lines.push('Project');
|
|
314
|
+
row('path', r.project.path);
|
|
315
|
+
if (r.project.name)
|
|
316
|
+
row('name', r.project.name);
|
|
317
|
+
row('framework', r.project.framework ? `${r.project.framework.name} ${r.project.framework.version ?? ''}`.trim() : 'not detected');
|
|
318
|
+
if (r.project.packages.length === 0)
|
|
319
|
+
row('Atlas packages', 'none in package.json');
|
|
320
|
+
for (const p of r.project.packages) {
|
|
321
|
+
row(p.name, `${p.installed ?? `${p.wanted} (not installed)`}${upd(p.update_available, p.latest)}`);
|
|
322
|
+
}
|
|
323
|
+
lines.push('');
|
|
324
|
+
lines.push('Instance');
|
|
325
|
+
if (!r.instance.configured)
|
|
326
|
+
row('credential', `not configured (${r.instance.error ?? 'no key'})`);
|
|
327
|
+
else {
|
|
328
|
+
row('secret key', `${r.instance.secret_key_prefix}… (${r.instance.key_source})`);
|
|
329
|
+
if (r.instance.instance_id)
|
|
330
|
+
row('instance', `${r.instance.instance_id} (${r.instance.environment ?? 'unknown'})`);
|
|
331
|
+
if (r.instance.frontend_api_host)
|
|
332
|
+
row('frontend API host', r.instance.frontend_api_host);
|
|
333
|
+
if (r.instance.error)
|
|
334
|
+
row('instance lookup', `failed: ${r.instance.error}`);
|
|
335
|
+
}
|
|
336
|
+
row('publishable key', r.instance.publishable_key_prefix
|
|
337
|
+
? `${r.instance.publishable_key_prefix}… (${r.instance.publishable_key_source})${r.instance.publishable_key_matches_instance === false
|
|
338
|
+
? ' MISMATCH: not this instance’s key'
|
|
339
|
+
: r.instance.publishable_key_matches_instance
|
|
340
|
+
? ' matches instance'
|
|
341
|
+
: ''}`
|
|
342
|
+
: 'not found in env or .env files');
|
|
343
|
+
lines.push('');
|
|
344
|
+
lines.push('API');
|
|
345
|
+
row('URL', r.instance.api_url ?? 'unknown');
|
|
346
|
+
row('reachable', r.api.reachable
|
|
347
|
+
? `yes (health ${r.api.health_status ?? '?'} in ${r.api.health_latency_ms ?? '?'} ms${r.api.instance_latency_ms !== null ? `, instance ${r.api.instance_latency_ms} ms` : ''})`
|
|
348
|
+
: `no${r.api.error ? ` (${r.api.error})` : r.api.health_status ? ` (health ${r.api.health_status})` : ''}`);
|
|
349
|
+
lines.push('');
|
|
350
|
+
lines.push('Preflight');
|
|
351
|
+
if (!r.preflight.ran)
|
|
352
|
+
row('status', r.preflight.error ? `failed: ${r.preflight.error}` : 'not run (no instance credential)');
|
|
353
|
+
else {
|
|
354
|
+
row('result', `${r.preflight.errors} error(s), ${r.preflight.warnings} warning(s), ${r.preflight.info} info`);
|
|
355
|
+
for (const f of r.preflight.findings.filter((x) => x.severity !== 'info'))
|
|
356
|
+
row(f.severity, f.code);
|
|
357
|
+
if (r.preflight.errors + r.preflight.warnings > 0)
|
|
358
|
+
lines.push(" Run 'atlas preflight' for the fixes.");
|
|
359
|
+
}
|
|
360
|
+
return lines;
|
|
361
|
+
}
|
|
362
|
+
//# sourceMappingURL=info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.js","sourceRoot":"","sources":["../../src/commands/info.ts"],"names":[],"mappings":";;AA8GA,8BAGC;AAGD,sCAEC;AAGD,0CAcC;AA8BD,oBASC;AAED,kCAgLC;AAGD,gCA2DC;AA9ZD,yCAA0C;AAC1C,gDAAiF;AAIjF,wCAAqC;AACrC,wCAAyC;AACzC,wCAAwC;AACxC,yDAAwD;AACxD,qCAAqC;AAErC;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,YAAY,GAAG,4BAA4B,CAAC;AAClD,MAAM,UAAU,GAAG,KAAK,CAAC;AAEzB,qFAAqF;AACrF,MAAM,UAAU,GAAgD;IAC9D,CAAC,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AAC;IAC1G,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ParsedArgs } from '../args';
|
|
2
|
+
import type { RunContext } from '../context';
|
|
3
|
+
/**
|
|
4
|
+
* `atlas mcp install --cursor | --claude-code | --codex | --vscode` — add the
|
|
5
|
+
* Atlas MCP server to an AI coding agent's config, so the agent can search and
|
|
6
|
+
* read the Atlas docs while it works.
|
|
7
|
+
*
|
|
8
|
+
* The server runs as `npx -y @atlasauth/mcp`. No key is written: without
|
|
9
|
+
* `ATLAS_SECRET_KEY` it serves only the read-only docs tools, which is what a
|
|
10
|
+
* coding agent needs. Existing servers in the file are kept; an existing
|
|
11
|
+
* `atlas` entry is replaced (or, in Codex's TOML, left alone and reported).
|
|
12
|
+
*/
|
|
13
|
+
export declare const MCP_SERVER_NAME = "atlas";
|
|
14
|
+
export declare const MCP_CLIENTS: readonly ["cursor", "claude-code", "codex", "vscode"];
|
|
15
|
+
export type McpClient = (typeof MCP_CLIENTS)[number];
|
|
16
|
+
interface InstallResult {
|
|
17
|
+
client: McpClient;
|
|
18
|
+
path: string;
|
|
19
|
+
status: 'added' | 'updated' | 'unchanged';
|
|
20
|
+
}
|
|
21
|
+
/** Where each client keeps its MCP config. Project files go under `dir`. */
|
|
22
|
+
export declare function mcpConfigPath(client: McpClient, opts: {
|
|
23
|
+
dir: string;
|
|
24
|
+
global: boolean;
|
|
25
|
+
env: NodeJS.ProcessEnv;
|
|
26
|
+
}): string;
|
|
27
|
+
/** Merge the Atlas server into a JSON MCP config. Pure, for tests. */
|
|
28
|
+
export declare function mergeJsonConfig(existing: string | null, client: McpClient): {
|
|
29
|
+
text: string;
|
|
30
|
+
status: InstallResult['status'];
|
|
31
|
+
};
|
|
32
|
+
/** Append the Atlas server to Codex's TOML config, unless one is already there. Pure, for tests. */
|
|
33
|
+
export declare function mergeCodexToml(existing: string | null): {
|
|
34
|
+
text: string;
|
|
35
|
+
status: InstallResult['status'];
|
|
36
|
+
};
|
|
37
|
+
export declare function mcp(ctx: RunContext, args: ParsedArgs): Promise<number>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MCP_CLIENTS = exports.MCP_SERVER_NAME = void 0;
|
|
4
|
+
exports.mcpConfigPath = mcpConfigPath;
|
|
5
|
+
exports.mergeJsonConfig = mergeJsonConfig;
|
|
6
|
+
exports.mergeCodexToml = mergeCodexToml;
|
|
7
|
+
exports.mcp = mcp;
|
|
8
|
+
const node_fs_1 = require("node:fs");
|
|
9
|
+
const node_os_1 = require("node:os");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const args_1 = require("../args");
|
|
12
|
+
const errors_1 = require("../errors");
|
|
13
|
+
const output_1 = require("../output");
|
|
14
|
+
const shared_1 = require("./shared");
|
|
15
|
+
/**
|
|
16
|
+
* `atlas mcp install --cursor | --claude-code | --codex | --vscode` — add the
|
|
17
|
+
* Atlas MCP server to an AI coding agent's config, so the agent can search and
|
|
18
|
+
* read the Atlas docs while it works.
|
|
19
|
+
*
|
|
20
|
+
* The server runs as `npx -y @atlasauth/mcp`. No key is written: without
|
|
21
|
+
* `ATLAS_SECRET_KEY` it serves only the read-only docs tools, which is what a
|
|
22
|
+
* coding agent needs. Existing servers in the file are kept; an existing
|
|
23
|
+
* `atlas` entry is replaced (or, in Codex's TOML, left alone and reported).
|
|
24
|
+
*/
|
|
25
|
+
exports.MCP_SERVER_NAME = 'atlas';
|
|
26
|
+
const COMMAND = 'npx';
|
|
27
|
+
const ARGS = ['-y', '@atlasauth/mcp'];
|
|
28
|
+
exports.MCP_CLIENTS = ['cursor', 'claude-code', 'codex', 'vscode'];
|
|
29
|
+
/** Where each client keeps its MCP config. Project files go under `dir`. */
|
|
30
|
+
function mcpConfigPath(client, opts) {
|
|
31
|
+
const home = opts.env.HOME || (0, node_os_1.homedir)();
|
|
32
|
+
switch (client) {
|
|
33
|
+
case 'cursor':
|
|
34
|
+
return opts.global ? (0, node_path_1.join)(home, '.cursor', 'mcp.json') : (0, node_path_1.join)(opts.dir, '.cursor', 'mcp.json');
|
|
35
|
+
case 'claude-code':
|
|
36
|
+
// Project scope: a checked-in `.mcp.json` that Claude Code offers to the whole team.
|
|
37
|
+
return (0, node_path_1.join)(opts.dir, '.mcp.json');
|
|
38
|
+
case 'vscode':
|
|
39
|
+
return (0, node_path_1.join)(opts.dir, '.vscode', 'mcp.json');
|
|
40
|
+
case 'codex':
|
|
41
|
+
return (0, node_path_1.join)(opts.env.CODEX_HOME || (0, node_path_1.join)(home, '.codex'), 'config.toml');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Merge the Atlas server into a JSON MCP config. Pure, for tests. */
|
|
45
|
+
function mergeJsonConfig(existing, client) {
|
|
46
|
+
let doc = {};
|
|
47
|
+
if (existing && existing.trim()) {
|
|
48
|
+
try {
|
|
49
|
+
const parsed = JSON.parse(existing);
|
|
50
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed))
|
|
51
|
+
throw new Error('not an object');
|
|
52
|
+
doc = parsed;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
throw new errors_1.CliError('The existing MCP config is not valid JSON. Fix or move it, then run this again; it was not changed.');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// VS Code calls the map `servers` and wants an explicit transport type.
|
|
59
|
+
const key = client === 'vscode' ? 'servers' : 'mcpServers';
|
|
60
|
+
const entry = client === 'vscode' ? { type: 'stdio', command: COMMAND, args: ARGS } : { command: COMMAND, args: ARGS };
|
|
61
|
+
const servers = (typeof doc[key] === 'object' && doc[key] !== null ? doc[key] : {});
|
|
62
|
+
const before = servers[exports.MCP_SERVER_NAME];
|
|
63
|
+
const status = before === undefined ? 'added' : JSON.stringify(before) === JSON.stringify(entry) ? 'unchanged' : 'updated';
|
|
64
|
+
doc[key] = { ...servers, [exports.MCP_SERVER_NAME]: entry };
|
|
65
|
+
return { text: `${JSON.stringify(doc, null, 2)}\n`, status };
|
|
66
|
+
}
|
|
67
|
+
/** Append the Atlas server to Codex's TOML config, unless one is already there. Pure, for tests. */
|
|
68
|
+
function mergeCodexToml(existing) {
|
|
69
|
+
const current = existing ?? '';
|
|
70
|
+
if (/^\s*\[mcp_servers\.(atlas|"atlas")\]\s*$/m.test(current))
|
|
71
|
+
return { text: current, status: 'unchanged' };
|
|
72
|
+
const block = `[mcp_servers.${exports.MCP_SERVER_NAME}]\ncommand = "${COMMAND}"\nargs = [${ARGS.map((a) => JSON.stringify(a)).join(', ')}]\n`;
|
|
73
|
+
const sep = current === '' ? '' : current.endsWith('\n\n') ? '' : current.endsWith('\n') ? '\n' : '\n\n';
|
|
74
|
+
return { text: `${current}${sep}${block}`, status: 'added' };
|
|
75
|
+
}
|
|
76
|
+
async function mcp(ctx, args) {
|
|
77
|
+
const sub = args.positionals[1];
|
|
78
|
+
if (sub !== 'install')
|
|
79
|
+
throw new errors_1.CliError("Usage: atlas mcp install --cursor | --claude-code | --codex | --vscode");
|
|
80
|
+
const chosen = exports.MCP_CLIENTS.filter((c) => args.values[c] === true);
|
|
81
|
+
if (chosen.length === 0) {
|
|
82
|
+
throw new errors_1.CliError('Choose at least one client: --cursor, --claude-code, --codex or --vscode.');
|
|
83
|
+
}
|
|
84
|
+
const dir = (0, node_path_1.resolve)((0, args_1.str)(args.values, 'dir') ?? process.cwd());
|
|
85
|
+
const global = args.values.global === true;
|
|
86
|
+
const results = [];
|
|
87
|
+
for (const client of chosen) {
|
|
88
|
+
const path = mcpConfigPath(client, { dir, global, env: ctx.env });
|
|
89
|
+
const existing = (0, node_fs_1.existsSync)(path) ? (0, node_fs_1.readFileSync)(path, 'utf8') : null;
|
|
90
|
+
const merged = client === 'codex' ? mergeCodexToml(existing) : mergeJsonConfig(existing, client);
|
|
91
|
+
if (merged.status !== 'unchanged') {
|
|
92
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(path), { recursive: true });
|
|
93
|
+
(0, node_fs_1.writeFileSync)(path, merged.text);
|
|
94
|
+
}
|
|
95
|
+
results.push({ client, path, status: merged.status });
|
|
96
|
+
}
|
|
97
|
+
if ((0, shared_1.wantsJson)(args.values))
|
|
98
|
+
(0, output_1.printJson)(ctx.io, { server: exports.MCP_SERVER_NAME, command: [COMMAND, ...ARGS].join(' '), results });
|
|
99
|
+
else {
|
|
100
|
+
for (const r of results) {
|
|
101
|
+
const verb = r.status === 'unchanged' ? 'already set up in' : r.status === 'updated' ? 'updated in' : 'added to';
|
|
102
|
+
ctx.io.out(`${r.client}: Atlas MCP server ${verb} ${r.path}`);
|
|
103
|
+
}
|
|
104
|
+
ctx.io.out('Restart the client (or reload its MCP servers). It can now search and read the Atlas docs.');
|
|
105
|
+
}
|
|
106
|
+
return 0;
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=mcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":";;;AAkCA,sCAaC;AAGD,0CAoBC;AAGD,wCAMC;AAED,kBAgCC;AAjHD,qCAA6E;AAC7E,qCAAkC;AAClC,yCAAmD;AACnD,kCAA+C;AAE/C,sCAAqC;AACrC,sCAAsC;AACtC,qCAAqC;AAErC;;;;;;;;;GASG;AAEU,QAAA,eAAe,GAAG,OAAO,CAAC;AACvC,MAAM,OAAO,GAAG,KAAK,CAAC;AACtB,MAAM,IAAI,GAAG,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;AAEzB,QAAA,WAAW,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC;AASjF,4EAA4E;AAC5E,SAAgB,aAAa,CAAC,MAAiB,EAAE,IAA8D;IAC7G,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,IAAA,iB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AAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;YACjH,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,MAAM,sBAAsB,IAAI,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;QAChE,CAAC;QACD,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,4FAA4F,CAAC,CAAC;IAC3G,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ParsedArgs } from '../args';
|
|
2
|
+
import type { RunContext } from '../context';
|
|
3
|
+
/**
|
|
4
|
+
* `atlas migrate code --from <vendor> [path]` — rewrite an app's auth code onto
|
|
5
|
+
* Atlas (Clerk, Auth.js/NextAuth, Supabase Auth, Auth0, Better Auth).
|
|
6
|
+
*
|
|
7
|
+
* Safe by default: without `--yes` it is a dry run that prints the diff of every
|
|
8
|
+
* file it would change plus a report of what it could not rewrite (file:line).
|
|
9
|
+
* `--yes` writes the changes. Running it again over migrated code changes nothing.
|
|
10
|
+
* Users move separately, with `atlas import --from <vendor>`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function migrate(ctx: RunContext, args: ParsedArgs): Promise<number>;
|