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
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"packages/vocab-runtime/src/contexts/fep-22cd.json"
]
},
"nodeModulesDir": "auto",
"nodeModulesDir": "none",
"tasks": {
"build": {
"command": "pnpm --recursive --filter '@fedify/*' --parallel --silent build",
Expand Down
3 changes: 3 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
"@fedify/vocab": "workspace:^",
"@fedify/vocab-runtime": "workspace:^",
"@fedify/relay": "workspace:^",
"@fedify/webfinger": "workspace:^",
"@hono/node-server": "^1.13.7",
"@js-temporal/polyfill": "catalog:",
"@logtape/file": "catalog:",
"@logtape/logtape": "catalog:",
"@nestjs/common": "catalog:",
"@opentelemetry/api": "catalog:",
"@opentelemetry/context-async-hooks": "catalog:",
"@opentelemetry/core": "catalog:",
"@opentelemetry/exporter-trace-otlp-proto": "catalog:",
"@opentelemetry/sdk-node": "catalog:",
"@opentelemetry/sdk-trace-base": "catalog:",
Expand Down
4 changes: 2 additions & 2 deletions examples/fresh/deno.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"tasks": {
"check": "deno fmt --check . && deno lint . && deno check",
"dev": "vite",
"build": "vite build",
"dev": "deno run -A npm:vite@^7.1.3 --configLoader native",
"build": "deno run -A npm:vite@^7.1.3 build --configLoader native",
"start": "deno serve -A _fresh/server.js",
"update": "deno run -A -r jsr:@fresh/update ."
},
Expand Down
14 changes: 14 additions & 0 deletions mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,19 @@ depends = [
"check:md",
"check-versions",
"check:manifest:workspace-protocol",
"check:node-modules",
]
run = "sacho check"

[tasks."check:node-modules"]
description = "Check that Deno leaves pnpm's node_modules directories alone"
run = '''
if ! jq -e '.nodeModulesDir == "none"' deno.json > /dev/null; then
echo 'Set nodeModulesDir to "none" so Deno preserves pnpm workspace links.'
exit 1
fi
'''

[tasks."check:fmt"]
description = "Check code formatting"
run = "deno fmt --check"
Expand Down Expand Up @@ -159,6 +169,10 @@ done
'''

# Testing
[tasks."test:pack"]
description = "Check that Deno preserves pnpm links and package packing"
run = "node scripts/test_pack.mjs"

[tasks."test:deno"]
description = "Run the test suite using Deno"
depends = ["prepare"]
Expand Down
1 change: 1 addition & 0 deletions packages/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"fastify": "catalog:"
},
"devDependencies": {
"@fedify/vocab": "workspace:^",
"@types/node": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:"
Expand Down
1 change: 1 addition & 0 deletions packages/sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@fedify/fedify": "workspace:^"
},
"devDependencies": {
"@fedify/fixture": "workspace:^",
"@fedify/testing": "workspace:^",
"@std/async": "catalog:",
"tsdown": "catalog:",
Expand Down
2 changes: 2 additions & 0 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@
},
"devDependencies": {
"@fedify/fixture": "workspace:^",
"@fedify/vocab": "workspace:^",
"@fedify/vocab-runtime": "workspace:^",
"@js-temporal/polyfill": "catalog:",
"@std/assert": "catalog:",
"@std/async": "catalog:",
Expand Down
21 changes: 21 additions & 0 deletions pnpm-lock.yaml

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

118 changes: 118 additions & 0 deletions scripts/test_pack.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import { deepStrictEqual, strictEqual } from "node:assert/strict";
import { execFileSync } from "node:child_process";
import {
mkdirSync,
mkdtempSync,
readdirSync,
readFileSync,
readlinkSync,
rmSync,
writeFileSync,
} from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import process from "node:process";
import { gunzipSync } from "node:zlib";

// Use the repository's setting, but never let the negative control damage its
// installed dependencies. Run through mise; DENO_TEST_BINARY may select a
// different installed Deno without changing the pinned toolchain.
const config = JSON.parse(
readFileSync(new URL("../deno.json", import.meta.url), "utf8"),
);
const deno = process.env.DENO_TEST_BINARY ?? "deno";
const root = mkdtempSync(join(tmpdir(), "fedify-pack-"));
function write(path, data) {
writeFileSync(join(root, path), data);
}
function json(path, value) {
write(path, JSON.stringify(value));
}
function run(command, args, cwd = root) {
return execFileSync(command, args, { cwd, encoding: "utf8", stdio: "pipe" });
}
function links() {
return [
readlinkSync(join(root, "packages/adapter/node_modules/@fedify/pack-core")),
readlinkSync(join(root, "packages/adapter/node_modules/chalk")),
readdirSync(join(root, "node_modules")).sort(),
];
}
function packedManifest(path) {
const tar = gunzipSync(readFileSync(path));
for (let offset = 0; offset < tar.length;) {
const name = tar.subarray(offset, offset + 100).toString().split("\0")[0];
const size = parseInt(
tar.subarray(offset + 124, offset + 136).toString().replace(/\0/g, ""),
8,
);
if (!name) break;
if (name === "package/package.json") {
return JSON.parse(tar.subarray(offset + 512, offset + 512 + size));
}
offset += 512 + Math.ceil(size / 512) * 512;
}
throw new Error("Packed package.json not found");
}

try {
mkdirSync(join(root, "packages/core"), { recursive: true });
mkdirSync(join(root, "packages/adapter"), { recursive: true });
json("package.json", { private: true });
write("pnpm-workspace.yaml", "packages:\n - packages/*\n");
json("deno.json", {
nodeModulesDir: config.nodeModulesDir,
workspace: ["./packages/core", "./packages/adapter"],
imports: { chalk: "npm:chalk@5.6.2" },
});
json("packages/core/deno.json", {
name: "@fedify/pack-core",
version: "1.2.3",
exports: "./mod.js",
});
json("packages/core/package.json", {
name: "@fedify/pack-core",
version: "1.2.3",
type: "module",
exports: "./mod.js",
});
write("packages/core/mod.js", "export const value = 42;\n");
json("packages/adapter/deno.json", { exports: "./mod.js" });
json("packages/adapter/package.json", {
name: "@fedify/pack-adapter",
version: "1.2.3",
type: "module",
peerDependencies: { "@fedify/pack-core": "workspace:^" },
devDependencies: { chalk: "5.6.2" },
scripts: { prepack: "node prepack.js" },
});
write(
"packages/adapter/mod.js",
'import chalk from "chalk";\nimport { value } from "@fedify/pack-core";\nconsole.log(chalk.green(String(value)));\n',
);
write(
"packages/adapter/prepack.js",
'import "./mod.js";\nimport { writeFileSync } from "node:fs";\nwriteFileSync("lifecycle.txt", "prepack ran");\n',
);
run("pnpm", ["install", "--ignore-scripts", "--no-frozen-lockfile"]);
const before = links();
console.log(run(deno, ["--version"]).trim());
run(deno, ["check", "packages/adapter/mod.js"]);
deepStrictEqual(links(), before, "Deno changed pnpm's node_modules");
run(
"pnpm",
["pack", "--pack-destination", root],
join(root, "packages/adapter"),
);
strictEqual(
readFileSync(join(root, "packages/adapter/lifecycle.txt"), "utf8"),
"prepack ran",
);
const manifest = packedManifest(join(root, "fedify-pack-adapter-1.2.3.tgz"));
strictEqual(manifest.peerDependencies["@fedify/pack-core"], "^1.2.3");
console.log(
"Deno preserved pnpm links and lifecycle-enabled packing passed.",
);
} finally {
rmSync(root, { recursive: true, force: true });
}
Loading