🐛 Fix the release scripts

This commit is contained in:
alonso.torres 2026-07-08 12:40:52 +02:00 committed by Andrey Antukh
parent e61c55e53c
commit f0cf8dca2a
3 changed files with 42 additions and 19 deletions

View File

@ -1,16 +1,19 @@
import esbuild from 'esbuild';
import { copy } from 'fs-extra';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
const source = 'libs/plugins-styles';
const dist = 'dist/plugins-styles';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
const source = resolve(root, 'libs/plugins-styles');
const dist = resolve(root, 'dist/plugins-styles');
const handleErr = (err) => {
console.error(err);
process.exit(1);
};
esbuild
.build({
Promise.all([
esbuild.build({
entryPoints: [`${source}/src/lib/styles.css`],
bundle: true,
outfile: `${dist}/styles.css`,
@ -18,9 +21,8 @@ esbuild
loader: {
'.svg': 'dataurl',
},
})
.catch(handleErr);
copy(`${source}/package.json`, `${dist}/package.json`).catch(handleErr);
copy(`${source}/README.md`, `${dist}/README.md`).catch(handleErr);
copy(`LICENSE`, `${dist}/LICENSE`).catch(handleErr);
}),
copy(`${source}/package.json`, `${dist}/package.json`),
copy(`${source}/README.md`, `${dist}/README.md`),
copy(resolve(root, 'LICENSE'), `${dist}/LICENSE`),
]).catch(handleErr);

View File

@ -1,14 +1,19 @@
import { copy } from 'fs-extra';
import { dirname, resolve } from 'path';
import { fileURLToPath } from 'url';
const source = 'libs/plugin-types';
const dist = 'dist/plugin-types';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
const source = resolve(root, 'libs/plugin-types');
const dist = resolve(root, 'dist/plugin-types');
const handleErr = (err) => {
console.error(err);
process.exit(1);
};
copy(`${source}/package.json`, `${dist}/package.json`).catch(handleErr);
copy(`${source}/README.md`, `${dist}/README.md`).catch(handleErr);
copy(`${source}/index.d.ts`, `${dist}/index.d.ts`).catch(handleErr);
copy(`LICENSE`, `${dist}/LICENSE`).catch(handleErr);
Promise.all([
copy(`${source}/package.json`, `${dist}/package.json`),
copy(`${source}/README.md`, `${dist}/README.md`),
copy(`${source}/index.d.ts`, `${dist}/index.d.ts`),
copy(resolve(root, 'LICENSE'), `${dist}/LICENSE`),
]).catch(handleErr);

View File

@ -1,5 +1,5 @@
import { execSync } from 'child_process';
import { readFileSync, writeFileSync } from 'fs';
import { cpSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
@ -66,6 +66,21 @@ const writePackageJson = (packagePath: string, content: PackageJson): void => {
writeFileSync(filePath, JSON.stringify(content, null, 2) + '\n');
};
const getPublishPath = (packagePath: string): string => {
return join('dist', packagePath.split('/').pop()!);
};
const prepareRuntimePackage = (): void => {
const source = 'libs/plugins-runtime';
const dist = getPublishPath(source);
mkdirSync(dist, { recursive: true });
cpSync(join(source, 'package.json'), join(dist, 'package.json'));
cpSync(join(source, 'README.md'), join(dist, 'README.md'));
cpSync('LICENSE', join(dist, 'LICENSE'));
cpSync(join(source, 'dist'), join(dist, 'dist'), { recursive: true });
};
const incrementVersion = (
currentVersion: string,
specifier: string,
@ -164,6 +179,7 @@ const log = (message: string, verbose: boolean, forceLog = false): void => {
stdio: 'inherit',
},
);
prepareRuntimePackage();
} else {
console.log(' [DRY RUN] Skipping build\n');
}
@ -176,7 +192,7 @@ const log = (message: string, verbose: boolean, forceLog = false): void => {
for (const packagePath of PACKAGES) {
const pkg = readPackageJson(packagePath);
const distPath = join('dist', packagePath.split('/').pop()!);
const distPath = getPublishPath(packagePath);
if (args.dryRun) {
console.log(
@ -188,7 +204,7 @@ const log = (message: string, verbose: boolean, forceLog = false): void => {
`pnpm publish --tag ${tag} --access public --no-git-checks`,
{
cwd: join(process.cwd(), distPath),
stdio: args.verbose ? 'inherit' : 'pipe',
stdio: 'inherit',
},
);
console.log(` ✅ Published ${pkg.name}@${newVersion}`);