Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: failing test for version bumping bug #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/build-dep-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ const glob = promisify(require('glob'));
const semver = require('semver');
const dependencyTypes = require('./dependency-types');
const execa = require('execa');
const fs = require('fs');
const readFile = promisify(fs.readFile);

function copyDeps(left, right) {
for (let dependencyType of dependencyTypes) {
left[dependencyType] = { ...right[dependencyType] };
}
}

function firstPass(workspaceMeta, workspacePackageJson, packageDirs) {
async function firstPass(workspaceMeta, workspacePackageJson, packageDirs) {
workspaceMeta.packageName = workspacePackageJson.name || 'Workspace Root';
workspaceMeta.version = workspacePackageJson.version;
workspaceMeta.isPrivate = true;
Expand All @@ -22,7 +24,7 @@ function firstPass(workspaceMeta, workspacePackageJson, packageDirs) {
for (let packageDir of packageDirs) {
let packageJson;
try {
packageJson = require(path.join(packageDir, 'package'));
packageJson = JSON.parse(await readFile(path.join(packageDir, 'package.json'), 'utf8'));
} catch (err) {
// ignore empty folders
continue;
Expand Down Expand Up @@ -81,7 +83,7 @@ async function buildDepGraph(workspaceCwd) {

let _1dFilesArray;
if (!workspaces) {
_1dFilesArray = (await execa.command('pnpm recursive exec -- node -e "console.log(process.cwd())"', { cwd: workspaceCwd })).stdout
_1dFilesArray = (await execa('pnpm', ['recursive', 'exec', '--', 'node', '-e', 'console.log(process.cwd())'], { cwd: workspaceCwd })).stdout
.split(/\r?\n/)
.map(workspace => path.relative(workspaceCwd, workspace));
} else {
Expand All @@ -104,7 +106,7 @@ async function buildDepGraph(workspaceCwd) {
cwd: workspaceCwd,
};

firstPass(workspaceMeta, workspacePackageJson, packageDirs);
await firstPass(workspaceMeta, workspacePackageJson, packageDirs);
secondPass(workspaceMeta);

return workspaceMeta;
Expand Down
66 changes: 66 additions & 0 deletions test/release-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -952,4 +952,70 @@ describe(_release, function() {

expect(stdout).to.equal(['foo', 'bar'].join(EOL));
});

it('ignores prior version bumps and changelogs', async function() {
fixturify.writeSync(tmpPath, {
'packages': {
'my-app': {
'package.json': stringifyJson({
'private': true,
'name': 'my-app',
'version': '1.0.0',
}),
},
},
'package.json': stringifyJson({
'private': true,
'name': 'my-monorepo',
'version': '1.0.0',
'workspaces': [
'packages/*',
],
}),
});

await execa('git', ['add', '.'], { cwd: tmpPath });
await execa('git', ['commit', '-m', 'chore: release'], { cwd: tmpPath });

await execa('git', ['tag', '[email protected]'], { cwd: tmpPath });
await execa('git', ['tag', '[email protected]'], { cwd: tmpPath });

fixturify.writeSync(tmpPath, {
'packages': {
'my-app': {
'index.js': 'foo',
},
},
});

await execa('git', ['add', '.'], { cwd: tmpPath });
await execa('git', ['commit', '-m', 'fix: foo'], { cwd: tmpPath });

await release();

let tags = await getTagsOnLastCommit(tmpPath);

expect(tags).to.deep.equal([
'[email protected]',
]);

fixturify.writeSync(tmpPath, {
'packages': {
'my-app': {
'index.js': 'bar',
},
},
});

await execa('git', ['add', '.'], { cwd: tmpPath });
await execa('git', ['commit', '-m', 'fix: bar'], { cwd: tmpPath });

await release();

tags = await getTagsOnLastCommit(tmpPath);

expect(tags).to.deep.equal([
'[email protected]',
]);
});
});