From 9ce2ea197fb266ec9aab054e52f8b85ad97b140b Mon Sep 17 00:00:00 2001 From: phuctm97 Date: Sat, 19 Jul 2025 14:10:21 +0700 Subject: [PATCH 1/2] Improve JSR publishing support with enhanced configuration handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add automatic LICENSE file copying to JSR packages during release preparation - Support deno.json and deno.jsonc files in addition to jsr.json - Skip private packages during release preparation - Include LICENSE and README.md in modelfetch-core JSR publish configuration - Disable JSON validation in VSCode settings to support jsonc files 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .nx/version-plans/improve-jsr-publishing.md | 5 ++++ .vscode/settings.json | 1 + libs/modelfetch-core/jsr.json | 2 +- .../prepare-release-publish/index.ts | 29 ++++++++++++++----- libs/nx-10x/src/index.ts | 11 +++++-- 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 .nx/version-plans/improve-jsr-publishing.md diff --git a/.nx/version-plans/improve-jsr-publishing.md b/.nx/version-plans/improve-jsr-publishing.md new file mode 100644 index 00000000..09916b4c --- /dev/null +++ b/.nx/version-plans/improve-jsr-publishing.md @@ -0,0 +1,5 @@ +--- +__default__: minor +--- + +Improve JSR publishing support with automatic LICENSE copying and enhanced configuration file handling diff --git a/.vscode/settings.json b/.vscode/settings.json index 38324560..e33d0288 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" }], diff --git a/libs/modelfetch-core/jsr.json b/libs/modelfetch-core/jsr.json index fb660d2e..d1f66cbf 100644 --- a/libs/modelfetch-core/jsr.json +++ b/libs/modelfetch-core/jsr.json @@ -1,4 +1,4 @@ { "exports": "./src/index.ts", - "publish": { "include": ["src"] } + "publish": { "include": ["src", "LICENSE", "README.md"] } } diff --git a/libs/nx-10x/src/executors/prepare-release-publish/index.ts b/libs/nx-10x/src/executors/prepare-release-publish/index.ts index 03a5433e..0188d5cd 100644 --- a/libs/nx-10x/src/executors/prepare-release-publish/index.ts +++ b/libs/nx-10x/src/executors/prepare-release-publish/index.ts @@ -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 @@ -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]; @@ -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 }; } diff --git a/libs/nx-10x/src/index.ts b/libs/nx-10x/src/index.ts index e52c4a1a..3950cb35 100644 --- a/libs/nx-10x/src/index.ts +++ b/libs/nx-10x/src/index.ts @@ -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) @@ -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}" }, From 1497abd22a3e0d1218a8387804fd464b23ffd536 Mon Sep 17 00:00:00 2001 From: phuctm97 Date: Sat, 19 Jul 2025 14:11:44 +0700 Subject: [PATCH 2/2] Fix version --- .nx/version-plans/improve-jsr-publishing.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.nx/version-plans/improve-jsr-publishing.md b/.nx/version-plans/improve-jsr-publishing.md index 09916b4c..a02fd159 100644 --- a/.nx/version-plans/improve-jsr-publishing.md +++ b/.nx/version-plans/improve-jsr-publishing.md @@ -1,5 +1,5 @@ --- -__default__: minor +__default__: patch --- Improve JSR publishing support with automatic LICENSE copying and enhanced configuration file handling