Skip to content

Commit 304e750

Browse files
committed
Use tar for Linux distros.
1 parent 6d46f27 commit 304e750

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

lib/src/cli/task_project_init.dart

+17-3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ import "context.dart";
3737
const _resourceZipUrl =
3838
"https://github.com/buijs-dev/klutter-dart/raw/develop/resources.zip";
3939

40+
const _resourceTarUrl =
41+
"https://github.com/buijs-dev/klutter-dart/raw/develop/resources.tar.gz";
42+
4043
/// Task to prepare a flutter project for using klutter plugins.
4144
///
4245
/// {@category consumer}
@@ -108,14 +111,18 @@ Future<void> _producerInit(
108111
..setupExample;
109112
}
110113

111-
/// Download [_resourceZipUrl] and return the unzipped directory.
114+
/// Download [_resourceZipUrl] or [_resourceTarUrl]
115+
/// and return the unzipped directory.
112116
Future<Directory> _downloadResourcesZipOrThrow(String pathToRoot) async {
113117
final cache = Directory(pathToRoot.normalize).kradleCache..maybeCreate;
114118
final target = cache.resolveDirectory("init.resources");
115119
final zip = target.resolveFile("resources.zip")
116120
..maybeDelete
117121
..createSync(recursive: true);
118-
await downloadOrThrow(_resourceZipUrl, zip, target);
122+
final endpoint = platform.isLinux
123+
? _resourceTarUrl
124+
: _resourceZipUrl;
125+
await downloadOrThrow(endpoint, zip, target);
119126

120127
if (!target.existsSync()) {
121128
throw const KlutterException("Failed to download resources.zip");
@@ -126,16 +133,23 @@ Future<Directory> _downloadResourcesZipOrThrow(String pathToRoot) async {
126133
"Failed to download resources (no content found)");
127134
}
128135

136+
print("content dowloaded:");
137+
target.listSync().map((e) => e.path).toList().forEach((e) {
138+
print(e);
139+
});
129140
return target;
130141
}
131142

132-
/// Download the flutter sdk or throw [KlutterException] on failure.
143+
/// Download the resources or throw [KlutterException] on failure.
133144
Future<void> downloadOrThrow(
134145
String endpoint, File zip, Directory target) async {
135146
print("resources download started: $endpoint");
136147
await download(endpoint, zip);
148+
print("resources download done: ${zip.lengthSync()}");
137149
if (zip.existsSync()) {
150+
print("resources download unzipping");
138151
await unzip(zip, target..maybeCreate);
152+
print("resources download unzipped");
139153
zip.deleteSync();
140154
}
141155

resources.tar.gz

57 KB
Binary file not shown.

0 commit comments

Comments
 (0)