Skip to content

Commit

Permalink
feat(publish-npm): Skip diffing experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
klarstrup committed Sep 9, 2024
1 parent c0a75e1 commit e2fa128
Showing 1 changed file with 41 additions and 36 deletions.
77 changes: 41 additions & 36 deletions publish-npm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -283,45 +283,50 @@ async function publish() {
]
}
]);
const packageJsonPaths = globSync('./dist/*/package.json');

const packageDiffs = {};
for (const packageJsonPath of packageJsonPaths) {
const pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
let npmPkg;
try {
npmPkg = await libnpm.manifest(`${pkg.name}@${tag}`);
} catch {}
const diffObj = await npmDiff(packageJsonPath, tag);

packageDiffs[packageJsonPath] = [
npmPkg || {...pkg, version: undefined},
diffObj,
Object.values(diffObj).reduce(
(memo, diff) => {
if (diff) {
memo.changeCount++;
const [
{
hunks: [hunk]

if (!tag.startsWith('experimental-')) {
const packageJsonPaths = globSync('./dist/*/package.json');
const packageDiffs = {};
for (const packageJsonPath of packageJsonPaths) {
const pkg = JSON.parse(await fs.readFile(packageJsonPath, 'utf-8'));
let npmPkg;
try {
npmPkg = await libnpm.manifest(`${pkg.name}@${tag}`);
} catch {}
const diffObj = await npmDiff(packageJsonPath, tag);

packageDiffs[packageJsonPath] = [
npmPkg || {...pkg, version: undefined},
diffObj,
Object.values(diffObj).reduce(
(memo, diff) => {
if (diff) {
memo.changeCount++;
const [
{
hunks: [hunk]
}
] = parsePatch(diff);
if (hunk) {
memo.addCount = memo.addCount + hunk.newLines;
memo.removeCount =
memo.removeCount + hunk.oldLines;
}
] = parsePatch(diff);
if (hunk) {
memo.addCount = memo.addCount + hunk.newLines;
memo.removeCount = memo.removeCount + hunk.oldLines;
}
}
return memo;
},
{addCount: 0, removeCount: 0, changeCount: 0}
return memo;
},
{addCount: 0, removeCount: 0, changeCount: 0}
)
];
}
if (
!Object.values(packageDiffs).find(
([, , {changeCount}]) => changeCount
)
];
}
if (
!Object.values(packageDiffs).find(([, , {changeCount}]) => changeCount)
) {
ora().info(`There are no changes to be published`);
process.exit();
) {
ora().info(`There are no changes to be published`);
process.exit();
}
}

const answers = await inquirer.prompt({
Expand Down

0 comments on commit e2fa128

Please sign in to comment.