@mercury-fw/plugin-atlassian-admin 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/atlassian-admin.json +10 -0
- package/dist/index.d.ts +13 -0
- package/index.ts +56 -0
- package/package.json +53 -0
- package/scripts/install-atlassian-admin-cli.ts +11 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @mercury-fw/plugin-atlassian-admin
|
|
2
|
+
|
|
3
|
+
Lets a [Mercury](https://github.com/lucabro81/mercury-fw) agent look up users in an Atlassian organization, through the `atlassian-admin` CLI (read-only). The pinned binary downloads when the package installs.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun add @mercury-fw/plugin-atlassian-admin
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
In the app: list it in `trustedDependencies` (or Bun skips the install script that downloads the binary), add `atlassian-admin` to `MERCURY_CLIS`, and declare it in `mercury.config.ts`:
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { atlassianAdminPlugin } from "@mercury-fw/plugin-atlassian-admin";
|
|
13
|
+
|
|
14
|
+
plugins: [atlassianAdminPlugin],
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Credentials
|
|
18
|
+
|
|
19
|
+
The CLI keeps its login under `~/.config/atlassian-admin-cli`, which in a container lives on the `cli-credentials` volume. Log in with the CLI's own setup (see [CLI-monorepo](https://github.com/lucabro81/CLI-monorepo)), then bring that folder into the volume; doing it from the env file is planned ([#57](https://github.com/lucabro81/mercury-fw/issues/57)).
|
|
20
|
+
|
|
21
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The atlassian-admin plugin — a minimal read-only CLI plugin (user get,
|
|
3
|
+
* doctor; no mutating or confirm-gated commands, no result post-processing, no
|
|
4
|
+
* post-turn guard, no prompt block of its own). Like Jira/Bitbucket it works
|
|
5
|
+
* only through a CLI, so it owns its tool: in `build()` it validates its own
|
|
6
|
+
* allowlist and builds its `atlassianAdminCommand` tool from it. Its allowlist
|
|
7
|
+
* (`atlassian-admin.json`) and its pinned CLI binary (via the package's
|
|
8
|
+
* postinstall, using `@mercury-fw/utils`) travel with the package.
|
|
9
|
+
*/
|
|
10
|
+
import { type Plugin } from "@mercury-fw/plugin-types";
|
|
11
|
+
/** The raw, unvalidated allowlist object. The plugin validates it itself through `@mercury-fw/cli-engine`'s loader, so nothing reaches the model's executable surface unvalidated. */
|
|
12
|
+
export declare const atlassianAdminCliConfig: unknown;
|
|
13
|
+
export declare const atlassianAdminPlugin: Plugin;
|
package/index.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The atlassian-admin plugin — a minimal read-only CLI plugin (user get,
|
|
3
|
+
* doctor; no mutating or confirm-gated commands, no result post-processing, no
|
|
4
|
+
* post-turn guard, no prompt block of its own). Like Jira/Bitbucket it works
|
|
5
|
+
* only through a CLI, so it owns its tool: in `build()` it validates its own
|
|
6
|
+
* allowlist and builds its `atlassianAdminCommand` tool from it. Its allowlist
|
|
7
|
+
* (`atlassian-admin.json`) and its pinned CLI binary (via the package's
|
|
8
|
+
* postinstall, using `@mercury-fw/utils`) travel with the package.
|
|
9
|
+
*/
|
|
10
|
+
import { PLUGIN_API_VERSION, type Plugin } from "@mercury-fw/plugin-types";
|
|
11
|
+
import { runCli, createCliTool, parseCliConfig, createCliStatusDescriber } from "@mercury-fw/cli-engine";
|
|
12
|
+
import rawConfig from "./atlassian-admin.json";
|
|
13
|
+
|
|
14
|
+
/** The raw, unvalidated allowlist object. The plugin validates it itself through `@mercury-fw/cli-engine`'s loader, so nothing reaches the model's executable surface unvalidated. */
|
|
15
|
+
export const atlassianAdminCliConfig: unknown = rawConfig;
|
|
16
|
+
|
|
17
|
+
/** Reads the command string off an `atlassianAdminCommand` call's input for the status label; a missing/non-string command falls back to the generic label. */
|
|
18
|
+
function commandOf(input: unknown): string | undefined {
|
|
19
|
+
if (typeof input === "object" && input !== null && "command" in input) {
|
|
20
|
+
const command = (input as { command: unknown }).command;
|
|
21
|
+
if (typeof command === "string") return command;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const atlassianAdminPlugin: Plugin = {
|
|
27
|
+
apiVersion: PLUGIN_API_VERSION,
|
|
28
|
+
name: "atlassian-admin",
|
|
29
|
+
build: (ctx) => {
|
|
30
|
+
// Schema-only validation — the pinned binary is co-shipped, so no
|
|
31
|
+
// `--version` check (see the Jira/Bitbucket plugins / `parseCliConfig`).
|
|
32
|
+
const loaded = parseCliConfig(atlassianAdminCliConfig);
|
|
33
|
+
if (!loaded.ok) {
|
|
34
|
+
ctx.log(`atlassian-admin allowlist failed to load, tool not contributed: ${loaded.reason}`);
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
const configs = { [loaded.binary]: loaded.config };
|
|
38
|
+
const describeCli = createCliStatusDescriber(configs, {});
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
sessionTools: (sctx) => {
|
|
42
|
+
const { runCommand } = createCliTool(runCli, configs, {
|
|
43
|
+
stageConfirmation: sctx.stageConfirmation,
|
|
44
|
+
stashDisplay: sctx.stashDisplay,
|
|
45
|
+
});
|
|
46
|
+
return { atlassianAdminCommand: runCommand };
|
|
47
|
+
},
|
|
48
|
+
toolStatusDescribers: {
|
|
49
|
+
atlassianAdminCommand: (input) => {
|
|
50
|
+
const command = commandOf(input);
|
|
51
|
+
return command !== undefined ? describeCli(command) : "esecuzione di un comando";
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mercury-fw/plugin-atlassian-admin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/lucabro81/mercury-fw.git",
|
|
8
|
+
"directory": "packages/tools/plugin-atlassian-admin"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"*.ts",
|
|
12
|
+
"dist",
|
|
13
|
+
"atlassian-admin.json",
|
|
14
|
+
"scripts",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"!**/*.test.ts"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"peerDependencies": {
|
|
22
|
+
"@mercury-fw/cli-engine": ">=0.24.0 <1.0.0",
|
|
23
|
+
"@mercury-fw/plugin-types": ">=0.24.0 <1.0.0",
|
|
24
|
+
"@mercury-fw/utils": ">=0.24.0 <1.0.0"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@mercury-fw/cli-engine": "0.25.0",
|
|
28
|
+
"@mercury-fw/plugin-types": "0.25.0",
|
|
29
|
+
"@mercury-fw/typescript-config": "*",
|
|
30
|
+
"@mercury-fw/utils": "0.25.0",
|
|
31
|
+
"@types/bun": "^1.4.0",
|
|
32
|
+
"typescript": "^6.0.3"
|
|
33
|
+
},
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"mercury-fw-source": "./index.ts",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./index.ts"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"postinstall": "bun run scripts/install-atlassian-admin-cli.ts",
|
|
43
|
+
"test": "bun test",
|
|
44
|
+
"typecheck": "tsc --noEmit"
|
|
45
|
+
},
|
|
46
|
+
"mercury": {
|
|
47
|
+
"cliBinary": {
|
|
48
|
+
"repo": "lucabro81/CLI-monorepo",
|
|
49
|
+
"crate": "atlassian-admin",
|
|
50
|
+
"version": "0.1.2"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* postinstall hook for @mercury-fw/plugin-atlassian-admin: downloads the pinned
|
|
3
|
+
* atlassian-admin CLI binary for the current platform into this package's
|
|
4
|
+
* `bin/`. Identical in shape to the Jira/Bitbucket plugins' — the mechanism
|
|
5
|
+
* lives in `@mercury-fw/utils`; this script only names the pin (its own
|
|
6
|
+
* package.json's `mercury.cliBinary`) and where to write it (`import.meta.url`).
|
|
7
|
+
*/
|
|
8
|
+
import { downloadPinnedBinary } from "@mercury-fw/utils";
|
|
9
|
+
import pkg from "../package.json";
|
|
10
|
+
|
|
11
|
+
await downloadPinnedBinary(pkg, import.meta.url);
|