@@ -14,11 +14,17 @@ void main() async {
14
14
15
15
await Future .wait ([prepareRepository, buildProject]);
16
16
17
+ prepareIndexHtmlForRemoteHost ();
17
18
copyFiles ();
18
19
await pushToOrigin ();
19
20
clear ();
20
21
}
21
22
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
+
22
28
Future <void > init () async {
23
29
print ('Use temp: $tmpDir ' );
24
30
originUrl = await repositoryOriginUrl (projectDir);
@@ -45,6 +51,23 @@ Future<void> fetchUpstream() async {
45
51
await cmd ('git fetch upstream' , workingDirectory: tmpDir);
46
52
}
47
53
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
+
48
71
void copyFiles () {
49
72
print ('Copy files:' );
50
73
copyDirectory (webBuildDir, tmpDir);
@@ -66,11 +89,6 @@ Future<void> pushToOrigin() async {
66
89
);
67
90
}
68
91
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
-
74
92
void clear () {
75
93
print ('Clear: $tmpDir ' );
76
94
tmpDir.deleteSync (recursive: true );
0 commit comments