@@ -203,21 +203,21 @@ describe('project generation', () => {
203203 expect ( project ) . toMatchObject ( {
204204 name : 'my-docs' ,
205205 private : true ,
206- dependencies : { purestack : cliVersion } ,
206+ dependencies : { purestack : 'latest' } ,
207207 } )
208208 expect ( prepared . packageManager ) . toBe ( 'yarn' )
209209 expect ( await readFile ( path . join ( destination , 'yarn.lock' ) , 'utf8' ) ) . toBe ( '' )
210210 expect ( project . packageManager ) . toBe ( 'yarn@4.18.1' )
211- expect ( project . devDependencies [ '@purestack/ts-minidom' ] ) . toBe ( cliVersion )
211+ expect ( project . devDependencies [ '@purestack/ts-minidom' ] ) . toBe ( 'latest' )
212212 const yarnConfig = await readFile (
213213 path . join ( destination , '.yarnrc.yml' ) ,
214214 'utf8' ,
215215 )
216216 expect ( yarnConfig ) . toContain ( 'nodeLinker: node-modules' )
217217 expect ( yarnConfig ) . toContain ( 'npmMinimalAgeGate: 0' )
218218 expect ( project . dependencies ) . toMatchObject ( {
219- '@purestack/ts-style' : cliVersion ,
220- regor : '^1.7.6 ' ,
219+ '@purestack/ts-style' : 'latest' ,
220+ regor : 'latest ' ,
221221 } )
222222 expect (
223223 JSON . parse (
@@ -241,6 +241,36 @@ describe('project generation', () => {
241241 ) . toContain ( 'yarn build' )
242242 } )
243243
244+ it ( 'preserves template dependency selectors instead of replacing them with the CLI version' , async ( ) => {
245+ const unpacked = await fixture ( )
246+ const packageFile = path . join ( unpacked , 'template/package.json' )
247+ const project = JSON . parse ( await readFile ( packageFile , 'utf8' ) )
248+ project . dependencies . purestack = '1.2.3'
249+ project . dependencies [ '@purestack/ts-style' ] = '^1.2.0'
250+ await writeFile ( packageFile , JSON . stringify ( project ) )
251+
252+ await prepareProject ( unpacked , path . join ( temporary , 'project' ) , cliVersion )
253+
254+ expect (
255+ JSON . parse ( await readFile ( packageFile , 'utf8' ) ) . dependencies ,
256+ ) . toEqual ( project . dependencies )
257+ } )
258+
259+ it . each ( [ undefined , 42 ] ) (
260+ 'rejects a missing or invalid PureStack dependency (%s)' ,
261+ async ( dependency ) => {
262+ const unpacked = await fixture ( )
263+ const packageFile = path . join ( unpacked , 'template/package.json' )
264+ const project = JSON . parse ( await readFile ( packageFile , 'utf8' ) )
265+ project . dependencies . purestack = dependency
266+ await writeFile ( packageFile , JSON . stringify ( project ) )
267+
268+ await expect (
269+ prepareProject ( unpacked , path . join ( temporary , 'project' ) , cliVersion ) ,
270+ ) . rejects . toThrow ( / m u s t d e c l a r e d e p e n d e n c i e s .p u r e s t a c k / )
271+ } ,
272+ )
273+
244274 it ( 'rejects incompatible templates without creating a destination' , async ( ) => {
245275 const unpacked = await fixture ( )
246276 const destination = path . join ( temporary , 'project' )
@@ -390,6 +420,7 @@ describe('project generation', () => {
390420 ' package.tgz ' ,
391421 '' ,
392422 '{{unknown}}' ,
423+ '{{purestackVersion}}' ,
393424 ] ) ( 'rejects nonportable dependency %s' , async ( version ) => {
394425 const unpacked = await fixture ( )
395426 const packageFile = path . join ( unpacked , 'template/package.json' )
0 commit comments