@nocobase/app-cli-client 0.0.0-stage → 0.1.0-beta.1
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 +24 -2
- package/dist/brand.d.ts +52 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +61 -0
- package/dist/brand.js.map +1 -0
- package/dist/commands.d.ts +9 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +30 -0
- package/dist/commands.js.map +1 -0
- package/dist/completion.d.ts +13 -0
- package/dist/completion.d.ts.map +1 -0
- package/dist/completion.js +157 -0
- package/dist/completion.js.map +1 -0
- package/dist/config.d.ts +100 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +43 -0
- package/dist/config.js.map +1 -0
- package/dist/docs.d.ts +9 -0
- package/dist/docs.d.ts.map +1 -0
- package/dist/docs.js +146 -0
- package/dist/docs.js.map +1 -0
- package/dist/dynamic/execute.d.ts +24 -0
- package/dist/dynamic/execute.d.ts.map +1 -0
- package/dist/dynamic/execute.js +125 -0
- package/dist/dynamic/execute.js.map +1 -0
- package/dist/dynamic/files.d.ts +21 -0
- package/dist/dynamic/files.d.ts.map +1 -0
- package/dist/dynamic/files.js +79 -0
- package/dist/dynamic/files.js.map +1 -0
- package/dist/dynamic/help.d.ts +6 -0
- package/dist/dynamic/help.d.ts.map +1 -0
- package/dist/dynamic/help.js +42 -0
- package/dist/dynamic/help.js.map +1 -0
- package/dist/dynamic/index.d.ts +34 -0
- package/dist/dynamic/index.d.ts.map +1 -0
- package/dist/dynamic/index.js +197 -0
- package/dist/dynamic/index.js.map +1 -0
- package/dist/dynamic/manifest.d.ts +21 -0
- package/dist/dynamic/manifest.d.ts.map +1 -0
- package/dist/dynamic/manifest.js +175 -0
- package/dist/dynamic/manifest.js.map +1 -0
- package/dist/dynamic/output.d.ts +14 -0
- package/dist/dynamic/output.d.ts.map +1 -0
- package/dist/dynamic/output.js +103 -0
- package/dist/dynamic/output.js.map +1 -0
- package/dist/dynamic/parse.d.ts +3 -0
- package/dist/dynamic/parse.d.ts.map +1 -0
- package/dist/dynamic/parse.js +13 -0
- package/dist/dynamic/parse.js.map +1 -0
- package/dist/dynamic/rest.d.ts +29 -0
- package/dist/dynamic/rest.d.ts.map +1 -0
- package/dist/dynamic/rest.js +212 -0
- package/dist/dynamic/rest.js.map +1 -0
- package/dist/dynamic/session.d.ts +20 -0
- package/dist/dynamic/session.d.ts.map +1 -0
- package/dist/dynamic/session.js +70 -0
- package/dist/dynamic/session.js.map +1 -0
- package/dist/dynamic/ticket.d.ts +13 -0
- package/dist/dynamic/ticket.d.ts.map +1 -0
- package/dist/dynamic/ticket.js +40 -0
- package/dist/dynamic/ticket.js.map +1 -0
- package/dist/hooks/command-not-found.d.ts +4 -0
- package/dist/hooks/command-not-found.d.ts.map +1 -0
- package/dist/hooks/command-not-found.js +6 -0
- package/dist/hooks/command-not-found.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +72 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +148 -0
- package/dist/install.js.map +1 -0
- package/dist/lib/command.d.ts +35 -0
- package/dist/lib/command.d.ts.map +1 -0
- package/dist/lib/command.js +97 -0
- package/dist/lib/command.js.map +1 -0
- package/dist/lib/credentials.d.ts +110 -0
- package/dist/lib/credentials.d.ts.map +1 -0
- package/dist/lib/credentials.js +330 -0
- package/dist/lib/credentials.js.map +1 -0
- package/dist/lib/device.d.ts +48 -0
- package/dist/lib/device.d.ts.map +1 -0
- package/dist/lib/device.js +189 -0
- package/dist/lib/device.js.map +1 -0
- package/dist/lib/envelope.d.ts +21 -0
- package/dist/lib/envelope.d.ts.map +1 -0
- package/dist/lib/envelope.js +87 -0
- package/dist/lib/envelope.js.map +1 -0
- package/dist/lib/files.d.ts +4 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/files.js +23 -0
- package/dist/lib/files.js.map +1 -0
- package/dist/lib/globals.d.ts +25 -0
- package/dist/lib/globals.d.ts.map +1 -0
- package/dist/lib/globals.js +77 -0
- package/dist/lib/globals.js.map +1 -0
- package/dist/lib/http.d.ts +45 -0
- package/dist/lib/http.d.ts.map +1 -0
- package/dist/lib/http.js +141 -0
- package/dist/lib/http.js.map +1 -0
- package/dist/lib/mime.d.ts +3 -0
- package/dist/lib/mime.d.ts.map +1 -0
- package/dist/lib/mime.js +38 -0
- package/dist/lib/mime.js.map +1 -0
- package/dist/lib/secrets/index.d.ts +18 -0
- package/dist/lib/secrets/index.d.ts.map +1 -0
- package/dist/lib/secrets/index.js +55 -0
- package/dist/lib/secrets/index.js.map +1 -0
- package/dist/lib/secrets/macos.d.ts +13 -0
- package/dist/lib/secrets/macos.d.ts.map +1 -0
- package/dist/lib/secrets/macos.js +61 -0
- package/dist/lib/secrets/macos.js.map +1 -0
- package/dist/lib/secrets/secret-service.d.ts +17 -0
- package/dist/lib/secrets/secret-service.d.ts.map +1 -0
- package/dist/lib/secrets/secret-service.js +81 -0
- package/dist/lib/secrets/secret-service.js.map +1 -0
- package/dist/lib/secrets/store.d.ts +28 -0
- package/dist/lib/secrets/store.d.ts.map +1 -0
- package/dist/lib/secrets/store.js +41 -0
- package/dist/lib/secrets/store.js.map +1 -0
- package/dist/lib/secrets/windows.d.ts +20 -0
- package/dist/lib/secrets/windows.d.ts.map +1 -0
- package/dist/lib/secrets/windows.js +155 -0
- package/dist/lib/secrets/windows.js.map +1 -0
- package/dist/lib/update-hint.d.ts +5 -0
- package/dist/lib/update-hint.d.ts.map +1 -0
- package/dist/lib/update-hint.js +26 -0
- package/dist/lib/update-hint.js.map +1 -0
- package/dist/login.d.ts +15 -0
- package/dist/login.d.ts.map +1 -0
- package/dist/login.js +232 -0
- package/dist/login.js.map +1 -0
- package/dist/logout.d.ts +13 -0
- package/dist/logout.d.ts.map +1 -0
- package/dist/logout.js +56 -0
- package/dist/logout.js.map +1 -0
- package/dist/parse/arguments.d.ts +84 -0
- package/dist/parse/arguments.d.ts.map +1 -0
- package/dist/parse/arguments.js +460 -0
- package/dist/parse/arguments.js.map +1 -0
- package/dist/parse/exit.d.ts +7 -0
- package/dist/parse/exit.d.ts.map +1 -0
- package/dist/parse/exit.js +24 -0
- package/dist/parse/exit.js.map +1 -0
- package/dist/parse/help.d.ts +22 -0
- package/dist/parse/help.d.ts.map +1 -0
- package/dist/parse/help.js +151 -0
- package/dist/parse/help.js.map +1 -0
- package/dist/parse/index.d.ts +5 -0
- package/dist/parse/index.d.ts.map +1 -0
- package/dist/parse/index.js +7 -0
- package/dist/parse/index.js.map +1 -0
- package/dist/parse/manifest.d.ts +97 -0
- package/dist/parse/manifest.d.ts.map +1 -0
- package/dist/parse/manifest.js +4 -0
- package/dist/parse/manifest.js.map +1 -0
- package/dist/profile.d.ts +4 -0
- package/dist/profile.d.ts.map +1 -0
- package/dist/profile.js +80 -0
- package/dist/profile.js.map +1 -0
- package/dist/request.d.ts +25 -0
- package/dist/request.d.ts.map +1 -0
- package/dist/request.js +35 -0
- package/dist/request.js.map +1 -0
- package/dist/run.d.ts +17 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +88 -0
- package/dist/run.js.map +1 -0
- package/dist/update.d.ts +45 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/update.js +177 -0
- package/dist/update.js.map +1 -0
- package/dist/whoami.d.ts +31 -0
- package/dist/whoami.d.ts.map +1 -0
- package/dist/whoami.js +118 -0
- package/dist/whoami.js.map +1 -0
- package/package.json +67 -3
package/README.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @nocobase/app-cli-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A command line for a NocoBase application, branded by the application: it signs in to a server and runs the business commands the server's command manifest (`GET /api/cli/manifest`) publishes for the caller, each a request to one API route. An application declares its brand under `nocobase.cli` in its `package.json` (`AppCliBrand`), and `nocobase cli build` and `nocobase cli link` of `@nocobase/app-cli` package it with an entry that calls `runAppCliPackage`, which reads the brand back from the packaged CLI's own `package.json` and runs it with `selfUpdate` on; an application's `acme` is made this way. A CLI may instead call `runAppCli` with an `AppCliConfig` of its own and add static commands.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { runAppCli } from '@nocobase/app-cli-client';
|
|
7
|
+
|
|
8
|
+
await runAppCli(
|
|
9
|
+
{
|
|
10
|
+
bin: 'acme',
|
|
11
|
+
displayName: 'Acme',
|
|
12
|
+
stateDir: '.acme',
|
|
13
|
+
homeEnv: 'ACME_HOME',
|
|
14
|
+
envPrefix: 'ACME',
|
|
15
|
+
runCredentialsFile: '.acme/run.json',
|
|
16
|
+
},
|
|
17
|
+
process.argv.slice(2),
|
|
18
|
+
);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
An application whose install script (`/api/agents/dist/installScript` of `@nocobase/app-plugin-agents`) installs its CLI names `selfUpdate` in the configuration, with the root of the CLI's package as it runs (`packageRoot`). The CLI then has `<bin> update`, which asks the signed-in server for the newest version it serves for this platform (`selfUpdate.product`, the command name by default), checks its SHA-256 and switches `<prefix>/current` to it, keeping the previous version; business commands and `login` say on stderr when a newer version is served, asking at most every 12 hours (`<state dir>/cache/update.json`). An installation the script made for the runner (`install.json` `mode: runner`) is the runner's, which updates itself, so `update` refuses it. `@nocobase/app-cli-client/install` is that installation layout (`<prefix>/versions/<version>`, `current`, `install.json`) and the update itself, without reading any CLI configuration, so a runner shares it.
|
|
22
|
+
|
|
23
|
+
`@nocobase/app-cli-client/request` exports `fillRequest`, which turns a manifest command and the values of its parameters into the request it makes. It imports nothing else, so a server that calls its own routes the way the CLI does, such as an online agent's tools in `@nocobase/app-plugin-agents`, builds the same request.
|
|
24
|
+
|
|
25
|
+
`@nocobase/app-cli-client/parse` is how the CLI reads a business command's line, with no file, environment or terminal of its own: `parseCommandLine(command, argv, { bin, io })` takes a manifest command and the words after its name, and answers the values of its parameters, the body read from `--file` and the files to send, or throws a `CliParseError` carrying the cli-envelope's `code`, message, suggestions and exit code. The `io` (`CliParseIo`) reads text files and environment variables, and optionally finds files to send (`file`, `changed`) and asks for a missing value (`ask`); a flag that sends a file is refused with `FILES_UNAVAILABLE` where `file` is absent. It also renders a command's help and an area's command list from the manifest (`renderCommandHelp`, `renderTopicHelp`) and maps a failed request to the CLI's exit code (`apiExitCode`). The CLI uses it over this machine, and the `acme` command of an online run's shell in `@nocobase/app-plugin-agents` over that shell, so both read a line the same way.
|
package/dist/brand.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { AppCliAuth, AppCliConfig } from './config.ts';
|
|
2
|
+
/** `nocobase.cli` in an application's `package.json`. */
|
|
3
|
+
export interface AppCliBrand {
|
|
4
|
+
/** The command, such as `acme`; also the product the application serves it as. */
|
|
5
|
+
readonly bin: string;
|
|
6
|
+
/** The application's name in messages, such as `Acme`; `bin` when left out. */
|
|
7
|
+
readonly displayName?: string;
|
|
8
|
+
/** The root help's description; the packaged CLI's `description` when left out. */
|
|
9
|
+
readonly description?: string;
|
|
10
|
+
/** The directory under the home directory the CLI keeps its state in; `.<bin>` when left out. */
|
|
11
|
+
readonly stateDir?: string;
|
|
12
|
+
/** An environment variable that moves the state directory, such as `ACME_HOME`. */
|
|
13
|
+
readonly homeEnv?: string;
|
|
14
|
+
/** The prefix of the environment variables that act without signing in, such as `ACME` for `ACME_SERVER`. */
|
|
15
|
+
readonly envPrefix?: string;
|
|
16
|
+
/** An environment variable whose value `off` turns the keychain off, such as `ACME_KEYCHAIN`. */
|
|
17
|
+
readonly keychainEnv?: string;
|
|
18
|
+
/** The keychain service of the person's credential; `<bin>-cli` when left out. */
|
|
19
|
+
readonly keychainService?: string;
|
|
20
|
+
/** Where a runner puts a run's credentials, relative to the run's directory; `<stateDir>/run.json` when left out. */
|
|
21
|
+
readonly runCredentialsFile?: string;
|
|
22
|
+
/** Shown as `<bin> login --server <example>`. */
|
|
23
|
+
readonly exampleServer?: string;
|
|
24
|
+
/** Signing in through the browser: the device authorization client id the server accepts, and its routes. */
|
|
25
|
+
readonly auth?: AppCliAuth;
|
|
26
|
+
/** The command manifest's path below the server's address; `CLI_ROUTES.manifest` when left out. */
|
|
27
|
+
readonly manifestPath?: string;
|
|
28
|
+
/**
|
|
29
|
+
* Skill directories, relative to the application, that the packaged CLI ships in its `skills/` (each a directory with
|
|
30
|
+
* a `SKILL.md`, or a directory of them): the runner gives them to every run whose CLI it is. Read when packaging only.
|
|
31
|
+
*/
|
|
32
|
+
readonly skills?: readonly string[];
|
|
33
|
+
/** The packaged CLI's version; the application's when left out. Read when packaging only. */
|
|
34
|
+
readonly version?: string;
|
|
35
|
+
}
|
|
36
|
+
/** What a packaged CLI is, beside its brand. */
|
|
37
|
+
export interface AppCliPackageInfo {
|
|
38
|
+
/** The root of the packaged CLI, `<prefix>/versions/<version>` once the install script installed it. */
|
|
39
|
+
readonly packageRoot: string;
|
|
40
|
+
readonly version: string;
|
|
41
|
+
readonly description?: string;
|
|
42
|
+
}
|
|
43
|
+
/** The configuration a packaged CLI runs with. */
|
|
44
|
+
export declare function appCliConfigOf(brand: AppCliBrand, info: AppCliPackageInfo): AppCliConfig;
|
|
45
|
+
/** The brand and package information of the packaged CLI at `packageRoot`, from its `package.json`. */
|
|
46
|
+
export declare function readAppCliPackage(packageRoot: string): {
|
|
47
|
+
brand: AppCliBrand;
|
|
48
|
+
info: AppCliPackageInfo;
|
|
49
|
+
};
|
|
50
|
+
/** Runs the packaged CLI at `packageRoot`: the entry `nocobase cli build` and `nocobase cli link` generate. */
|
|
51
|
+
export declare function runAppCliPackage(packageRoot: string, argv?: string[]): Promise<void>;
|
|
52
|
+
//# sourceMappingURL=brand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand.d.ts","sourceRoot":"","sources":["../src/brand.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,C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IAAI,EAAE,iBAAiB,GACtB,YAAY,CA4Bd;AAQD,uGAAuG;AACvG,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG;IACtD,KAAK,EAAE,WAAW,CAAC;IACnB,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAwBA;AAED,+GAA+G;AAC/G,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,MAAM,EAA0B,GACrC,OAAO,CAAC,IAAI,CAAC,CAGf"}
|
package/dist/brand.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// An application's CLI as its `package.json` declares it, under `nocobase.cli`: the JSON a packaged CLI carries in its
|
|
2
|
+
// own `package.json` (`nocobase cli build` and `nocobase cli link` of `@nocobase/app-cli` write it), which
|
|
3
|
+
// `runAppCliPackage` turns into the `AppCliConfig` it runs with. Only plain data: everything a function would decide
|
|
4
|
+
// is derived here, such as `selfUpdate`, which a packaged CLI always has.
|
|
5
|
+
import { readFileSync } from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { runAppCli } from "./run.js";
|
|
8
|
+
/** The configuration a packaged CLI runs with. */
|
|
9
|
+
export function appCliConfigOf(brand, info) {
|
|
10
|
+
const stateDir = brand.stateDir ?? `.${brand.bin}`;
|
|
11
|
+
const description = brand.description ?? info.description;
|
|
12
|
+
return {
|
|
13
|
+
bin: brand.bin,
|
|
14
|
+
displayName: brand.displayName ?? brand.bin,
|
|
15
|
+
stateDir,
|
|
16
|
+
runCredentialsFile: brand.runCredentialsFile ?? path.posix.join(stateDir, 'run.json'),
|
|
17
|
+
...(brand.homeEnv === undefined ? {} : { homeEnv: brand.homeEnv }),
|
|
18
|
+
...(brand.envPrefix === undefined ? {} : { envPrefix: brand.envPrefix }),
|
|
19
|
+
...(brand.keychainEnv === undefined
|
|
20
|
+
? {}
|
|
21
|
+
: { keychainEnv: brand.keychainEnv }),
|
|
22
|
+
...(brand.keychainService === undefined
|
|
23
|
+
? {}
|
|
24
|
+
: { keychainService: brand.keychainService }),
|
|
25
|
+
...(brand.exampleServer === undefined
|
|
26
|
+
? {}
|
|
27
|
+
: { exampleServer: brand.exampleServer }),
|
|
28
|
+
...(brand.auth === undefined ? {} : { auth: brand.auth }),
|
|
29
|
+
...(brand.manifestPath === undefined
|
|
30
|
+
? {}
|
|
31
|
+
: { manifestPath: brand.manifestPath }),
|
|
32
|
+
...(description === undefined ? {} : { description }),
|
|
33
|
+
version: info.version,
|
|
34
|
+
selfUpdate: { packageRoot: info.packageRoot, product: brand.bin },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The brand and package information of the packaged CLI at `packageRoot`, from its `package.json`. */
|
|
38
|
+
export function readAppCliPackage(packageRoot) {
|
|
39
|
+
const manifest = JSON.parse(readFileSync(path.join(packageRoot, 'package.json'), 'utf8'));
|
|
40
|
+
const brand = manifest.nocobase?.cli;
|
|
41
|
+
if (brand === undefined ||
|
|
42
|
+
typeof brand !== 'object' ||
|
|
43
|
+
typeof brand.bin !== 'string')
|
|
44
|
+
throw new Error(`${path.join(packageRoot, 'package.json')} names no CLI under nocobase.cli.`);
|
|
45
|
+
return {
|
|
46
|
+
brand,
|
|
47
|
+
info: {
|
|
48
|
+
packageRoot,
|
|
49
|
+
version: typeof manifest.version === 'string' ? manifest.version : '0.0.0',
|
|
50
|
+
...(typeof manifest.description === 'string'
|
|
51
|
+
? { description: manifest.description }
|
|
52
|
+
: {}),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** Runs the packaged CLI at `packageRoot`: the entry `nocobase cli build` and `nocobase cli link` generate. */
|
|
57
|
+
export async function runAppCliPackage(packageRoot, argv = process.argv.slice(2)) {
|
|
58
|
+
const { brand, info } = readAppCliPackage(packageRoot);
|
|
59
|
+
await runAppCli(appCliConfigOf(brand, info), argv);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=brand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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;YACX,OAAO,EACL,OAAO,QAAQ,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO;YACnE,GAAG,CAAC,OAAO,QAAQ,CAAC,WAAW,KAAK,QAAQ;gBAC1C,CAAC,CAAC,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE;gBACvC,CAAC,CAAC,EAAE,CAAC;SACR;KACF,CAAC;AACJ,CAAC;AAED,+GAA+G;AAC/G,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,WAAmB,EACnB,OAAiB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAEtC,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,iBAAiB,CAAC,WAAW,CAAC,CAAC;IACvD,MAAM,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Command } from '@oclif/core';
|
|
2
|
+
import type { AppCliConfig } from './config.ts';
|
|
3
|
+
export declare const COMMANDS: Record<string, Command.Class>;
|
|
4
|
+
/** The topics of the static commands, for help. */
|
|
5
|
+
export declare const STATIC_TOPICS: Readonly<Record<string, {
|
|
6
|
+
description: string;
|
|
7
|
+
}>>;
|
|
8
|
+
export declare function defineCommands(config: AppCliConfig, extra?: Readonly<Record<string, Command.Class>>): void;
|
|
9
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAQhD,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAM,CAAC;AAE1D,mDAAmD;AACnD,eAAO,MAAM,aAAa,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CAKzE,CAAC;AAEJ,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,KAAK,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAM,GAClD,IAAI,CAiBN"}
|
package/dist/commands.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { completionCommands } from "./completion.js";
|
|
2
|
+
import { docsCommand } from "./docs.js";
|
|
3
|
+
import { loginCommand } from "./login.js";
|
|
4
|
+
import { logoutCommand } from "./logout.js";
|
|
5
|
+
import { profileCommands } from "./profile.js";
|
|
6
|
+
import { updateCommand } from "./update.js";
|
|
7
|
+
import { whoamiCommand } from "./whoami.js";
|
|
8
|
+
export const COMMANDS = {};
|
|
9
|
+
/** The topics of the static commands, for help. */
|
|
10
|
+
export const STATIC_TOPICS = {
|
|
11
|
+
profile: {
|
|
12
|
+
description: 'The servers you are signed in to, one profile each.',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
export function defineCommands(config, extra = {}) {
|
|
16
|
+
for (const key of Object.keys(COMMANDS))
|
|
17
|
+
delete COMMANDS[key];
|
|
18
|
+
Object.assign(COMMANDS, {
|
|
19
|
+
login: loginCommand(config),
|
|
20
|
+
logout: logoutCommand(config),
|
|
21
|
+
whoami: whoamiCommand(config),
|
|
22
|
+
docs: docsCommand(config),
|
|
23
|
+
...profileCommands(config),
|
|
24
|
+
...completionCommands(config),
|
|
25
|
+
...(config.selfUpdate === undefined
|
|
26
|
+
? {}
|
|
27
|
+
: { update: updateCommand(config) }),
|
|
28
|
+
}, extra);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands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1
|
+
import { type Command } from '@oclif/core';
|
|
2
|
+
import type { AppCliConfig } from './config.ts';
|
|
3
|
+
import { type CliCommand } from './dynamic/manifest.ts';
|
|
4
|
+
export declare const SHELLS: readonly string[];
|
|
5
|
+
/** The script for `shell`, which calls `<bin> __complete -- <words…> <current>`. */
|
|
6
|
+
export declare function completionScript(bin: string, shell: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* The words that may complete `current` after `words`: the next word of a command, a command's flags, or the values
|
|
9
|
+
* of the flag before it. `statics` are the static commands' ids (`profile:use`) with their flags.
|
|
10
|
+
*/
|
|
11
|
+
export declare function completeLine(words: readonly string[], current: string, statics: ReadonlyMap<string, readonly string[]>, commands: readonly CliCommand[]): string[];
|
|
12
|
+
export declare function completionCommands(app: AppCliConfig): Record<string, Command.Class>;
|
|
13
|
+
//# sourceMappingURL=completion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.d.ts","sourceRoot":"","sources":["../src/completion.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiC,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAE1E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAsB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAK5E,eAAO,MAAM,MAAM,EAAE,SAAS,MAAM,EAA4B,CAAC;AAEjE,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAyBnE;AAwBD;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,EAC/C,QAAQ,EAAE,SAAS,UAAU,EAAE,GAC9B,MAAM,EAAE,CAoCV;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,YAAY,GAChB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CA2D/B"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
// Shell completion: `<bin> completion zsh|bash|fish` prints a script that asks `<bin> __complete` for the words that
|
|
2
|
+
// may come next. Those come from the static commands and the cached command manifest (`dynamic/manifest.ts`), never
|
|
3
|
+
// from the network, so completing is quick and works offline; the cache is refreshed by any command that runs.
|
|
4
|
+
import { Args, Command as OclifCommand } from '@oclif/core';
|
|
5
|
+
import { readCachedManifest } from "./dynamic/manifest.js";
|
|
6
|
+
import { peekSession } from "./dynamic/session.js";
|
|
7
|
+
import { AppCommand } from "./lib/command.js";
|
|
8
|
+
import { GLOBAL_FLAG_HELP } from "./lib/globals.js";
|
|
9
|
+
export const SHELLS = ['zsh', 'bash', 'fish'];
|
|
10
|
+
/** The script for `shell`, which calls `<bin> __complete -- <words…> <current>`. */
|
|
11
|
+
export function completionScript(bin, shell) {
|
|
12
|
+
const fn = `_${bin.replace(/[^A-Za-z0-9_]/gu, '_')}`;
|
|
13
|
+
switch (shell) {
|
|
14
|
+
case 'zsh':
|
|
15
|
+
return `#compdef ${bin}
|
|
16
|
+
${fn}() {
|
|
17
|
+
local -a completions
|
|
18
|
+
completions=("\${(@f)$(${bin} __complete -- "\${(@)words[2,CURRENT-1]}" "\${words[CURRENT]}" 2>/dev/null)}")
|
|
19
|
+
compadd -a completions
|
|
20
|
+
}
|
|
21
|
+
compdef ${fn} ${bin}
|
|
22
|
+
`;
|
|
23
|
+
case 'bash':
|
|
24
|
+
return `${fn}() {
|
|
25
|
+
local IFS=$'\\n'
|
|
26
|
+
COMPREPLY=($(${bin} __complete -- "\${COMP_WORDS[@]:1:COMP_CWORD-1}" "\${COMP_WORDS[COMP_CWORD]}" 2>/dev/null))
|
|
27
|
+
}
|
|
28
|
+
complete -o default -F ${fn} ${bin}
|
|
29
|
+
`;
|
|
30
|
+
case 'fish':
|
|
31
|
+
return `complete -c ${bin} -f -a '(${bin} __complete -- (commandline -opc)[2..-1] (commandline -ct) 2>/dev/null)'
|
|
32
|
+
`;
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Not a shell: ${shell}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const GLOBAL_FLAGS = GLOBAL_FLAG_HELP.flatMap(([flag]) => flag
|
|
38
|
+
.split(/,\s*/u)
|
|
39
|
+
.map((part) => part.split(' ')[0])
|
|
40
|
+
.filter((part) => part.startsWith('--')));
|
|
41
|
+
/** The flags of a manifest command, as typed. */
|
|
42
|
+
function flagsOf(command) {
|
|
43
|
+
const flags = [];
|
|
44
|
+
for (const parameter of command.parameters) {
|
|
45
|
+
if (parameter.position !== undefined)
|
|
46
|
+
continue;
|
|
47
|
+
flags.push(`--${parameter.name}`);
|
|
48
|
+
if (parameter.contentFile)
|
|
49
|
+
flags.push(`--${parameter.name}-file`);
|
|
50
|
+
}
|
|
51
|
+
if (command.parameters.some((parameter) => parameter.fromEnv !== undefined))
|
|
52
|
+
flags.push('--from-env');
|
|
53
|
+
if (command.body?.file)
|
|
54
|
+
flags.push(`--${command.body.file}`);
|
|
55
|
+
if (command.output.kind === 'download')
|
|
56
|
+
flags.push('--out');
|
|
57
|
+
return flags;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The words that may complete `current` after `words`: the next word of a command, a command's flags, or the values
|
|
61
|
+
* of the flag before it. `statics` are the static commands' ids (`profile:use`) with their flags.
|
|
62
|
+
*/
|
|
63
|
+
export function completeLine(words, current, statics, commands) {
|
|
64
|
+
const typed = words.filter((word) => !word.startsWith('-'));
|
|
65
|
+
const byId = new Map(commands.map((command) => [command.id, command]));
|
|
66
|
+
let resolved;
|
|
67
|
+
for (let count = typed.length; count > 0 && !resolved; count -= 1) {
|
|
68
|
+
const id = typed.slice(0, count).join(':');
|
|
69
|
+
const command = byId.get(id);
|
|
70
|
+
if (command)
|
|
71
|
+
resolved = { flags: flagsOf(command), command };
|
|
72
|
+
else if (statics.has(id))
|
|
73
|
+
resolved = { flags: statics.get(id) };
|
|
74
|
+
}
|
|
75
|
+
if (resolved) {
|
|
76
|
+
const previous = words.at(-1);
|
|
77
|
+
const flag = previous?.startsWith('--')
|
|
78
|
+
? resolved.command?.parameters.find((parameter) => `--${parameter.name}` === previous)
|
|
79
|
+
: undefined;
|
|
80
|
+
if (flag && flag.type !== 'boolean' && !current.startsWith('-'))
|
|
81
|
+
return (flag.enum ?? []).filter((value) => value.startsWith(current));
|
|
82
|
+
if (current !== '' && !current.startsWith('-'))
|
|
83
|
+
return [];
|
|
84
|
+
return [...new Set([...resolved.flags, ...GLOBAL_FLAGS])]
|
|
85
|
+
.filter((candidate) => candidate.startsWith(current))
|
|
86
|
+
.sort();
|
|
87
|
+
}
|
|
88
|
+
const ids = [...statics.keys(), ...commands.map((command) => command.id)].map((id) => id.split(':'));
|
|
89
|
+
const next = new Set();
|
|
90
|
+
for (const id of ids) {
|
|
91
|
+
if (id.length <= typed.length)
|
|
92
|
+
continue;
|
|
93
|
+
if (typed.every((word, index) => id[index] === word)) {
|
|
94
|
+
const word = id[typed.length];
|
|
95
|
+
if (word.startsWith(current) && !word.startsWith('_'))
|
|
96
|
+
next.add(word);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return [...next].sort();
|
|
100
|
+
}
|
|
101
|
+
export function completionCommands(app) {
|
|
102
|
+
class Completion extends AppCommand {
|
|
103
|
+
static summary = 'Print a shell completion script.';
|
|
104
|
+
static description = 'Completes commands and flags from the commands the server last offered you (the cached manifest), so it ' +
|
|
105
|
+
'works offline and follows your permissions after any command has run.\n\n' +
|
|
106
|
+
`zsh: ${app.bin} completion zsh > "\${fpath[1]}/_${app.bin}" (or: source <(${app.bin} completion zsh) in ~/.zshrc)\n` +
|
|
107
|
+
`bash: source <(${app.bin} completion bash) in ~/.bashrc\n` +
|
|
108
|
+
`fish: ${app.bin} completion fish > ~/.config/fish/completions/${app.bin}.fish`;
|
|
109
|
+
static args = {
|
|
110
|
+
shell: Args.string({
|
|
111
|
+
description: 'The shell.',
|
|
112
|
+
options: [...SHELLS],
|
|
113
|
+
required: true,
|
|
114
|
+
}),
|
|
115
|
+
};
|
|
116
|
+
static examples = [`<%= config.bin %> completion zsh`];
|
|
117
|
+
async run() {
|
|
118
|
+
const { args } = await this.parse(Completion);
|
|
119
|
+
const script = completionScript(app.bin, args.shell);
|
|
120
|
+
if (!this.jsonEnabled())
|
|
121
|
+
process.stdout.write(script);
|
|
122
|
+
return { shell: args.shell, script };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
// Not an AppCommand: it prints bare words for a shell, and never fails loudly.
|
|
126
|
+
class Complete extends OclifCommand {
|
|
127
|
+
static hidden = true;
|
|
128
|
+
static strict = false;
|
|
129
|
+
static summary = 'Answer a completion script.';
|
|
130
|
+
async run() {
|
|
131
|
+
const argv = [...this.argv];
|
|
132
|
+
if (argv[0] === '--')
|
|
133
|
+
argv.shift();
|
|
134
|
+
const current = argv.pop() ?? '';
|
|
135
|
+
const statics = new Map();
|
|
136
|
+
for (const command of this.config.commands) {
|
|
137
|
+
if (command.hidden)
|
|
138
|
+
continue;
|
|
139
|
+
statics.set(command.id, Object.keys(command.flags ?? {}).map((name) => `--${name}`));
|
|
140
|
+
}
|
|
141
|
+
let commands;
|
|
142
|
+
try {
|
|
143
|
+
const session = await peekSession();
|
|
144
|
+
commands = session
|
|
145
|
+
? ((await readCachedManifest(session))?.commands ?? [])
|
|
146
|
+
: [];
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
commands = [];
|
|
150
|
+
}
|
|
151
|
+
for (const word of completeLine(argv, current, statics, commands))
|
|
152
|
+
process.stdout.write(`${word}\n`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return { completion: Completion, __complete: Complete };
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=completion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completion.js","sourceRoot":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, such as `acme`. */
|
|
3
|
+
readonly bin: string;
|
|
4
|
+
/** The application's name in messages, such as `Acme`. */
|
|
5
|
+
readonly displayName: string;
|
|
6
|
+
/** The directory under the home directory the CLI keeps its state in, such as `.acme`. */
|
|
7
|
+
readonly stateDir: string;
|
|
8
|
+
/** An environment variable that moves the state directory, such as `ACME_HOME`; tests use it. */
|
|
9
|
+
readonly homeEnv?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Where a runner puts a run's credentials, relative to the run's working directory, such as `.acme/run.json`. The CLI
|
|
12
|
+
* finds the nearest one at or above its working directory and then acts as the run.
|
|
13
|
+
*/
|
|
14
|
+
readonly runCredentialsFile: string;
|
|
15
|
+
/**
|
|
16
|
+
* The keychain service the person's credential (the session `login` signed in, or an API key) is kept under; `cliKeychainService(bin)` by default, such as `acme-cli`,
|
|
17
|
+
* which is also what a runner keeps agents away from.
|
|
18
|
+
*/
|
|
19
|
+
readonly keychainService?: string;
|
|
20
|
+
/** An environment variable whose value `off` turns the keychain off, such as `ACME_KEYCHAIN`; the credential then goes into `config.json`. */
|
|
21
|
+
readonly keychainEnv?: string;
|
|
22
|
+
/**
|
|
23
|
+
* The prefix of the environment variables that act without signing in, such as `ACME` for `ACME_SERVER`,
|
|
24
|
+
* `ACME_API_KEY` and `ACME_PROFILE`; none are read without one.
|
|
25
|
+
*/
|
|
26
|
+
readonly envPrefix?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Signing in through the browser (`<bin> login` without a key), when the server offers it: Better Auth's device
|
|
29
|
+
* authorization (`deviceAuthorization()` and `bearer()` on the server).
|
|
30
|
+
*/
|
|
31
|
+
readonly auth?: AppCliAuth;
|
|
32
|
+
/** The manifest path relative to the server's address; `CLI_ROUTES.manifest` by default. */
|
|
33
|
+
readonly manifestPath?: string;
|
|
34
|
+
/** Shown as `acme login --server <example>`. */
|
|
35
|
+
readonly exampleServer?: string;
|
|
36
|
+
/** What `--version` prints; this package's own version when left out. */
|
|
37
|
+
readonly version?: string;
|
|
38
|
+
/** The root help's description. */
|
|
39
|
+
readonly description?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Asked, as the signed-in person, after `login` and after each business command's manifest fetch: a line saying a
|
|
42
|
+
* newer CLI is available, printed on stderr once, or undefined. It should be quick and remember what it found;
|
|
43
|
+
* whatever it throws is ignored.
|
|
44
|
+
*/
|
|
45
|
+
readonly updateHint?: (session: AppCliSession) => Promise<string | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* How the CLI updates itself when the application's install script installed it: `<bin> update`, and the hint that a
|
|
48
|
+
* newer version is served when `updateHint` is left out (`update.ts`). Without it the CLI has no `update`.
|
|
49
|
+
*/
|
|
50
|
+
readonly selfUpdate?: AppCliSelfUpdate;
|
|
51
|
+
}
|
|
52
|
+
/** What `<bin> update` needs to know of the CLI's own installation. */
|
|
53
|
+
export interface AppCliSelfUpdate {
|
|
54
|
+
/**
|
|
55
|
+
* The root of the CLI's package as it runs, which is `<prefix>/versions/<version>` when the install script installed
|
|
56
|
+
* it (`install.ts`).
|
|
57
|
+
*/
|
|
58
|
+
readonly packageRoot: string;
|
|
59
|
+
/** The product the application serves the CLI as (`DIST_ROUTES.resolve`); `bin` by default. */
|
|
60
|
+
readonly product?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Where the signed-in person's requests go, and the headers that authenticate them. */
|
|
63
|
+
export interface AppCliSession {
|
|
64
|
+
/** As configured: `https://host/app`. */
|
|
65
|
+
readonly server: string;
|
|
66
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
67
|
+
}
|
|
68
|
+
/** The client id a CLI sends when its configuration names none. */
|
|
69
|
+
export declare const DEFAULT_CLI_CLIENT_ID = "nocobase-cli";
|
|
70
|
+
/** Better Auth's routes below the server's address, unless the configuration names others. */
|
|
71
|
+
export declare const DEFAULT_AUTH_BASE_PATH = "/api/auth";
|
|
72
|
+
/**
|
|
73
|
+
* How the CLI signs in through the browser (RFC 8628, Better Auth's `deviceAuthorization()`): it asks
|
|
74
|
+
* `<basePath>/device/code` for a code, the person approves it on the page the server names, and
|
|
75
|
+
* `<basePath>/device/token` answers a session token the CLI then sends as `Authorization: Bearer`; `logout` signs that
|
|
76
|
+
* session out (`<basePath>/sign-out`).
|
|
77
|
+
*/
|
|
78
|
+
export interface AppCliAuth {
|
|
79
|
+
/** The client id the server's `validateClient` accepts, such as `acme`; `DEFAULT_CLI_CLIENT_ID` when left out. */
|
|
80
|
+
readonly clientId?: string;
|
|
81
|
+
/** Better Auth's routes, relative to the server's address; `DEFAULT_AUTH_BASE_PATH` when left out. */
|
|
82
|
+
readonly basePath?: string;
|
|
83
|
+
}
|
|
84
|
+
/** The client id of `auth`. */
|
|
85
|
+
export declare function cliClientIdOf(auth: AppCliAuth): string;
|
|
86
|
+
/** `route` below Better Auth's base path, such as `/api/auth/device/code`. */
|
|
87
|
+
export declare function authRouteOf(auth: AppCliAuth | undefined, route: string): string;
|
|
88
|
+
export declare function configureAppCli(config: AppCliConfig): void;
|
|
89
|
+
export declare function appCliConfig(): AppCliConfig;
|
|
90
|
+
export declare function manifestPathOf(config: AppCliConfig): string;
|
|
91
|
+
export interface AppCliPaths {
|
|
92
|
+
home: string;
|
|
93
|
+
/** The signed-in user and where their key is kept (0600). */
|
|
94
|
+
userConfig: string;
|
|
95
|
+
/** Cached command manifests. */
|
|
96
|
+
manifestCache: string;
|
|
97
|
+
}
|
|
98
|
+
export declare function appCliHome(config?: AppCliConfig, env?: NodeJS.ProcessEnv): string;
|
|
99
|
+
export declare function appCliPaths(home?: string): AppCliPaths;
|
|
100
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,YAAY;IAC3B,wCAAwC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,0FAA0F;I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AC,CAAC;CACpD;AAED,mEAAmE;AACnE,eAAO,MAAM,qBAAqB,iBAAiB,CAAC;AAEpD,8FAA8F;AAC9F,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAElD;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,kHAAkH;IAClH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,sGAAsG;IACtG,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,+BAA+B;AAC/B,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED,8EAA8E;AAC9E,wBAAgB,WAAW,CACzB,IAAI,EAAE,UAAU,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GACZ,MAAM,CAER;AAID,wBAAgB,eAAe,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAE1D;AAED,wBAAgB,YAAY,IAAI,YAAY,CAI3C;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAE3D;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAC;IACnB,gCAAgC;IAChC,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,UAAU,CACxB,MAAM,GAAE,YAA6B,EACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAMR;AAED,wBAAgB,WAAW,CAAC,IAAI,GAAE,MAAqB,GAAG,WAAW,CAMpE"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// What makes the client an application's CLI: its command name, where it keeps state, and which file a run's
|
|
2
|
+
// credentials are in. `runAppCli` takes one of these; everything else in src/client/ reads it through `appCliConfig()`.
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { CLI_ROUTES } from '@nocobase/agent-protocol';
|
|
6
|
+
/** The client id a CLI sends when its configuration names none. */
|
|
7
|
+
export const DEFAULT_CLI_CLIENT_ID = 'nocobase-cli';
|
|
8
|
+
/** Better Auth's routes below the server's address, unless the configuration names others. */
|
|
9
|
+
export const DEFAULT_AUTH_BASE_PATH = '/api/auth';
|
|
10
|
+
/** The client id of `auth`. */
|
|
11
|
+
export function cliClientIdOf(auth) {
|
|
12
|
+
return auth.clientId ?? DEFAULT_CLI_CLIENT_ID;
|
|
13
|
+
}
|
|
14
|
+
/** `route` below Better Auth's base path, such as `/api/auth/device/code`. */
|
|
15
|
+
export function authRouteOf(auth, route) {
|
|
16
|
+
return `${(auth?.basePath ?? DEFAULT_AUTH_BASE_PATH).replace(/\/+$/u, '')}${route}`;
|
|
17
|
+
}
|
|
18
|
+
let current;
|
|
19
|
+
export function configureAppCli(config) {
|
|
20
|
+
current = config;
|
|
21
|
+
}
|
|
22
|
+
export function appCliConfig() {
|
|
23
|
+
if (current === undefined)
|
|
24
|
+
throw new Error('The CLI was started without runAppCli().');
|
|
25
|
+
return current;
|
|
26
|
+
}
|
|
27
|
+
export function manifestPathOf(config) {
|
|
28
|
+
return config.manifestPath ?? CLI_ROUTES.manifest;
|
|
29
|
+
}
|
|
30
|
+
export function appCliHome(config = appCliConfig(), env = process.env) {
|
|
31
|
+
const configured = config.homeEnv === undefined ? undefined : env[config.homeEnv];
|
|
32
|
+
return configured !== undefined && configured !== ''
|
|
33
|
+
? path.resolve(configured)
|
|
34
|
+
: path.join(os.homedir(), config.stateDir);
|
|
35
|
+
}
|
|
36
|
+
export function appCliPaths(home = appCliHome()) {
|
|
37
|
+
return {
|
|
38
|
+
home,
|
|
39
|
+
userConfig: path.join(home, 'config.json'),
|
|
40
|
+
manifestCache: path.join(home, 'cache', 'manifests'),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.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AS,IAAI,UAAU,KAAK,EAAE;QAClD,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QAC1B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,OAAe,UAAU,EAAE;IACrD,OAAO;QACL,IAAI;QACJ,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC;QAC1C,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,WAAW,CAAC;KACrD,CAAC;AACJ,CAAC"}
|
package/dist/docs.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Command } from '@oclif/core';
|
|
2
|
+
import type { AppCliConfig } from './config.ts';
|
|
3
|
+
import type { CliCommand, CliManifest } from './dynamic/manifest.ts';
|
|
4
|
+
/** A command's documentation as text. */
|
|
5
|
+
export declare function commandDocs(command: CliCommand, bin: string): string;
|
|
6
|
+
/** How the CLI works, and the commands by area. */
|
|
7
|
+
export declare function overviewDocs(manifest: CliManifest, app: AppCliConfig): string;
|
|
8
|
+
export declare function docsCommand(app: AppCliConfig): Command.Class;
|
|
9
|
+
//# sourceMappingURL=docs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../src/docs.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,aAAa,CAAC;AAIvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAMhD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAqBrE,yCAAyC;AACzC,wBAAgB,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CA2BpE;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,EAAE,YAAY,GAAG,MAAM,CA4B7E;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,KAAK,CA2E5D"}
|