Skip to content

Commit 4665b32

Browse files
committed
Allow users to omit packages
1 parent 106feff commit 4665b32

File tree

3 files changed

+0
-300
lines changed

3 files changed

+0
-300
lines changed

src/functional.test.ts

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -606,116 +606,6 @@ describe('create-release-branch (functional)', () => {
606606
);
607607
});
608608

609-
it('errors before making any changes if the edited release spec omits changed packages', async () => {
610-
await withMonorepoProjectEnvironment(
611-
{
612-
packages: {
613-
$root$: {
614-
name: '@scope/monorepo',
615-
version: '1.0.0',
616-
directoryPath: '.',
617-
},
618-
a: {
619-
name: '@scope/a',
620-
version: '0.1.2',
621-
directoryPath: 'packages/a',
622-
},
623-
b: {
624-
name: '@scope/b',
625-
version: '1.1.4',
626-
directoryPath: 'packages/b',
627-
},
628-
c: {
629-
name: '@scope/c',
630-
version: '2.0.13',
631-
directoryPath: 'packages/c',
632-
},
633-
d: {
634-
name: '@scope/d',
635-
version: '1.2.3',
636-
directoryPath: 'packages/d',
637-
},
638-
},
639-
workspaces: {
640-
'.': ['packages/*'],
641-
},
642-
},
643-
async (environment) => {
644-
await expect(
645-
environment.runTool({
646-
releaseSpecification: {
647-
packages: {
648-
a: 'major',
649-
c: 'patch',
650-
},
651-
},
652-
}),
653-
).toThrowExecaError(
654-
`
655-
Error: Your release spec could not be processed due to the following issues:
656-
657-
* The following packages, which have changed since their latest release, are missing.
658-
659-
- @scope/b
660-
- @scope/d
661-
662-
Consider including them in the release spec so that any packages that rely on them won't break in production.
663-
664-
If you are ABSOLUTELY SURE that this won't occur, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:
665-
666-
packages:
667-
"@scope/b": intentionally-skip
668-
"@scope/d": intentionally-skip
669-
670-
The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.
671-
672-
<<release-spec-file-path>>
673-
<<stack-trace>>
674-
`.trim(),
675-
{
676-
replacements: [
677-
{
678-
from: `${environment.tempDirectoryPath}/RELEASE_SPEC.yml`,
679-
to: '<<release-spec-file-path>>',
680-
},
681-
],
682-
},
683-
);
684-
685-
expect(await environment.readJsonFile('package.json')).toStrictEqual({
686-
name: '@scope/monorepo',
687-
version: '1.0.0',
688-
private: true,
689-
workspaces: ['packages/*'],
690-
});
691-
expect(
692-
await environment.readJsonFileWithinPackage('a', 'package.json'),
693-
).toStrictEqual({
694-
name: '@scope/a',
695-
version: '0.1.2',
696-
});
697-
expect(
698-
await environment.readJsonFileWithinPackage('b', 'package.json'),
699-
).toStrictEqual({
700-
name: '@scope/b',
701-
version: '1.1.4',
702-
});
703-
expect(
704-
await environment.readJsonFileWithinPackage('c', 'package.json'),
705-
).toStrictEqual({
706-
name: '@scope/c',
707-
version: '2.0.13',
708-
});
709-
expect(
710-
await environment.readJsonFileWithinPackage('d', 'package.json'),
711-
).toStrictEqual({
712-
name: '@scope/d',
713-
version: '1.2.3',
714-
});
715-
},
716-
);
717-
});
718-
719609
it('does not update the versions of any packages that have been tagged with intentionally-skip', async () => {
720610
await withMonorepoProjectEnvironment(
721611
{

src/release-specification.test.ts

Lines changed: 0 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -572,118 +572,6 @@ Your release spec could not be processed due to the following issues:
572572
});
573573
});
574574

