@atlasauth/cli 0.6.0 → 0.8.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 +21 -0
- package/README.md +5 -0
- package/dist/args.d.ts +34 -0
- package/dist/args.js +14 -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/config.d.ts +41 -1
- package/dist/commands/config.js +115 -26
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/import-better-auth.d.ts +3 -0
- package/dist/commands/import-better-auth.js +164 -0
- package/dist/commands/import-better-auth.js.map +1 -0
- package/dist/commands/import.js +7 -0
- package/dist/commands/import.js.map +1 -1
- 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/migrate.d.ts +12 -0
- package/dist/commands/migrate.js +104 -0
- package/dist/commands/migrate.js.map +1 -0
- package/dist/context.d.ts +9 -1
- package/dist/context.js.map +1 -1
- package/dist/help.d.ts +1 -1
- package/dist/help.js +102 -2
- package/dist/help.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/migrate/better-auth/integration.d.ts +59 -0
- package/dist/migrate/better-auth/integration.js +81 -0
- package/dist/migrate/better-auth/integration.js.map +1 -0
- package/dist/migrate/better-auth/orchestrator.d.ts +43 -0
- package/dist/migrate/better-auth/orchestrator.js +525 -0
- package/dist/migrate/better-auth/orchestrator.js.map +1 -0
- package/dist/migrate/better-auth/output.d.ts +20 -0
- package/dist/migrate/better-auth/output.js +146 -0
- package/dist/migrate/better-auth/output.js.map +1 -0
- package/dist/migrate/better-auth/translate.d.ts +77 -0
- package/dist/migrate/better-auth/translate.js +1989 -0
- package/dist/migrate/better-auth/translate.js.map +1 -0
- package/dist/run.js +4 -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,8BAG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IAAI,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,MAAM,CAAC;YAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACnG,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,wCAAwC,CAAC,CAAC;IAC1G,CAAC;IACD,OAAO,KAAK,CAAC;AACf,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>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrate = migrate;
|
|
4
|
+
const node_fs_1 = require("node:fs");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
6
|
+
const upgrade_1 = require("@atlasauth/upgrade");
|
|
7
|
+
const args_1 = require("../args");
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
const output_1 = require("../output");
|
|
10
|
+
const shared_1 = require("./shared");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
|
+
const orchestrator_1 = require("../migrate/better-auth/orchestrator");
|
|
13
|
+
const output_2 = require("../migrate/better-auth/output");
|
|
14
|
+
const translate_1 = require("../migrate/better-auth/translate");
|
|
15
|
+
/**
|
|
16
|
+
* `atlas migrate code --from <vendor> [path]` — rewrite an app's auth code onto
|
|
17
|
+
* Atlas (Clerk, Auth.js/NextAuth, Supabase Auth, Auth0, Better Auth).
|
|
18
|
+
*
|
|
19
|
+
* Safe by default: without `--yes` it is a dry run that prints the diff of every
|
|
20
|
+
* file it would change plus a report of what it could not rewrite (file:line).
|
|
21
|
+
* `--yes` writes the changes. Running it again over migrated code changes nothing.
|
|
22
|
+
* Users move separately, with `atlas import --from <vendor>`.
|
|
23
|
+
*/
|
|
24
|
+
async function migrate(ctx, args) {
|
|
25
|
+
const sub = args.positionals[1];
|
|
26
|
+
if (sub === 'better-auth') {
|
|
27
|
+
if (args.positionals[2] === 'config')
|
|
28
|
+
return betterAuthConfig(ctx, args, args.positionals[3]);
|
|
29
|
+
return (0, orchestrator_1.migrateBetterAuth)(ctx, args, args.positionals[2]);
|
|
30
|
+
}
|
|
31
|
+
if (sub !== 'code') {
|
|
32
|
+
throw new errors_1.CliError(sub ? `Unknown subcommand 'migrate ${sub}'. Try: code, better-auth.` : 'migrate needs a subcommand: code, better-auth.');
|
|
33
|
+
}
|
|
34
|
+
const raw = (0, args_1.str)(args.values, 'from');
|
|
35
|
+
const vendor = (0, upgrade_1.resolveVendor)(raw);
|
|
36
|
+
if (!vendor) {
|
|
37
|
+
throw new errors_1.CliError(raw
|
|
38
|
+
? `Unknown --from '${raw}'. Use one of: ${upgrade_1.MIGRATE_VENDORS.join(', ')}.`
|
|
39
|
+
: `migrate code needs --from <${upgrade_1.MIGRATE_VENDORS.join('|')}>.`);
|
|
40
|
+
}
|
|
41
|
+
const target = (0, node_path_1.resolve)(args.positionals[2] ?? process.cwd());
|
|
42
|
+
if (!(0, node_fs_1.existsSync)(target))
|
|
43
|
+
throw new errors_1.CliError(`Path not found: ${target}`);
|
|
44
|
+
const write = args.values.yes === true && args.values['dry-run'] !== true;
|
|
45
|
+
const result = (0, upgrade_1.runMigration)(target, { from: vendor, write });
|
|
46
|
+
if ((0, shared_1.wantsJson)(args.values)) {
|
|
47
|
+
(0, output_1.printJson)(ctx.io, {
|
|
48
|
+
object: 'code_migration',
|
|
49
|
+
vendor: result.vendor,
|
|
50
|
+
written: write,
|
|
51
|
+
env_style: result.envStyle,
|
|
52
|
+
files_scanned: result.filesScanned,
|
|
53
|
+
files_changed: result.filesChanged,
|
|
54
|
+
rewrites: result.rewrites,
|
|
55
|
+
changes: result.changes.map((c) => ({ path: c.path, diff: (0, upgrade_1.unifiedDiff)(c.before, c.after, c.path) })),
|
|
56
|
+
manual: result.manual,
|
|
57
|
+
packages: result.packages,
|
|
58
|
+
env_to_set: result.envToSet,
|
|
59
|
+
});
|
|
60
|
+
return 0;
|
|
61
|
+
}
|
|
62
|
+
for (const change of result.changes) {
|
|
63
|
+
if (write)
|
|
64
|
+
ctx.io.out(`updated ${change.path}`);
|
|
65
|
+
else {
|
|
66
|
+
ctx.io.out((0, upgrade_1.unifiedDiff)(change.before, change.after, change.path));
|
|
67
|
+
ctx.io.out('');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
for (const line of (0, upgrade_1.formatMigration)(result, { written: write }))
|
|
71
|
+
ctx.io.out(line);
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* `atlas migrate better-auth config [path]` — offline: read the app's Better Auth
|
|
76
|
+
* setup statically and write the Atlas config-as-code files plus the report.
|
|
77
|
+
* Needs no login; nothing is sent anywhere.
|
|
78
|
+
*/
|
|
79
|
+
async function betterAuthConfig(ctx, args, pathArg) {
|
|
80
|
+
const target = (0, node_path_1.resolve)(pathArg ?? process.cwd());
|
|
81
|
+
if (!(0, node_fs_1.existsSync)(target))
|
|
82
|
+
throw new errors_1.CliError(`Path not found: ${target}`);
|
|
83
|
+
const entry = (0, args_1.str)(args.values, 'entry');
|
|
84
|
+
const analysis = (0, upgrade_1.analyzeBetterAuth)(target, entry ? { entry } : {});
|
|
85
|
+
if (!analysis.instances.length) {
|
|
86
|
+
throw new errors_1.CliError(`No betterAuth({...}) call found under ${target}. Point at the app folder, or pass --entry <file>.`);
|
|
87
|
+
}
|
|
88
|
+
const translation = (0, translate_1.translateBetterAuth)(analysis);
|
|
89
|
+
const format = (0, config_1.resolveFormat)(args.values);
|
|
90
|
+
const root = (0, node_fs_1.statSync)(target).isDirectory() ? target : (0, node_path_1.dirname)(target);
|
|
91
|
+
const dir = (0, node_path_1.resolve)(root, (0, args_1.str)(args.values, 'dir') ?? 'atlas-migrate/config');
|
|
92
|
+
const written = (0, output_2.writeTranslation)(translation, dir, format);
|
|
93
|
+
if ((0, shared_1.wantsJson)(args.values)) {
|
|
94
|
+
(0, output_1.printJson)(ctx.io, { ...(0, output_2.reportJson)(translation), config_dir: dir, files: written });
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
for (const line of (0, output_2.summaryLines)(translation, dir, written))
|
|
98
|
+
ctx.io.out(line);
|
|
99
|
+
ctx.io.out('');
|
|
100
|
+
ctx.io.out(`Review the files, then apply them with: atlas config import --dir ${dir} --dry-run`);
|
|
101
|
+
ctx.io.out('Or run the whole program: atlas migrate better-auth');
|
|
102
|
+
return 0;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":";;AAsBA,0BAoDC;AA1ED,qCAA+C;AAC/C,yCAA6C;AAC7C,gDAAmI;AACnI,kCAA+C;AAE/C,sCAAqC;AACrC,sCAAsC;AACtC,qCAAqC;AACrC,qCAAyC;AACzC,sEAAwE;AACxE,0DAA2F;AAC3F,gEAAuE;AAEvE;;;;;;;;GAQG;AACI,KAAK,UAAU,OAAO,CAAC,GAAe,EAAE,IA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C,CAAC,IAAA,mBAAO,EAAC,MAAM,CAAC,CAAC;IACvE,MAAM,GAAG,GAAG,IAAA,mBAAO,EAAC,IAAI,EAAE,IAAA,UAAG,EAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,sBAAsB,CAAC,CAAC;IAC7E,MAAM,OAAO,GAAG,IAAA,yBAAgB,EAAC,WAAW,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;IAC3D,IAAI,IAAA,kBAAS,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAC3B,IAAA,kBAAS,EAAC,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,IAAA,mBAAU,EAAC,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC;QACnF,OAAO,CAAC,CAAC;IACX,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,IAAA,qBAAY,EAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC;QAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC7E,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACf,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,qEAAqE,GAAG,YAAY,CAAC,CAAC;IACjG,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,qDAAqD,CAAC,CAAC;IAClE,OAAO,CAAC,CAAC;AACX,CAAC"}
|
package/dist/context.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { type Prompter } from './prompt';
|
|
|
9
9
|
* enforces — that the command set maps only onto namespaces that really exist,
|
|
10
10
|
* and it keeps the fake a test injects small (five namespaces, not forty).
|
|
11
11
|
*/
|
|
12
|
-
export type ManagementClient = Pick<AtlasClient, 'users' | 'organizations' | 'apiKeys' | 'webhooks' | 'sessions' | 'actions'>;
|
|
12
|
+
export type ManagementClient = Pick<AtlasClient, 'users' | 'organizations' | 'apiKeys' | 'webhooks' | 'sessions' | 'actions' | 'actionGallery' | 'actionTemplates'>;
|
|
13
13
|
/**
|
|
14
14
|
* Everything a command touches the outside world through, in one injectable
|
|
15
15
|
* bag. Production wires the real IO/config/prompt/client; every test builds
|
|
@@ -49,6 +49,14 @@ export interface RunContext {
|
|
|
49
49
|
fetch?: typeof fetch;
|
|
50
50
|
/** Wait between polls (`--wait`). Optional; defaults to a real timer. */
|
|
51
51
|
sleep?: (ms: number) => Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Run a program with inherited stdio and return its exit code (`atlas migrate
|
|
54
|
+
* better-auth --run-export` runs the exporter in the app). Optional; defaults
|
|
55
|
+
* to a real child process.
|
|
56
|
+
*/
|
|
57
|
+
exec?: (cmd: string, args: string[], opts: {
|
|
58
|
+
cwd: string;
|
|
59
|
+
}) => Promise<number>;
|
|
52
60
|
}
|
|
53
61
|
/**
|
|
54
62
|
* The production context, with any piece overridable. Tests call this with a
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAgEA,wCAWC;AA3ED,qCAAuC;AACvC,gDAAyE;AACzE,qCAAgF;AAChF,+CAAkE;AAClE,6BAA0C;AAC1C,qCAA0D;AAsD1D;;;;GAIG;AACH,SAAgB,cAAc,CAAC,YAAiC,EAAE;IAChE,OAAO;QACL,EAAE,EAAE,IAAA,cAAS,GAAE;QACf,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,MAAM,EAAE,IAAI,wBAAe,CAAC,IAAA,0BAAiB,GAAE,CAAC;QAChD,MAAM,EAAE,IAAA,wBAAe,GAAE;QACzB,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAA,2BAAiB,EAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAC/E,QAAQ,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAA,8BAAgB,EAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;QAC5E,QAAQ,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAA,sBAAY,EAAC,IAAI,EAAE,MAAM,CAAC;QAC9C,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
package/dist/help.d.ts
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* out of the handlers so the dispatch code stays about control flow and the
|
|
4
4
|
* copy can be read (and kept consistent) in one place.
|
|
5
5
|
*/
|
|
6
|
-
export declare const TOP_HELP = "atlas \u2014 manage an Atlas instance from the terminal\n\nUsage: atlas <command> [subcommand] [arguments] [options]\n\nCommands:\n login Authenticate and store a profile credential\n logout Remove a stored profile credential\n whoami Show the active profile and instance\n users list|get|create|delete\n orgs list|get|members\n api-keys list|create|revoke\n webhooks list|create\n sessions revoke\n config export|import Config-as-code: round-trip the instance's config\n actions list|deploy|test|logs\n init Create or complete an app's setup (idempotent); secrets to 0600 files\n preflight Check an instance's setup; non-zero exit on errors (for CI)\n env Print deploy variables: public values + secret file paths\n client rotate Rotate an OAuth client secret straight into its file\n referrals connect|backfill|status\n Connect a referral platform, backfill, check the connection\n import --from <vendor> <file>\n Move users from Auth0, Clerk, Supabase, Firebase, Cognito,\n Auth.js, WorkOS or Better Auth (resumable; --dry-run first)\n mcp install Add the Atlas MCP server (docs search) to Cursor, Claude Code,\n Codex or VS Code\n\nGlobal options:\n --profile <name> Use a named profile (default: active, else \"default\")\n --json Emit raw JSON instead of a human table\n --limit <n> Page size for list commands that paginate\n --starting-after <cursor> Pagination cursor (from a prior page's hint)\n -h, --help Show this help, or help for a command\n -v, --version Print the version\n\nEnvironment overrides:\n ATLAS_SECRET_KEY Secret key to use instead of the stored one\n ATLAS_API_URL API URL to use instead of the stored one\n ATLAS_PLATFORM_KEY Platform key (psk_) for atlas init\n REFERALLY_BASE_URL Referalli base URL for atlas referrals connect\n REFERALLY_API_KEY Referalli merchant key for atlas referrals connect (never stored)\n\nSecrets: a command that receives a secret writes it to a 0600 file under\n~/.config/<product>/ and prints only the path. --print-secret prints it instead.\n\nRun 'atlas <command> --help' for command-specific help.";
|
|
6
|
+
export declare const TOP_HELP = "atlas \u2014 manage an Atlas instance from the terminal\n\nUsage: atlas <command> [subcommand] [arguments] [options]\n\nCommands:\n login Authenticate and store a profile credential\n logout Remove a stored profile credential\n whoami Show the active profile and instance\n users list|get|create|delete\n orgs list|get|members\n api-keys list|create|revoke\n webhooks list|create\n sessions revoke\n config export|import Config-as-code: round-trip the instance's config\n actions list|deploy|test|logs|gallery|show|install|installs|update|publish\n init Create or complete an app's setup (idempotent); secrets to 0600 files\n preflight Check an instance's setup; non-zero exit on errors (for CI)\n env Print deploy variables: public values + secret file paths\n client rotate Rotate an OAuth client secret straight into its file\n referrals connect|backfill|status\n Connect a referral platform, backfill, check the connection\n import --from <vendor> <file>\n Move users from Auth0, Clerk, Supabase, Firebase, Cognito,\n Auth.js, WorkOS or Better Auth (resumable; --dry-run first)\n migrate code --from <vendor> [path]\n Rewrite an app's auth code onto Atlas (Clerk, Auth.js,\n Supabase, Auth0, Better Auth); a dry run with a diff unless --yes\n migrate better-auth [path] Move a Better Auth app to Atlas end to end: config, users,\n sessions and code, resumable (--dry-run, --resume, --yes)\n migrate better-auth config [path]\n Translate the app's betterAuth({...}) options into Atlas\n config files plus a report (offline)\n info [path] Print the environment for a support ticket (versions, SDKs,\n instance, API latency, preflight); secrets redacted\n mcp install Add the Atlas MCP server (docs search) to Cursor, Claude Code,\n Codex or VS Code\n\nGlobal options:\n --profile <name> Use a named profile (default: active, else \"default\")\n --json Emit raw JSON instead of a human table\n --limit <n> Page size for list commands that paginate\n --starting-after <cursor> Pagination cursor (from a prior page's hint)\n -h, --help Show this help, or help for a command\n -v, --version Print the version\n\nEnvironment overrides:\n ATLAS_SECRET_KEY Secret key to use instead of the stored one\n ATLAS_API_URL API URL to use instead of the stored one\n ATLAS_PLATFORM_KEY Platform key (psk_) for atlas init\n REFERALLY_BASE_URL Referalli base URL for atlas referrals connect\n REFERALLY_API_KEY Referalli merchant key for atlas referrals connect (never stored)\n\nSecrets: a command that receives a secret writes it to a 0600 file under\n~/.config/<product>/ and prints only the path. --print-secret prints it instead.\n\nRun 'atlas <command> --help' for command-specific help.";
|
|
7
7
|
/** Per-command help, keyed by the resource word. */
|
|
8
8
|
export declare const COMMAND_HELP: Record<string, string>;
|