Skip to content

Commit

Permalink
* proj: add publish script.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Dec 21, 2023
1 parent ac0774e commit 919a710
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ build/
exts/
!scripts/build/
.vscode/
publish/LICENSE
publish/README.md
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "zui",
"version": "3.0.0-alpha.1",
"type": "module",
"private": true,
"engines": {
"node": ">=14",
"pnpm": ">=8"
Expand Down Expand Up @@ -32,7 +33,8 @@
"docs:build:exts": "pnpm docs:prepare -- --copy --exts --lib=zui*exts && cd docs && pnpm build",
"docs:serve": "cd docs && pnpm serve",
"docs:prepare": "tsx ./scripts/docs/prepare.ts",
"extend-lib": "tsx ./scripts/libs/extend-lib.ts"
"extend-lib": "tsx ./scripts/libs/extend-lib.ts",
"publish:npm": "pnpm build -- --ignoreNotReady && tsx ./scripts/build/publish.ts && cd ./publish && npm publish"
},
"workspaces": [
"./lib"
Expand Down
23 changes: 23 additions & 0 deletions publish/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "zui",
"version": "3.0.0-alpha.1",
"type": "module",
"engines": {
"node": ">=14",
"pnpm": ">=8"
},
"files": ["dist"],
"main": "./dist/zui.js",
"module": "./dist/zui.esm.js",
"exports": {
".": {
"import": "./dist/zui.esm.js",
"require": "./dist/zui.js"
},
"./css": "./dist/zui.css"
},
"dependencies": {
},
"devDependencies": {
}
}
18 changes: 18 additions & 0 deletions scripts/build/publish.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import path from 'path';
import fs from 'fs-extra';

const publishPath = path.resolve(process.cwd(), './publish');
const publishDistPath = path.resolve(publishPath, 'dist');

await fs.emptyDir(publishDistPath);
await fs.copy(path.resolve(process.cwd(), './dist/zui'), publishDistPath);
await fs.copyFile(path.resolve(process.cwd(), './README.md'), path.resolve(publishPath, './README.md'))
await fs.copyFile(path.resolve(process.cwd(), './LICENSE'), path.resolve(publishPath, './LICENSE'))

const packageJson = await fs.readJSON(path.resolve(process.cwd(), './package.json'));
const publishPackageJson = await fs.readJSON(path.resolve(publishPath, './package.json'));

if (publishPackageJson.version !== packageJson.version) {
publishPackageJson.version = packageJson.version;
await fs.writeJSON(path.resolve(publishPath, './package.json'), publishPackageJson);
}

0 comments on commit 919a710

Please sign in to comment.