@copado/agentia-cli 1.0.0-beta.7 → 1.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +286 -302
- package/dist/commands/plugins/install.js +76 -0
- package/dist/lib/plugin-trust/catalog.js +6 -0
- package/dist/lib/plugin-trust/gate.js +14 -0
- package/dist/lib/plugin-trust/http.js +5 -0
- package/dist/lib/plugin-trust/policy.js +3 -0
- package/dist/lib/runtime.js +1 -1
- package/oclif.manifest.json +70 -1
- package/package.json +1 -1
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { confirm } from '@inquirer/prompts';
|
|
2
|
+
import { Args, Flags } from '@oclif/core';
|
|
3
|
+
import { AgentiaCommand } from '../../lib/agentia-command.js';
|
|
4
|
+
import { assessInstalls, enforceInstalls, parseInstallArguments, PluginTrustError, stockInstallArguments, uncheckedWarning } from '../../lib/plugin-trust/gate.js';
|
|
5
|
+
export default class PluginsInstall extends AgentiaCommand {
|
|
6
|
+
static aliases = ['plugins:add'];
|
|
7
|
+
static args = {
|
|
8
|
+
plugin: Args.string({ description: 'npm package name (optionally with @tag) or git URL.', required: true }),
|
|
9
|
+
};
|
|
10
|
+
static description = `Install plugins with npm after checking them against the Agentia plugin catalog.
|
|
11
|
+
|
|
12
|
+
Official and Verified plugins install without a prompt. Community, unlisted, and git URL plugins ask first. Use --allow-unverified when there is no terminal or with --json.
|
|
13
|
+
|
|
14
|
+
A revoked version, or an npm tarball that differs from the hash in the catalog, is always refused. If the catalog cannot be reached, the command warns and the install continues.`;
|
|
15
|
+
static examples = [
|
|
16
|
+
'<%= config.bin %> <%= command.id %> @acme/agentia-plugin-x',
|
|
17
|
+
'<%= config.bin %> <%= command.id %> @acme/agentia-plugin-x@1.2.0 --allow-unverified --json',
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
'allow-unverified': Flags.boolean({ description: 'Install plugins that are not Official or Verified without asking. Never overrides a revoked or mismatched version.' }),
|
|
21
|
+
force: Flags.boolean({ char: 'f', description: 'Force npm to fetch remote resources even if a local copy exists.' }),
|
|
22
|
+
silent: Flags.boolean({ char: 's', description: 'Silence npm output.' }),
|
|
23
|
+
verbose: Flags.boolean({ char: 'v', description: 'Show verbose npm output.' }),
|
|
24
|
+
};
|
|
25
|
+
static strict = false;
|
|
26
|
+
async run() {
|
|
27
|
+
let plugins;
|
|
28
|
+
let stockArguments;
|
|
29
|
+
try {
|
|
30
|
+
const parsed = parseInstallArguments(this.argv);
|
|
31
|
+
const inputs = this.applyAliases(parsed.inputs);
|
|
32
|
+
if (inputs.length === 0)
|
|
33
|
+
this.error('Missing 1 required arg:\nplugin Plugin to install.', { exit: 2 });
|
|
34
|
+
// The installer reads this registry setting; a hash from public npm would not describe a package from another registry.
|
|
35
|
+
const registryVariable = this.config.scopedEnvVarKey('NPM_REGISTRY');
|
|
36
|
+
const customRegistry = Boolean(process.env[registryVariable]);
|
|
37
|
+
const { assessments } = await assessInstalls(inputs, { resolve: !customRegistry });
|
|
38
|
+
const skipped = uncheckedWarning(assessments);
|
|
39
|
+
if (skipped)
|
|
40
|
+
this.display(() => this.warn(skipped));
|
|
41
|
+
if (customRegistry)
|
|
42
|
+
this.display(() => this.warn(`${registryVariable} is set, so versions cannot be checked against the catalog.`));
|
|
43
|
+
plugins = await enforceInstalls(assessments, {
|
|
44
|
+
allowUnverified: parsed.allowUnverified,
|
|
45
|
+
confirm: async (message) => confirm({ default: false, message }),
|
|
46
|
+
interactive: !this.jsonEnabled() && Boolean(process.stdin.isTTY && process.stdout.isTTY),
|
|
47
|
+
warn: (line) => this.display(() => this.warn(line)),
|
|
48
|
+
});
|
|
49
|
+
stockArguments = stockInstallArguments(parsed, assessments);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
if (error instanceof PluginTrustError)
|
|
53
|
+
this.error(error.message, { exit: 1 });
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
await this.runStockInstall(stockArguments);
|
|
57
|
+
return { plugins };
|
|
58
|
+
}
|
|
59
|
+
applyAliases(inputs) {
|
|
60
|
+
const aliases = this.config.pjson.oclif.aliases ?? {};
|
|
61
|
+
return inputs.map((input) => {
|
|
62
|
+
if (aliases[input] === null)
|
|
63
|
+
this.error(`${input} is blocked`, { exit: 1 });
|
|
64
|
+
return aliases[input] ?? input;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Runs the stock @oclif/plugin-plugins command, which still does the npm install.
|
|
68
|
+
async runStockInstall(argv) {
|
|
69
|
+
const stock = this.config.plugins.get('@oclif/plugin-plugins')?.commands.find((command) => command.id === 'plugins:install');
|
|
70
|
+
if (stock === undefined)
|
|
71
|
+
this.error('@oclif/plugin-plugins is not available, so plugins cannot be installed.', { exit: 1 });
|
|
72
|
+
const StockInstall = await stock.load();
|
|
73
|
+
await StockInstall.run(argv, this.config);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=install.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import {modules} from '../runtime.js';
|
|
2
|
+
const DEFAULT_CATALOG_URL = modules["plugin-trust/catalog.js"]["DEFAULT_CATALOG_URL"]
|
|
3
|
+
const cleanText = modules["plugin-trust/catalog.js"]["cleanText"]
|
|
4
|
+
const loadCatalog = modules["plugin-trust/catalog.js"]["loadCatalog"]
|
|
5
|
+
const parseCatalog = modules["plugin-trust/catalog.js"]["parseCatalog"]
|
|
6
|
+
export {DEFAULT_CATALOG_URL, cleanText, loadCatalog, parseCatalog};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {modules} from '../runtime.js';
|
|
2
|
+
const PluginTrustError = modules["plugin-trust/gate.js"]["PluginTrustError"]
|
|
3
|
+
const assessInstalls = modules["plugin-trust/gate.js"]["assessInstalls"]
|
|
4
|
+
const confirmationWarning = modules["plugin-trust/gate.js"]["confirmationWarning"]
|
|
5
|
+
const deprecationWarning = modules["plugin-trust/gate.js"]["deprecationWarning"]
|
|
6
|
+
const enforceInstalls = modules["plugin-trust/gate.js"]["enforceInstalls"]
|
|
7
|
+
const installPrompt = modules["plugin-trust/gate.js"]["installPrompt"]
|
|
8
|
+
const parseInstallArguments = modules["plugin-trust/gate.js"]["parseInstallArguments"]
|
|
9
|
+
const parseInstallTarget = modules["plugin-trust/gate.js"]["parseInstallTarget"]
|
|
10
|
+
const pluginSpec = modules["plugin-trust/gate.js"]["pluginSpec"]
|
|
11
|
+
const resolveNpmVersion = modules["plugin-trust/gate.js"]["resolveNpmVersion"]
|
|
12
|
+
const stockInstallArguments = modules["plugin-trust/gate.js"]["stockInstallArguments"]
|
|
13
|
+
const uncheckedWarning = modules["plugin-trust/gate.js"]["uncheckedWarning"]
|
|
14
|
+
export {PluginTrustError, assessInstalls, confirmationWarning, deprecationWarning, enforceInstalls, installPrompt, parseInstallArguments, parseInstallTarget, pluginSpec, resolveNpmVersion, stockInstallArguments, uncheckedWarning};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import {modules} from '../runtime.js';
|
|
2
|
+
const defaultFetchJson = modules["plugin-trust/http.js"]["defaultFetchJson"]
|
|
3
|
+
const fetchJson = modules["plugin-trust/http.js"]["fetchJson"]
|
|
4
|
+
const setFetchJsonForTests = modules["plugin-trust/http.js"]["setFetchJsonForTests"]
|
|
5
|
+
export {defaultFetchJson, fetchJson, setFetchJsonForTests};
|