@mikaelkaron/skills-tessl 0.3.0 → 0.4.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.
@@ -5,8 +5,16 @@ export default class TesslInstall extends Command {
5
5
  description: string;
6
6
  command: string;
7
7
  }[];
8
+ static strict: boolean;
8
9
  static args: {
9
10
  plugin: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
10
11
  };
12
+ static flags: {
13
+ global: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ "accept-warnings": import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ agent: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
18
+ };
11
19
  run(): Promise<void>;
12
20
  }
@@ -1,4 +1,4 @@
1
- import { Args, Command } from "@oclif/core";
1
+ import { Args, Command, Flags } from "@oclif/core";
2
2
  import { install } from "../../lib/tessl.js";
3
3
  export default class TesslInstall extends Command {
4
4
  static summary = "Install the tessl skill tile for an installed plugin.";
@@ -8,30 +8,65 @@ export default class TesslInstall extends Command {
8
8
  command: "<%= config.bin %> <%= command.id %> cherry-pick-filter",
9
9
  },
10
10
  ];
11
+ static strict = false;
11
12
  static args = {
12
13
  plugin: Args.string({
13
- description: "Installed plugin name whose tile should be installed",
14
+ description: "Installed plugin name(s) whose tile should be installed",
14
15
  required: true,
15
16
  }),
16
17
  };
18
+ static flags = {
19
+ global: Flags.boolean({
20
+ char: "g",
21
+ description: "Install tiles globally to ~/.tessl/ instead of the current project",
22
+ }),
23
+ yes: Flags.boolean({
24
+ description: "Skip confirmation prompts and auto-select all skills",
25
+ }),
26
+ verbose: Flags.boolean({
27
+ char: "v",
28
+ description: "Show detailed warning messages during installation",
29
+ }),
30
+ "accept-warnings": Flags.boolean({
31
+ description: "Pre-accept install policy warnings (no interactive prompt)",
32
+ }),
33
+ agent: Flags.string({
34
+ multiple: true,
35
+ description: "Override agents to install for",
36
+ }),
37
+ };
17
38
  async run() {
18
- const { args } = await this.parse(TesslInstall);
19
- const plugin = [...this.config.plugins.values()].find((p) => p.pjson.oclif?.id === args.plugin);
20
- if (!plugin) {
21
- this.error(`Plugin '${args.plugin}' is not installed.`, { exit: 1 });
22
- }
23
- const tesslPjson = plugin.pjson.tessl;
24
- if (!tesslPjson?.tile) {
25
- this.error(`Plugin '${args.plugin}' does not declare a tessl tile in package.json.`, { exit: 1 });
26
- }
27
- const tileRef = tesslPjson.version
28
- ? `${tesslPjson.tile}@${tesslPjson.version}`
29
- : tesslPjson.tile;
30
- try {
31
- install(tileRef);
32
- }
33
- catch (err) {
34
- this.error(err.message, { exit: 1 });
39
+ const { flags, argv } = await this.parse(TesslInstall);
40
+ const pluginNames = argv;
41
+ const extraArgs = [];
42
+ if (flags.global)
43
+ extraArgs.push("--global");
44
+ if (flags.yes)
45
+ extraArgs.push("--yes");
46
+ if (flags.verbose)
47
+ extraArgs.push("--verbose");
48
+ if (flags["accept-warnings"])
49
+ extraArgs.push("--accept-warnings");
50
+ for (const agent of flags.agent ?? [])
51
+ extraArgs.push("--agent", agent);
52
+ for (const pluginName of pluginNames) {
53
+ const plugin = [...this.config.plugins.values()].find((p) => p.pjson.oclif?.id === pluginName);
54
+ if (!plugin) {
55
+ this.error(`Plugin '${pluginName}' is not installed.`, { exit: 1 });
56
+ }
57
+ const tesslPjson = plugin.pjson.tessl;
58
+ if (!tesslPjson?.tile) {
59
+ this.error(`Plugin '${pluginName}' does not declare a tessl tile in package.json.`, { exit: 1 });
60
+ }
61
+ const tileRef = tesslPjson.version
62
+ ? `${tesslPjson.tile}@${tesslPjson.version}`
63
+ : tesslPjson.tile;
64
+ try {
65
+ install(tileRef, undefined, extraArgs);
66
+ }
67
+ catch (err) {
68
+ this.error(err.message, { exit: 1 });
69
+ }
35
70
  }
36
71
  }
37
72
  }
