|
15 | 15 | import 'dart:convert'; |
16 | 16 | import 'dart:io'; |
17 | 17 |
|
18 | | -import 'package:archive/archive.dart'; |
19 | 18 | import 'package:grinder/grinder.dart'; |
20 | 19 | import 'package:meta/meta.dart'; |
21 | 20 | import 'package:path/path.dart' as p; |
@@ -213,31 +212,28 @@ Future<void> _build() async { |
213 | 212 | dir.createSync(recursive: true); |
214 | 213 |
|
215 | 214 | writeString("build/chocolatey/$_chocolateyName.nuspec", _nuspec.toString()); |
216 | | - Directory("build/chocolatey/tools").createSync(); |
| 215 | + Directory("build/chocolatey/tools/source").createSync(recursive: true); |
| 216 | + |
217 | 217 | writeString("build/chocolatey/tools/LICENSE", await license); |
218 | 218 |
|
219 | | - var sourceFiles = Archive() |
220 | | - ..addFile(fileFromString( |
221 | | - "source/pubspec.yaml", |
222 | | - // Don't download useless dev dependencies to users' computers. |
223 | | - json.encode(Map.of(rawPubspec) |
224 | | - ..remove('dev_dependencies') |
225 | | - ..remove('dependency_overrides')))); |
| 219 | + writeString( |
| 220 | + 'build/chocolatey/tools/source/pubspec.yaml', |
| 221 | + json.encode(Map.of(rawPubspec) |
| 222 | + ..remove('dev_dependencies') |
| 223 | + ..remove('dependency_overrides'))); |
| 224 | + |
226 | 225 | for (var path in chocolateyFiles.value) { |
227 | 226 | var relative = p.relative(path); |
228 | 227 | if (relative == 'pubspec.yaml') continue; |
229 | | - sourceFiles.addFile(file(p.join('source', relative), path)); |
| 228 | + |
| 229 | + safeCopy( |
| 230 | + relative, p.join('build/chocolatey/tools/source', p.dirname(path))); |
230 | 231 | } |
231 | | - writeBytes( |
232 | | - "build/chocolatey/tools/source.zip", ZipEncoder().encode(sourceFiles)); |
233 | 232 |
|
234 | 233 | var install = StringBuffer(""" |
235 | 234 | \$ToolsDir = (Split-Path -parent \$MyInvocation.MyCommand.Definition) |
236 | | -Get-ChocolateyUnzip -PackageName '$_chocolateyName' ` |
237 | | - -File "\$ToolsDir\\source.zip" -Destination \$PackageFolder |
238 | | -
|
239 | 235 | Write-Host "Fetching Dart dependencies..." |
240 | | -\$SourceDir = "\$PackageFolder\\source" |
| 236 | +\$SourceDir = "\$ToolsDir\\source" |
241 | 237 | Push-Location -Path \$SourceDir |
242 | 238 | pub get --no-precompile | Out-Null |
243 | 239 | Pop-Location |
@@ -276,10 +272,16 @@ Future<void> _nupkg() async { |
276 | 272 |
|
277 | 273 | /// Deploys the Chocolatey package to Chocolatey. |
278 | 274 | Future<void> _deploy() async { |
279 | | - var nupkgPath = "build/$_chocolateyName.$_chocolateyVersion.nupkg"; |
| 275 | + var nupkgPath = p.join("build", "$_chocolateyName.$_chocolateyVersion.nupkg"); |
280 | 276 | log("choco push --source https://chocolatey.org --key=... $nupkgPath"); |
281 | | - var process = await Process.start("choco", |
282 | | - ["push", "--source", "https://chocolatey.org", "--key", nupkgPath]); |
| 277 | + var process = await Process.start("choco", [ |
| 278 | + "push", |
| 279 | + nupkgPath, |
| 280 | + "--source", |
| 281 | + "https://chocolatey.org", |
| 282 | + "--key", |
| 283 | + "$chocolateyToken" |
| 284 | + ]); |
283 | 285 | LineSplitter().bind(utf8.decoder.bind(process.stdout)).listen(log); |
284 | 286 | LineSplitter().bind(utf8.decoder.bind(process.stderr)).listen(log); |
285 | 287 | if (await process.exitCode != 0) fail("choco push failed"); |
|
0 commit comments