reply-cli 0.1.2 → 0.3.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/README.md +99 -393
- package/dist/api/headers.d.ts +4 -0
- package/dist/api/headers.js +13 -0
- package/dist/api/headers.js.map +1 -0
- package/dist/auth/oauth-flow.d.ts +38 -0
- package/dist/auth/oauth-flow.js +193 -0
- package/dist/auth/oauth-flow.js.map +1 -0
- package/dist/auth/pkce.d.ts +9 -0
- package/dist/auth/pkce.js +19 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/request-identity.d.ts +16 -0
- package/dist/auth/request-identity.js +67 -0
- package/dist/auth/request-identity.js.map +1 -0
- package/dist/auth/resolve.d.ts +23 -0
- package/dist/auth/resolve.js +55 -0
- package/dist/auth/resolve.js.map +1 -0
- package/dist/auth/status.d.ts +19 -0
- package/dist/auth/status.js +27 -0
- package/dist/auth/status.js.map +1 -0
- package/dist/auth/token.d.ts +29 -0
- package/dist/auth/token.js +39 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/commands/api.d.ts +19 -0
- package/dist/commands/api.js +137 -0
- package/dist/commands/api.js.map +1 -0
- package/dist/commands/auth.d.ts +21 -0
- package/dist/commands/auth.js +266 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/authed.d.ts +13 -0
- package/dist/commands/authed.js +20 -0
- package/dist/commands/authed.js.map +1 -0
- package/dist/commands/profile.d.ts +31 -0
- package/dist/commands/profile.js +348 -0
- package/dist/commands/profile.js.map +1 -0
- package/dist/commands/team.d.ts +17 -0
- package/dist/commands/team.js +146 -0
- package/dist/commands/team.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +80 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +15 -0
- package/dist/context.js +17 -0
- package/dist/context.js.map +1 -0
- package/dist/credentials/file-store.d.ts +13 -0
- package/dist/credentials/file-store.js +88 -0
- package/dist/credentials/file-store.js.map +1 -0
- package/dist/credentials/types.d.ts +25 -0
- package/dist/credentials/types.js +3 -0
- package/dist/credentials/types.js.map +1 -0
- package/dist/index.js +104 -41
- package/dist/index.js.map +1 -1
- package/dist/profile.d.ts +51 -0
- package/dist/profile.js +295 -0
- package/dist/profile.js.map +1 -0
- package/dist/teams.d.ts +14 -0
- package/dist/teams.js +103 -0
- package/dist/teams.js.map +1 -0
- package/dist/utils/client.d.ts +21 -9
- package/dist/utils/client.js +136 -88
- package/dist/utils/client.js.map +1 -1
- package/dist/utils/errors.d.ts +47 -0
- package/dist/utils/errors.js +86 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/output.d.ts +7 -10
- package/dist/utils/output.js +39 -71
- package/dist/utils/output.js.map +1 -1
- package/package.json +10 -25
- package/dist/commands/accounts.d.ts +0 -6
- package/dist/commands/accounts.js +0 -62
- package/dist/commands/accounts.js.map +0 -1
- package/dist/commands/contacts.d.ts +0 -20
- package/dist/commands/contacts.js +0 -321
- package/dist/commands/contacts.js.map +0 -1
- package/dist/commands/import.d.ts +0 -6
- package/dist/commands/import.js +0 -137
- package/dist/commands/import.js.map +0 -1
- package/dist/commands/schedules.d.ts +0 -9
- package/dist/commands/schedules.js +0 -119
- package/dist/commands/schedules.js.map +0 -1
- package/dist/commands/sequence-contacts.d.ts +0 -8
- package/dist/commands/sequence-contacts.js +0 -141
- package/dist/commands/sequence-contacts.js.map +0 -1
- package/dist/commands/sequences-stats.d.ts +0 -7
- package/dist/commands/sequences-stats.js +0 -183
- package/dist/commands/sequences-stats.js.map +0 -1
- package/dist/commands/sequences.d.ts +0 -12
- package/dist/commands/sequences.js +0 -225
- package/dist/commands/sequences.js.map +0 -1
- package/dist/utils/auth.d.ts +0 -2
- package/dist/utils/auth.js +0 -33
- package/dist/utils/auth.js.map +0 -1
- package/dist/utils/command.d.ts +0 -11
- package/dist/utils/command.js +0 -20
- package/dist/utils/command.js.map +0 -1
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CredentialStore, Oauth_record } from './credentials/types';
|
|
2
|
+
type Cli_context = {
|
|
3
|
+
profile: string;
|
|
4
|
+
authority: string;
|
|
5
|
+
api_base: string;
|
|
6
|
+
key: string;
|
|
7
|
+
team_id?: number;
|
|
8
|
+
store: CredentialStore;
|
|
9
|
+
refresh: (record: Oauth_record) => Promise<Oauth_record>;
|
|
10
|
+
};
|
|
11
|
+
declare const build_context: (opts?: {
|
|
12
|
+
profile?: string;
|
|
13
|
+
}) => Cli_context;
|
|
14
|
+
export { build_context };
|
|
15
|
+
export type { Cli_context };
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.build_context = void 0;
|
|
4
|
+
const profile_1 = require("./profile");
|
|
5
|
+
const file_store_1 = require("./credentials/file-store");
|
|
6
|
+
const oauth_flow_1 = require("./auth/oauth-flow");
|
|
7
|
+
const build_context = (opts = {}) => {
|
|
8
|
+
const p = (0, profile_1.resolve_profile)(opts.profile);
|
|
9
|
+
const store = (0, file_store_1.default_credential_store)();
|
|
10
|
+
const refresh = (record) => (0, oauth_flow_1.refresh_stored)({ authority: p.authority, record });
|
|
11
|
+
return {
|
|
12
|
+
profile: p.name, authority: p.authority, api_base: p.api_base,
|
|
13
|
+
key: p.name, team_id: p.team_id, store, refresh,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
exports.build_context = build_context;
|
|
17
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;AAAA,uCAA0C;AAC1C,yDAAkE;AAClE,kDAAiD;AAgBjD,MAAM,aAAa,GAAG,CAAC,OAA2B,EAAE,EAAc,EAAE;IAChE,MAAM,CAAC,GAAG,IAAA,yBAAe,EAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,KAAK,GAAG,IAAA,qCAAwB,GAAE,CAAC;IACzC,MAAM,OAAO,GAAG,CAAC,MAAoB,EAAwB,EAAE,CAC3D,IAAA,2BAAc,EAAC,EAAC,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,MAAM,EAAC,CAAC,CAAC;IACrD,OAAO;QACH,OAAO,EAAE,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ;QAC7D,GAAG,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO;KAClD,CAAC;AACN,CAAC,CAAC;AAEM,sCAAa"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Credential_record, CredentialStore } from './types';
|
|
2
|
+
declare class FileCredentialStore implements CredentialStore {
|
|
3
|
+
private readonly file;
|
|
4
|
+
constructor(file: string);
|
|
5
|
+
get(key: string): Promise<Credential_record | undefined>;
|
|
6
|
+
set(key: string, record: Credential_record): Promise<void>;
|
|
7
|
+
remove(key: string): Promise<boolean>;
|
|
8
|
+
keys(): Promise<string[]>;
|
|
9
|
+
private read;
|
|
10
|
+
private write;
|
|
11
|
+
}
|
|
12
|
+
declare const default_credential_store: () => CredentialStore;
|
|
13
|
+
export { FileCredentialStore, default_credential_store };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default_credential_store = exports.FileCredentialStore = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const config_1 = require("../config");
|
|
10
|
+
const errors_1 = require("../utils/errors");
|
|
11
|
+
// v1 credential backend: a single JSON file keyed by profile name, written
|
|
12
|
+
// with strict 0600 perms in a 0700 dir (the gh/aws/az plaintext-file model).
|
|
13
|
+
class FileCredentialStore {
|
|
14
|
+
file;
|
|
15
|
+
constructor(file) {
|
|
16
|
+
this.file = file;
|
|
17
|
+
}
|
|
18
|
+
async get(key) {
|
|
19
|
+
return this.read()[key];
|
|
20
|
+
}
|
|
21
|
+
async set(key, record) {
|
|
22
|
+
const map = this.read();
|
|
23
|
+
map[key] = record;
|
|
24
|
+
this.write(map);
|
|
25
|
+
}
|
|
26
|
+
async remove(key) {
|
|
27
|
+
const map = this.read();
|
|
28
|
+
if (!(key in map)) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
delete map[key];
|
|
32
|
+
this.write(map);
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
async keys() {
|
|
36
|
+
return Object.keys(this.read());
|
|
37
|
+
}
|
|
38
|
+
read() {
|
|
39
|
+
let raw;
|
|
40
|
+
try {
|
|
41
|
+
raw = fs_1.default.readFileSync(this.file, 'utf8');
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
if (e.code === 'ENOENT') {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
throw new errors_1.RuntimeError('Could not read the credential store.', {
|
|
48
|
+
code: 'store.read', detail: this.file,
|
|
49
|
+
hint: e.message,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (!raw.trim()) {
|
|
53
|
+
return {};
|
|
54
|
+
}
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = JSON.parse(raw);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
throw new errors_1.RuntimeError('Credential store is corrupt (invalid JSON).', {
|
|
61
|
+
code: 'store.corrupt', detail: this.file,
|
|
62
|
+
hint: 'Delete the file and log in again.',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
66
|
+
throw new errors_1.RuntimeError('Credential store is corrupt (unexpected shape).', {
|
|
67
|
+
code: 'store.corrupt', detail: this.file,
|
|
68
|
+
hint: 'Delete the file and log in again.',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return parsed;
|
|
72
|
+
}
|
|
73
|
+
// Atomic write: temp file created 0600, then renamed into place so the
|
|
74
|
+
// final file is never briefly world-readable and rewrites keep 0600.
|
|
75
|
+
write(map) {
|
|
76
|
+
const dir = path_1.default.dirname(this.file);
|
|
77
|
+
fs_1.default.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
78
|
+
fs_1.default.chmodSync(dir, 0o700);
|
|
79
|
+
const tmp = `${this.file}.${process.pid}.tmp`;
|
|
80
|
+
fs_1.default.writeFileSync(tmp, JSON.stringify(map, null, 2), { mode: 0o600 });
|
|
81
|
+
fs_1.default.chmodSync(tmp, 0o600);
|
|
82
|
+
fs_1.default.renameSync(tmp, this.file);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.FileCredentialStore = FileCredentialStore;
|
|
86
|
+
const default_credential_store = () => new FileCredentialStore((0, config_1.credentials_file)());
|
|
87
|
+
exports.default_credential_store = default_credential_store;
|
|
88
|
+
//# sourceMappingURL=file-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-store.js","sourceRoot":"","sources":["../../src/credentials/file-store.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAoB;AACpB,gDAAwB;AACxB,sCAA2C;AAC3C,4CAA6C;AAK7C,2EAA2E;AAC3E,6EAA6E;AAC7E,MAAM,mBAAmB;IACJ,IAAI,CAAS;IAE9B,YAAY,IAAY;QAEpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QAEjB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GA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AG,GAAmB,EAAE,CAClD,IAAI,mBAAmB,CAAC,IAAA,yBAAgB,GAAE,CAAC,CAAC;AAEnB,4DAAwB"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
type Principal = {
|
|
2
|
+
id?: number;
|
|
3
|
+
username?: string;
|
|
4
|
+
team_id?: number;
|
|
5
|
+
};
|
|
6
|
+
type Oauth_record = {
|
|
7
|
+
type: 'oauth';
|
|
8
|
+
access_token: string;
|
|
9
|
+
refresh_token?: string;
|
|
10
|
+
expires_at: number;
|
|
11
|
+
user?: Principal;
|
|
12
|
+
};
|
|
13
|
+
type Api_key_record = {
|
|
14
|
+
type: 'api_key';
|
|
15
|
+
key: string;
|
|
16
|
+
user?: Principal;
|
|
17
|
+
};
|
|
18
|
+
type Credential_record = Oauth_record | Api_key_record;
|
|
19
|
+
interface CredentialStore {
|
|
20
|
+
get(key: string): Promise<Credential_record | undefined>;
|
|
21
|
+
set(key: string, record: Credential_record): Promise<void>;
|
|
22
|
+
remove(key: string): Promise<boolean>;
|
|
23
|
+
keys(): Promise<string[]>;
|
|
24
|
+
}
|
|
25
|
+
export type { Principal, Oauth_record, Api_key_record, Credential_record, CredentialStore };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/credentials/types.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -3,60 +3,123 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.build_program = void 0;
|
|
5
5
|
const commander_1 = require("commander");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
6
|
+
const config_1 = require("./config");
|
|
7
|
+
const auth_1 = require("./commands/auth");
|
|
8
|
+
const profile_1 = require("./commands/profile");
|
|
9
|
+
const team_1 = require("./commands/team");
|
|
10
|
+
const api_1 = require("./commands/api");
|
|
11
|
+
const errors_1 = require("./utils/errors");
|
|
12
|
+
const output_1 = require("./utils/output");
|
|
13
|
+
// Route every command through commander's throwing mode so usage errors reach
|
|
14
|
+
// our handler and map to exit code 2 (vs 1 for runtime/API failures).
|
|
15
|
+
const set_exit_override = (cmd) => {
|
|
16
|
+
cmd.exitOverride();
|
|
17
|
+
for (const sub of cmd.commands) {
|
|
18
|
+
set_exit_override(sub);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
13
21
|
const build_program = () => {
|
|
14
22
|
const program = new commander_1.Command();
|
|
23
|
+
const PREFIX = config_1.PROGRAM_NAME.toUpperCase();
|
|
15
24
|
program
|
|
16
|
-
.name(
|
|
17
|
-
.description('Command-line interface for Reply.io
|
|
18
|
-
|
|
19
|
-
.
|
|
20
|
-
.option('-
|
|
21
|
-
.option('--
|
|
22
|
-
.option('--
|
|
23
|
-
.option('--
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
program.
|
|
25
|
+
.name(config_1.PROGRAM_NAME)
|
|
26
|
+
.description('Command-line interface for Reply.io — authentication and identity (v1).')
|
|
27
|
+
.version((0, config_1.cli_version)(), '-v, --version')
|
|
28
|
+
.option('-k, --api-key <key>', 'API key (overrides env var and stored credential)')
|
|
29
|
+
.option('-p, --profile <name>', 'Named backend profile (default: prod)')
|
|
30
|
+
.option('--team-id <id>', `Team/workspace to act in (X-TEAM-ID); else ${PREFIX}_TEAM_ID or the profile`)
|
|
31
|
+
.option('--user-id <id>', 'Act as this user id — organization API keys only (X-USER-ID)')
|
|
32
|
+
.option('--user-email <email>', 'Act as this user email — organization API keys only (needs a team id)')
|
|
33
|
+
.option('--json', 'Output compact JSON to stdout')
|
|
34
|
+
.option('--pretty', 'Output indented JSON to stdout')
|
|
35
|
+
.option('--verbose', 'Print the full request/response to stderr, credentials redacted (api)')
|
|
36
|
+
.option('-q, --quiet', 'Suppress progress messages on stderr (warnings and errors still shown)')
|
|
37
|
+
.showHelpAfterError();
|
|
38
|
+
// Apply --quiet before any command action runs, so progress output is
|
|
39
|
+
// silenced for the whole invocation.
|
|
40
|
+
program.hook('preAction', () => { (0, output_1.set_quiet)(program.opts().quiet === true); });
|
|
41
|
+
program.addCommand(auth_1.auth_command);
|
|
42
|
+
program.addCommand(profile_1.profile_command);
|
|
43
|
+
program.addCommand(team_1.team_command);
|
|
44
|
+
program.addCommand(api_1.api_command);
|
|
32
45
|
program.addHelpText('after', `
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
Credential precedence:
|
|
47
|
+
1. --api-key <key> 2. ${PREFIX}_API_KEY env 3. stored credential
|
|
48
|
+
|
|
49
|
+
Profiles (which backend to talk to):
|
|
50
|
+
Precedence: --profile <name> > ${PREFIX}_PROFILE > current profile > default (prod).
|
|
51
|
+
Define your own profiles under "profiles" in the config file, e.g.:
|
|
52
|
+
{ "profiles": { "dev": { "authority": "https://…", "api_base": "https://…" } } }
|
|
53
|
+
Then set one as current so you don't repeat --profile:
|
|
54
|
+
${config_1.PROGRAM_NAME} profile use dev # used until you change it
|
|
55
|
+
${config_1.PROGRAM_NAME} profile list # see all, * marks current
|
|
56
|
+
${config_1.PROGRAM_NAME} profile current
|
|
57
|
+
${config_1.PROGRAM_NAME} profile show [name] # backend, team, auth (no secrets)
|
|
58
|
+
${config_1.PROGRAM_NAME} profile rename <old> <new>
|
|
59
|
+
${config_1.PROGRAM_NAME} profile delete <name> # also removes its stored credential
|
|
60
|
+
${config_1.PROGRAM_NAME} profile unset <name> <field> # clear authority|api_base|team-id
|
|
61
|
+
|
|
62
|
+
Team & acting user (headers):
|
|
63
|
+
--team-id <id> Team/workspace to act in. Precedence: --team-id > ${PREFIX}_TEAM_ID > profile team_id.
|
|
64
|
+
Pin one on a profile: ${config_1.PROGRAM_NAME} profile set <name> --team-id <id>
|
|
65
|
+
--user-id <id> / --user-email <email> Identify the acting user for an ORGANIZATION API key.
|
|
66
|
+
Flag-only (never env, never stored); pass exactly one; --user-email also needs a team id.
|
|
67
|
+
Team commands (see & set the current profile's team):
|
|
68
|
+
${config_1.PROGRAM_NAME} team list # teams you can act in (* marks the profile's)
|
|
69
|
+
${config_1.PROGRAM_NAME} team current # pinned + effective team
|
|
70
|
+
${config_1.PROGRAM_NAME} team use <id> # pin a team on the current profile
|
|
71
|
+
${config_1.PROGRAM_NAME} team clear # remove the pin
|
|
72
|
+
|
|
73
|
+
Raw API (agent/CI escape hatch) — docs: https://docs.reply.io/api-reference/introduction
|
|
74
|
+
Use the path as in the docs (starts with /v3); the query string goes in the path.
|
|
75
|
+
${config_1.PROGRAM_NAME} api /v3/whoami # GET your identity + team
|
|
76
|
+
${config_1.PROGRAM_NAME} api /v3/sequences # GET list of sequences
|
|
77
|
+
${config_1.PROGRAM_NAME} api /v3/contacts --body @c.json # POST (a body switches method; schema per docs)
|
|
78
|
+
${config_1.PROGRAM_NAME} api /v3/whoami --verbose # full req/resp to stderr (creds redacted)
|
|
79
|
+
Prints {code, data}; exits non-zero on HTTP >= 400.
|
|
41
80
|
|
|
42
|
-
|
|
43
|
-
|
|
81
|
+
Configuration (env vars):
|
|
82
|
+
${PREFIX}_API_KEY API key used as the bearer credential
|
|
83
|
+
${PREFIX}_PROFILE Profile to use (same as --profile)
|
|
84
|
+
${PREFIX}_TEAM_ID Team/workspace id (same as --team-id)
|
|
85
|
+
${PREFIX}_CONFIG_DIR Override the per-user config directory
|
|
44
86
|
|
|
45
87
|
Examples:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
88
|
+
${config_1.PROGRAM_NAME} auth login
|
|
89
|
+
echo <key> | ${config_1.PROGRAM_NAME} auth login --with-token
|
|
90
|
+
${config_1.PROGRAM_NAME} --profile dev auth whoami --json
|
|
91
|
+
${config_1.PROGRAM_NAME} auth status
|
|
92
|
+
${config_1.PROGRAM_NAME} team list
|
|
93
|
+
${config_1.PROGRAM_NAME} api /v3/sequences
|
|
51
94
|
`);
|
|
52
95
|
return program;
|
|
53
96
|
};
|
|
54
97
|
exports.build_program = build_program;
|
|
98
|
+
const wants_json = () => process.argv.includes('--json') || process.argv.includes('--pretty');
|
|
55
99
|
const main = async () => {
|
|
56
|
-
build_program()
|
|
100
|
+
const program = build_program();
|
|
101
|
+
set_exit_override(program);
|
|
102
|
+
await program.parseAsync(process.argv);
|
|
57
103
|
};
|
|
58
|
-
void main().catch(error => {
|
|
59
|
-
|
|
104
|
+
void main().catch((error) => {
|
|
105
|
+
if (error instanceof commander_1.CommanderError) {
|
|
106
|
+
// commander has already written help/usage text; help & version exit 0,
|
|
107
|
+
// any other usage problem exits 2.
|
|
108
|
+
const ok = error.code === 'commander.helpDisplayed'
|
|
109
|
+
|| error.code === 'commander.version'
|
|
110
|
+
|| error.code === 'commander.help';
|
|
111
|
+
process.exit(ok ? 0 : 2);
|
|
112
|
+
}
|
|
113
|
+
if (error instanceof errors_1.CliError) {
|
|
114
|
+
if (wants_json()) {
|
|
115
|
+
console.error(JSON.stringify(error.to_json()));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.error(error.message);
|
|
119
|
+
}
|
|
120
|
+
process.exit(error.exit_code);
|
|
121
|
+
}
|
|
122
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
60
123
|
process.exit(1);
|
|
61
124
|
});
|
|
62
125
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AACA,yCAAkD;AAClD,qCAAmD;AACnD,0CAA6C;AAC7C,gDAAmD;AACnD,0CAA6C;AAC7C,wCAA2C;AAC3C,2CAAwC;A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AyB;eAC5C,KAAK,CAAC,IAAI,KAAK,mBAAmB;eAClC,KAAK,CAAC,IAAI,KAAK,gBAAgB,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK,YAAY,iBAAQ,EAC7B,CAAC;QACG,IAAI,UAAU,EAAE,EAChB,CAAC;YACG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACnD,CAAC;aAED,CAAC;YACG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QACjC,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACpB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type Env } from './config';
|
|
2
|
+
type Profile = {
|
|
3
|
+
name: string;
|
|
4
|
+
authority: string;
|
|
5
|
+
api_base: string;
|
|
6
|
+
team_id?: number;
|
|
7
|
+
};
|
|
8
|
+
declare const EMBEDDED: {
|
|
9
|
+
authority: string;
|
|
10
|
+
api_base: string;
|
|
11
|
+
};
|
|
12
|
+
declare const PROD: {
|
|
13
|
+
authority: string;
|
|
14
|
+
api_base: string;
|
|
15
|
+
};
|
|
16
|
+
declare const resolve_profile: (flag?: string, env?: Env) => Profile;
|
|
17
|
+
declare const current_profile_name: (env?: Env) => string;
|
|
18
|
+
type Profile_description = {
|
|
19
|
+
name: string;
|
|
20
|
+
authority: string;
|
|
21
|
+
api_base: string;
|
|
22
|
+
team_id?: number;
|
|
23
|
+
is_current: boolean;
|
|
24
|
+
inherited: {
|
|
25
|
+
authority: boolean;
|
|
26
|
+
api_base: boolean;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
declare const describe_profile: (name: string, env?: Env) => Profile_description;
|
|
30
|
+
declare const list_profiles: (env?: Env) => {
|
|
31
|
+
current: string;
|
|
32
|
+
available: string[];
|
|
33
|
+
};
|
|
34
|
+
type Profile_fields = {
|
|
35
|
+
authority?: string;
|
|
36
|
+
api_base?: string;
|
|
37
|
+
team_id?: number;
|
|
38
|
+
};
|
|
39
|
+
type Clearable_field = 'authority' | 'api_base' | 'team_id';
|
|
40
|
+
declare const add_profile: (name: string, fields: Profile_fields, env?: Env) => void;
|
|
41
|
+
declare const set_profile: (name: string, fields: Profile_fields, env?: Env) => void;
|
|
42
|
+
declare const rename_profile_def: (old_name: string, new_name: string, env?: Env) => void;
|
|
43
|
+
declare const delete_profile_def: (name: string, env?: Env) => {
|
|
44
|
+
was_current: boolean;
|
|
45
|
+
};
|
|
46
|
+
declare const unset_profile_field: (name: string, field: Clearable_field, env?: Env) => {
|
|
47
|
+
changed: boolean;
|
|
48
|
+
};
|
|
49
|
+
declare const set_current_profile: (name: string, env?: Env) => void;
|
|
50
|
+
export { resolve_profile, current_profile_name, list_profiles, set_current_profile, add_profile, set_profile, rename_profile_def, delete_profile_def, unset_profile_field, describe_profile, EMBEDDED, PROD };
|
|
51
|
+
export type { Profile, Profile_fields, Clearable_field, Profile_description };
|