Skip to content

Commit

Permalink
feat: Refactor package.json and add publish scripts (generate jsr fro…
Browse files Browse the repository at this point in the history
…m package.json)

This commit refactors the package.json file to simplify the exports
section and adds new scripts for preparing the package for publishing.
It also includes a new script file (gen_jsr_json.ts) that generates
the jsr.json file needed for publishing. The .gitignore file has been
updated to ignore the jsr.json and LICENSE files in the package
directory.
  • Loading branch information
ryoppippi committed Jul 31, 2024
1 parent 62d8ad0 commit 5a11d26
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 98 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ jobs:
with:
bun-version: latest
- run: bun i --frozen-lockfile
- name: copy files
run: |
cp LICENSE $PACKAGE_DIR
- run: bun run publish --allow-dirty
- run: bun run publish
working-directory: ${{env.PACKAGE_DIR}}

release:
Expand Down
2 changes: 2 additions & 0 deletions packages/unplugin-typia/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/jsr.json
/LICENSE
27 changes: 0 additions & 27 deletions packages/unplugin-typia/jsr.json

This file was deleted.

88 changes: 21 additions & 67 deletions packages/unplugin-typia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,81 +12,35 @@
"rollup",
"transform"
],
"files": [
"src",
"package.json",
"jsr.json",
"README.md",
"LICENSE"
],
"exports": {
".": {
"import": "./src/index.ts"
},
"./api": {
"import": "./src/api.ts"
},
"./vite": {
"import": "./src/vite.ts"
},
"./webpack": {
"import": "./src/webpack.ts"
},
"./rollup": {
"import": "./src/rollup.ts"
},
"./esbuild": {
"import": "./src/esbuild.ts"
},
"./next": {
"import": "./src/next.ts"
},
"./rolldown": {
"import": "./src/rolldown.ts"
},
"./farm": {
"import": "./src/farm.ts"
},
"./rspack": {
"import": "./src/rspack.ts"
},
"./bun": {
"import": "./src/bun.ts"
},
".": "./src/index.ts",
"./api": "./src/api.ts",
"./vite": "./src/vite.ts",
"./webpack": "./src/webpack.ts",
"./rollup": "./src/rollup.ts",
"./esbuild": "./src/esbuild.ts",
"./next": "./src/next.ts",
"./rolldown": "./src/rolldown.ts",
"./farm": "./src/farm.ts",
"./rspack": "./src/rspack.ts",
"./bun": "./src/bun.ts",
"./package.json": "./package.json"
},
"files": [
"dist"
],
"scripts": {
"lint": "nr check && eslint --cache .",
"format": "eslint --cache --fix .",
"test": "nr check && bun test ./test/*.ts",
"check": "nr tsc --noEmit",
"publish": "nlx jsr publish"
},
"peerDependencies": {
"esbuild": "*",
"rollup": "^3",
"svelte": "^3 || ^4 || ^5",
"vite": ">=3.2.10",
"webpack": "^4 || ^5"
},
"peerDependenciesMeta": {
"@nuxt/kit": {
"optional": true
},
"@nuxt/schema": {
"optional": true
},
"esbuild": {
"optional": true
},
"rollup": {
"optional": true
},
"svelte": {
"optional": true
},
"vite": {
"optional": true
},
"webpack": {
"optional": true
}
"publish": "nr publish:prepare && nlx jsr publish --allow-dirty",
"publish:prepare": "bun run ./scripts/gen_jsr_json.ts && bun run --shell bun publish:copy_license",
"publish:copy_license": "cp ../../LICENSE ."
},
"dependencies": {
"@rollup/pluginutils": "^5.1.0",
Expand Down
20 changes: 20 additions & 0 deletions packages/unplugin-typia/scripts/gen_jsr_json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { join } from 'node:path';
import {
exports,
files,
name,
version,
} from '../package.json';

const jsrJSON = {
version,
name,
exports,
publish: {
include: files,
},
} as const;

const exportJSRPath = join(import.meta.dirname, '../jsr.json');

await Bun.write(exportJSRPath, JSON.stringify(jsrJSON, null, '\t'));

0 comments on commit 5a11d26

Please sign in to comment.