11import fs from 'fs' ;
22import { exec } from 'child_process' ;
33import Generator from 'yeoman-generator' ;
4+ import path from 'path' ;
5+ import { fileURLToPath } from 'url' ;
6+
7+ // Convert `import.meta.url` to a path
8+ const __filename = fileURLToPath ( import . meta. url ) ;
9+ const __dirname = path . dirname ( __filename ) ;
10+
411
512function toKebabCase ( str ) {
613 return str . replace ( / ( [ a - z 0 - 9 ] ) ( [ A - Z ] ) / g, '$1-$2' ) . toLowerCase ( ) . replace ( / \s + / g, '-' ) ;
@@ -9,6 +16,7 @@ function toKebabCase(str) {
916export default class extends Generator {
1017 constructor ( args , opts ) {
1118 super ( args , opts ) ;
19+ this . sourceRoot ( path . join ( __dirname , 'templates' ) ) ;
1220
1321 // Define options
1422 this . option ( 'project' , {
@@ -103,12 +111,13 @@ export default class extends Generator {
103111 }
104112
105113 this . patchFiles = async function ( ) {
106- // await new Promise((resolve, reject) => this.fs.commit((err) => (err ? reject(err) : resolve())));
107114 if ( this . options . storybook ) {
108115 if ( this . options . typescript ) {
109116 this . log ( 'Replace Next.js\' TypeScript configuration file with JS...' ) ;
110117 // Remove TypeScript configuration files given they require Next.js 15
111118 fs . unlinkSync ( this . destinationPath ( 'next.config.ts' ) ) ;
119+ console . log ( 'Template Path:' , this . templatePath ( 'next.config.js' ) ) ;
120+ console . log ( 'Destination Path:' , this . destinationPath ( 'next.config.js' ) ) ;
112121 this . fs . copyTpl (
113122 this . templatePath ( 'next.config.js' ) ,
114123 this . destinationPath ( 'next.config.js' ) ,
0 commit comments