From 228564a4666bc976eb622d928ac970a74b92dbf8 Mon Sep 17 00:00:00 2001 From: Tony Date: Mon, 12 Aug 2024 22:49:34 +0800 Subject: [PATCH] Improve publish process --- package.json | 8 +++++--- scripts/clean-lib-folder.js | 8 ++++++++ scripts/copy-css.js | 8 ++++++-- scripts/tsconfig.json | 7 +++++++ 4 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 scripts/clean-lib-folder.js create mode 100644 scripts/tsconfig.json diff --git a/package.json b/package.json index cd84a78..d9bcc03 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "docusaurus-plugin-native-ideal-image", - "version": "0.0.1", + "version": "0.0.2", "description": "Pre-process images to multiple formats and low quality image placeholders", "keywords": ["docusaurus"], "author": "Tony", "license": "MIT", "repository": { "type": "git", - "url": "https://github.com/Legend-Master/docusaurus-plugin-native-ideal-image.git" + "url": "git+https://github.com/Legend-Master/docusaurus-plugin-native-ideal-image.git" }, "homepage": "https://github.com/Legend-Master/docusaurus-plugin-native-ideal-image", "main": "./lib/index.js", @@ -18,7 +18,9 @@ "scripts": { "build": "tsc -p ./src && npm run copy-css", "watch": "tsc -p ./src --watch", - "copy-css": "node scripts/copy-css.js" + "copy-css": "node scripts/copy-css.js", + "clean-lib-folder": "node scripts/clean-lib-folder.js", + "publish": "npm run clean-lib-folder && npm run build && npm publish" }, "devDependencies": { "@types/loader-utils": "^2.0.6", diff --git a/scripts/clean-lib-folder.js b/scripts/clean-lib-folder.js new file mode 100644 index 0000000..6fdafe1 --- /dev/null +++ b/scripts/clean-lib-folder.js @@ -0,0 +1,8 @@ +import { existsSync } from 'node:fs' +import { rm } from 'node:fs/promises' +import { fileURLToPath } from 'node:url' + +const libDirectory = fileURLToPath(import.meta.resolve('../lib')) +if (existsSync(libDirectory)) { + await rm(libDirectory, { recursive: true }) +} diff --git a/scripts/copy-css.js b/scripts/copy-css.js index 8615b8a..5f39d42 100644 --- a/scripts/copy-css.js +++ b/scripts/copy-css.js @@ -1,3 +1,7 @@ -import { copyFile } from 'fs/promises' +import { copyFile } from 'node:fs/promises' +import { fileURLToPath } from 'node:url' -await copyFile('src/theme/NativeIdealImage.css', 'lib/theme/NativeIdealImage.css') +await copyFile( + fileURLToPath(import.meta.resolve('../src/theme/NativeIdealImage.css')), + fileURLToPath(import.meta.resolve('../lib/theme/NativeIdealImage.css')) +) diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json new file mode 100644 index 0000000..d969451 --- /dev/null +++ b/scripts/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "checkJs": true, + "noEmit": true, + } +} \ No newline at end of file