diff --git a/package.json b/package.json index 7e4963e..b3bc363 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ "build": "vite build", "serve": "vite preview", "release": "esno ./scripts/release.mts", - "pnpm:devPreinstall": "node ./scripts/devPreinstall.js", + "pnpm:devPreinstall": "node -e \"if (process.env.INIT_CWD === process.cwd()) { process.exit(1) }\" || node ./scripts/devPreinstall.mjs", "preinstall": "node -e \"if (process.env.INIT_CWD === process.cwd()) { process.exit(1) }\" || npx only-allow pnpm", "postinstall": "node -e \"if (process.env.INIT_CWD === process.cwd()) { process.exit(1) }\" || npx simple-git-hooks" }, @@ -134,4 +134,4 @@ ], "{scripts,src}": "eslint --cache --fix" } -} \ No newline at end of file +} diff --git a/scripts/dev.mts b/scripts/dev.mts index f71e333..f05d23e 100644 --- a/scripts/dev.mts +++ b/scripts/dev.mts @@ -166,7 +166,7 @@ async function dev() { await installDependencies() } - spawn.sync('npx', ['vite', '--open'], { stdio: 'inherit' }) + spawn.sync('npx', ['vite', '--open', '--force'], { stdio: 'inherit' }) async function installDependencies() { if (['darwin', 'linux'].includes(process.platform)) { @@ -202,8 +202,8 @@ async function dev() { } */ console.log(cyan('Setting registry...')) spawn.sync('pnpm', ['config', 'set', 'registry', 'https://registry.npmmirror.com'], { stdio: 'inherit' }) - console.log(cyan('Installing node lts...')) - spawn.sync('pnpm', ['env', 'use', '-g', 'lts'], { stdio: 'inherit' }) + // console.log(cyan('Installing node lts...')) + // spawn.sync('pnpm', ['env', 'use', '-g', 'lts'], { stdio: 'inherit' }) console.log(cyan('Installing global packages...')) spawn('pnpm', ['add', 'cnpm', '@antfu/ni', '-g'], { stdio: 'inherit' }) console.log(cyan('Deleting ./node_modules...')) diff --git a/scripts/devPreinstall.js b/scripts/devPreinstall.mjs similarity index 96% rename from scripts/devPreinstall.js rename to scripts/devPreinstall.mjs index 365451a..be57886 100644 --- a/scripts/devPreinstall.js +++ b/scripts/devPreinstall.mjs @@ -1,4 +1,4 @@ -const fs = require('node:fs') +import fs from 'node:fs' function devPreinstall() { // 安装依赖前,将 devDependencies 的版本号替换为 latest diff --git a/scripts/release.mts b/scripts/release.mts index 753bf5e..f36b4f0 100644 --- a/scripts/release.mts +++ b/scripts/release.mts @@ -17,11 +17,6 @@ async function release() { return } - console.log(cyan('Upgrading dependencies...')) - if (spawn.sync('pnpm', ['up'], { stdio: 'inherit' }).status === 1) { - return - } - console.log(cyan('Linting staged...')) if (spawn.sync('npx', ['lint-staged'], { stdio: 'inherit' }).status === 1) { return @@ -37,8 +32,6 @@ async function release() { return } - open('./stats.html') - console.log(cyan('Packing...')) if (spawn.sync('npm', ['pack'], { stdio: 'inherit' }).status === 1) { return @@ -121,14 +114,6 @@ async function release() { pkg.version = targetVersion fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)) - console.log(cyan('Publishing...')) - if (spawn.sync('npm', ['publish', '--registry=https://registry.npmjs.org'], { stdio: 'inherit' }).status === 1) { - // 恢复版本号 - pkg.version = currentVersion - fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)) - return - } - console.log(cyan('Committing...')) if (spawn.sync('git', ['add', '-A'], { stdio: 'inherit' }).status === 1) { return @@ -148,6 +133,14 @@ async function release() { return } + console.log(cyan('Publishing...')) + if (spawn.sync('npm', ['publish', '--registry=https://registry.npmjs.org'], { stdio: 'inherit' }).status === 1) { + // 恢复版本号 + // pkg.version = currentVersion + // fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2)) + return + } + console.log(cyan('Updating npmmirror...')) spawn.sync('cnpm', ['sync'], { stdio: 'inherit' }) open(`https://npmmirror.com/sync/${name}`)