@revition/cli 0.0.0-reserved → 0.1.0-canary.a06d97b
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/LICENSE +201 -0
- package/NOTICE +8 -0
- package/bin/corvito +5 -0
- package/bin/run +30 -0
- package/dist/background-worker.d.ts +1 -0
- package/dist/background-worker.js +40 -0
- package/dist/background-worker.js.map +1 -0
- package/dist/bundle/startup.js +16167 -0
- package/dist/commands/auth/status.d.ts +22 -0
- package/dist/commands/auth/status.js +49 -0
- package/dist/commands/auth/status.js.map +1 -0
- package/dist/commands/autocomplete.d.ts +17 -0
- package/dist/commands/autocomplete.js +41 -0
- package/dist/commands/autocomplete.js.map +1 -0
- package/dist/commands/commands.d.ts +35 -0
- package/dist/commands/commands.js +49 -0
- package/dist/commands/commands.js.map +1 -0
- package/dist/commands/config/edit.d.ts +12 -0
- package/dist/commands/config/edit.js +40 -0
- package/dist/commands/config/edit.js.map +1 -0
- package/dist/commands/config/get.d.ts +16 -0
- package/dist/commands/config/get.js +29 -0
- package/dist/commands/config/get.js.map +1 -0
- package/dist/commands/config/list.d.ts +13 -0
- package/dist/commands/config/list.js +26 -0
- package/dist/commands/config/list.js.map +1 -0
- package/dist/commands/config/path.d.ts +8 -0
- package/dist/commands/config/path.js +22 -0
- package/dist/commands/config/path.js.map +1 -0
- package/dist/commands/config/set.d.ts +21 -0
- package/dist/commands/config/set.js +46 -0
- package/dist/commands/config/set.js.map +1 -0
- package/dist/commands/config/unset.d.ts +16 -0
- package/dist/commands/config/unset.js +28 -0
- package/dist/commands/config/unset.js.map +1 -0
- package/dist/commands/doctor.d.ts +8 -0
- package/dist/commands/doctor.js +101 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/flags/probe.d.ts +22 -0
- package/dist/commands/flags/probe.js +44 -0
- package/dist/commands/flags/probe.js.map +1 -0
- package/dist/commands/login.d.ts +28 -0
- package/dist/commands/login.js +138 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +15 -0
- package/dist/commands/logout.js +50 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/plugins/install.d.ts +28 -0
- package/dist/commands/plugins/install.js +51 -0
- package/dist/commands/plugins/install.js.map +1 -0
- package/dist/commands/plugins/list.d.ts +21 -0
- package/dist/commands/plugins/list.js +38 -0
- package/dist/commands/plugins/list.js.map +1 -0
- package/dist/commands/plugins/remove.d.ts +16 -0
- package/dist/commands/plugins/remove.js +30 -0
- package/dist/commands/plugins/remove.js.map +1 -0
- package/dist/commands/plugins/run.d.ts +23 -0
- package/dist/commands/plugins/run.js +49 -0
- package/dist/commands/plugins/run.js.map +1 -0
- package/dist/commands/plugins/search.d.ts +23 -0
- package/dist/commands/plugins/search.js +32 -0
- package/dist/commands/plugins/search.js.map +1 -0
- package/dist/commands/plugins/update.d.ts +27 -0
- package/dist/commands/plugins/update.js +50 -0
- package/dist/commands/plugins/update.js.map +1 -0
- package/dist/commands/profiles/list.d.ts +18 -0
- package/dist/commands/profiles/list.js +30 -0
- package/dist/commands/profiles/list.js.map +1 -0
- package/dist/commands/profiles/remove.d.ts +17 -0
- package/dist/commands/profiles/remove.js +42 -0
- package/dist/commands/profiles/remove.js.map +1 -0
- package/dist/commands/profiles/use.d.ts +15 -0
- package/dist/commands/profiles/use.js +28 -0
- package/dist/commands/profiles/use.js.map +1 -0
- package/dist/commands/telemetry/disable.d.ts +13 -0
- package/dist/commands/telemetry/disable.js +27 -0
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.d.ts +13 -0
- package/dist/commands/telemetry/enable.js +28 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/show-last.d.ts +12 -0
- package/dist/commands/telemetry/show-last.js +22 -0
- package/dist/commands/telemetry/show-last.js.map +1 -0
- package/dist/commands/telemetry/status.d.ts +15 -0
- package/dist/commands/telemetry/status.js +28 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/commands/token/create.d.ts +27 -0
- package/dist/commands/token/create.js +51 -0
- package/dist/commands/token/create.js.map +1 -0
- package/dist/commands/token/list.d.ts +21 -0
- package/dist/commands/token/list.js +38 -0
- package/dist/commands/token/list.js.map +1 -0
- package/dist/commands/token/revoke.d.ts +16 -0
- package/dist/commands/token/revoke.js +29 -0
- package/dist/commands/token/revoke.js.map +1 -0
- package/dist/commands/upgrade.d.ts +19 -0
- package/dist/commands/upgrade.js +47 -0
- package/dist/commands/upgrade.js.map +1 -0
- package/dist/commands/whoami.d.ts +8 -0
- package/dist/commands/whoami.js +43 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/completion.d.ts +13 -0
- package/dist/completion.js +108 -0
- package/dist/completion.js.map +1 -0
- package/dist/enabled-flags.d.ts +6 -0
- package/dist/enabled-flags.js +11 -0
- package/dist/enabled-flags.js.map +1 -0
- package/dist/help.d.ts +12 -0
- package/dist/help.js +28 -0
- package/dist/help.js.map +1 -0
- package/dist/hooks/command-not-found.d.ts +4 -0
- package/dist/hooks/command-not-found.js +13 -0
- package/dist/hooks/command-not-found.js.map +1 -0
- package/dist/hooks/init.d.ts +11 -0
- package/dist/hooks/init.js +35 -0
- package/dist/hooks/init.js.map +1 -0
- package/dist/hooks/postrun.d.ts +4 -0
- package/dist/hooks/postrun.js +7 -0
- package/dist/hooks/postrun.js.map +1 -0
- package/dist/hooks/prerun.d.ts +7 -0
- package/dist/hooks/prerun.js +15 -0
- package/dist/hooks/prerun.js.map +1 -0
- package/dist/plugin-guard.d.ts +17 -0
- package/dist/plugin-guard.js +11 -0
- package/dist/plugin-guard.js.map +1 -0
- package/dist/plugins-runtime.d.ts +14 -0
- package/dist/plugins-runtime.js +20 -0
- package/dist/plugins-runtime.js.map +1 -0
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +4 -0
- package/dist/runtime.js.map +1 -0
- package/dist/services.d.ts +2 -0
- package/dist/services.js +61 -0
- package/dist/services.js.map +1 -0
- package/dist/signals.d.ts +9 -0
- package/dist/signals.js +19 -0
- package/dist/signals.js.map +1 -0
- package/dist/startup-bundle.d.ts +10 -0
- package/dist/startup-bundle.js +11 -0
- package/dist/startup-bundle.js.map +1 -0
- package/dist/startup-path.d.ts +13 -0
- package/dist/startup-path.js +16 -0
- package/dist/startup-path.js.map +1 -0
- package/dist/suggest.d.ts +7 -0
- package/dist/suggest.js +40 -0
- package/dist/suggest.js.map +1 -0
- package/dist/telemetry-flags.d.ts +13 -0
- package/dist/telemetry-flags.js +82 -0
- package/dist/telemetry-flags.js.map +1 -0
- package/dist/update-notifier.d.ts +8 -0
- package/dist/update-notifier.js +41 -0
- package/dist/update-notifier.js.map +1 -0
- package/dist/update-worker.d.ts +1 -0
- package/dist/update-worker.js +7 -0
- package/dist/update-worker.js.map +1 -0
- package/oclif.manifest.json +3128 -0
- package/package.json +90 -7
- package/README.md +0 -6
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RevitionCommand, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
interface Out {
|
|
3
|
+
/** Shown ONCE: the platform keeps only its hash. */
|
|
4
|
+
readonly token: string;
|
|
5
|
+
readonly tokenId: string;
|
|
6
|
+
readonly prefix: string;
|
|
7
|
+
readonly scopes: readonly string[];
|
|
8
|
+
readonly expiresAt: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function parseDays(raw: string): number;
|
|
11
|
+
export default class TokenCreate extends RevitionCommand<Out> {
|
|
12
|
+
static summary: string;
|
|
13
|
+
static examples: string[];
|
|
14
|
+
static meta: CommandMeta;
|
|
15
|
+
static flags: {
|
|
16
|
+
name: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
scopes: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
18
|
+
expires: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
19
|
+
};
|
|
20
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
21
|
+
protected human(d: Out): HumanView;
|
|
22
|
+
protected reveal(d: Out): {
|
|
23
|
+
key: string;
|
|
24
|
+
value: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Flags } from '@oclif/core';
|
|
2
|
+
import { CLI_SCOPES, RevitionCommand, usageError, } from '@revition/cli-core';
|
|
3
|
+
import { runtime } from '../../runtime.js';
|
|
4
|
+
export function parseDays(raw) {
|
|
5
|
+
const m = /^(\d{1,3})d?$/.exec(raw.trim());
|
|
6
|
+
if (m === null)
|
|
7
|
+
throw usageError('EXPIRES_INVALID', `"${raw}" is not a duration in days (e.g. 30d).`);
|
|
8
|
+
return Number(m[1]);
|
|
9
|
+
}
|
|
10
|
+
export default class TokenCreate extends RevitionCommand {
|
|
11
|
+
static summary = 'Create a personal access token for CI (shown once; never stored by the CLI).';
|
|
12
|
+
static examples = ['revition token create --name ci-deploy --scopes cli:read,cli:write --expires 30d --yes'];
|
|
13
|
+
static meta = {
|
|
14
|
+
id: 'token:create',
|
|
15
|
+
summary: TokenCreate.summary,
|
|
16
|
+
examples: TokenCreate.examples,
|
|
17
|
+
requiredScopes: ['cli:write'],
|
|
18
|
+
mutates: true,
|
|
19
|
+
confirm: 'prompt',
|
|
20
|
+
jsonSchemaId: 'revition.token.create.v1',
|
|
21
|
+
stability: 'stable',
|
|
22
|
+
};
|
|
23
|
+
static flags = {
|
|
24
|
+
name: Flags.string({ required: true, description: 'A label for the token (up to 60 characters).' }),
|
|
25
|
+
scopes: Flags.string({ default: 'cli:read', description: `Comma-separated scopes (${CLI_SCOPES.join(', ')}).` }),
|
|
26
|
+
expires: Flags.string({ default: '30d', description: 'Lifetime in days, at most 90 (e.g. 30d).' }),
|
|
27
|
+
};
|
|
28
|
+
async run2(ctx) {
|
|
29
|
+
const f = ctx.commandFlags;
|
|
30
|
+
const scopes = String(f['scopes']).split(',').map((s) => s.trim()).filter((s) => s !== '');
|
|
31
|
+
const rt = await runtime(ctx);
|
|
32
|
+
const res = await rt.session.client.request({
|
|
33
|
+
method: 'POST',
|
|
34
|
+
path: '/dev/tokens',
|
|
35
|
+
body: { name: String(f['name']), scopes, expiresInDays: parseDays(String(f['expires'])) },
|
|
36
|
+
});
|
|
37
|
+
if (ctx.flags.json)
|
|
38
|
+
ctx.warn('data.token is shown once: store it in your CI secret store now; it cannot be shown again.');
|
|
39
|
+
else if (ctx.io.stdoutIsTTY)
|
|
40
|
+
ctx.io.err('This token is shown once. Store it in your CI secret store now; it cannot be shown again.\n');
|
|
41
|
+
return { token: res.body.token, tokenId: res.body.pat.tokenId, prefix: res.body.pat.prefix, scopes: res.body.pat.scopes, expiresAt: res.body.pat.expiresAt };
|
|
42
|
+
}
|
|
43
|
+
human(d) {
|
|
44
|
+
// The token is the one value printed unredacted, once, on stdout (T1.3.6); stderr carries the warning only.
|
|
45
|
+
return { text: '', reveal: d.token };
|
|
46
|
+
}
|
|
47
|
+
reveal(d) {
|
|
48
|
+
return { key: 'token', value: d.token };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/token/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,UAAU,EACV,eAAe,EACf,UAAU,GAIX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAW3C,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAC3C,IAAI,CAAC,KAAK,IAAI;QAAE,MAAM,UAAU,CAAC,iBAAiB,EAAE,IAAI,GAAG,yCAAyC,CAAC,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RevitionCommand, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
interface Token {
|
|
3
|
+
readonly tokenId: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly prefix: string;
|
|
6
|
+
readonly scopes: readonly string[];
|
|
7
|
+
readonly expiresAt: string;
|
|
8
|
+
readonly revokedAt: string | null;
|
|
9
|
+
readonly lastUsedAt: string | null;
|
|
10
|
+
}
|
|
11
|
+
interface Out {
|
|
12
|
+
readonly tokens: readonly Token[];
|
|
13
|
+
}
|
|
14
|
+
export default class TokenList extends RevitionCommand<Out> {
|
|
15
|
+
static summary: string;
|
|
16
|
+
static examples: string[];
|
|
17
|
+
static meta: CommandMeta;
|
|
18
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
19
|
+
protected human(d: Out): HumanView;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RevitionCommand, renderTable, terminalTable } from '@revition/cli-core';
|
|
2
|
+
import { runtime } from '../../runtime.js';
|
|
3
|
+
export default class TokenList extends RevitionCommand {
|
|
4
|
+
static summary = 'List your personal access tokens (prefix only, never the token).';
|
|
5
|
+
static examples = ['revition token list', 'revition token list --json'];
|
|
6
|
+
static meta = {
|
|
7
|
+
id: 'token:list',
|
|
8
|
+
summary: TokenList.summary,
|
|
9
|
+
examples: TokenList.examples,
|
|
10
|
+
// The platform route is `any` scope (route-scopes.ts 'GET /dev/tokens'): any credential lists its own tokens.
|
|
11
|
+
requiredScopes: [],
|
|
12
|
+
mutates: false,
|
|
13
|
+
confirm: 'none',
|
|
14
|
+
jsonSchemaId: 'revition.token.list.v1',
|
|
15
|
+
stability: 'stable',
|
|
16
|
+
};
|
|
17
|
+
async run2(ctx) {
|
|
18
|
+
const rt = await runtime(ctx);
|
|
19
|
+
const body = (await rt.session.client.request({ method: 'GET', path: '/dev/tokens' })).body;
|
|
20
|
+
return {
|
|
21
|
+
tokens: body.tokens.map((t) => ({
|
|
22
|
+
tokenId: t.tokenId,
|
|
23
|
+
name: t.name,
|
|
24
|
+
prefix: t.prefix,
|
|
25
|
+
scopes: t.scopes,
|
|
26
|
+
expiresAt: t.expiresAt,
|
|
27
|
+
revokedAt: t.revokedAt ?? null,
|
|
28
|
+
lastUsedAt: t.lastUsedAt ?? null,
|
|
29
|
+
})),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
human(d) {
|
|
33
|
+
return {
|
|
34
|
+
text: renderTable(['id', 'name', 'prefix', 'scopes', 'expires', 'state'], d.tokens.map((t) => [t.tokenId, t.name, t.prefix, t.scopes.join(','), t.expiresAt.slice(0, 10), t.revokedAt === null ? 'active' : 'revoked']), terminalTable()),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/token/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAyD,MAAM,oBAAoB,CAAC;AAExI,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAgB3C,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,eAAoB;IACzD,MAAM,CAAU,OAAO,GAAG,kEAAkE,CAAC;IAC7F,MAAM,CAAU,QAAQ,GAAG,CAAC,qBAAqB,EAAE,4BAA4B,CAAC,CAAC;IACjF,MAAM,CAAC,IAAI,GAAgB;QACzB,EAAE,EAAE,YAAY;QAChB,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,QAAQ,EAAE,SAAS,CAAC,QAAQ;QAC5B,8GAA8G;QAC9G,cAAc,EAAE,EAAE;QAClB,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,wBAAwB;QACtC,SAAS,EAAE,QAAQ;KACpB,CAAC;IAEQ,KAAK,CAAC,IAAI,CAAC,GA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@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RevitionCommand, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
interface Out {
|
|
3
|
+
readonly tokenId: string;
|
|
4
|
+
readonly revokedAt: string | null;
|
|
5
|
+
}
|
|
6
|
+
export default class TokenRevoke extends RevitionCommand<Out> {
|
|
7
|
+
static summary: string;
|
|
8
|
+
static examples: string[];
|
|
9
|
+
static meta: CommandMeta;
|
|
10
|
+
static args: {
|
|
11
|
+
id: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
|
|
12
|
+
};
|
|
13
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
14
|
+
protected human(d: Out): HumanView;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Args } from '@oclif/core';
|
|
2
|
+
import { RevitionCommand } from '@revition/cli-core';
|
|
3
|
+
import { runtime } from '../../runtime.js';
|
|
4
|
+
export default class TokenRevoke extends RevitionCommand {
|
|
5
|
+
static summary = 'Revoke a personal access token (it stops working at once).';
|
|
6
|
+
static examples = ['revition token revoke tok_123 --yes'];
|
|
7
|
+
static meta = {
|
|
8
|
+
id: 'token:revoke',
|
|
9
|
+
summary: TokenRevoke.summary,
|
|
10
|
+
examples: TokenRevoke.examples,
|
|
11
|
+
// The platform route is `any` scope ('DELETE /dev/tokens/{tokenId}'): revoking your own token is always allowed.
|
|
12
|
+
requiredScopes: [],
|
|
13
|
+
mutates: true,
|
|
14
|
+
confirm: 'prompt',
|
|
15
|
+
jsonSchemaId: 'revition.token.revoke.v1',
|
|
16
|
+
stability: 'stable',
|
|
17
|
+
};
|
|
18
|
+
static args = { id: Args.string({ required: true, description: 'The token id (from `token list`).' }) };
|
|
19
|
+
async run2(ctx) {
|
|
20
|
+
const id = String(ctx.args['id']);
|
|
21
|
+
const rt = await runtime(ctx);
|
|
22
|
+
const body = (await rt.session.client.request({ method: 'DELETE', path: `/dev/tokens/${encodeURIComponent(id)}` })).body;
|
|
23
|
+
return { tokenId: id, revokedAt: body.revokedAt ?? null };
|
|
24
|
+
}
|
|
25
|
+
human(d) {
|
|
26
|
+
return { text: `Revoked ${d.tokenId}.\n` };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=revoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.js","sourceRoot":"","sources":["../../../src/commands/token/revoke.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,eAAe,EAAyD,MAAM,oBAAoB,CAAC;AAE5G,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,eAAoB;IAC3D,MAAM,CAAU,OAAO,GAAG,4DAA4D,CAAC;IACvF,MAAM,CAAU,QAAQ,GAAG,CAAC,qCAAqC,CAAC,CAAC;IACnE,MAAM,CAAC,IAAI,GAAgB;QACzB,EAAE,EAAE,cAAc;QAClB,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,iHAAiH;QACjH,cAAc,EAAE,EAAE;QAClB,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,QAAQ;QACjB,YAAY,EAAE,0BAA0B;QACxC,SAAS,EAAE,QAAQ;KACpB,CAAC;IACF,MAAM,CAAU,IAAI,GAAG,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,mCAAmC,EAAE,CAAC,EAAE,CAAC;IAEvG,KAAK,CAAC,IAAI,CAAC,GAAmB;QACtC,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAClC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9B,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAgC,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACxJ,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;IAC5D,CAAC;IAEkB,KAAK,CAAC,CAAM;QAC7B,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,OAAO,KAAK,EAAE,CAAC;IAC7C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RevitionCommand, type Channel, type CommandContext, type CommandMeta, type HumanView } from '@revition/cli-core';
|
|
2
|
+
interface Out {
|
|
3
|
+
readonly installer: string;
|
|
4
|
+
readonly channel: Channel;
|
|
5
|
+
readonly command: string | null;
|
|
6
|
+
readonly ran: boolean;
|
|
7
|
+
readonly instructions: string | null;
|
|
8
|
+
}
|
|
9
|
+
export default class Upgrade extends RevitionCommand<Out> {
|
|
10
|
+
static summary: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
static meta: CommandMeta;
|
|
13
|
+
static flags: {
|
|
14
|
+
channel: import("@oclif/core/interfaces").OptionFlag<"latest" | "next" | "canary" | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
15
|
+
};
|
|
16
|
+
protected run2(ctx: CommandContext): Promise<Out>;
|
|
17
|
+
protected human(d: Out): HumanView;
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { Flags } from '@oclif/core';
|
|
3
|
+
import { channelOf, detectInstaller, RevitionCliError, RevitionCommand, runUpgrade, upgradeCommand, USER_PREFIX_HINT, VERIFY_HINT, } from '@revition/cli-core';
|
|
4
|
+
export default class Upgrade extends RevitionCommand {
|
|
5
|
+
static summary = 'Upgrade the CLI with the package manager that installed it (prints the command first).';
|
|
6
|
+
static examples = ['revition upgrade', 'revition upgrade --channel next'];
|
|
7
|
+
static meta = {
|
|
8
|
+
id: 'upgrade',
|
|
9
|
+
summary: Upgrade.summary,
|
|
10
|
+
examples: Upgrade.examples,
|
|
11
|
+
requiredScopes: [],
|
|
12
|
+
mutates: false,
|
|
13
|
+
confirm: 'none',
|
|
14
|
+
jsonSchemaId: 'revition.upgrade.v1',
|
|
15
|
+
stability: 'stable',
|
|
16
|
+
};
|
|
17
|
+
static flags = {
|
|
18
|
+
channel: Flags.option({ options: ['latest', 'next', 'canary'], description: 'The release channel (default: the installed one).' })(),
|
|
19
|
+
};
|
|
20
|
+
async run2(ctx) {
|
|
21
|
+
const channel = ctx.commandFlags['channel'] ?? channelOf(ctx.cliVersion);
|
|
22
|
+
const installer = detectInstaller(this.config.root);
|
|
23
|
+
const cmd = upgradeCommand(installer, channel);
|
|
24
|
+
if (cmd === null) {
|
|
25
|
+
return {
|
|
26
|
+
installer,
|
|
27
|
+
channel,
|
|
28
|
+
command: null,
|
|
29
|
+
ran: false,
|
|
30
|
+
instructions: `The installer of this CLI could not be detected. Upgrade it the way you installed it, e.g. npm install --global @revition/cli@${channel}.`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const [bin, args] = cmd;
|
|
34
|
+
const line = `${bin} ${args.join(' ')}`;
|
|
35
|
+
ctx.io.err(`Running: ${line}\n`);
|
|
36
|
+
ctx.io.flush();
|
|
37
|
+
const code = await runUpgrade(cmd, spawn);
|
|
38
|
+
if (code !== 0) {
|
|
39
|
+
throw new RevitionCliError({ code: 'UPGRADE_FAILED', message: `${line} exited ${code}.`, hint: USER_PREFIX_HINT });
|
|
40
|
+
}
|
|
41
|
+
return { installer, channel, command: line, ran: true, instructions: VERIFY_HINT };
|
|
42
|
+
}
|
|
43
|
+
human(d) {
|
|
44
|
+
return { text: `${d.ran ? `Upgraded with: ${d.command}\n` : ''}${d.instructions ?? ''}\n` };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=upgrade.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/commands/upgrade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EACL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,GAKZ,MAAM,oBAAoB,CAAC;AAU5B,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,eAAoB;IACvD,MAAM,CAAU,OAAO,GAAG,wFAAwF,CAAC;IACnH,MAAM,CAAU,QAAQ,GAAG,CAAC,kBAAkB,EAAE,iCAAiC,CAAC,CAAC;IACnF,MAAM,CAAC,IAAI,GAAgB;QACzB,EAAE,EAAE,SAAS;QACb,OAAO,EAAE,OAAO,CAAC,OAAO;QACxB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,cAAc,EAAE,EAAE;QAClB,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,qBAAqB;QACnC,SAAS,EAAE,QAAQ;KACpB,CAAC;IACF,MAAM,CAAU,KAAK,GAAG;QACtB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAU,EAAE,WAAW,EAAE,mDAAmD,EAAE,CAAC,EAAE;KAC9I,CAAC;IAEQ,KAAK,CAAC,IAAI,CAAC,GAAmB;QACtC,MAAM,OAAO,GAAI,GAAG,CAAC,YAAY,CAAC,SAAS,CAAyB,IAAI,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QAClG,MAAM,SAAS,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0 +1,8 @@
|
|
|
1
|
+
import { RevitionCommand, type CommandContext, type CommandMeta, type HumanView, type Identity } from '@revition/cli-core';
|
|
2
|
+
export default class Whoami extends RevitionCommand<Identity> {
|
|
3
|
+
static summary: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static meta: CommandMeta;
|
|
6
|
+
protected run2(ctx: CommandContext): Promise<Identity>;
|
|
7
|
+
protected human(i: Identity): HumanView;
|
|
8
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describeIdentity, RevitionCliError, RevitionCommand, } from '@revition/cli-core';
|
|
2
|
+
import { runtime } from '../runtime.js';
|
|
3
|
+
export default class Whoami extends RevitionCommand {
|
|
4
|
+
static summary = 'Show who you are signed in as, the workspace the platform resolved, and the host.';
|
|
5
|
+
static examples = ['revition whoami', 'revition whoami --json'];
|
|
6
|
+
static meta = {
|
|
7
|
+
id: 'whoami',
|
|
8
|
+
summary: Whoami.summary,
|
|
9
|
+
examples: Whoami.examples,
|
|
10
|
+
requiredScopes: ['cli:read'],
|
|
11
|
+
mutates: false,
|
|
12
|
+
confirm: 'none',
|
|
13
|
+
jsonSchemaId: 'revition.whoami.v1',
|
|
14
|
+
stability: 'stable',
|
|
15
|
+
};
|
|
16
|
+
async run2(ctx) {
|
|
17
|
+
const rt = await runtime(ctx);
|
|
18
|
+
if (rt.session.mode === 'none') {
|
|
19
|
+
throw new RevitionCliError({ code: 'AUTH_REQUIRED', message: 'You are not signed in.', hint: 'Run `revition login`.' }, 3);
|
|
20
|
+
}
|
|
21
|
+
const me = (await rt.session.client.request({ method: 'GET', path: '/dev/me' })).body;
|
|
22
|
+
const s = rt.session.stored;
|
|
23
|
+
return describeIdentity(me, {
|
|
24
|
+
host: rt.host,
|
|
25
|
+
profile: rt.profile,
|
|
26
|
+
email: s?.email ?? null,
|
|
27
|
+
sessionId: s?.sessionId ?? null,
|
|
28
|
+
authFreshUntil: s?.authFreshUntil ?? null,
|
|
29
|
+
method: rt.session.mode === 'pat' ? 'token' : (s?.method ?? 'browser'),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
human(i) {
|
|
33
|
+
const lines = [
|
|
34
|
+
`${i.user} (${i.identityKind})`,
|
|
35
|
+
`workspace: ${i.workspace ?? 'none'}`,
|
|
36
|
+
`host: ${i.host} profile: ${i.profile} sign-in: ${i.method}`,
|
|
37
|
+
...(i.sessionId === null ? [] : [`session: ${i.sessionId} fresh until: ${i.authFreshUntil ?? '-'}`]),
|
|
38
|
+
...(i.note === null ? [] : [i.note]),
|
|
39
|
+
];
|
|
40
|
+
return { text: `${lines.join('\n')}\n` };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=whoami.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../src/commands/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,GAMhB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,eAAyB;IAC3D,MAAM,CAAU,OAAO,GAAG,mFAAmF,CAAC;IAC9G,MAAM,CAAU,QAAQ,GAAG,CAAC,iBAAiB,EAAE,wBAAwB,CAAC,CAAC;IACzE,MAAM,CAAC,IAAI,GAAgB;QACzB,EAAE,EAAE,QAAQ;QACZ,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,cAAc,EAAE,CAAC,UAAU,CAAC;QAC5B,OAAO,EAAE,KAAK;QACd,OAAO,EAAE,MAAM;QACf,YAAY,EAAE,oBAAoB;QAClC,SAAS,EAAE,QAAQ;KACpB,CAAC;IAEQ,KAAK,CAAC,IAAI,CAAC,GAAmB;QACtC,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9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,SAAS,kBAAkB,CAAC,CAAC,cAAc,IAAI,GAAG,EAAE,CAAC,CAAC;YACrG,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACrC,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IAC3C,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T1.1.6 - completion scripts for bash, zsh, fish and PowerShell, generated from the command manifest (so every
|
|
3
|
+
* command, topic and flag the CLI has completes, and nothing else). PURE.
|
|
4
|
+
*/
|
|
5
|
+
export declare const SHELLS: readonly ["bash", "zsh", "fish", "powershell"];
|
|
6
|
+
export type Shell = (typeof SHELLS)[number];
|
|
7
|
+
export interface CompletionCommand {
|
|
8
|
+
/** Space-separated words, e.g. `config get`. */
|
|
9
|
+
readonly words: string;
|
|
10
|
+
readonly summary: string;
|
|
11
|
+
readonly flags: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
export declare function completionScript(shell: Shell, bin: string, commands: readonly CompletionCommand[]): string;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T1.1.6 - completion scripts for bash, zsh, fish and PowerShell, generated from the command manifest (so every
|
|
3
|
+
* command, topic and flag the CLI has completes, and nothing else). PURE.
|
|
4
|
+
*/
|
|
5
|
+
export const SHELLS = ['bash', 'zsh', 'fish', 'powershell'];
|
|
6
|
+
/** For each command path prefix, the words that may follow it ('' = top level). */
|
|
7
|
+
function tree(commands) {
|
|
8
|
+
const next = new Map();
|
|
9
|
+
for (const c of commands) {
|
|
10
|
+
const parts = c.words.split(' ');
|
|
11
|
+
for (let i = 0; i < parts.length; i++) {
|
|
12
|
+
const prefix = parts.slice(0, i).join(' ');
|
|
13
|
+
const set = next.get(prefix) ?? new Set();
|
|
14
|
+
set.add(parts[i] ?? '');
|
|
15
|
+
next.set(prefix, set);
|
|
16
|
+
}
|
|
17
|
+
const set = next.get(c.words) ?? new Set();
|
|
18
|
+
for (const f of c.flags)
|
|
19
|
+
set.add(`--${f}`);
|
|
20
|
+
next.set(c.words, set);
|
|
21
|
+
}
|
|
22
|
+
return next;
|
|
23
|
+
}
|
|
24
|
+
const q = (s) => s.replace(/'/g, "'\\''");
|
|
25
|
+
export function completionScript(shell, bin, commands) {
|
|
26
|
+
const t = tree(commands);
|
|
27
|
+
const entries = [...t.entries()].sort(([a], [b]) => a.localeCompare(b));
|
|
28
|
+
const fn = `_${bin.replace(/[^a-z0-9]/gi, '_')}_complete`;
|
|
29
|
+
if (shell === 'bash') {
|
|
30
|
+
const cases = entries.map(([k, v]) => ` '${q(k)}') opts='${q([...v].sort().join(' '))}' ;;`).join('\n');
|
|
31
|
+
return [
|
|
32
|
+
`# ${bin} completion for bash. Install: ${bin} autocomplete bash > ~/.${bin}-completion.bash && echo 'source ~/.${bin}-completion.bash' >> ~/.bashrc`,
|
|
33
|
+
`${fn}() {`,
|
|
34
|
+
' local cur words key opts',
|
|
35
|
+
' cur="${COMP_WORDS[COMP_CWORD]}"',
|
|
36
|
+
' words=("${COMP_WORDS[@]:1:COMP_CWORD-1}")',
|
|
37
|
+
' key="${words[*]}"',
|
|
38
|
+
// Longest known prefix wins: drop the last word until the key is in the table (or empty, then nothing).
|
|
39
|
+
' opts=""',
|
|
40
|
+
' while true; do',
|
|
41
|
+
' case "$key" in',
|
|
42
|
+
cases,
|
|
43
|
+
' *)',
|
|
44
|
+
' if [ -z "$key" ]; then break; fi',
|
|
45
|
+
' case "$key" in *" "*) key="${key% *}" ;; *) key="" ;; esac',
|
|
46
|
+
' continue ;;',
|
|
47
|
+
' esac',
|
|
48
|
+
' break',
|
|
49
|
+
' done',
|
|
50
|
+
' COMPREPLY=($(compgen -W "$opts" -- "$cur"))',
|
|
51
|
+
'}',
|
|
52
|
+
`complete -F ${fn} ${bin}`,
|
|
53
|
+
'',
|
|
54
|
+
].join('\n');
|
|
55
|
+
}
|
|
56
|
+
if (shell === 'zsh') {
|
|
57
|
+
const cases = entries.map(([k, v]) => ` '${q(k)}') opts=(${[...v].sort().map((w) => `'${q(w)}'`).join(' ')}) ;;`).join('\n');
|
|
58
|
+
return [
|
|
59
|
+
`#compdef ${bin}`,
|
|
60
|
+
`# ${bin} completion for zsh. Install: ${bin} autocomplete zsh > "\${fpath[1]}/_${bin}" && compinit`,
|
|
61
|
+
`${fn}() {`,
|
|
62
|
+
' local key="${words[2,CURRENT-1]}"',
|
|
63
|
+
' local -a opts',
|
|
64
|
+
' case "$key" in',
|
|
65
|
+
cases,
|
|
66
|
+
' *) opts=() ;;',
|
|
67
|
+
' esac',
|
|
68
|
+
' compadd -- $opts',
|
|
69
|
+
'}',
|
|
70
|
+
`compdef ${fn} ${bin}`,
|
|
71
|
+
'',
|
|
72
|
+
].join('\n');
|
|
73
|
+
}
|
|
74
|
+
if (shell === 'fish') {
|
|
75
|
+
const lines = [`# ${bin} completion for fish. Install: ${bin} autocomplete fish > ~/.config/fish/completions/${bin}.fish`];
|
|
76
|
+
lines.push(`complete -c ${bin} -f`);
|
|
77
|
+
for (const [k, v] of entries) {
|
|
78
|
+
const condition = k === '' ? `__fish_use_subcommand` : `__fish_seen_subcommand_from ${k.split(' ').pop() ?? ''}`;
|
|
79
|
+
for (const w of [...v].sort()) {
|
|
80
|
+
if (w.startsWith('--'))
|
|
81
|
+
lines.push(`complete -c ${bin} -n '${condition}' -l '${q(w.slice(2))}'`);
|
|
82
|
+
else
|
|
83
|
+
lines.push(`complete -c ${bin} -n '${condition}' -a '${q(w)}'`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return `${lines.join('\n')}\n`;
|
|
87
|
+
}
|
|
88
|
+
const table = entries.map(([k, v]) => ` '${k.replace(/'/g, "''")}' = @(${[...v].sort().map((w) => `'${w.replace(/'/g, "''")}'`).join(', ')})`).join('\n');
|
|
89
|
+
return [
|
|
90
|
+
`# ${bin} completion for PowerShell. Install: ${bin} autocomplete powershell >> $PROFILE`,
|
|
91
|
+
`$${fn}Tree = @{`,
|
|
92
|
+
table,
|
|
93
|
+
'}',
|
|
94
|
+
`Register-ArgumentCompleter -Native -CommandName ${bin} -ScriptBlock {`,
|
|
95
|
+
' param($wordToComplete, $commandAst, $cursorPosition)',
|
|
96
|
+
' $words = @($commandAst.CommandElements | Select-Object -Skip 1 | ForEach-Object { $_.ToString() })',
|
|
97
|
+
" if ($wordToComplete -ne '') { $words = @($words | Select-Object -SkipLast 1) }",
|
|
98
|
+
" $key = ($words -join ' ')",
|
|
99
|
+
` $opts = $${fn}Tree[$key]`,
|
|
100
|
+
' if ($null -eq $opts) { $opts = @() }',
|
|
101
|
+
' $opts | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {',
|
|
102
|
+
" [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)",
|
|
103
|
+
' }',
|
|
104
|
+
'}',
|
|
105
|
+
'',
|
|
106
|
+
].join('\n');
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAU,CAAC;AAUrE,mFAAmF;AACnF,SAAS,IAAI,CAAC,QAAsC;IAClD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,C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,EAAE,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3J,OAAO;QACL,KAAK,GAAG,wCAAwC,GAAG,sCAAsC;QACzF,IAAI,EAAE,WAAW;QACjB,KAAK;QACL,GAAG;QACH,mDAAmD,GAAG,iBAAiB;QACvE,wDAAwD;QACxD,sGAAsG;QACtG,kFAAkF;QAClF,6BAA6B;QAC7B,cAAc,EAAE,YAAY;QAC5B,wCAAwC;QACxC,2EAA2E;QAC3E,wFAAwF;QACxF,KAAK;QACL,GAAG;QACH,EAAE;KACH,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T1.4.3 - the server feature flags that are ON for a profile, from the local flag cache (no network). Loaded from the
|
|
3
|
+
* core's light `startup` entry so `revition --help` (which lists only the commands that may run) never loads the whole
|
|
4
|
+
* core: T1.1.1 AC6, `--help` starts in <= 300 ms.
|
|
5
|
+
*/
|
|
6
|
+
export declare function enabledFlags(profile: string): ReadonlySet<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { defaultCliPaths, readFlagCache } from '@revition/cli-core/startup';
|
|
2
|
+
/**
|
|
3
|
+
* T1.4.3 - the server feature flags that are ON for a profile, from the local flag cache (no network). Loaded from the
|
|
4
|
+
* core's light `startup` entry so `revition --help` (which lists only the commands that may run) never loads the whole
|
|
5
|
+
* core: T1.1.1 AC6, `--help` starts in <= 300 ms.
|
|
6
|
+
*/
|
|
7
|
+
export function enabledFlags(profile) {
|
|
8
|
+
const c = readFlagCache(defaultCliPaths().cacheDir, profile);
|
|
9
|
+
return new Set(Object.entries(c?.flags ?? {}).filter(([, on]) => on).map(([n]) => n));
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=enabled-flags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enabled-flags.js","sourceRoot":"","sources":["../src/enabled-flags.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE5E;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,MAAM,CAAC,GAAG,aAAa,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC7D,OAAO,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
package/dist/help.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CommandMeta } from '@revition/cli-core';
|
|
2
|
+
import type { Command } from '@oclif/core';
|
|
3
|
+
import { Help } from '@oclif/core/help';
|
|
4
|
+
/**
|
|
5
|
+
* T1.1.1 / T1.4.3 - help lists a command only when it may run: experimental commands are hidden without the opt-in
|
|
6
|
+
* (REVITION_EXPERIMENTAL=1 or --experimental); a command behind a server feature flag is hidden until the flag is on
|
|
7
|
+
* (defaults off; the flag cache lands with T1.4.3).
|
|
8
|
+
*/
|
|
9
|
+
export declare function visibleInHelp(meta: CommandMeta | undefined, env: Readonly<Record<string, string | undefined>>, argv: readonly string[], enabledFlags?: ReadonlySet<string>): boolean;
|
|
10
|
+
export default class RevitionHelp extends Help {
|
|
11
|
+
protected get sortedCommands(): Command.Loadable[];
|
|
12
|
+
}
|
package/dist/help.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { experimentalOptIn } from '@revition/cli-core/startup';
|
|
2
|
+
// The help entry, not the package index: the index loads every oclif module plus semver (47 files) on each --help
|
|
3
|
+
// (T1.1.1 AC6, 300 ms on the 3 OS).
|
|
4
|
+
import { Help } from '@oclif/core/help';
|
|
5
|
+
import { enabledFlags } from './enabled-flags.js';
|
|
6
|
+
/**
|
|
7
|
+
* T1.1.1 / T1.4.3 - help lists a command only when it may run: experimental commands are hidden without the opt-in
|
|
8
|
+
* (REVITION_EXPERIMENTAL=1 or --experimental); a command behind a server feature flag is hidden until the flag is on
|
|
9
|
+
* (defaults off; the flag cache lands with T1.4.3).
|
|
10
|
+
*/
|
|
11
|
+
export function visibleInHelp(meta, env, argv, enabledFlags = new Set()) {
|
|
12
|
+
if (meta === undefined)
|
|
13
|
+
return true;
|
|
14
|
+
if (meta.stability === 'experimental' && !experimentalOptIn(env, argv.includes('--experimental')))
|
|
15
|
+
return false;
|
|
16
|
+
if (meta.featureFlag !== undefined && !enabledFlags.has(meta.featureFlag))
|
|
17
|
+
return false;
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
export default class RevitionHelp extends Help {
|
|
21
|
+
get sortedCommands() {
|
|
22
|
+
const profileAt = process.argv.indexOf('--profile');
|
|
23
|
+
const profile = profileAt >= 0 ? (process.argv[profileAt + 1] ?? 'default') : (process.env['REVITION_PROFILE'] ?? 'default');
|
|
24
|
+
const flags = enabledFlags(profile);
|
|
25
|
+
return super.sortedCommands.filter((c) => visibleInHelp(c.meta, process.env, process.argv, flags));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=help.js.map
|
package/dist/help.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../src/help.ts"],"names":[],"mappings":"AACA,OAAO,EA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,KAAK,CAAC,CAC/F,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { suggestCommand } from '../suggest.js';
|
|
2
|
+
/** T1.1.6 AC2 - an unknown command prints a suggestion and exits 2; nothing runs. */
|
|
3
|
+
const hook = async function (opts) {
|
|
4
|
+
const ids = opts.config.commands.filter((c) => c.hidden !== true).map((c) => c.id);
|
|
5
|
+
const suggestion = suggestCommand(opts.id, ids);
|
|
6
|
+
const typed = opts.id.replace(/:/g, ' ');
|
|
7
|
+
process.stderr.write(suggestion === null
|
|
8
|
+
? `"${typed}" is not a revition command. Run \`revition --help\` to see the commands.\n`
|
|
9
|
+
: `"${typed}" is not a revition command. Did you mean '${suggestion}'?\n`);
|
|
10
|
+
this.exit(2);
|
|
11
|
+
};
|
|
12
|
+
export default hook;
|
|
13
|
+
//# sourceMappingURL=command-not-found.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-not-found.js","sourceRoot":"","sources":["../../src/hooks/command-not-found.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,qFAAqF;AACrF,MAAM,IAAI,GAA8B,KAAK,WAAW,IAAI;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACnF,MAAM,UAAU,GAAG,cAAc,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;IAChD,MAAM,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACzC,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,UAAU,KAAK,IAAI;QACjB,CAAC,CAAC,IAAI,KAAK,6EAA6E;QACxF,CAAC,CAAC,IAAI,KAAK,8CAA8C,UAAU,MAAM,CAC5E,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACf,CAAC,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hook } from '@oclif/core';
|
|
2
|
+
/**
|
|
3
|
+
* T1.1.1 - runs before any command: Ctrl-C handling; the plugin policy (a plugin that redefines a core command is
|
|
4
|
+
* refused). Third-party installs are decided by `plugins install` itself (T4.2.1-T4.2.3: listed + allowed + verified;
|
|
5
|
+
* anything else refused with the policy, exit 4).
|
|
6
|
+
*
|
|
7
|
+
* T1.1.1 AC6 (startup <= 300 ms): a `--version` / `--help` run executes no command, so the command setup (and the core
|
|
8
|
+
* it imports) is loaded only for a run that executes one. The plugin policy is checked on every run.
|
|
9
|
+
*/
|
|
10
|
+
declare const hook: Hook<'init'>;
|
|
11
|
+
export default hook;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { duplicateCommandRefusals } from '../plugin-guard.js';
|
|
2
|
+
import { infoOnlyRun } from '../startup-path.js';
|
|
3
|
+
/** Exit code for a policy refusal (permission denied, T1.1.3). */
|
|
4
|
+
const POLICY_EXIT = 4;
|
|
5
|
+
/**
|
|
6
|
+
* T1.1.1 - runs before any command: Ctrl-C handling; the plugin policy (a plugin that redefines a core command is
|
|
7
|
+
* refused). Third-party installs are decided by `plugins install` itself (T4.2.1-T4.2.3: listed + allowed + verified;
|
|
8
|
+
* anything else refused with the policy, exit 4).
|
|
9
|
+
*
|
|
10
|
+
* T1.1.1 AC6 (startup <= 300 ms): a `--version` / `--help` run executes no command, so the command setup (and the core
|
|
11
|
+
* it imports) is loaded only for a run that executes one. The plugin policy is checked on every run.
|
|
12
|
+
*/
|
|
13
|
+
const hook = async function (opts) {
|
|
14
|
+
const argv = opts.id === undefined ? opts.argv : [opts.id, ...opts.argv];
|
|
15
|
+
if (!infoOnlyRun(argv, opts.config.pjson.oclif)) {
|
|
16
|
+
const [{ setDefaultServices }, { cliServices }, { printUpdateNotice }, { installSigint }] = await Promise.all([
|
|
17
|
+
import('@revition/cli-core'),
|
|
18
|
+
import('../services.js'),
|
|
19
|
+
import('../update-notifier.js'),
|
|
20
|
+
import('../signals.js'),
|
|
21
|
+
]);
|
|
22
|
+
installSigint();
|
|
23
|
+
setDefaultServices(cliServices(opts.config.version));
|
|
24
|
+
await printUpdateNotice(opts.argv, opts.config.version);
|
|
25
|
+
}
|
|
26
|
+
const owners = opts.config.commands.map((c) => ({ id: c.id, pluginName: c.pluginName ?? '' }));
|
|
27
|
+
const dupes = duplicateCommandRefusals(owners, opts.config.name);
|
|
28
|
+
if (dupes.length > 0) {
|
|
29
|
+
for (const d of dupes)
|
|
30
|
+
process.stderr.write(`${d}\n`);
|
|
31
|
+
this.exit(POLICY_EXIT);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
export default hook;
|
|
35
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/hooks/init.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAuB,MAAM,oBAAoB,CAAC;AAEtE,kEAAkE;AAClE,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB;;;;;;;GAOG;AACH,MAAM,IAAI,GAAiB,KAAK,WAAW,IAAI;IAC7C,MAAM,IAAI,GAAG,IAAI,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IACzE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAuB,C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