-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(build): Add release-packages.js script for updating sub-package
package.json files during the release stage chore: Update package.json
- Loading branch information
1 parent
aff4fef
commit e4a1c10
Showing
2 changed files
with
61 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,46 +2,14 @@ | |
"type": "module", | ||
"version": "0.0.0", | ||
"packageManager": "[email protected]", | ||
"description": "_description_", | ||
"author": "Anthony Fu <[email protected]>", | ||
"license": "MIT", | ||
"funding": "https://github.com/sponsors/wuxian-space", | ||
"homepage": "https://github.com/wuxian-space/wuxianx-charts#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/wuxian-space/wuxianx-charts.git" | ||
}, | ||
"bugs": "https://github.com/wuxian-space/wuxianx-charts/issues", | ||
"keywords": [], | ||
"sideEffects": false, | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.cjs" | ||
} | ||
}, | ||
"main": "./dist/index.mjs", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"typesVersions": { | ||
"*": { | ||
"*": [ | ||
"./dist/*", | ||
"./dist/index.d.ts" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"prepare": "simple-git-hooks", | ||
"prepublishOnly": "nr build", | ||
"docs:dev": "pnpm --filter docs dev", | ||
"test": "vitest", | ||
"build": "node scripts/build.js", | ||
"release": "bumpp && npm publish", | ||
"release-packages": "node scripts/release-packages.js", | ||
"typecheck": "tsc --noEmit && pnpm -r typecheck", | ||
"lint": "eslint ." | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { existsSync, readdirSync, statSync } from 'node:fs' | ||
import { writeFile } from 'node:fs/promises' | ||
import { createRequire } from 'node:module' | ||
import path from 'node:path' | ||
|
||
const require = createRequire(import.meta.url) | ||
|
||
run() | ||
|
||
async function run() { | ||
const pkgs = readdirSync('packages') | ||
|
||
await Promise.all(pkgs.map(updatePkg)) | ||
} | ||
|
||
async function updatePkg(name) { | ||
const isPkg = statSync(`packages/${name}`).isDirectory() && existsSync(`packages/${name}/package.json`) | ||
|
||
if (!isPkg) | ||
return | ||
|
||
const file = path.resolve(`./packages/${name}/package.json`) | ||
|
||
const pkg = require(`../packages/${name}/package.json`) | ||
if (pkg.private) | ||
return false | ||
|
||
const rest = { | ||
...pkg, | ||
main: `dist/${name}.cjs.js`, | ||
module: `dist/${name}.esm-bundler.js`, | ||
types: `dist/${name}.d.ts`, | ||
files: [ | ||
'dist', | ||
], | ||
exports: { | ||
'.': { | ||
types: `./dist/${name}.d.ts`, | ||
node: `./dist/${name}.cjs.js`, | ||
module: `./dist/${name}.esm-bundler.js`, | ||
import: `./dist/${name}.esm-bundler.js`, | ||
require: `./dist/${name}.cjs.js`, | ||
}, | ||
'./*': './*', | ||
}, | ||
author: '岳晓亮 <https://github.com/yuexiaoliang>', | ||
license: 'MIT', | ||
homepage: 'https://github.com/wuxian-space/wuxianx-charts#readme', | ||
repository: { | ||
type: 'git', | ||
url: 'git+https://github.com/wuxian-space/wuxianx-charts.git', | ||
directory: `packages/${name}`, | ||
}, | ||
bugs: { | ||
url: 'https://github.com/wuxian-space/wuxianx-charts/issues', | ||
}, | ||
} | ||
|
||
await writeFile(file, JSON.stringify(rest, null, 2)) | ||
} |