From 80662d6f0dd11f3765064a1e35108bb88da4555b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 6 Feb 2023 23:35:36 +0800 Subject: [PATCH] feat(zcloak-dev-build-ts): replace workspace protocol version to semver in package dependencies. release-as: 0.14.0 --- packages/dev/scripts/zcloak-dev-build-ts.mjs | 19 ++++++++++++++----- .../dev/scripts/zcloak-dev-clean-build.mjs | 4 ++-- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/dev/scripts/zcloak-dev-build-ts.mjs b/packages/dev/scripts/zcloak-dev-build-ts.mjs index c2f453d..2520a3f 100755 --- a/packages/dev/scripts/zcloak-dev-build-ts.mjs +++ b/packages/dev/scripts/zcloak-dev-build-ts.mjs @@ -19,6 +19,8 @@ const CPX = ['patch', 'js', 'cjs', 'mjs', 'json', 'd.ts', 'css', 'gif', 'hbs', ' console.log('$ zcloak-dev-build-ts', process.argv.slice(2).join(' ')); +const rootPkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), './package.json'), 'utf-8')); + // webpack build function buildWebpack() { const config = WP_CONFIGS.find((c) => fs.existsSync(path.join(process.cwd(), c))); @@ -201,6 +203,15 @@ function buildExports() { // cleanup extraneous fields delete pkg.devDependencies; + // replace workspace: version + if (pkg.dependencies) { + Object.entries(pkg.dependencies).forEach(([name, version]) => { + if (version.startsWith('workspace:')) { + pkg.dependencies[name] = version.replace('workspace:', '') + rootPkg.version; + } + }); + } + if (!pkg.main && fs.existsSync(path.join(buildDir, 'index.d.ts'))) { pkg.main = 'index.js'; } @@ -434,15 +445,13 @@ async function buildJs(repoPath, dir) { async function main() { execSync('yarn zcloak-dev-clean-build'); - const pkg = JSON.parse(fs.readFileSync(path.join(process.cwd(), './package.json'), 'utf-8')); - - if (pkg.scripts && pkg.scripts['build:extra']) { + if (rootPkg.scripts && rootPkg.scripts['build:extra']) { execSync('yarn build:extra'); } - const repoPath = pkg.repository.url.split('https://github.com/')[1].split('.git')[0]; + const repoPath = rootPkg.repository.url.split('https://github.com/')[1].split('.git')[0]; - orderPackageJson(repoPath, null, pkg); + orderPackageJson(repoPath, null, rootPkg); execSync('yarn zcloak-exec-tsc --build tsconfig.build.json'); process.chdir('packages'); diff --git a/packages/dev/scripts/zcloak-dev-clean-build.mjs b/packages/dev/scripts/zcloak-dev-clean-build.mjs index 63ea238..dc82ae5 100755 --- a/packages/dev/scripts/zcloak-dev-clean-build.mjs +++ b/packages/dev/scripts/zcloak-dev-clean-build.mjs @@ -9,8 +9,8 @@ import rimraf from 'rimraf'; const PKGS = path.join(process.cwd(), 'packages'); const DIRS = [ 'build', - ...['cjs', 'esm', 'deno', 'docs', 'swc', 'swc-cjs', 'swc-esm'].map((d) => `build-${d}`), - ...['tsbuildinfo', '*.tsbuildinfo'].map((d) => `tsconfig.${d}`) + ...['cjs', 'esm'].map((d) => `build-${d}`), + ...['tsbuildinfo', 'build.tsbuildinfo'].map((d) => `tsconfig.${d}`) ]; console.log('$ zcloak-dev-clean-build', process.argv.slice(2).join(' '));