Skip to content

Commit 2e7d127

Browse files
committed
Fix missing constraints plugin
1 parent e01e3a4 commit 2e7d127

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

src/functional.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ describe('create-release-branch (functional)', () => {
8383
private: true,
8484
workspaces: ['packages/*'],
8585
scripts: { foo: 'bar' },
86+
packageManager: '[email protected]',
8687
});
8788
expect(
8889
await environment.readJsonFileWithinPackage('a', 'package.json'),
@@ -195,6 +196,7 @@ describe('create-release-branch (functional)', () => {
195196
private: true,
196197
workspaces: ['packages/*'],
197198
scripts: { foo: 'bar' },
199+
packageManager: '[email protected]',
198200
});
199201
expect(
200202
await environment.readJsonFileWithinPackage('a', 'package.json'),
@@ -691,6 +693,7 @@ describe('create-release-branch (functional)', () => {
691693
version: '2.0.0',
692694
private: true,
693695
workspaces: ['packages/*'],
696+
packageManager: '[email protected]',
694697
});
695698
expect(
696699
await environment.readJsonFileWithinPackage('a', 'package.json'),

tests/functional/helpers/local-monorepo.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,48 @@ export default class LocalMonorepo<
159159
protected async afterCreate() {
160160
await super.afterCreate();
161161

162-
await this.writeJsonFile('package.json', { private: true });
162+
await this.writeJsonFile('package.json', {
163+
private: true,
164+
packageManager: '[email protected]',
165+
});
166+
167+
const constraintsProContent = `
168+
% Ensure that a package has a name defined
169+
enforce_has_name(Pkg) :-
170+
package_json(Pkg, 'name', _).
171+
172+
% Ensure that a package has a version defined
173+
enforce_has_version(Pkg) :-
174+
package_json(Pkg, 'version', _).
175+
176+
% Check all packages in the workspace
177+
enforce_all :-
178+
workspace_package(Pkg),
179+
enforce_has_name(Pkg),
180+
enforce_has_version(Pkg).
181+
`;
182+
await this.writeFile('constraints.pro', constraintsProContent);
183+
184+
const yarnLockContent = `
185+
# This file is generated by running "yarn install" inside your project.
186+
# Manual changes might be lost - proceed with caution!
187+
188+
__metadata:
189+
version: 6
190+
191+
${knownKeysOf(this.#packages)
192+
.map((packageName) => {
193+
const pkg = this.#packages[packageName];
194+
return `
195+
"${pkg.name}@workspace:${pkg.directoryPath}":
196+
version: ${pkg.version}
197+
resolution: "${pkg.name}@workspace:${pkg.directoryPath}"
198+
languageName: unknown
199+
linkType: soft`;
200+
})
201+
.join('\n\n')}
202+
`;
203+
await this.writeFile('yarn.lock', yarnLockContent);
163204

164205
// Update manifests for root and workspace packages with `name`, `version`,
165206
// and (optionally) `workspaces`
@@ -179,6 +220,8 @@ export default class LocalMonorepo<
179220
);
180221
}),
181222
);
223+
224+
await this.runCommand('yarn', ['plugin', 'import', 'constraints']);
182225
}
183226

184227
/**

0 commit comments

Comments
 (0)