@@ -159,7 +159,48 @@ export default class LocalMonorepo<
159
159
protected async afterCreate ( ) {
160
160
await super . afterCreate ( ) ;
161
161
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 ) ;
163
204
164
205
// Update manifests for root and workspace packages with `name`, `version`,
165
206
// and (optionally) `workspaces`
@@ -179,6 +220,8 @@ export default class LocalMonorepo<
179
220
) ;
180
221
} ) ,
181
222
) ;
223
+
224
+ await this . runCommand ( 'yarn' , [ 'plugin' , 'import' , 'constraints' ] ) ;
182
225
}
183
226
184
227
/**
0 commit comments