Skip to content

Commit ad3c9ca

Browse files
authored
Merge pull request #38 from ilopX/fix-web-demos-logo-local-remote-host
Fix web demos logo local to remote host.
2 parents 15161ae + 5d11f07 commit ad3c9ca

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

bin/deploy_flutter_demos.dart

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
2228
Future<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+
4871
void 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-
7492
void clear() {
7593
print('Clear: $tmpDir');
7694
tmpDir.deleteSync(recursive: true);

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<base href="/design-patterns-dart/">
4+
<base href="/">
55

66
<meta charset="UTF-8">
77
<meta content="IE=Edge" http-equiv="X-UA-Compatible">

0 commit comments

Comments
 (0)