patch method
Server Universe
Implementation
Stream<GeneralLibraryApiStatus> patch({
required Directory directoryBase,
}) async* {
Directory directory_project = Directory(directoryBase.uri.toFilePath());
// ignore: unused_local_variable
String project_name = path.basename(directory_project.path);
File file_pubspec = File(path.join(directory_project.path, "pubspec.yaml"));
if (!file_pubspec.existsSync()) {
yield GeneralLibraryApiStatus(
serverUniverseApiStatusType: GeneralLibraryApiStatusType.failed,
value: "Failed Create Project:");
return;
}
// build/web/flutter_bootstrap.js
// android
Directory directory_build_web = Directory(
path.join(directory_project.uri.toFilePath(), "build", "web"));
if (directory_build_web.existsSync()) {
yield GeneralLibraryApiStatus(
serverUniverseApiStatusType: GeneralLibraryApiStatusType.info,
value: "Started Patch Web");
// auto setup settings gradle
File file_flutter_bootstrap_js = File(path.join(
directory_build_web.uri.toFilePath(), "flutter_bootstrap.js"));
if (file_flutter_bootstrap_js.existsSync()) {
yield GeneralLibraryApiStatus(
serverUniverseApiStatusType: GeneralLibraryApiStatusType.info,
value: "Check File: build/web/flutter_bootstrap.js");
String value = await file_flutter_bootstrap_js.readAsString();
final String canvasKitBaseUrlFrom = """
return a.canvasKitBaseUrl?a.canvasKitBaseUrl:t.engineRevision&&!t.useLocalCanvasKit?_("https://www.gstatic.com/flutter-canvaskit",t.engineRevision):"canvaskit"
"""
.trim();
value = value.replaceAll(canvasKitBaseUrlFrom, "return \"canvaskit\";");
await file_flutter_bootstrap_js.writeAsString(value);
print("Replace canvaskit on flutter_bootstrap.js");
}
// auto setup settings gradle
File file_main_dart_js =
File(path.join(directory_build_web.uri.toFilePath(), "main.dart.js"));
if (file_main_dart_js.existsSync()) {
yield GeneralLibraryApiStatus(
serverUniverseApiStatusType: GeneralLibraryApiStatusType.info,
value: "Check File: build/web/main.dart.js");
String value = await file_main_dart_js.readAsString();
final String canvasKitBaseUrlFrom = """
return s==null?"https://fonts.gstatic.com/s/":s
"""
.trim();
value = value.replaceAll(canvasKitBaseUrlFrom, "return \"\";");
await file_main_dart_js.writeAsString(value);
print("Replace canvaskit on main.dart.js");
}
///
/// add file
///
///
File file_roboto_v20_font_ttf = File(path.join(
directory_build_web.uri.toFilePath(),
"roboto",
"v20",
"KFOmCnqEu92Fr1Me5WZLCzYlKw.ttf"));
final String path_relative = path.relative(file_roboto_v20_font_ttf.path,
from: directory_build_web.uri.toFilePath());
if (file_roboto_v20_font_ttf.parent.existsSync() == false) {
file_roboto_v20_font_ttf.parent.createSync(recursive: true);
print("create Directory: ${path_relative}");
}
await file_roboto_v20_font_ttf
.writeAsBytes(file_KFOmCnqEu92Fr1Me5WZLCzYlKw);
print("create file: ${path_relative}");
}
}