From c9c48de5b20c33071055625397b1a1cf5efbb13f Mon Sep 17 00:00:00 2001 From: Vyacheslav Terekhov Date: Mon, 14 Feb 2022 12:00:38 +0400 Subject: [PATCH] refactor: add publishConfig and clean-publish package (#752) * refactor: add publishCongif and clean-publish package * refactor: add del-cli --- .clean-publish | 4 ++ .gitignore | 3 +- package.json | 22 +++---- pnpm-lock.yaml | 150 ++++++++++++++++++++++++++++++++++++++++++++--- rollup.config.js | 10 ++-- 5 files changed, 163 insertions(+), 26 deletions(-) create mode 100644 .clean-publish diff --git a/.clean-publish b/.clean-publish new file mode 100644 index 00000000..711387ff --- /dev/null +++ b/.clean-publish @@ -0,0 +1,4 @@ +{ + "withoutPublish": true, + "tempDir": "package" +} diff --git a/.gitignore b/.gitignore index ec75eaaa..f809b2e1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,8 @@ node_modules # builds -build dist -es +package # misc .DS_Store diff --git a/package.json b/package.json index 2ba17810..0b5f50f5 100644 --- a/package.json +++ b/package.json @@ -36,17 +36,16 @@ "Wrapper", "Charts" ], - "main": "dist/vue-chartjs.cjs", - "module": "dist/vue-chartjs.mjs", - "jsnext:main": "es/index.js", - "typings": "types/index.d.ts", - "files": [ - "src", - "dist", - "es", - "types/*.d.ts" - ], + "main": "./src/index.js", + "typings": "./dist/index.d.ts", + "publishConfig": { + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "directory": "package" + }, "scripts": { + "prepublishOnly": "pnpm test && pnpm build && del ./package && clean-publish", + "postpublish": "del ./package", "emitDeclarations": "tsc --skipLibCheck --emitDeclarationOnly", "build": "rollup -c & pnpm emitDeclarations", "unit": "jest -c jest.config.json", @@ -54,7 +53,6 @@ "lint": "eslint --ext .js,.vue src test", "format": "prettier --write src test", "release": "standard-version", - "prepublishOnly": "pnpm lint && pnpm test && pnpm build", "docs:dev": "vuepress dev docs", "docs:build": "vuepress build docs", "commit": "cz", @@ -85,10 +83,12 @@ "babel-loader": "8.2.3", "browserslist": "^4.19.1", "chart.js": "^2.8.0", + "clean-publish": "^4.0.0", "commitizen": "^4.2.4", "cross-env": "^5.1.1", "css-loader": "^0.28.0", "cz-conventional-changelog": "3.3.0", + "del-cli": "^4.0.1", "eslint": "7.28.0", "eslint-config-prettier": "^8.3.0", "eslint-config-standard": "^10.2.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b29d9fb4..fd1e01fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,10 +19,12 @@ specifiers: babel-loader: 8.2.3 browserslist: ^4.19.1 chart.js: ^2.8.0 + clean-publish: ^4.0.0 commitizen: ^4.2.4 cross-env: ^5.1.1 css-loader: ^0.28.0 cz-conventional-changelog: 3.3.0 + del-cli: ^4.0.1 eslint: 7.28.0 eslint-config-prettier: ^8.3.0 eslint-config-standard: ^10.2.1 @@ -72,10 +74,12 @@ devDependencies: babel-loader: 8.2.3_@babel+core@7.16.5 browserslist: 4.19.1 chart.js: 2.9.4 + clean-publish: 4.0.0 commitizen: 4.2.4 cross-env: 5.2.1 css-loader: 0.28.11 cz-conventional-changelog: 3.3.0 + del-cli: 4.0.1 eslint: 7.28.0 eslint-config-prettier: 8.3.0_eslint@7.28.0 eslint-config-standard: 10.2.1_b8f056fd5d26348df7e8f986ab8fffad @@ -7635,7 +7639,7 @@ packages: engines: {node: '>=10'} dependencies: ansi-align: 3.0.1 - camelcase: 6.2.1 + camelcase: 6.3.0 chalk: 4.1.2 cli-boxes: 2.2.1 string-width: 4.2.3 @@ -8002,6 +8006,16 @@ packages: quick-lru: 4.0.1 dev: true + /camelcase-keys/7.0.2: + resolution: {integrity: sha512-Rjs1H+A9R+Ig+4E/9oyB66UC5Mj9Xq3N//vcLf2WzgdTi/3gUu3Z9KoqmlrEG4VuuLK8wJHofxzdQXz/knhiYg==} + engines: {node: '>=12'} + dependencies: + camelcase: 6.3.0 + map-obj: 4.3.0 + quick-lru: 5.1.1 + type-fest: 1.4.0 + dev: true + /camelcase/1.2.1: resolution: {integrity: sha1-m7UwTS4LVmmLLHWLCKPqqdqlijk=} engines: {node: '>=0.10.0'} @@ -8017,8 +8031,8 @@ packages: engines: {node: '>=6'} dev: true - /camelcase/6.2.1: - resolution: {integrity: sha512-tVI4q5jjFV5CavAU8DXfza/TJcZutVKo/5Foskmsqcm0MsL91moHvwiGNnqaa2o6PF/7yT5ikDRcVcl8Rj6LCA==} + /camelcase/6.3.0: + resolution: {integrity: sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==} engines: {node: '>=10'} dev: true @@ -8274,6 +8288,16 @@ packages: source-map: 0.6.1 dev: true + /clean-publish/4.0.0: + resolution: {integrity: sha512-PcOxJSnPgncx/ANmgPw8hj9DDtdLHTxIc6Vh/yXCX7IA9w1oUSx2POL0Vno/7omhyrKxMKTpnRh2wlzwH5zaCw==} + hasBin: true + dependencies: + cross-spawn: 7.0.3 + fast-glob: 3.2.11 + lilconfig: 2.0.4 + micromatch: 4.0.4 + dev: true + /clean-stack/2.2.0: resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} engines: {node: '>=6'} @@ -9403,6 +9427,11 @@ packages: engines: {node: '>=0.10.0'} dev: true + /decamelize/5.0.1: + resolution: {integrity: sha512-VfxadyCECXgQlkoEAjeghAr5gY3Hf+IKjKb+X8tGVDtveCjN+USwprd2q3QXBR9T1+x2DG0XZF5/w+7HAtSaXA==} + engines: {node: '>=10'} + dev: true + /decimal.js/10.3.1: resolution: {integrity: sha512-V0pfhfr8suzyPGOx3nmq4aHqabehUZn6Ch9kyFpV79TGDTWFmHqUqXdabR7QHqxzrYolF4+tVmJhUG4OURg5dQ==} dev: true @@ -9476,6 +9505,29 @@ packages: resolution: {integrity: sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=} dev: true + /del-cli/4.0.1: + resolution: {integrity: sha512-KtR/6cBfZkGDAP2NA7z+bP4p1OMob3wjN9mq13+SWvExx6jT9gFWfLgXEeX8J2B47OKeNCq9yTONmtryQ+m+6g==} + engines: {node: '>=12.20'} + hasBin: true + dependencies: + del: 6.0.0 + meow: 10.1.2 + dev: true + + /del/6.0.0: + resolution: {integrity: sha512-1shh9DQ23L16oXSZKB2JxpL7iMy2E0S9d517ptA1P8iw0alkPtQcrKH7ru31rYtKwF499HkTu+DRzq3TCKDFRQ==} + engines: {node: '>=10'} + dependencies: + globby: 11.1.0 + graceful-fs: 4.2.9 + is-glob: 4.0.3 + is-path-cwd: 2.2.0 + is-path-inside: 3.0.3 + p-map: 4.0.0 + rimraf: 3.0.2 + slash: 3.0.0 + dev: true + /delayed-stream/1.0.0: resolution: {integrity: sha1-3zrhmayt+31ECqrgsp4icrJOxhk=} engines: {node: '>=0.4.0'} @@ -10629,8 +10681,8 @@ packages: micromatch: 3.1.10 dev: true - /fast-glob/3.2.10: - resolution: {integrity: sha512-s9nFhFnvR63wls6/kM88kQqDhMu0AfdjqouE2l5GVQPbqLgyFjjU5ry/r2yKsJxpb9Py1EYNqieFrmMaX4v++A==} + /fast-glob/3.2.11: + resolution: {integrity: sha512-xrO3+1bxSo3ZVHAnqzyuewYT6aMFHRAd4Kcs92MAonjwQZLsK9d0SF1IyQ3k5PoirxTW0Oe/RqFgMQ6TcNE5Ew==} engines: {node: '>=8.6.0'} dependencies: '@nodelib/fs.stat': 2.0.5 @@ -11414,7 +11466,7 @@ packages: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.2.10 + fast-glob: 3.2.11 ignore: 5.2.0 merge2: 1.4.1 slash: 3.0.0 @@ -11426,7 +11478,7 @@ packages: dependencies: array-union: 2.1.0 dir-glob: 3.0.1 - fast-glob: 3.2.10 + fast-glob: 3.2.11 ignore: 5.2.0 merge2: 1.4.1 slash: 3.0.0 @@ -12085,6 +12137,11 @@ packages: engines: {node: '>=8'} dev: true + /indent-string/5.0.0: + resolution: {integrity: sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==} + engines: {node: '>=12'} + dev: true + /indexes-of/1.0.1: resolution: {integrity: sha1-8w9xbI4r00bHtn0985FVZqfAVgc=} dev: true @@ -12512,6 +12569,11 @@ packages: resolution: {integrity: sha512-2rRIahhZr2UWb45fIOuvZGpFtz0TyOZLf32KxBbSoUCeZR495zCKlWUKKUByk3geS2eAs7ZAABt0Y/Rx0GiQGA==} dev: true + /is-path-cwd/2.2.0: + resolution: {integrity: sha512-w942bTcih8fdJPJmQHFzkS76NEP8Kzzvmw92cXsazb8intwLqPibPPdXf4ANdKV3rYMuuQYGIWtvz9JilB3NFQ==} + engines: {node: '>=6'} + dev: true + /is-path-inside/1.0.1: resolution: {integrity: sha1-jvW33lBDej/cprToZe96pVy0gDY=} engines: {node: '>=0.10.0'} @@ -12519,6 +12581,11 @@ packages: path-is-inside: 1.0.2 dev: true + /is-path-inside/3.0.3: + resolution: {integrity: sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==} + engines: {node: '>=8'} + dev: true + /is-plain-obj/1.1.0: resolution: {integrity: sha1-caUMhCnfync8kqOQpKA7OfzVHT4=} engines: {node: '>=0.10.0'} @@ -13275,7 +13342,7 @@ packages: engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} dependencies: '@jest/types': 27.4.2 - camelcase: 6.2.1 + camelcase: 6.3.0 chalk: 4.1.2 jest-get-type: 27.4.0 leven: 3.1.0 @@ -14288,6 +14355,24 @@ packages: readable-stream: 2.3.7 dev: true + /meow/10.1.2: + resolution: {integrity: sha512-zbuAlN+V/sXlbGchNS9WTWjUzeamwMt/BApKCJi7B0QyZstZaMx0n4Unll/fg0njGtMdC9UP5SAscvOCLYdM+Q==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + dependencies: + '@types/minimist': 1.2.2 + camelcase-keys: 7.0.2 + decamelize: 5.0.1 + decamelize-keys: 1.1.0 + hard-rejection: 2.1.0 + minimist-options: 4.1.0 + normalize-package-data: 3.0.3 + read-pkg-up: 8.0.0 + redent: 4.0.0 + trim-newlines: 4.0.2 + type-fest: 1.4.0 + yargs-parser: 20.2.9 + dev: true + /meow/5.0.0: resolution: {integrity: sha512-CbTqYU17ABaLefO8vCU153ZZlprKYWDljcndKKDCFcYQITzWCXZAVk4QMFZPgvzrnUQ3uItnIE/LoUOwrT15Ig==} engines: {node: '>=6'} @@ -16259,6 +16344,11 @@ packages: engines: {node: '>=8'} dev: true + /quick-lru/5.1.1: + resolution: {integrity: sha512-WuyALRjWPDGtt/wzJiadO5AXY+8hZ80hVpe6MyivgraREW751X3SbhRvG3eLKOYN+8VEvqLcf3wdnt44Z4S4SA==} + engines: {node: '>=10'} + dev: true + /ramda/0.21.0: resolution: {integrity: sha1-oAGr7bP/YQd9T/HVd9RN536NCjU=} dev: true @@ -16640,6 +16730,15 @@ packages: type-fest: 0.8.1 dev: true + /read-pkg-up/8.0.0: + resolution: {integrity: sha512-snVCqPczksT0HS2EC+SxUndvSzn6LRCwpfSvLrIfR5BKDQQZMaI6jPRC9dYvYFDRAuFEAnkwww8kBBNE/3VvzQ==} + engines: {node: '>=12'} + dependencies: + find-up: 5.0.0 + read-pkg: 6.0.0 + type-fest: 1.4.0 + dev: true + /read-pkg/3.0.0: resolution: {integrity: sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k=} engines: {node: '>=4'} @@ -16659,6 +16758,16 @@ packages: type-fest: 0.6.0 dev: true + /read-pkg/6.0.0: + resolution: {integrity: sha512-X1Fu3dPuk/8ZLsMhEj5f4wFAF0DWoK7qhGJvgaijocXxBmSToKfbFtqbxMO7bVjNA1dmE5huAzjXj/ey86iw9Q==} + engines: {node: '>=12'} + dependencies: + '@types/normalize-package-data': 2.4.1 + normalize-package-data: 3.0.3 + parse-json: 5.2.0 + type-fest: 1.4.0 + dev: true + /readable-stream/2.3.7: resolution: {integrity: sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw==} dependencies: @@ -16749,6 +16858,14 @@ packages: strip-indent: 3.0.0 dev: true + /redent/4.0.0: + resolution: {integrity: sha512-tYkDkVVtYkSVhuQ4zBgfvciymHaeuel+zFKXShfDnFP5SyVEP7qo70Rf1jTOTCx3vGNAbnEi/xFkcfQVMIBWag==} + engines: {node: '>=12'} + dependencies: + indent-string: 5.0.0 + strip-indent: 4.0.0 + dev: true + /reduce-css-calc/1.3.0: resolution: {integrity: sha1-dHyRTgSWFKTJz7umKYca0dKSdxY=} dependencies: @@ -18068,6 +18185,13 @@ packages: min-indent: 1.0.1 dev: true + /strip-indent/4.0.0: + resolution: {integrity: sha512-mnVSV2l+Zv6BLpSD/8V87CW/y9EmmbYzGCIavsnsI6/nwn26DwffM/yztm30Z/I2DY9wdS3vXVCMnHDgZaVNoA==} + engines: {node: '>=12'} + dependencies: + min-indent: 1.0.1 + dev: true + /strip-json-comments/2.0.1: resolution: {integrity: sha1-PFMZQukIwml8DsNEhYwobHygpgo=} engines: {node: '>=0.10.0'} @@ -18597,6 +18721,11 @@ packages: engines: {node: '>=8'} dev: true + /trim-newlines/4.0.2: + resolution: {integrity: sha512-GJtWyq9InR/2HRiLZgpIKv+ufIKrVrvjQWEj7PxAXNc5dwbNJkqhAUoAGgzRmULAnoOM5EIpveYd3J2VeSAIew==} + engines: {node: '>=12'} + dev: true + /trim-right/1.0.1: resolution: {integrity: sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=} engines: {node: '>=0.10.0'} @@ -18748,6 +18877,11 @@ packages: engines: {node: '>=8'} dev: true + /type-fest/1.4.0: + resolution: {integrity: sha512-yGSza74xk0UG8k+pLh5oeoYirvIiWo5t0/o3zHHAO2tRDiZcxWP7fywNlXhqb6/r6sWvwi+RsyQMWhVLe4BVuA==} + engines: {node: '>=10'} + dev: true + /type-is/1.6.18: resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} engines: {node: '>= 0.6'} diff --git a/rollup.config.js b/rollup.config.js index 22cb4d79..475603e4 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -23,7 +23,7 @@ const plugins = (targets, vueOptions = {}) => [ export default [ { - input: 'src/index.js', + input: pkg.main, plugins: plugins('defaults, not ie 11, not ie_mob 11', { template: { optimizeSSR: true @@ -32,18 +32,18 @@ export default [ external, output: { format: 'cjs', - file: pkg.main, + file: pkg.publishConfig.main, exports: 'named', sourcemap: true } }, { - input: 'src/index.js', + input: pkg.main, plugins: plugins('defaults and supports es6-module'), external, output: { - format: 'esm', - file: pkg.module, + format: 'es', + file: pkg.publishConfig.module, sourcemap: true } }