@@ -144,6 +144,107 @@ export const copyTemplateFiles = async (
144144 path . join ( root , "/.babelrc" )
145145 ) ;
146146 }
147+
148+ // * Apply the applicationName to template files
149+ const readmeFile = await fs . readFile ( path . join ( root , "README.md" ) , "utf-8" ) ;
150+ const newReadmeContent = readmeFile . replace (
151+ / _ _ _ A P P N A M E _ _ _ / gm,
152+ applicationName
153+ ) ;
154+ await fs . writeFile ( path . join ( root , "README.md" ) , newReadmeContent , "utf8" ) ;
155+
156+ if ( language === "js" ) {
157+ // * src/index.js
158+ const indexFile = await fs . readFile (
159+ path . join ( root , "/src/index.js" ) ,
160+ "utf-8"
161+ ) ;
162+ const newIndexFileContent = indexFile . replace (
163+ / _ _ _ A P P N A M E _ _ _ / gm,
164+ applicationName
165+ ) ;
166+ await fs . writeFile (
167+ path . join ( root , "/src/index.js" ) ,
168+ newIndexFileContent ,
169+ "utf8"
170+ ) ;
171+
172+ // * src/menu.js
173+ const menuFile = await fs . readFile (
174+ path . join ( root , "/src/menu.js" ) ,
175+ "utf-8"
176+ ) ;
177+ const newMenuFileContent = menuFile . replace (
178+ / _ _ _ A P P N A M E _ _ _ / gm,
179+ applicationName
180+ ) ;
181+ await fs . writeFile (
182+ path . join ( root , "/src/menu.js" ) ,
183+ newMenuFileContent ,
184+ "utf8"
185+ ) ;
186+
187+ // * src/setup.js
188+ const setupFile = await fs . readFile (
189+ path . join ( root , "/src/setup.js" ) ,
190+ "utf-8"
191+ ) ;
192+ const newSetupFileContent = setupFile . replace (
193+ / _ _ _ A P P N A M E _ _ _ / gm,
194+ applicationName
195+ ) ;
196+ await fs . writeFile (
197+ path . join ( root , "/src/setup.js" ) ,
198+ newSetupFileContent ,
199+ "utf8"
200+ ) ;
201+ } else if ( language === "ts" ) {
202+ // * src/index.ts
203+ const indexFile = await fs . readFile (
204+ path . join ( root , "/src/index.ts" ) ,
205+ "utf-8"
206+ ) ;
207+ const newIndexFileContent = indexFile . replace (
208+ / _ _ _ A P P N A M E _ _ _ / gm,
209+ applicationName
210+ ) ;
211+ await fs . writeFile (
212+ path . join ( root , "/src/index.ts" ) ,
213+ newIndexFileContent ,
214+ "utf8"
215+ ) ;
216+
217+ // * src/menu.ts
218+ const menuFile = await fs . readFile (
219+ path . join ( root , "/src/menu.ts" ) ,
220+ "utf-8"
221+ ) ;
222+ const newMenuFileContent = menuFile . replace (
223+ / _ _ _ A P P N A M E _ _ _ / gm,
224+ applicationName
225+ ) ;
226+ await fs . writeFile (
227+ path . join ( root , "/src/menu.ts" ) ,
228+ newMenuFileContent ,
229+ "utf8"
230+ ) ;
231+
232+ // * src/setup.ts
233+ const setupFile = await fs . readFile (
234+ path . join ( root , "/src/setup.ts" ) ,
235+ "utf-8"
236+ ) ;
237+ const newSetupFileContent = setupFile . replace (
238+ / _ _ _ A P P N A M E _ _ _ / gm,
239+ applicationName
240+ ) ;
241+ await fs . writeFile (
242+ path . join ( root , "/src/setup.ts" ) ,
243+ newSetupFileContent ,
244+ "utf8"
245+ ) ;
246+ }
247+
147248 spinner . succeed ( "Template files copied successfully" ) ;
148249 } catch ( error ) {
149250 spinner . fail ( ) ;
0 commit comments