toolfactory 0.1.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 +166 -0
- package/dist/bindings/index.d.ts +23 -0
- package/dist/bindings/index.js +29 -0
- package/dist/bindings/python.d.ts +33 -0
- package/dist/bindings/python.js +805 -0
- package/dist/bindings/python.test.d.ts +1 -0
- package/dist/bindings/python.test.js +316 -0
- package/dist/bindings/typescript.d.ts +39 -0
- package/dist/bindings/typescript.js +758 -0
- package/dist/bindings/typescript.test.d.ts +1 -0
- package/dist/bindings/typescript.test.js +264 -0
- package/dist/commands.d.ts +188 -0
- package/dist/commands.js +662 -0
- package/dist/commands.test.d.ts +1 -0
- package/dist/commands.test.js +215 -0
- package/dist/e2e.test.d.ts +1 -0
- package/dist/e2e.test.js +124 -0
- package/dist/hosts/browser.d.ts +10 -0
- package/dist/hosts/browser.js +94 -0
- package/dist/hosts/github.d.ts +66 -0
- package/dist/hosts/github.js +247 -0
- package/dist/hosts/openclaw.d.ts +4 -0
- package/dist/hosts/openclaw.js +94 -0
- package/dist/hosts/template.d.ts +15 -0
- package/dist/hosts/template.js +142 -0
- package/dist/hosts/web.d.ts +4 -0
- package/dist/hosts/web.js +89 -0
- package/dist/identity/name.d.ts +20 -0
- package/dist/identity/name.js +33 -0
- package/dist/identity/name.test.d.ts +1 -0
- package/dist/identity/name.test.js +37 -0
- package/dist/identity/read.d.ts +9 -0
- package/dist/identity/read.js +106 -0
- package/dist/identity/read.test.d.ts +1 -0
- package/dist/identity/read.test.js +76 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/introspect/index.d.ts +15 -0
- package/dist/introspect/index.js +63 -0
- package/dist/model.d.ts +236 -0
- package/dist/model.js +214 -0
- package/dist/ops.d.ts +255 -0
- package/dist/ops.js +297 -0
- package/dist/project/apply.d.ts +35 -0
- package/dist/project/apply.js +360 -0
- package/dist/project/apply.test.d.ts +1 -0
- package/dist/project/apply.test.js +285 -0
- package/dist/project/gate.d.ts +129 -0
- package/dist/project/gate.js +597 -0
- package/dist/project/history.d.ts +62 -0
- package/dist/project/history.js +41 -0
- package/dist/project/load.d.ts +21 -0
- package/dist/project/load.js +82 -0
- package/dist/project/lock.d.ts +28 -0
- package/dist/project/lock.js +42 -0
- package/dist/project/plan.d.ts +5 -0
- package/dist/project/plan.js +96 -0
- package/dist/report/coverage.d.ts +22 -0
- package/dist/report/coverage.js +72 -0
- package/dist/report/coverage.test.d.ts +1 -0
- package/dist/report/coverage.test.js +93 -0
- package/dist/surfaces/agent-plugins.d.ts +10 -0
- package/dist/surfaces/agent-plugins.js +36 -0
- package/dist/surfaces/agents.d.ts +35 -0
- package/dist/surfaces/agents.js +609 -0
- package/dist/surfaces/agents.template.d.ts +8 -0
- package/dist/surfaces/agents.template.js +21 -0
- package/dist/surfaces/agents.test.d.ts +1 -0
- package/dist/surfaces/agents.test.js +181 -0
- package/dist/surfaces/browser-extension.d.ts +101 -0
- package/dist/surfaces/browser-extension.js +1034 -0
- package/dist/surfaces/browser-extension.test.d.ts +1 -0
- package/dist/surfaces/browser-extension.test.js +145 -0
- package/dist/surfaces/claude.d.ts +2 -0
- package/dist/surfaces/claude.js +81 -0
- package/dist/surfaces/codex.d.ts +13 -0
- package/dist/surfaces/codex.js +101 -0
- package/dist/surfaces/codex.test.d.ts +1 -0
- package/dist/surfaces/codex.test.js +67 -0
- package/dist/surfaces/cursor.d.ts +2 -0
- package/dist/surfaces/cursor.js +50 -0
- package/dist/surfaces/distribution.test.d.ts +1 -0
- package/dist/surfaces/distribution.test.js +146 -0
- package/dist/surfaces/dsh.d.ts +25 -0
- package/dist/surfaces/dsh.js +147 -0
- package/dist/surfaces/dsh.test.d.ts +1 -0
- package/dist/surfaces/dsh.test.js +100 -0
- package/dist/surfaces/external.d.ts +9 -0
- package/dist/surfaces/external.js +4 -0
- package/dist/surfaces/gemini.d.ts +29 -0
- package/dist/surfaces/gemini.js +68 -0
- package/dist/surfaces/gemini.test.d.ts +1 -0
- package/dist/surfaces/gemini.test.js +74 -0
- package/dist/surfaces/hermes-native.d.ts +53 -0
- package/dist/surfaces/hermes-native.js +507 -0
- package/dist/surfaces/hermes-native.test.d.ts +1 -0
- package/dist/surfaces/hermes-native.test.js +156 -0
- package/dist/surfaces/kernel.d.ts +5 -0
- package/dist/surfaces/kernel.js +63 -0
- package/dist/surfaces/mcp-registry.d.ts +19 -0
- package/dist/surfaces/mcp-registry.js +160 -0
- package/dist/surfaces/mcp-registry.test.d.ts +1 -0
- package/dist/surfaces/mcp-registry.test.js +79 -0
- package/dist/surfaces/mcpb.d.ts +11 -0
- package/dist/surfaces/mcpb.js +118 -0
- package/dist/surfaces/mcpb.test.d.ts +1 -0
- package/dist/surfaces/mcpb.test.js +104 -0
- package/dist/surfaces/npm.d.ts +6 -0
- package/dist/surfaces/npm.js +72 -0
- package/dist/surfaces/openclaw-native.d.ts +93 -0
- package/dist/surfaces/openclaw-native.js +956 -0
- package/dist/surfaces/openclaw-native.test.d.ts +1 -0
- package/dist/surfaces/openclaw-native.test.js +246 -0
- package/dist/surfaces/pypi.d.ts +5 -0
- package/dist/surfaces/pypi.js +82 -0
- package/dist/surfaces/readme.d.ts +7 -0
- package/dist/surfaces/readme.js +181 -0
- package/dist/surfaces/registry.d.ts +6 -0
- package/dist/surfaces/registry.js +73 -0
- package/dist/surfaces/shared.d.ts +49 -0
- package/dist/surfaces/shared.js +112 -0
- package/dist/surfaces/skill.d.ts +7 -0
- package/dist/surfaces/skill.js +118 -0
- package/dist/surfaces/skill.test.d.ts +1 -0
- package/dist/surfaces/skill.test.js +87 -0
- package/dist/surfaces/web.d.ts +97 -0
- package/dist/surfaces/web.js +1285 -0
- package/dist/surfaces/web.test.d.ts +1 -0
- package/dist/surfaces/web.test.js +255 -0
- package/dist/surfaces/workflows.d.ts +2 -0
- package/dist/surfaces/workflows.js +809 -0
- package/dist/surfaces/workflows.test.d.ts +1 -0
- package/dist/surfaces/workflows.test.js +563 -0
- package/dist/toolfactory/cli.d.ts +2 -0
- package/dist/toolfactory/cli.js +65 -0
- package/dist/toolfactory/config.d.ts +3 -0
- package/dist/toolfactory/config.js +27 -0
- package/dist/toolfactory/mcp.d.ts +37 -0
- package/dist/toolfactory/mcp.js +269 -0
- package/dist/toolfactory/types.d.ts +31 -0
- package/dist/toolfactory/types.js +10 -0
- package/dist/toolfactory/web.d.ts +4 -0
- package/dist/toolfactory/web.js +40 -0
- package/dist/validate/agent-plugins.d.ts +5 -0
- package/dist/validate/agent-plugins.js +46 -0
- package/package.json +68 -0
- package/schemas/agent-plugins/mcp.schema.json +120 -0
- package/schemas/agent-plugins/plugin.schema.json +65 -0
- package/src/bindings/index.ts +47 -0
- package/src/bindings/python.test.ts +374 -0
- package/src/bindings/python.ts +862 -0
- package/src/bindings/typescript.test.ts +329 -0
- package/src/bindings/typescript.ts +818 -0
- package/src/commands.test.ts +253 -0
- package/src/commands.ts +886 -0
- package/src/e2e.test.ts +169 -0
- package/src/hosts/browser.ts +106 -0
- package/src/hosts/github.ts +321 -0
- package/src/hosts/openclaw.ts +110 -0
- package/src/hosts/template.ts +149 -0
- package/src/hosts/web.ts +111 -0
- package/src/identity/name.test.ts +43 -0
- package/src/identity/name.ts +39 -0
- package/src/identity/read.test.ts +92 -0
- package/src/identity/read.ts +119 -0
- package/src/index.ts +11 -0
- package/src/introspect/index.ts +72 -0
- package/src/model.ts +386 -0
- package/src/ops.ts +333 -0
- package/src/project/apply.test.ts +348 -0
- package/src/project/apply.ts +417 -0
- package/src/project/gate.ts +717 -0
- package/src/project/history.ts +46 -0
- package/src/project/load.ts +104 -0
- package/src/project/lock.ts +54 -0
- package/src/project/plan.ts +101 -0
- package/src/report/coverage.test.ts +108 -0
- package/src/report/coverage.ts +113 -0
- package/src/surfaces/agent-plugins.ts +47 -0
- package/src/surfaces/agents.template.ts +32 -0
- package/src/surfaces/agents.test.ts +206 -0
- package/src/surfaces/agents.ts +729 -0
- package/src/surfaces/browser-extension.test.ts +175 -0
- package/src/surfaces/browser-extension.ts +1095 -0
- package/src/surfaces/claude.ts +99 -0
- package/src/surfaces/codex.test.ts +71 -0
- package/src/surfaces/codex.ts +105 -0
- package/src/surfaces/cursor.ts +62 -0
- package/src/surfaces/distribution.test.ts +166 -0
- package/src/surfaces/dsh.test.ts +110 -0
- package/src/surfaces/dsh.ts +159 -0
- package/src/surfaces/external.ts +13 -0
- package/src/surfaces/gemini.test.ts +80 -0
- package/src/surfaces/gemini.ts +84 -0
- package/src/surfaces/hermes-native.test.ts +179 -0
- package/src/surfaces/hermes-native.ts +584 -0
- package/src/surfaces/kernel.ts +68 -0
- package/src/surfaces/mcp-registry.test.ts +99 -0
- package/src/surfaces/mcp-registry.ts +190 -0
- package/src/surfaces/mcpb.test.ts +112 -0
- package/src/surfaces/mcpb.ts +130 -0
- package/src/surfaces/npm.ts +78 -0
- package/src/surfaces/openclaw-native.test.ts +283 -0
- package/src/surfaces/openclaw-native.ts +1070 -0
- package/src/surfaces/pypi.ts +84 -0
- package/src/surfaces/readme.ts +218 -0
- package/src/surfaces/registry.ts +79 -0
- package/src/surfaces/shared.ts +140 -0
- package/src/surfaces/skill.test.ts +103 -0
- package/src/surfaces/skill.ts +136 -0
- package/src/surfaces/web.test.ts +303 -0
- package/src/surfaces/web.ts +1310 -0
- package/src/surfaces/workflows.test.ts +677 -0
- package/src/surfaces/workflows.ts +936 -0
- package/src/toolfactory/cli.ts +74 -0
- package/src/toolfactory/config.ts +33 -0
- package/src/toolfactory/mcp.ts +311 -0
- package/src/toolfactory/types.ts +52 -0
- package/src/toolfactory/web.ts +45 -0
- package/src/validate/agent-plugins.ts +53 -0
- package/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/web/dist/assets/index-CCXhQKK3.css +2 -0
- package/web/dist/assets/index-D1PwZ3qS.js +10 -0
- package/web/dist/index.html +14 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The command layer's own behaviour: the step runner behind `gate`/`package`, the `gh`
|
|
3
|
+
* invocations `init --repo` makes (dry-run only — `gh` is not installed here and
|
|
4
|
+
* api.github.com is unreachable, so the shape is proved, never the call), and what `init`
|
|
5
|
+
* leaves behind in a real directory.
|
|
6
|
+
*/
|
|
7
|
+
import { execFileSync } from "node:child_process";
|
|
8
|
+
import { existsSync, mkdtempSync, readFileSync, writeFileSync } from "node:fs";
|
|
9
|
+
import { tmpdir } from "node:os";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
12
|
+
import * as commands from "./commands.js";
|
|
13
|
+
import { createRepo } from "./hosts/github.js";
|
|
14
|
+
import {
|
|
15
|
+
assertNoSensitiveArgument,
|
|
16
|
+
defaultSurfaces,
|
|
17
|
+
type Operation,
|
|
18
|
+
type Project,
|
|
19
|
+
type SurfaceId,
|
|
20
|
+
ToolConfigSchema,
|
|
21
|
+
} from "./model.js";
|
|
22
|
+
import { RELOAD } from "./surfaces/agents.js";
|
|
23
|
+
|
|
24
|
+
function project(surfaces: SurfaceId[]): Project {
|
|
25
|
+
return {
|
|
26
|
+
root: "/repo",
|
|
27
|
+
tool: {
|
|
28
|
+
schemaVersion: 1,
|
|
29
|
+
identity: "plugin.json",
|
|
30
|
+
binding: "typescript",
|
|
31
|
+
surfaces,
|
|
32
|
+
bundle: { runtime: "package" },
|
|
33
|
+
tests: { examples: {} },
|
|
34
|
+
},
|
|
35
|
+
identity: { name: "probe", version: "0.1.0", description: "A probe tool" },
|
|
36
|
+
identityExtra: {},
|
|
37
|
+
operations: [],
|
|
38
|
+
toolfactoryVersion: "0.1.0",
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const environment = { ...process.env };
|
|
43
|
+
afterEach(() => {
|
|
44
|
+
process.env = { ...environment };
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe("runSteps", () => {
|
|
48
|
+
it("runs in order, skips CI-only provisioning, and stops at the first failure", () => {
|
|
49
|
+
const { steps } = commands.runSteps(tmpdir(), [
|
|
50
|
+
{ name: "first", run: "true" },
|
|
51
|
+
{ name: "provisioning", run: "exit 1", when: "ci" },
|
|
52
|
+
{ name: "boom", run: "exit 3" },
|
|
53
|
+
{ name: "never", run: "true" },
|
|
54
|
+
]);
|
|
55
|
+
expect(steps.map((step) => [step.name, step.ok])).toEqual([
|
|
56
|
+
["first", true],
|
|
57
|
+
["boom", false],
|
|
58
|
+
]);
|
|
59
|
+
expect(steps.every((step) => step.durationMs >= 0)).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
describe("createRepo", () => {
|
|
64
|
+
it("dry-runs the exact gh invocations: private, from the checkout, one topic per surface", () => {
|
|
65
|
+
expect(
|
|
66
|
+
createRepo(project(["skill", "mcp", "openclaw-native", "cli"]), {
|
|
67
|
+
slug: "GoatInAHat/probe",
|
|
68
|
+
dryRun: true,
|
|
69
|
+
}),
|
|
70
|
+
).toEqual({
|
|
71
|
+
repository: "GoatInAHat/probe",
|
|
72
|
+
visibility: "private",
|
|
73
|
+
topics: ["agent-skill", "mcp-server", "openclaw-plugin", "toolfactory"],
|
|
74
|
+
commands: [
|
|
75
|
+
'gh repo create GoatInAHat/probe --private --description "A probe tool" --source . --remote origin --push',
|
|
76
|
+
"gh repo edit GoatInAHat/probe --add-topic agent-skill,mcp-server,openclaw-plugin,toolfactory",
|
|
77
|
+
],
|
|
78
|
+
dryRun: true,
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("makes the repository public only when asked", () => {
|
|
83
|
+
const { commands: lines } = createRepo(project(["mcp"]), {
|
|
84
|
+
slug: "GoatInAHat/probe",
|
|
85
|
+
public: true,
|
|
86
|
+
dryRun: true,
|
|
87
|
+
});
|
|
88
|
+
expect(lines[0]).toContain("--public");
|
|
89
|
+
expect(lines[0]).not.toContain("--private");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("init", () => {
|
|
94
|
+
it("initialises a git repository, commits, and reports the reload line of this harness", () => {
|
|
95
|
+
const dir = mkdtempSync(join(tmpdir(), "toolfactory-init-"));
|
|
96
|
+
process.env.CLAUDECODE = "1";
|
|
97
|
+
// No git identity, as on a CI runner: the first commit must still land.
|
|
98
|
+
process.env.GIT_CONFIG_GLOBAL = "/dev/null";
|
|
99
|
+
process.env.GIT_CONFIG_SYSTEM = "/dev/null";
|
|
100
|
+
// `setup: false`: `.agents/setup` installs dependencies, which belongs to the end-to-end
|
|
101
|
+
// proof in a real project, not to a unit test.
|
|
102
|
+
const result = commands.init({
|
|
103
|
+
root: dir,
|
|
104
|
+
name: "probe",
|
|
105
|
+
binding: "typescript",
|
|
106
|
+
surfaces: ["cli"],
|
|
107
|
+
repo: "GoatInAHat/probe",
|
|
108
|
+
dryRun: true,
|
|
109
|
+
setup: false,
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
expect(existsSync(join(dir, ".git"))).toBe(true);
|
|
113
|
+
expect(execFileSync("git", ["log", "--format=%s"], { cwd: dir, encoding: "utf8" }).trim()).toBe(
|
|
114
|
+
"toolfactory init",
|
|
115
|
+
);
|
|
116
|
+
expect(result.repository?.commands[0]).toBe(
|
|
117
|
+
"gh repo create GoatInAHat/probe --private --source . --remote origin --push",
|
|
118
|
+
);
|
|
119
|
+
// Nothing ran: no remote, and no live-tests bootstrap without a declared credential.
|
|
120
|
+
expect(execFileSync("git", ["remote"], { cwd: dir, encoding: "utf8" }).trim()).toBe("");
|
|
121
|
+
expect(result.repository?.secrets).toEqual([]);
|
|
122
|
+
expect(result.nextSteps[1]).toBe(RELOAD.find((row) => row.harness === "Claude Code")?.line);
|
|
123
|
+
expect(result.nextSteps[2]).toContain("src/ops.ts");
|
|
124
|
+
// `keywords` defaults to `[name]` — Kiro Powers and Agent Plugins key activation off it —
|
|
125
|
+
// and lands in the scaffolded identity file (`package.json`, here) like the rest of identity.
|
|
126
|
+
expect(JSON.parse(readFileSync(join(dir, "package.json"), "utf8")).keywords).toEqual(["probe"]);
|
|
127
|
+
// Asked for nothing, init selects the skills-first minimum; host plugins are opt-in.
|
|
128
|
+
expect(defaultSurfaces("python")).toEqual(["skill", "agent-plugins", "mcp", "cli", "pypi"]);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
it("creates an instruction-only Codex plugin without a generated runtime", async () => {
|
|
132
|
+
const dir = mkdtempSync(join(tmpdir(), "toolfactory-instructions-"));
|
|
133
|
+
const result = commands.init({
|
|
134
|
+
root: dir,
|
|
135
|
+
name: "paper-viz",
|
|
136
|
+
binding: "typescript",
|
|
137
|
+
runtime: "none",
|
|
138
|
+
surfaces: ["skill", "codex"],
|
|
139
|
+
git: false,
|
|
140
|
+
setup: false,
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(existsSync(join(dir, "package.json"))).toBe(false);
|
|
144
|
+
expect(existsSync(join(dir, "src/toolfactory/mcp.ts"))).toBe(false);
|
|
145
|
+
expect(existsSync(join(dir, "mcp.json"))).toBe(false);
|
|
146
|
+
expect(
|
|
147
|
+
JSON.parse(readFileSync(join(dir, ".codex-plugin/plugin.json"), "utf8")),
|
|
148
|
+
).not.toHaveProperty("mcpServers");
|
|
149
|
+
expect(readFileSync(join(dir, "skills/paper-viz/SKILL.md"), "utf8")).not.toContain(
|
|
150
|
+
"No operations yet",
|
|
151
|
+
);
|
|
152
|
+
expect(result.nextSteps[2]).toContain("SKILL.md");
|
|
153
|
+
await expect(commands.check(dir)).resolves.toBeDefined();
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it("refuses runtime none with a surface that needs an executable payload", () => {
|
|
157
|
+
expect(() =>
|
|
158
|
+
ToolConfigSchema.parse({
|
|
159
|
+
schemaVersion: 1,
|
|
160
|
+
identity: "plugin.json",
|
|
161
|
+
binding: "typescript",
|
|
162
|
+
runtime: "none",
|
|
163
|
+
surfaces: ["skill", "mcp"],
|
|
164
|
+
}),
|
|
165
|
+
).toThrow(/skill and codex surfaces/);
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
describe("secrets", () => {
|
|
170
|
+
it("inventories the tool's sensitive keys and the registries' tokens — presence only, never a value", () => {
|
|
171
|
+
const dir = mkdtempSync(join(tmpdir(), "toolfactory-secrets-"));
|
|
172
|
+
writeFileSync(join(dir, ".env"), "API_KEY=canary-3f9a\n");
|
|
173
|
+
const target = project(["cli", "npm"]);
|
|
174
|
+
target.root = dir;
|
|
175
|
+
target.tool.config = {
|
|
176
|
+
type: "object",
|
|
177
|
+
properties: {
|
|
178
|
+
api_key: {
|
|
179
|
+
type: "string",
|
|
180
|
+
"x-toolfactory": { sensitive: true, url: "https://example.com/keys" },
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
required: ["api_key"],
|
|
184
|
+
};
|
|
185
|
+
const report = commands.secretsReport(target);
|
|
186
|
+
expect(report.secrets.map((secret) => secret.name)).toEqual(["API_KEY", "NPM_TOKEN"]);
|
|
187
|
+
expect(report.secrets[0]).toMatchObject({
|
|
188
|
+
kind: "config",
|
|
189
|
+
required: true,
|
|
190
|
+
local: true,
|
|
191
|
+
url: "https://example.com/keys",
|
|
192
|
+
});
|
|
193
|
+
expect(report.secrets[1]).toMatchObject({
|
|
194
|
+
kind: "release",
|
|
195
|
+
required: false,
|
|
196
|
+
local: false,
|
|
197
|
+
needs: ["npm"],
|
|
198
|
+
});
|
|
199
|
+
expect(JSON.stringify(report)).not.toContain("canary-3f9a");
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("refuses an operation input named like a sensitive config key", () => {
|
|
203
|
+
const login = {
|
|
204
|
+
name: "login",
|
|
205
|
+
inputSchema: { type: "object", properties: { password: { type: "string" } } },
|
|
206
|
+
requires: [],
|
|
207
|
+
} as unknown as Operation;
|
|
208
|
+
expect(() =>
|
|
209
|
+
assertNoSensitiveArgument(
|
|
210
|
+
{ properties: { password: { type: "string", "x-toolfactory": { sensitive: true } } } },
|
|
211
|
+
[login],
|
|
212
|
+
),
|
|
213
|
+
).toThrow(/"login" declares an input named "password"/);
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe("unpublish", () => {
|
|
218
|
+
it("diffs tool.json against the previous tag and retracts what a dropped surface published", () => {
|
|
219
|
+
const dir = mkdtempSync(join(tmpdir(), "toolfactory-unpublish-"));
|
|
220
|
+
process.env.GIT_CONFIG_GLOBAL = "/dev/null";
|
|
221
|
+
process.env.GIT_CONFIG_SYSTEM = "/dev/null";
|
|
222
|
+
commands.init({
|
|
223
|
+
root: dir,
|
|
224
|
+
name: "probe",
|
|
225
|
+
binding: "typescript",
|
|
226
|
+
surfaces: ["cli", "npm"],
|
|
227
|
+
dryRun: true,
|
|
228
|
+
setup: false,
|
|
229
|
+
});
|
|
230
|
+
const git = (...args: string[]) =>
|
|
231
|
+
execFileSync("git", args, {
|
|
232
|
+
cwd: dir,
|
|
233
|
+
encoding: "utf8",
|
|
234
|
+
env: {
|
|
235
|
+
...process.env,
|
|
236
|
+
GIT_AUTHOR_NAME: "t",
|
|
237
|
+
GIT_AUTHOR_EMAIL: "t@example.com",
|
|
238
|
+
GIT_COMMITTER_NAME: "t",
|
|
239
|
+
GIT_COMMITTER_EMAIL: "t@example.com",
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
git("tag", "v0.1.0");
|
|
243
|
+
const toolPath = join(dir, "dev.toolfactory", "tool.json");
|
|
244
|
+
const tool = JSON.parse(readFileSync(toolPath, "utf8"));
|
|
245
|
+
tool.surfaces = tool.surfaces.filter((surface: string) => surface !== "npm");
|
|
246
|
+
writeFileSync(toolPath, JSON.stringify(tool, null, 2));
|
|
247
|
+
git("commit", "-qam", "drop npm");
|
|
248
|
+
git("tag", "v0.2.0");
|
|
249
|
+
const result = commands.unpublish(dir, { dryRun: true });
|
|
250
|
+
expect(result.dropped).toEqual(["npm"]);
|
|
251
|
+
expect(result.steps.some((step) => step.run.includes("npm deprecate probe@'*'"))).toBe(true);
|
|
252
|
+
});
|
|
253
|
+
});
|