@@ -15,6 +15,8 @@ import { DEFAULT_VALUES, type CreateOptions } from './options.js';
15
15
import { selectPackageManager , type PackageManager } from './package-manager.js' ;
16
16
import { copyTemplate } from './template.js' ;
17
17
18
+ const TUTORIALKIT_VERSION = pkg . version ;
19
+
18
20
export async function createTutorial ( flags : yargs . Arguments ) {
19
21
if ( flags . _ [ 1 ] === 'help' || flags . help || flags . h ) {
20
22
printHelp ( {
@@ -255,6 +257,9 @@ function updatePackageJson(dest: string, projectName: string, flags: CreateOptio
255
257
256
258
pkgJson . name = projectName ;
257
259
260
+ updateWorkspaceVersions ( pkgJson . dependencies , TUTORIALKIT_VERSION ) ;
261
+ updateWorkspaceVersions ( pkgJson . devDependencies , TUTORIALKIT_VERSION ) ;
262
+
258
263
fs . writeFileSync ( pkgPath , JSON . stringify ( pkgJson , undefined , 2 ) ) ;
259
264
260
265
try {
@@ -313,3 +318,19 @@ function verifyFlags(flags: CreateOptions) {
313
318
throw new Error ( 'Cannot start project without installing dependencies.' ) ;
314
319
}
315
320
}
321
+
322
+ function updateWorkspaceVersions ( dependencies : Record < string , string > , version : string ) {
323
+ for ( const dependency in dependencies ) {
324
+ const depVersion = dependencies [ dependency ] ;
325
+
326
+ if ( depVersion === 'workspace:*' ) {
327
+ if ( process . env . TK_DIRECTORY ) {
328
+ const name = dependency . split ( '/' ) [ 1 ] ;
329
+
330
+ dependencies [ dependency ] = `file:${ process . env . TK_DIRECTORY } /packages/${ name . replace ( '-' , '/' ) } ` ;
331
+ } else {
332
+ dependencies [ dependency ] = version ;
333
+ }
334
+ }
335
+ }
336
+ }
0 commit comments