Skip to content

Commit 6aedb45

Browse files
authored
Merge pull request #204 from proofgeist/feature/fix-addon-install-flow
Fix addon install flow for existing projects
2 parents 94d6068 + 8818805 commit 6aedb45

9 files changed

Lines changed: 37 additions & 26 deletions

File tree

.changeset/clear-lions-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@proofkit/webviewer": patch
3+
---
4+
5+
Document the `proofkit add addon webviewer` command in the WebViewer skill and setup docs.

.changeset/fair-poems-care.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@proofkit/cli": patch
3+
---
4+
5+
Fix `proofkit add addon` so it works outside an existing ProofKit project.

apps/docs/content/docs/cli/webviewer/getting-started.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Creating a ProofKit project for a FileMaker WebViewer is extremely similar to th
1515

1616
## Prep your FileMaker file
1717

18-
- Install the ProofKit WebViewer add-on into the file you want to target.
18+
- Install the ProofKit WebViewer add-on into the file you want to target. If you already have a ProofKit project, run `proofkit add addon webviewer` to copy the local add-on files, then install the add-on into the FileMaker file.
1919
- Make sure the file has the scripts needed by your WebViewer workflow, such as `Launch Web Viewer for Dev` and `UploadWebviewerWidget`.
2020
- If you want local typegen without a hosted server, start the FM MCP bridge and keep a connected FileMaker file open.
2121

apps/docs/content/docs/webviewer/index.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@ For web-based applications where you're looking to interact with the Data API us
1919

2020
We strongly recommend using the [ProofKit CLI](/docs/cli) to setup your project. It will also walk you through a FileMaker add-on that installs the neccesary layouts, scripts and custom functions to get you started.
2121

22+
If you already have a ProofKit WebViewer project and need to install or update the FileMaker add-on manually, run `proofkit add addon webviewer` from the project root. That copies the local add-on files; you still need to install the add-on into the FileMaker file.
23+
2224
<Accordions type="single">
2325
<Accordion title="Manual Installation">
2426

2527
{" "}
2628
<Callout type="warn">
2729
This demo file is a very simplified example. To see more features, use the
28-
[ProofKit CLI](/docs/cli) to build a new app and follow the instructions to
29-
install the FileMaker addon.
30+
[ProofKit CLI](/docs/cli) to build a new app or run `proofkit add addon webviewer`
31+
in an existing ProofKit project, then install the FileMaker add-on.
3032
</Callout>
3133

3234
Use your preferred package manager to install the package.

packages/cli/src/cli/add/addon.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { select } from "~/cli/prompts.js";
33
import { debugOption, nonInteractiveOption } from "~/globalOptions.js";
44
import { installFmAddonExplicitly } from "~/installers/install-fm-addon.js";
55
import { initProgramState, isNonInteractiveMode } from "~/state.js";
6-
import { getSettings } from "~/utils/parseSettings.js";
7-
import { abortIfCancel, ensureProofKitProject } from "../utils.js";
6+
import { abortIfCancel } from "../utils.js";
87

98
type AddonTarget = "webviewer" | "auth";
109

@@ -29,18 +28,8 @@ async function resolveAddonTarget(name?: string): Promise<AddonTarget> {
2928
}
3029

3130
export async function runAddAddonAction(targetName?: string) {
32-
ensureProofKitProject({ commandName: "add addon" });
33-
const settings = getSettings();
3431
const target = await resolveAddonTarget(targetName);
3532

36-
if (target === "webviewer" && settings.appType !== "webviewer") {
37-
throw new Error("The WebViewer add-on can only be added from a WebViewer ProofKit project.");
38-
}
39-
40-
if (target === "auth" && settings.appType !== "browser") {
41-
throw new Error("The auth add-on can only be added from a browser ProofKit project.");
42-
}
43-
4433
await installFmAddonExplicitly({ addonName: target === "webviewer" ? "wv" : "auth" });
4534
}
4635

