Skip to content
This repository was archived by the owner on Dec 12, 2025. It is now read-only.
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
5 changes: 5 additions & 0 deletions .nx/version-plans/improve-jsr-publishing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
__default__: patch
---

Improve JSR publishing support with automatic LICENSE copying and enhanced configuration file handling
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"tailwindCSS.experimental.configFile": {
"apps/modelfetch-website/app/layout.css": "apps/modelfetch-website/**"
},
"json.validate.enable": false,
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"eslint.workingDirectories": [{ "mode": "auto" }],
Expand Down
2 changes: 1 addition & 1 deletion libs/modelfetch-core/jsr.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"exports": "./src/index.ts",
"publish": { "include": ["src"] }
"publish": { "include": ["src", "LICENSE", "README.md"] }
}
29 changes: 21 additions & 8 deletions libs/nx-10x/src/executors/prepare-release-publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ExecutorContext } from "@nx/devkit";
import type { PackageJson } from "type-fest";

import { existsSync } from "node:fs";
import { readFile, writeFile } from "node:fs/promises";
import { copyFile, readFile, writeFile } from "node:fs/promises";
import path from "node:path";

interface JsrJson
Expand All @@ -23,6 +23,7 @@ export default async function prepareReleasePublish(
const packageJson = JSON.parse(
await readFile(packageJsonPath, "utf8"),
) as PackageJson;
if (packageJson.private) return { success: false };
for (const key of ["scripts", "devDependencies"])
if (key in packageJson) delete packageJson[key];
const exportEntries = [packageJson.exports];
Expand All @@ -38,13 +39,25 @@ export default async function prepareReleasePublish(
}
}
await writeFile(packageJsonPath, JSON.stringify(packageJson));
const jsrJsonPath = path.join(context.root, project.root, "jsr.json");
if (existsSync(jsrJsonPath)) {
const jsrJson = JSON.parse(await readFile(jsrJsonPath, "utf8")) as JsrJson;
jsrJson.name = packageJson.name;
jsrJson.version = packageJson.version;
jsrJson.license = packageJson.license;
await writeFile(jsrJsonPath, JSON.stringify(jsrJson));
let isPublishingToJSR = false;
for (const name of ["jsr.json", "deno.json", "deno.jsonc"]) {
const jsrJsonPath = path.join(context.root, project.root, name);
if (existsSync(jsrJsonPath)) {
isPublishingToJSR = true;
const jsrJson = JSON.parse(
await readFile(jsrJsonPath, "utf8"),
) as JsrJson;
jsrJson.name = packageJson.name;
jsrJson.version = packageJson.version;
jsrJson.license = packageJson.license;
await writeFile(jsrJsonPath, JSON.stringify(jsrJson));
}
}
if (isPublishingToJSR) {
await copyFile(
path.join(context.root, "LICENSE"),
path.join(context.root, project.root, "LICENSE"),
);
}
return { success: true };
}
11 changes: 9 additions & 2 deletions libs/nx-10x/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ function getDefaultStartCommand(
entryPoint.endsWith(".cjs") ||
entryPoint.endsWith(".mjs");
if (!isTypeScript && !isJavaScript) return;
if (fs.existsSync(path.join(projectRoot, "deno.json")))
if (
fs.existsSync(path.join(projectRoot, "deno.json")) ||
fs.existsSync(path.join(projectRoot, "deno.jsonc"))
)
return `deno run -A ${entryPoint}`;
if (fs.existsSync(path.join(projectRoot, "bunfig.toml"))) return "bun .";
if (packageJson.dependencies?.tsx || packageJson.devDependencies?.tsx)
Expand Down Expand Up @@ -236,7 +239,11 @@ export const createNodesV2: CreateNodesV2 = [
targets["prepare-release-publish"] = {
executor: "nx-10x:prepare-release-publish",
};
if (fs.existsSync(path.join(projectRoot, "jsr.json"))) {
if (
fs.existsSync(path.join(projectRoot, "jsr.json")) ||
fs.existsSync(path.join(projectRoot, "deno.json")) ||
fs.existsSync(path.join(projectRoot, "deno.jsonc"))
) {
targets["jsr-release-publish"] = {
command: "deno publish --allow-dirty --allow-slow-types",
options: { cwd: "{projectRoot}" },
Expand Down