88import {
99 access ,
1010 appendFile ,
11+ copyFile ,
1112 mkdir ,
1213 readFile ,
1314 writeFile ,
@@ -43,6 +44,7 @@ const templateNames = [
4344 'lib-solid-ts' ,
4445 'doc' ,
4546 'doc-i18n' ,
47+ 'turborepo' ,
4648] ;
4749
4850const resolveTemplateName = ( template : string ) : string => {
@@ -55,7 +57,7 @@ const resolveTemplateName = (template: string): string => {
5557
5658const getTemplateName = async ( { template } : Argv ) : Promise < string > => {
5759 if ( typeof template === 'string' ) {
58- if ( / ^ (?: a p p | l i b | d o c ) (?: - | $ ) / u. test ( template ) ) {
60+ if ( / ^ (?: a p p | l i b | d o c | t u r b o r e p o ) (?: - | $ ) / u. test ( template ) ) {
5961 return resolveTemplateName ( template ) ;
6062 }
6163
@@ -69,10 +71,22 @@ const getTemplateName = async ({ template }: Argv): Promise<string> => {
6971 { value : 'app' , label : 'Web Application' } ,
7072 { value : 'lib' , label : 'Library' } ,
7173 { value : 'doc' , label : 'Documentation' } ,
74+ { value : 'monorepo' , label : 'Monorepo' } ,
7275 ] ,
7376 } ) ,
7477 ) ;
7578
79+ if ( projectType === 'monorepo' ) {
80+ const monorepoType = checkCancel < string > (
81+ await select ( {
82+ message : 'Select monorepo tool' ,
83+ options : [ { value : 'turborepo' , label : 'Turborepo' , hint : 'pnpm' } ] ,
84+ } ) ,
85+ ) ;
86+
87+ return resolveTemplateName ( monorepoType ) ;
88+ }
89+
7690 if ( projectType === 'doc' ) {
7791 const documentationType = checkCancel < string > (
7892 await select ( {
@@ -215,11 +229,29 @@ const injectStagedSetup = async ({
215229 ] ) ;
216230} ;
217231
232+ const configureTurborepo = async ( {
233+ templateName,
234+ distFolder,
235+ } : GitResolvedContext ) : Promise < void > => {
236+ if ( templateName !== 'turborepo' ) {
237+ return ;
238+ }
239+
240+ // The toolkit may skip this file based on the invoking package manager.
241+ await copyFile (
242+ path . join ( packageRoot , 'template-turborepo/pnpm-workspace.yaml' ) ,
243+ path . join ( distFolder , 'pnpm-workspace.yaml' ) ,
244+ ) ;
245+ } ;
246+
218247await create ( {
219248 root : packageRoot ,
220249 name : 'rstack' ,
221250 templates : templateNames ,
222251 builtinTools : [ ] ,
223252 getTemplateName,
224- onGitResolved : injectStagedSetup ,
253+ onGitResolved : async ( context ) => {
254+ await configureTurborepo ( context ) ;
255+ await injectStagedSetup ( context ) ;
256+ } ,
225257} ) ;
0 commit comments