Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion packages/pstack/src/check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import * as NodePath from "node:path";
import * as NodeURL from "node:url";
import { describe, expect, it } from "vite-plus/test";
import { checkPack } from "./check.ts";
import { fileFingerprint, packFiles, type UpstreamManifest } from "./files.ts";
import { fileFingerprint, packFiles, readManifest, type UpstreamManifest } from "./files.ts";
import {
parsePstackRoleDefaults,
pstackContentHash,
pstackPackEntries,
PSTACK_PACKAGED_PRUNED_DIR,
PSTACK_SKILL_PREFIX,
PSTACK_LAYOUT_VERSION,
} from "./index.ts";
Expand Down Expand Up @@ -201,6 +202,28 @@ describe("pack interface", () => {
expect(() => pstackPackEntries(pack.root)).not.toThrow();
});

it("delivers a complete pack when packaging pruned the statechart test corpus", () => {
using pack = fixture();
pack.write("upstream/skills/statechart/scripts/statechart.ts", "export {};\n");
pack.write(`upstream/${PSTACK_PACKAGED_PRUNED_DIR}/corpus/Counter/chart.mmd`, "chart\n");
pack.seal();
expect(checkPack(pack.root)).toEqual([]);
NodeFS.rmSync(NodePath.join(pack.root, "upstream", PSTACK_PACKAGED_PRUNED_DIR), {
recursive: true,
});
const entries = pstackPackEntries(pack.root);
expect(entries.map(({ packPath }) => packPath)).toContain(
"skills/statechart/scripts/statechart.ts",
);
expect(entries.filter(({ sourcePath }) => !NodeFS.existsSync(sourcePath))).toEqual([]);
});

it("prunes a corpus the shipped snapshot actually carries", () => {
const pruned = (packPath: string) => packPath.startsWith(`${PSTACK_PACKAGED_PRUNED_DIR}/`);
expect(Object.keys(readManifest(packageDir).files).some(pruned)).toBe(true);
expect(pstackPackEntries(packageDir).some(({ packPath }) => pruned(packPath))).toBe(false);
});

it("invalidates the delivery stamp from the adapter layout", () => {
using pack = fixture();
expect(pstackContentHash(pack.root)).not.toBe(pstackContentHash(pack.root, 2));
Expand Down
7 changes: 6 additions & 1 deletion packages/pstack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ export { parsePstackRoleDefaults, PSTACK_PANEL_ROLES, type PstackRoleDefault } f
export const PSTACK_SKILL_PREFIX = "pstack:";
export const PSTACK_LAYOUT_VERSION = 3;

const isRuntimePackFile = (packPath: string) => NodePath.posix.basename(packPath) !== ".gitignore";
/** Upstream test corpus that packaged desktop builds delete; the runtime pack never needs it. */
export const PSTACK_PACKAGED_PRUNED_DIR = "skills/statechart/scripts/test";

const isRuntimePackFile = (packPath: string) =>
NodePath.posix.basename(packPath) !== ".gitignore" &&
!packPath.startsWith(`${PSTACK_PACKAGED_PRUNED_DIR}/`);

/** Files relative to a source root containing upstream/ and UPSTREAM.json. */
export function pstackPackEntries(sourceRoot: string): ReadonlyArray<{
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions scripts/build-desktop-artifact.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import {
ReleasePackageManifestError,
releasePackageFiles,
} from "./update-release-package-versions.ts";
import { pstackPackEntries } from "@t3tools/pstack";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { symlinksSupported } from "@t3tools/shared/testing/symlinks";

Expand Down Expand Up @@ -1377,10 +1378,17 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
path.join(import.meta.dirname, "../packages/pstack/upstream"),
path.join(packagedPstackDir, "upstream"),
);
yield* fs.copy(
path.join(import.meta.dirname, "../packages/pstack/UPSTREAM.json"),
path.join(packagedPstackDir, "UPSTREAM.json"),
);
yield* prunePackagedPstackTestFixtures(packagedPstackDir);
const scriptsDir = path.join(packagedPstackDir, "upstream/skills/statechart/scripts");
assert.isFalse(yield* fs.exists(path.join(scriptsDir, "test")));
assert.isTrue(yield* fs.exists(path.join(scriptsDir, "statechart.ts")));
for (const { sourcePath } of pstackPackEntries(packagedPstackDir)) {
assert.isTrue(yield* fs.exists(sourcePath), sourcePath);
}
yield* stageSelfContainedPlatformPackages(
path.join(import.meta.dirname, "../apps/server/node_modules"),
path.join(fixture.packagedAppDir, "resources/node_modules"),
Expand Down
3 changes: 2 additions & 1 deletion scripts/build-desktop-artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
type DirectoryRecord,
} from "@electron/asar";

import { PSTACK_PACKAGED_PRUNED_DIR } from "@t3tools/pstack";
import { fromYaml } from "@t3tools/shared/schemaYaml";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { clerkFrontendApiHostnameFromPublishableKey } from "@t3tools/shared/relayAuth";
Expand Down Expand Up @@ -3106,7 +3107,7 @@ export const prunePackagedPstackTestFixtures = Effect.fn("prunePackagedPstackTes
function* (pstackDir: string) {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const fixtureDir = path.join(pstackDir, "upstream/skills/statechart/scripts/test");
const fixtureDir = path.join(pstackDir, "upstream", PSTACK_PACKAGED_PRUNED_DIR);
yield* fs.remove(fixtureDir, { recursive: true, force: true });
},
);
Expand Down
1 change: 1 addition & 0 deletions scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@electron/asar": "^4.3.0",
"@electron/osx-sign": "2.7.0",
"@t3tools/contracts": "workspace:*",
"@t3tools/pstack": "workspace:*",
"@t3tools/shared": "workspace:*",
"@t3tools/tailscale": "workspace:*",
"agent-device": "0.21.32",
Expand Down
Loading