575-
it('throws if there are any packages not listed in the release spec which have changed', async () => {
576-
await withSandbox(async (sandbox) => {
577-
const project = buildMockProject({
578-
workspacePackages: {
579-
a: buildMockPackage('a', {
580-
hasChangesSinceLatestRelease: true,
581-
}),
582-
b: buildMockPackage('b', {
583-
hasChangesSinceLatestRelease: true,
584-
}),
585-
c: buildMockPackage('c', {
586-
hasChangesSinceLatestRelease: true,
587-
}),
588-
},
589-
});
590-
const releaseSpecificationPath = path.join(
591-
sandbox.directoryPath,
592-
'release-spec',
593-
);
594-
await fs.promises.writeFile(
595-
releaseSpecificationPath,
596-
YAML.stringify({
597-
packages: {
598-
a: 'major',
599-
},
600-
}),
601-
);
602-
603-
await expect(
604-
validateReleaseSpecification(project, releaseSpecificationPath),
605-
).rejects.toThrow(
606-
`
607-
Your release spec could not be processed due to the following issues:
608-
609-
* The following packages, which have changed since their latest release, are missing.
610-
611-
- b
612-
- c
613-
614-
Consider including them in the release spec so that any packages that rely on them won't break in production.
615-
616-
If you are ABSOLUTELY SURE that this won't occur, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:
617-
618-
packages:
619-
b: intentionally-skip
620-
c: intentionally-skip
621-
622-
The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.
623-
624-
${releaseSpecificationPath}
625-
`.trim(),
626-
);
627-
});
628-
});
629-
630-
it('throws if there are any packages listed in the release spec which have changed but their version specifiers are null', async () => {
631-
await withSandbox(async (sandbox) => {
632-
const project = buildMockProject({
633-
workspacePackages: {
634-
a: buildMockPackage('a', {
635-
hasChangesSinceLatestRelease: true,
636-
}),
637-
b: buildMockPackage('b', {
638-
hasChangesSinceLatestRelease: true,
639-
}),
640-
c: buildMockPackage('c', {
641-
hasChangesSinceLatestRelease: true,
642-
}),
643-
},
644-
});
645-
const releaseSpecificationPath = path.join(
646-
sandbox.directoryPath,
647-
'release-spec',
648-
);
649-
await fs.promises.writeFile(
650-
releaseSpecificationPath,
651-
YAML.stringify({
652-
packages: {
653-
a: 'major',
654-
b: null,
655-
c: null,
656-
},
657-
}),
658-
);
659-
660-
await expect(
661-
validateReleaseSpecification(project, releaseSpecificationPath),
662-
).rejects.toThrow(
663-
`
664-
Your release spec could not be processed due to the following issues:
665-
666-
* The following packages, which have changed since their latest release, are missing.
667-
668-
- b
669-
- c
670-
671-
Consider including them in the release spec so that any packages that rely on them won't break in production.
672-
673-
If you are ABSOLUTELY SURE that this won't occur, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:
674-
675-
packages:
676-
b: intentionally-skip
677-
c: intentionally-skip
678-
679-
The release spec file has been retained for you to edit again and make the necessary fixes. Once you've done this, re-run this tool.
680-
681-
${releaseSpecificationPath}
682-
`.trim(),
683-
);
684-
});
685-
});
686-
687575
it('throws if there are any packages in the release with a major version bump using the word "major", but any of their dependents defined as "dependencies" are not listed in the release', async () => {
688576
await withSandbox(async (sandbox) => {
689577
const project = buildMockProject({

src/release-specification.ts

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -207,84 +207,6 @@ export async function validateReleaseSpecification(
207207

208208
const errors: { message: string | string[]; lineNumber?: number }[] = [];
209209

210-
const changedPackageNames = Object.keys(project.workspacePackages).filter(
211-
(packageName) =>
212-
project.workspacePackages[packageName].hasChangesSinceLatestRelease,
213-
);
214-
215-
const missingChangedPackageNames = changedPackageNames.filter(
216-
(packageName) =>
217-
!hasProperty(unvalidatedReleaseSpecification.packages, packageName) ||
218-
unvalidatedReleaseSpecification.packages[packageName] === null,
219-
);
220-
221-
const packageNamesToReportMissing = missingChangedPackageNames.filter(
222-
(missingChangedPackageName) => {
223-
const missingChangedPackage =
224-
project.workspacePackages[missingChangedPackageName];
225-
226-
const isInternalDependency = Object.values(
227-
project.workspacePackages,
228-
).some((workspacePackage) => {
229-
const { dependencies, peerDependencies } =
230-
workspacePackage.validatedManifest;
231-
return (
232-
hasProperty(dependencies, missingChangedPackageName) ||
233-
hasProperty(peerDependencies, missingChangedPackageName)
234-
);
235-
});
236-
237-
const hasInternalDependencyWithBreakingChanges = Object.keys({
238-
...missingChangedPackage.validatedManifest.dependencies,
239-
...missingChangedPackage.validatedManifest.peerDependencies,
240-
})
241-
.filter((dependency) => project.workspacePackages[dependency])
242-
.some((dependency) => {
243-
const internalDependencyVersionSpecifierOrDirective =
244-
unvalidatedReleaseSpecification.packages[dependency];
245-
return (
246-
internalDependencyVersionSpecifierOrDirective &&
247-
(internalDependencyVersionSpecifierOrDirective === 'major' ||
248-
(isValidSemver(internalDependencyVersionSpecifierOrDirective) &&
249-
diff(
250-
missingChangedPackage.validatedManifest.version,
251-
internalDependencyVersionSpecifierOrDirective,
252-
) === 'major'))
253-
);
254-
});
255-
256-
return !isInternalDependency && !hasInternalDependencyWithBreakingChanges;
257-
},
258-
);
259-
260-
if (packageNamesToReportMissing.length > 0) {
261-
errors.push({
262-
message: [
263-
'The following packages, which have changed since their latest release, are missing.',
264-
packageNamesToReportMissing
265-
.map((packageName) => ` - ${packageName}`)
266-
.join('\n'),
267-
" Consider including them in the release spec so that any packages that rely on them won't break in production.",
268-
` If you are ABSOLUTELY SURE that this won't occur, however, and want to postpone the release of a package, then list it with a directive of "intentionally-skip". For example:`,
269-
YAML.stringify({
270-
packages: packageNamesToReportMissing.reduce(
271-
(object, packageName) => {
272-
return {
273-
...object,
274-
[packageName]: INTENTIONALLY_SKIP_PACKAGE_DIRECTIVE,
275-
};
276-
},
277-
{},
278-
),
279-
})
280-
.trim()
281-
.split('\n')
282-
.map((line) => ` ${line}`)
283-
.join('\n'),
284-
].join('\n\n'),
285-
});
286-
}
287-
288210
Object.entries(unvalidatedReleaseSpecification.packages).forEach(
289211
([changedPackageName, versionSpecifierOrDirective], index) => {
290212
const lineNumber = indexOfFirstUsableLine + index + 2;

0 commit comments

Comments
 (0)