Skip to content

Commit

Permalink
feat(zcloak-dev-build-ts): replace workspace protocol version to semv…
Browse files Browse the repository at this point in the history
…er in package dependencies.

release-as: 0.14.0
  • Loading branch information
actions-user committed Feb 6, 2023
1 parent f20a885 commit 80662d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
19 changes: 14 additions & 5 deletions packages/dev/scripts/zcloak-dev-build-ts.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -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';
}
Expand Down Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions packages/dev/scripts/zcloak-dev-clean-build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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(' '));
Expand Down

0 comments on commit 80662d6

Please sign in to comment.