@mikaelkaron/skills-tessl 0.0.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/bin/run.ts ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env -S node --experimental-strip-types
2
+
3
+ import { execute } from "@oclif/core";
4
+ await execute({ dir: import.meta.url });
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@mikaelkaron/skills-tessl",
3
+ "version": "0.0.0",
4
+ "bin": {
5
+ "mks-tessl": "bin/run.ts"
6
+ },
7
+ "files": [
8
+ "bin",
9
+ "src",
10
+ "oclif.manifest.json"
11
+ ],
12
+ "type": "module",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "scripts": {
17
+ "test": "node --experimental-strip-types --test 'test/**/*.test.ts'",
18
+ "test:types": "tsc --noEmit"
19
+ },
20
+ "dependencies": {
21
+ "@oclif/core": "^4"
22
+ },
23
+ "devDependencies": {
24
+ "@oclif/test": "^4.1.18",
25
+ "@types/node": "^22",
26
+ "typescript": "^5"
27
+ },
28
+ "oclif": {
29
+ "bin": "mks-tessl",
30
+ "commands": {
31
+ "globPatterns": [
32
+ "**/*.ts"
33
+ ],
34
+ "strategy": "pattern",
35
+ "target": "./src/commands"
36
+ },
37
+ "id": "tessl"
38
+ },
39
+ "engines": {
40
+ "node": ">=22.18"
41
+ },
42
+ "tessl": {
43
+ "tile": "mikaelkaron/tessl",
44
+ "version": "0.1.0"
45
+ }
46
+ }
@@ -0,0 +1,66 @@
1
+ import { Args, Command } from "@oclif/core";
2
+ import { spawnSync } from "node:child_process";
3
+
4
+ type PluginPjson = {
5
+ tessl?: { tile?: string; version?: string };
6
+ oclif?: { id?: string };
7
+ };
8
+
9
+ export default class TesslInstall extends Command {
10
+ static override summary =
11
+ "Install the tessl skill tile for an installed plugin.";
12
+
13
+ static override examples = [
14
+ {
15
+ description: "Install the skill tile for the cherry-pick-filter plugin",
16
+ command: "<%= config.bin %> <%= command.id %> cherry-pick-filter",
17
+ },
18
+ ];
19
+
20
+ static override args = {
21
+ plugin: Args.string({
22
+ description: "Installed plugin name whose tile should be installed",
23
+ required: true,
24
+ }),
25
+ };
26
+
27
+ async run(): Promise<void> {
28
+ const { args } = await this.parse(TesslInstall);
29
+
30
+ const plugin = [...this.config.plugins.values()].find(
31
+ (p) => (p.pjson as PluginPjson).oclif?.id === args.plugin,
32
+ );
33
+
34
+ if (!plugin) {
35
+ this.error(`Plugin '${args.plugin}' is not installed.`, { exit: 1 });
36
+ }
37
+
38
+ const tesslPjson = (plugin.pjson as PluginPjson).tessl;
39
+ if (!tesslPjson?.tile) {
40
+ this.error(
41
+ `Plugin '${args.plugin}' does not declare a tessl tile in package.json.`,
42
+ { exit: 1 },
43
+ );
44
+ }
45
+
46
+ const tileRef = tesslPjson.version
47
+ ? `${tesslPjson.tile}@${tesslPjson.version}`
48
+ : tesslPjson.tile;
49
+
50
+ const tessCmd = process.env["TESSL_CMD"] ?? "tessl";
51
+ const result = spawnSync(tessCmd, ["tile", "install", tileRef]);
52
+
53
+ if (result.error) {
54
+ this.error(
55
+ result.error.message.includes("ENOENT")
56
+ ? "tessl CLI not found. Install it from https://tessl.io"
57
+ : result.error.message,
58
+ { exit: 1 },
59
+ );
60
+ }
61
+
62
+ if (result.status !== 0) {
63
+ this.exit(result.status ?? 1);
64
+ }
65
+ }
66
+ }