@drsamonline/cli 0.12.6 → 0.12.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/cli.js +4 -14
- package/src/commands-extra.js +1 -1
- package/src/onboarding.js +3 -3
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -17,7 +17,7 @@ import { stdin, stdout } from 'node:process';
|
|
|
17
17
|
import { dirname, join, resolve } from 'node:path';
|
|
18
18
|
import { fileURLToPath } from 'node:url';
|
|
19
19
|
import { createGateway, loadEnvFile } from '@drsamonline/gateway';
|
|
20
|
-
import { auditConfig, defaultConfigPath, hashApiKey, normalizeConfig, providerHasCredentials, sanitizeConfig, suiHome, INVARIANTS } from '@drsamonline/core';
|
|
20
|
+
import { auditConfig, defaultConfigPath, hashApiKey, normalizeConfig, providerHasCredentials, runAs, sanitizeConfig, suiHome, INVARIANTS } from '@drsamonline/core';
|
|
21
21
|
import { runInit } from './onboarding.js';
|
|
22
22
|
import { detectTools, writeToolConfig } from './tools.js';
|
|
23
23
|
import { applyImport, diffImport, readMigrationSource, smokeTest } from './migrate.js';
|
|
@@ -34,19 +34,9 @@ const HERE_DIR = dirname(fileURLToPath(import.meta.url));
|
|
|
34
34
|
* anyway sends people to a command that fails — and the failure looks like a
|
|
35
35
|
* broken install rather than an unpublished package.
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// reliable command is the package name — not `sui`, which is a bin name and not
|
|
41
|
-
// something `npx` can resolve. Printing `npx sui` sent people to a command that
|
|
42
|
-
// cannot work, and it did so again the moment the package was renamed.
|
|
43
|
-
if (/node_modules/.test(invoked)) {
|
|
44
|
-
const pkg = JSON.parse(readFileSync(join(HERE_DIR, '..', 'package.json'), 'utf8'));
|
|
45
|
-
return `npx ${pkg.name}`;
|
|
46
|
-
}
|
|
47
|
-
if (!/apps[\\/]cli[\\/]bin/.test(invoked)) return 'sui';
|
|
48
|
-
return process.platform === 'win32' ? '.\\sui.cmd' : './sui';
|
|
49
|
-
})();
|
|
37
|
+
// One definition, in core, so the CLI and the errors it throws cannot disagree
|
|
38
|
+
// about what to type next.
|
|
39
|
+
const RUN_AS = runAs();
|
|
50
40
|
|
|
51
41
|
const VERSION = (() => {
|
|
52
42
|
// The CLI's own manifest, not the repository root: from a registry install there
|
package/src/commands-extra.js
CHANGED
|
@@ -254,7 +254,7 @@ async function readSecret(question) {
|
|
|
254
254
|
|
|
255
255
|
export function cmdConfig(flags, args) {
|
|
256
256
|
const path = flags.config ?? defaultConfigPath();
|
|
257
|
-
if (!path) throw new ConfigError(
|
|
257
|
+
if (!path) throw new ConfigError(`No config found. Run \`${runAs()} init\` first.`);
|
|
258
258
|
const raw = JSON.parse(readFileSync(path, 'utf8'));
|
|
259
259
|
const sub = args[0] ?? 'show';
|
|
260
260
|
const dotted = args[1];
|
package/src/onboarding.js
CHANGED
|
@@ -10,7 +10,7 @@ import { copyFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
|
10
10
|
import { join, dirname } from 'node:path';
|
|
11
11
|
import { fileURLToPath } from 'node:url';
|
|
12
12
|
import { createGateway, loadEnvFile } from '@drsamonline/gateway';
|
|
13
|
-
import { providerHasCredentials, suiHome } from '@drsamonline/core';
|
|
13
|
+
import { providerHasCredentials, suiHome, runAs } from '@drsamonline/core';
|
|
14
14
|
import { detectTools, writeToolConfig } from './tools.js';
|
|
15
15
|
|
|
16
16
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
@@ -150,7 +150,7 @@ export async function runInit(opts = {}) {
|
|
|
150
150
|
roundTrip = { ok: false, combo, error: /** @type {any} */ (err).message, ms: Date.now() - started };
|
|
151
151
|
out(` failed: ${roundTrip.error}`);
|
|
152
152
|
out('');
|
|
153
|
-
out('Nothing was marked ready. Fix the problem above and run
|
|
153
|
+
out('Nothing was marked ready. Fix the problem above and run `${runAs()} init` again.');
|
|
154
154
|
return { ok: false, configPath, config, roundTrip, tools };
|
|
155
155
|
}
|
|
156
156
|
|
|
@@ -184,7 +184,7 @@ export async function runInit(opts = {}) {
|
|
|
184
184
|
}
|
|
185
185
|
} else if (detected.length) {
|
|
186
186
|
out('');
|
|
187
|
-
out('Next:
|
|
187
|
+
out('Next: `${runAs()} tools` to point one of these at the gateway.');
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
return { ok: true, configPath, config, roundTrip, endpoint, tools, toolResult, demo };
|