From a797fef9d3ed6297eb189786dd3d1127c92b8f19 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Tue, 4 May 2021 10:27:03 -0400 Subject: [PATCH 1/6] Added verification file --- lib/src/chocolatey.dart | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/src/chocolatey.dart b/lib/src/chocolatey.dart index a328502..4745a50 100644 --- a/lib/src/chocolatey.dart +++ b/lib/src/chocolatey.dart @@ -15,6 +15,7 @@ import 'dart:convert'; import 'dart:io'; +import 'package:cli_pkg/cli_pkg.dart'; import 'package:grinder/grinder.dart'; import 'package:meta/meta.dart'; import 'package:path/path.dart' as p; @@ -214,6 +215,8 @@ Future _build() async { writeString("build/chocolatey/tools/LICENSE", await license); + writeString("build/chocolatey/tools/VERIFICATION.txt", _verificationFile); + writeString( 'build/chocolatey/tools/source/pubspec.yaml', json.encode(Map.of(rawPubspec) @@ -318,3 +321,41 @@ String _pathToElement(XmlNode? parent, String name) { return nesting.reversed.join(" > "); } + +// Generates verification file +String get _verificationFile { + final os = Platform.operatingSystem; + final osVersion = Platform.operatingSystemVersion; + final dartInfo = Platform.version; + final tag = version.toString(); + final repo = 'https://github.com/${githubRepo.value}'; + final releaseUrl = '$repo/releases/tag/$tag'; + + final dartVersion = dartInfo.split(' ')[0]; + final contents = '''VERIFICATION +Verification is intended to assist the Chocolatey moderators and community +in verifying that this package's contents are trustworthy. + +The executables in this package are built from source: + +Repository: $repo +Tag: $tag +Release URL: $releaseUrl + +On the following environment: + +* $os - $osVersion +* Dart - $dartInfo + +The following steps are used to build. +1. Install Dart (choco install dart-sdk --version $dartVersion) +2. git clone -b $tag $repo.git +3. Get project dependencies (dart pub get) in project root +4. Install Grinder (dart pub global activate grinder) +5. grind pkg-chocolatey-pack +6. Go to build/chocolatey + +'''; + + return contents; +} From 92ffbc930ce84442979cef381cda4b8ad1decac5 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Fri, 7 May 2021 06:44:34 -0400 Subject: [PATCH 2/6] Added verification test --- test/chocolatey_test.dart | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/test/chocolatey_test.dart b/test/chocolatey_test.dart index 7c2061d..dbe277a 100644 --- a/test/chocolatey_test.dart +++ b/test/chocolatey_test.dart @@ -14,14 +14,14 @@ import 'dart:async'; import 'dart:convert'; +import 'dart:io'; +import 'package:cli_pkg/src/chocolatey.dart'; +import 'package:cli_pkg/src/utils.dart'; import 'package:test/test.dart'; import 'package:test_process/test_process.dart'; import 'package:xml/xml.dart' hide parse; -import 'package:cli_pkg/src/chocolatey.dart'; -import 'package:cli_pkg/src/utils.dart'; - import 'descriptor.dart' as d; import 'utils.dart'; @@ -211,7 +211,7 @@ void main() { _enableChocolatey(), [_nuspec(), d.file("LICENSE", "Please use my code")]) .create(); - await (await grind(["pkg-chocolatey"])).shouldExit(0); + await (await grind(["pkg-chocolatey-pack"])).shouldExit(0); await d .file( @@ -225,6 +225,21 @@ void main() { .validate(); }); + test('the Verification file', () async { + await d.package(pubspec, _enableChocolatey(), [_nuspec()]).create(); + await (await grind(["pkg-chocolatey"])).shouldExit(0); + + await d + .file( + "my_app/build/chocolatey/tools/VERIFICATION.txt", + allOf([ + contains(Platform.version), + contains(Platform.operatingSystem), + contains(Platform.operatingSystemVersion), + ])) + .validate(); + }); + test("is still generated if the package doesn't have a license", () async { await d.package(pubspec, _enableChocolatey(), [_nuspec()]).create(); From 9ffd59a92f8e646624fe7dd2e12b79a5a32cc498 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Wed, 19 May 2021 06:14:29 -0400 Subject: [PATCH 3/6] Add githubRepo to chocolatey test --- test/chocolatey_test.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/test/chocolatey_test.dart b/test/chocolatey_test.dart index dbe277a..b264e63 100644 --- a/test/chocolatey_test.dart +++ b/test/chocolatey_test.dart @@ -323,6 +323,7 @@ String _enableChocolatey({bool token = true}) { if (token) buffer.writeln('pkg.chocolateyToken.value = "tkn";'); buffer.writeln("pkg.addChocolateyTasks();"); + buffer.writeln('pkg.githubRepo.value = "google/right";'); buffer.writeln("grind(args);"); buffer.writeln("}"); From 558704563b9e54605a650158fa33a81a9023e518 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Tue, 1 Jun 2021 11:36:48 -0400 Subject: [PATCH 4/6] Added chocolatey release url --- lib/src/chocolatey.dart | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/src/chocolatey.dart b/lib/src/chocolatey.dart index 4745a50..ddb39ad 100644 --- a/lib/src/chocolatey.dart +++ b/lib/src/chocolatey.dart @@ -88,6 +88,21 @@ String get chocolateyDartVersion { return result.toString(); } +/// The Chocolatey Repo Url +/// +/// This is used for the Chocolatey verification file. +/// It defaults to [githubRepo]. +final chocolateyRepoUrl = InternalConfigVariable.fn( + () => 'https://github.com/${githubRepo.value}', +); + +/// The Chocolatey Release URL +/// +/// This is the Release URL used for the verification file. +/// It defaults to https://github.com/[githubRepo]/releases/tag/[tag]. +final chocolateyReleaseUrl = InternalConfigVariable.fn(() => + 'https://github.com/${githubRepo.value}/releases/tag/${version.toString()}'); + /// The set of files to include directly in the Chocolatey package. /// /// This should be at least enough files to compile the package's executables. @@ -328,7 +343,7 @@ String get _verificationFile { final osVersion = Platform.operatingSystemVersion; final dartInfo = Platform.version; final tag = version.toString(); - final repo = 'https://github.com/${githubRepo.value}'; + final repo = chocolateyRepoUrl.value; final releaseUrl = '$repo/releases/tag/$tag'; final dartVersion = dartInfo.split(' ')[0]; From 6a0c151aade581b51f8b25b81351c3ccf54b2ea3 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Tue, 1 Jun 2021 12:08:52 -0400 Subject: [PATCH 5/6] Release url and tweaked tests --- lib/src/chocolatey.dart | 2 +- test/chocolatey_test.dart | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/src/chocolatey.dart b/lib/src/chocolatey.dart index 968216c..c5320dd 100644 --- a/lib/src/chocolatey.dart +++ b/lib/src/chocolatey.dart @@ -349,7 +349,7 @@ String get _verificationFile { final dartInfo = Platform.version; final tag = version.toString(); final repo = chocolateyRepoUrl.value; - final releaseUrl = '$repo/releases/tag/$tag'; + final releaseUrl = chocolateyReleaseUrl.value; final dartVersion = dartInfo.split(' ')[0]; final contents = '''VERIFICATION diff --git a/test/chocolatey_test.dart b/test/chocolatey_test.dart index 1a8ca9c..0ac3b4b 100644 --- a/test/chocolatey_test.dart +++ b/test/chocolatey_test.dart @@ -16,6 +16,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:cli_pkg/cli_pkg.dart'; import 'package:cli_pkg/src/chocolatey.dart'; import 'package:cli_pkg/src/utils.dart'; import 'package:test/test.dart'; @@ -228,7 +229,7 @@ void main() { test('the Verification file', () async { await d.package(pubspec, _enableChocolatey(), [_nuspec()]).create(); await (await grind(["pkg-chocolatey"])).shouldExit(0); - + final version = dartVersion.isPreRelease ? "1.2.3-beta" : "1.2.3"; await d .file( "my_app/build/chocolatey/tools/VERIFICATION.txt", @@ -236,6 +237,11 @@ void main() { contains(Platform.version), contains(Platform.operatingSystem), contains(Platform.operatingSystemVersion), + contains(version), + contains('https://github.com/google/right'), + contains( + 'https://github.com/google/right/releases/tag/$version', + ), ])) .validate(); }); From 4c9a7f3a343de848d904216368a4688794137422 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Thu, 23 Dec 2021 16:05:28 -0500 Subject: [PATCH 6/6] Update chocolatey_test.dart --- test/chocolatey_test.dart | 43 ++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/test/chocolatey_test.dart b/test/chocolatey_test.dart index 97e1095..37a8f3f 100644 --- a/test/chocolatey_test.dart +++ b/test/chocolatey_test.dart @@ -16,7 +16,6 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; -import 'package:cli_pkg/cli_pkg.dart'; import 'package:cli_pkg/src/chocolatey.dart'; import 'package:cli_pkg/src/utils.dart'; import 'package:test/test.dart'; @@ -183,6 +182,26 @@ void main() { .validate(); }); + test('the Verification file', () async { + await d.package(pubspec, _enableChocolatey(), [_nuspec()]).create(); + await (await grind(["pkg-chocolatey"])).shouldExit(0); + final version = dartVersion.isPreRelease ? "1.2.3-beta" : "1.2.3"; + await d + .file( + "my_app/build/chocolatey/tools/VERIFICATION.txt", + allOf([ + contains(Platform.version), + contains(Platform.operatingSystem), + contains(Platform.operatingSystemVersion), + contains(version), + contains('https://github.com/google/right'), + contains( + 'https://github.com/google/right/releases/tag/$version', + ), + ])) + .validate(); + }); + test("Dart", () async { await d.package(pubspec, _enableChocolatey(), [_nuspec()]).create(); await (await grind(["pkg-chocolatey"])).shouldExit(0); @@ -235,7 +254,6 @@ void main() { "dependencies": { "indirect_dep": {"path": "../indirect_dep"} } - })) ]).create(); @@ -268,27 +286,6 @@ void main() { contains("Indirect dependency license")) .validate(); }); - - }); - - test('the Verification file', () async { - await d.package(pubspec, _enableChocolatey(), [_nuspec()]).create(); - await (await grind(["pkg-chocolatey"])).shouldExit(0); - final version = dartVersion.isPreRelease ? "1.2.3-beta" : "1.2.3"; - await d - .file( - "my_app/build/chocolatey/tools/VERIFICATION.txt", - allOf([ - contains(Platform.version), - contains(Platform.operatingSystem), - contains(Platform.operatingSystemVersion), - contains(version), - contains('https://github.com/google/right'), - contains( - 'https://github.com/google/right/releases/tag/$version', - ), - ])) - .validate(); }); test("is still generated if the package doesn't have a license",