@@ -22,11 +22,12 @@ async function runCommand(cmd, args, options = {}) {
2222
2323describe ( 'create-tinker-stack generator' , ( ) => {
2424 test (
25- 'scaffolds project and passes build checks' ,
25+ 'scaffolds project with all examples by default and passes build checks' ,
2626 async ( ) => {
2727 const tempRoot = await mkdtemp ( path . join ( os . tmpdir ( ) , 'tinker-stack-' ) ) ;
2828 const appFolder = 'demo-app' ;
2929 const projectDir = path . join ( tempRoot , appFolder ) ;
30+ const exampleDir = path . join ( projectDir , 'examples' , 'react-router' ) ;
3031
3132 try {
3233 await runCommand ( 'node' , [ CLI_ENTRY , appFolder ] , {
@@ -46,6 +47,10 @@ describe('create-tinker-stack generator', () => {
4647
4748 const readme = await readFile ( path . join ( projectDir , 'README.md' ) , 'utf8' ) ;
4849 expect ( readme ) . toContain ( 'Demo Title' ) ;
50+ const examplePackageJson = JSON . parse (
51+ await readFile ( path . join ( exampleDir , 'package.json' ) , 'utf8' )
52+ ) ;
53+ expect ( examplePackageJson . scripts ) . toHaveProperty ( 'build' ) ;
4954
5055 await runCommand ( 'npm' , [ 'install' ] , { cwd : projectDir } ) ;
5156 await runCommand ( 'npm' , [ 'run' , 'typecheck' ] , { cwd : projectDir } ) ;
@@ -101,6 +106,36 @@ describe('create-tinker-stack generator', () => {
101106 5 * 60 * 1000
102107 ) ;
103108
109+ test (
110+ 'skips copying example templates when --no-examples is passed' ,
111+ async ( ) => {
112+ const tempRoot = await mkdtemp ( path . join ( os . tmpdir ( ) , 'tinker-stack-' ) ) ;
113+ const appFolder = 'demo-app' ;
114+ const projectDir = path . join ( tempRoot , appFolder ) ;
115+
116+ try {
117+ await runCommand ( 'node' , [ CLI_ENTRY , '--no-examples' , appFolder ] , {
118+ env : {
119+ ...process . env ,
120+ CI : '1' ,
121+ SKIP_SETUP : '1' ,
122+ SKIP_FORMAT : '1'
123+ } ,
124+ cwd : tempRoot
125+ } ) ;
126+
127+ const packageJson = JSON . parse ( await readFile ( path . join ( projectDir , 'package.json' ) , 'utf8' ) ) ;
128+ expect ( packageJson . name ) . toBe ( 'demo-title' ) ;
129+ await expect ( readFile ( path . join ( projectDir , 'examples' , 'react-router' , 'package.json' ) , 'utf8' ) )
130+ . rejects
131+ . toMatchObject ( { code : 'ENOENT' } ) ;
132+ } finally {
133+ await rm ( tempRoot , { recursive : true , force : true } ) ;
134+ }
135+ } ,
136+ 5 * 60 * 1000
137+ ) ;
138+
104139 test (
105140 'scaffolds into the current working directory when no target is provided' ,
106141 async ( ) => {
0 commit comments