Skip to content

Commit

Permalink
Merge pull request #1500 from NullVoxPopuli/repo-relative-release-pla…
Browse files Browse the repository at this point in the history
…n-paths

Make the package-json path repo-relative
  • Loading branch information
NullVoxPopuli authored Jul 5, 2023
2 parents d660c6a + 33efc39 commit 67f82f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
8 changes: 4 additions & 4 deletions test-packages/release/src/interdep.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import glob from 'globby';
import { resolve } from 'path';
import { resolve, join } from 'path';
import { readFileSync, readJSONSync } from 'fs-extra';
import yaml from 'js-yaml';

Expand All @@ -21,15 +21,15 @@ export function publishedInterPackageDeps(): Map<string, PkgEntry> {
for (let pattern of (yaml.load(readFileSync(resolve(__dirname, '../../../pnpm-workspace.yaml'), 'utf8')) as any)
.packages) {
for (let dir of glob.sync(pattern, { cwd: rootDir, expandDirectories: false, onlyDirectories: true })) {
let pkgJSONPath = resolve(rootDir, dir, 'package.json');
let pkg = readJSONSync(pkgJSONPath);
let absolutePkgJSONPath = resolve(rootDir, dir, 'package.json');
let pkg = readJSONSync(absolutePkgJSONPath);
if (pkg.private) {
continue;
}
pkgJSONS.set(pkg.name, pkg);
packages.set(pkg.name, {
version: pkg.version,
pkgJSONPath,
pkgJSONPath: join(dir, 'package.json'),
isDependencyOf: new Map(),
isPeerDependencyOf: new Map(),
});
Expand Down
5 changes: 3 additions & 2 deletions test-packages/release/src/prepare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { readFileSync, writeFileSync } from 'fs';
import { resolve } from 'path';
import { planVersionBumps, saveSolution, Solution } from './plan';
import { readJSONSync, writeJSONSync } from 'fs-extra';
import { relativeToAbsolute } from './utils';

const changelogPreamble = `# Embroider Changelog
`;
Expand Down Expand Up @@ -36,9 +37,9 @@ function versionSummary(solution: Solution): string {
function updateVersions(solution: Solution) {
for (let entry of solution.values()) {
if (entry.impact) {
let pkg = readJSONSync(entry.pkgJSONPath);
let pkg = readJSONSync(relativeToAbsolute(entry.pkgJSONPath));
pkg.version = entry.newVersion;
writeJSONSync(entry.pkgJSONPath, pkg, { spaces: 2 });
writeJSONSync(relativeToAbsolute(entry.pkgJSONPath), pkg, { spaces: 2 });
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions test-packages/release/src/publish.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import execa from 'execa';
import { loadSolution, Solution } from './plan';
import { dirname } from 'path';
import { Octokit } from '@octokit/rest';
import { absoluteDirname } from './utils';

async function hasCleanRepo(): Promise<boolean> {
let result = await execa('git', ['status', '--porcelain=v1'], { cwd: __dirname });
Expand All @@ -27,7 +27,7 @@ async function makeTags(solution: Solution, reporter: IssueReporter): Promise<vo
}
try {
await execa('git', ['tag', tagFor(pkgName, entry)], {
cwd: dirname(entry.pkgJSONPath),
cwd: absoluteDirname(entry.pkgJSONPath),
stderr: 'inherit',
stdout: 'inherit',
});
Expand Down Expand Up @@ -81,7 +81,7 @@ async function pnpmPublish(solution: Solution, reporter: IssueReporter): Promise
}
try {
await execa('pnpm', ['publish', '--access=public'], {
cwd: dirname(entry.pkgJSONPath),
cwd: absoluteDirname(entry.pkgJSONPath),
stderr: 'inherit',
stdout: 'inherit',
});
Expand Down
11 changes: 11 additions & 0 deletions test-packages/release/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { dirname, join, resolve } from 'path';

export const root = resolve(__dirname, '../../../');

export function relativeToAbsolute(repoRelative: string) {
return join(root, repoRelative);
}

export function absoluteDirname(repoRelative: string) {
return dirname(relativeToAbsolute(repoRelative));
}

0 comments on commit 67f82f3

Please sign in to comment.