@@ -43,6 +43,12 @@ const updatePackageInfos = async (projectName) => {
4343 type : 'git' ,
4444 url : 'git+https://github.com/user/repo-name.git' ,
4545 } ;
46+
47+ const appReleaseScript = packageJson . scripts [ 'app-release' ] ;
48+ packageJson . scripts [ 'app-release' ] = appReleaseScript . replace (
49+ 'template' ,
50+ projectName
51+ ) ;
4652 fs . writeJsonSync ( packageJsonPath , packageJson , { spaces : 2 } ) ;
4753} ;
4854
@@ -60,17 +66,54 @@ const updateProjectConfig = async (projectName) => {
6066} ;
6167
6268const updateGitHubWorkflows = ( projectName ) => {
63- const upstreamToPRWorkflowPath = path . join (
64- process . cwd ( ) ,
65- `${ projectName } /.github/workflows/upstream-to-pr.yml`
66- ) ;
67- const contents = fs . readFileSync ( upstreamToPRWorkflowPath , {
68- encoding : 'utf-8' ,
69- } ) ;
69+ const WORKFLOW_FILES = [
70+ {
71+ fileName : '.github/workflows/upstream-to-pr.yml' ,
72+ replacements : [
73+ {
74+ searchValue : UPSTREAM_REPOSITORY ,
75+ replaceValue : TEMPLATE_REPOSITORY ,
76+ } ,
77+ ] ,
78+ } ,
79+ {
80+ fileName : '.github/workflows/new-template-version.yml' ,
81+ replacements : [
82+ {
83+ searchValue : 'new version of the template' ,
84+ replaceValue : 'new version of the app' ,
85+ } ,
86+ {
87+ searchValue : 'New Template Version' ,
88+ replaceValue : `New ${ projectName } Version` ,
89+ } ,
90+ {
91+ searchValue : 'Run Template release' ,
92+ replaceValue : 'Run App release' ,
93+ } ,
94+ {
95+ searchValue : / ^ \s * e n v i r o n m e n t : \s * \n \s * n a m e : \s * t e m p l a t e \s * \n / m,
96+ replaceValue : '' ,
97+ } ,
98+ ] ,
99+ } ,
100+ ] ;
101+
102+ WORKFLOW_FILES . forEach ( ( { fileName, replacements } ) => {
103+ const workflowPath = path . join ( process . cwd ( ) , `${ projectName } /${ fileName } ` ) ;
104+
105+ const contents = fs . readFileSync ( workflowPath , {
106+ encoding : 'utf-8' ,
107+ } ) ;
70108
71- const replaced = contents . replace ( UPSTREAM_REPOSITORY , TEMPLATE_REPOSITORY ) ;
109+ let replaced = contents ;
72110
73- fs . writeFileSync ( upstreamToPRWorkflowPath , replaced , { spaces : 2 } ) ;
111+ replacements . forEach ( ( { searchValue, replaceValue } ) => {
112+ replaced = replaced . replace ( searchValue , replaceValue ) ;
113+ } ) ;
114+
115+ fs . writeFileSync ( workflowPath , replaced , { spaces : 2 } ) ;
116+ } ) ;
74117} ;
75118
76119const renameFiles = ( projectName ) => {
@@ -79,6 +122,10 @@ const renameFiles = (projectName) => {
79122 oldFileName : 'README-project.md' ,
80123 newFileName : 'README.md' ,
81124 } ,
125+ {
126+ oldFileName : '.github/workflows/new-template-version.yml' ,
127+ newFileName : '.github/workflows/new-app-version.yml' ,
128+ } ,
82129 ] ;
83130
84131 FILES_TO_RENAME . forEach ( ( { oldFileName, newFileName } ) => {
0 commit comments