@@ -14,11 +14,17 @@ void main() async {
1414
1515 await Future .wait ([prepareRepository, buildProject]);
1616
17+ prepareIndexHtmlForRemoteHost ();
1718 copyFiles ();
1819 await pushToOrigin ();
1920 clear ();
2021}
2122
23+ late final tmpDir = Directory .systemTemp.createTempSync ();
24+ late final projectDir = thisPath (r'..\' );
25+ late final webBuildDir = Directory (projectDir.uri.toFilePath () + r'build\web' );
26+ late final String originUrl;
27+
2228Future <void > init () async {
2329 print ('Use temp: $tmpDir ' );
2430 originUrl = await repositoryOriginUrl (projectDir);
@@ -45,6 +51,23 @@ Future<void> fetchUpstream() async {
4551 await cmd ('git fetch upstream' , workingDirectory: tmpDir);
4652}
4753
54+ void prepareIndexHtmlForRemoteHost () {
55+ print ('Prepare "index.html" for remote host.' );
56+
57+ final indexHtmlFile = File (webBuildDir.path + r'\index.html' );
58+ final indexContent = indexHtmlFile.readAsStringSync ();
59+ final fixedIndexContent = indexContent.replaceFirst (
60+ r'<base href="/">' ,
61+ r'<base href="/design-patterns-dart/">' ,
62+ );
63+
64+ if (indexContent == fixedIndexContent) {
65+ throw 'Base url not found. It should be <base href="/">' ;
66+ }
67+
68+ indexHtmlFile.writeAsStringSync (fixedIndexContent);
69+ }
70+
4871void copyFiles () {
4972 print ('Copy files:' );
5073 copyDirectory (webBuildDir, tmpDir);
@@ -66,11 +89,6 @@ Future<void> pushToOrigin() async {
6689 );
6790}
6891
69- late final tmpDir = Directory .systemTemp.createTempSync ();
70- late final projectDir = thisPath (r'..\' );
71- late final webBuildDir = Directory (projectDir.uri.toFilePath () + r'build\web' );
72- late final String originUrl;
73-
7492void clear () {
7593 print ('Clear: $tmpDir ' );
7694 tmpDir.deleteSync (recursive: true );
0 commit comments