packages/cli/src/installers/install-fm-addon.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,16 @@ export async function inspectFmAddon(
211211
export function getFmAddonInstallInstructions(addonName: FmAddonName) {
212212
const addonDisplayName = getAddonDisplayName(addonName);
213213
const installCommand = getAddonInstallCommand(addonName);
214+
const removeOldStep = `If your FileMaker file already has an older ${addonDisplayName} add-on installed, remove that old add-on first`;
214215

215216
return {
216217
addonDisplayName,
217218
installCommand,
218219
docsUrl: addonName === "auth" ? "https://proofkit.dev/auth/fm-addon" : "https://proofkit.dev/webviewer",
219220
steps: [
220221
`Run \`${installCommand}\` to install or update the local add-on files`,
221-
"Restart FileMaker Pro (if it's currently running)",
222+
"Restart FileMaker Pro so the new local add-on files appear",
223+
removeOldStep,
222224
`Open your FileMaker file, go to layout mode, and install the ${addonDisplayName} add-on to the file`,
223225
],
224226
};
@@ -256,8 +258,9 @@ export async function installFmAddonExplicitly({ addonName }: { addonName: FmAdd
256258
);
257259
}
258260
const steps = [
259-
"Restart FileMaker Pro (if it's currently running)",
260-
`Open your FileMaker file, go to layout mode, and install the ${addonDisplayName} addon to the file`,
261+
"Restart FileMaker Pro so the new local add-on files appear",
262+
`If your FileMaker file already has an older ${addonDisplayName} add-on installed, remove that old add-on first`,
263+
`Open your FileMaker file, go to layout mode, and install the ${addonDisplayName} add-on to the file`,
261264
];
262265
steps.forEach((step, index) => {
263266
console.log(`${index + 1}. ${step}`);

packages/cli/tests/cli.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,6 @@ describe("proofkit CLI", () => {
137137
it("supports `proofkit add addon webviewer`", async () => {
138138
const cwd = await fs.mkdtemp(path.join(os.tmpdir(), "proofkit-new-cli-addon-project-"));
139139
const addonModulesDir = await fs.mkdtemp(path.join(os.tmpdir(), "proofkit-new-cli-addon-modules-"));
140-
await fs.writeJson(path.join(cwd, "proofkit.json"), {
141-
appType: "webviewer",
142-
ui: "shadcn",
143-
dataSources: [],
144-
replacedMainPage: false,
145-
registryTemplates: [],
146-
});
147140

148141
const result = spawnSync("node", [distEntry, "add", "addon", "webviewer", "--non-interactive"], {
149142
cwd,

packages/cli/tests/install-fm-addon.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import os from "node:os";
22
import path from "node:path";
33
import fs from "fs-extra";
44
import { describe, expect, it } from "vitest";
5-
import { compareAddonVersions, inspectFmAddon } from "~/installers/install-fm-addon.js";
5+
import { compareAddonVersions, getFmAddonInstallInstructions, inspectFmAddon } from "~/installers/install-fm-addon.js";
66
import { getWebViewerAddonMessages } from "~/installers/proofkit-webviewer.js";
77

88
async function writeAddonVersion(dir: string, version: string) {
@@ -112,3 +112,12 @@ describe("getWebViewerAddonMessages", () => {
112112
expect(messages.nextSteps).toEqual(["proofkit add addon webviewer"]);
113113
});
114114
});
115+
116+
describe("getFmAddonInstallInstructions", () => {
117+
it("includes restart and old add-on removal guidance", () => {
118+
const instructions = getFmAddonInstallInstructions("wv");
119+
120+
expect(instructions.steps).toContain("Restart FileMaker Pro so the new local add-on files appear");
121+
expect(instructions.steps.join("\n")).toContain("remove that old add-on first");
122+
});
123+
});

packages/webviewer/skills/webviewer-integration/SKILL.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,13 @@ sources:
1515

1616
## Setup
1717

18+
This package assumes the user has already added specific layouts, scripts, etc into their FileMaker file. This is accomplished using a FileMaker add-on, downloaded during the setup process if the project was created using @proofkit/cli, but the user must still manually install the add-on in their FileMaker file.
19+
To download the latest version of the add-on to the user's computer, run `npx -y @proofkit/cli@beta add addon webviewer` in any directory.
20+
1821
Install the package and set the webviewer name before calling any scripts.
1922

23+
24+
2025
```ts
2126
import { fmFetch, globalSettings } from "@proofkit/webviewer";
2227

0 commit comments

Comments
 (0)