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

Make the package-json path repo-relative #1500

Merged
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
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));
}