@@ -0,0 +1,16 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class TesslUninstall extends Command {
3
+ static summary: string;
4
+ static examples: {
5
+ description: string;
6
+ command: string;
7
+ }[];
8
+ static strict: boolean;
9
+ static args: {
10
+ plugin: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
11
+ };
12
+ static flags: {
13
+ global: import("@oclif/core/interfaces").BooleanFlag<boolean>;
14
+ };
15
+ run(): Promise<void>;
16
+ }
@@ -0,0 +1,50 @@
1
+ import { Args, Command, Flags } from "@oclif/core";
2
+ import { uninstall } from "../../lib/tessl.js";
3
+ export default class TesslUninstall extends Command {
4
+ static summary = "Uninstall the tessl skill tile for an installed plugin.";
5
+ static examples = [
6
+ {
7
+ description: "Uninstall the skill tile for the cherry-pick-filter plugin",
8
+ command: "<%= config.bin %> <%= command.id %> cherry-pick-filter",
9
+ },
10
+ ];
11
+ static strict = false;
12
+ static args = {
13
+ plugin: Args.string({
14
+ description: "Installed plugin name(s) whose tile should be uninstalled",
15
+ required: true,
16
+ }),
17
+ };
18
+ static flags = {
19
+ global: Flags.boolean({
20
+ char: "g",
21
+ description: "Uninstall tiles from global ~/.tessl/ instead of the current project",
22
+ }),
23
+ };
24
+ async run() {
25
+ const { flags, argv } = await this.parse(TesslUninstall);
26
+ const pluginNames = argv;
27
+ const extraArgs = [];
28
+ if (flags.global)
29
+ extraArgs.push("--global");
30
+ for (const pluginName of pluginNames) {
31
+ const plugin = [...this.config.plugins.values()].find((p) => p.pjson.oclif?.id === pluginName);
32
+ if (!plugin) {
33
+ this.error(`Plugin '${pluginName}' is not installed.`, { exit: 1 });
34
+ }
35
+ const tesslPjson = plugin.pjson.tessl;
36
+ if (!tesslPjson?.tile) {
37
+ this.error(`Plugin '${pluginName}' does not declare a tessl tile in package.json.`, { exit: 1 });
38
+ }
39
+ const tileRef = tesslPjson.version
40
+ ? `${tesslPjson.tile}@${tesslPjson.version}`
41
+ : tesslPjson.tile;
42
+ try {
43
+ uninstall(tileRef, undefined, extraArgs);
44
+ }
45
+ catch (err) {
46
+ this.error(err.message, { exit: 1 });
47
+ }
48
+ }
49
+ }
50
+ }
@@ -1 +1,2 @@
1
- export declare function install(tile: string, cmd?: string): void;
1
+ export declare function install(tile: string, cmd?: string, extraArgs?: string[]): void;
2
+ export declare function uninstall(tile: string, cmd?: string, extraArgs?: string[]): void;
package/dist/lib/tessl.js CHANGED
@@ -1,6 +1,12 @@
1
1
  import { spawnSync } from "node:child_process";
2
- export function install(tile, cmd = process.env["TESSL_CMD"] ?? "tessl") {
3
- const result = spawnSync(cmd, ["install", tile], { stdio: "inherit" });
2
+ import which from "which";
3
+ function defaultCmd() {
4
+ return (process.env["TESSL_CMD"] ??
5
+ which.sync("tessl", { nothrow: true }) ??
6
+ "tessl");
7
+ }
8
+ function run(args, cmd = defaultCmd()) {
9
+ const result = spawnSync(cmd, args, { stdio: "inherit" });
4
10
  if (result.error) {
5
11
  throw new Error(result.error.message.includes("ENOENT")
6
12
  ? "tessl CLI not found. Install it from https://tessl.io"
@@ -10,3 +16,9 @@ export function install(tile, cmd = process.env["TESSL_CMD"] ?? "tessl") {
10
16
  process.exit(result.status ?? 1);
11
17
  }
12
18
  }
19
+ export function install(tile, cmd, extraArgs = []) {
20
+ run(["install", tile, ...extraArgs], cmd);
21
+ }
22
+ export function uninstall(tile, cmd, extraArgs = []) {
23
+ run(["uninstall", tile, ...extraArgs], cmd);
24
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikaelkaron/skills-tessl",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "bin": {
5
5
  "mks-tessl": "bin/run.js"
6
6
  },
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "scripts": {
17
17
  "build": "tsc",
18
+ "pretest": "npm run build",
18
19
  "test": "node --experimental-strip-types --test 'test/**/*.test.ts'",
19
20
  "test:types": "tsc -p test/tsconfig.json"
20
21
  },