From 9fd695c46a9f8c4f016e6d39718b50ef73631713 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:05:44 -0400 Subject: [PATCH 1/7] Adding pubspec support for survey validator --- .../workflows/contextual-json-validator.yml | 2 +- surveys/contextual-survey-metadata.json | 4 + surveys/survey-validator/.gitignore | 3 + .../survey-validator/analysis_options.yaml | 30 ++ .../bin/survey_validator.dart | 10 + .../lib/survey_validator.dart} | 114 +++-- surveys/survey-validator/pubspec.lock | 405 ++++++++++++++++++ surveys/survey-validator/pubspec.yaml | 15 + 8 files changed, 535 insertions(+), 48 deletions(-) create mode 100644 surveys/survey-validator/.gitignore create mode 100644 surveys/survey-validator/analysis_options.yaml create mode 100644 surveys/survey-validator/bin/survey_validator.dart rename surveys/{validator/json-validator.dart => survey-validator/lib/survey_validator.dart} (87%) create mode 100644 surveys/survey-validator/pubspec.lock create mode 100644 surveys/survey-validator/pubspec.yaml diff --git a/.github/workflows/contextual-json-validator.yml b/.github/workflows/contextual-json-validator.yml index 0834d9c..833c587 100644 --- a/.github/workflows/contextual-json-validator.yml +++ b/.github/workflows/contextual-json-validator.yml @@ -24,7 +24,7 @@ jobs: runs-on: ubuntu-latest defaults: run: - working-directory: surveys/validator + working-directory: surveys/survey-validator steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f diff --git a/surveys/contextual-survey-metadata.json b/surveys/contextual-survey-metadata.json index d850fc1..29502e5 100644 --- a/surveys/contextual-survey-metadata.json +++ b/surveys/contextual-survey-metadata.json @@ -6,6 +6,10 @@ "description": "Help improve Flutter's release builds with this 3-question survey!", "snoozeForMinutes": 7200, "samplingRate": 0.1, + "excludeDashTools": [ + "flutter-tool", + "dart-tool" + ], "conditions": [ { "field": "logFileStats.recordCount", diff --git a/surveys/survey-validator/.gitignore b/surveys/survey-validator/.gitignore new file mode 100644 index 0000000..3a85790 --- /dev/null +++ b/surveys/survey-validator/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/surveys/survey-validator/analysis_options.yaml b/surveys/survey-validator/analysis_options.yaml new file mode 100644 index 0000000..dee8927 --- /dev/null +++ b/surveys/survey-validator/analysis_options.yaml @@ -0,0 +1,30 @@ +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +# linter: +# rules: +# - camel_case_types + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/surveys/survey-validator/bin/survey_validator.dart b/surveys/survey-validator/bin/survey_validator.dart new file mode 100644 index 0000000..a7ee421 --- /dev/null +++ b/surveys/survey-validator/bin/survey_validator.dart @@ -0,0 +1,10 @@ +import 'dart:io'; + +import 'package:survey_validator/survey_validator.dart' as survey_validator; + +void main(List arguments) { + final contextualSurveyFile = + File('${Directory.current.path}/surveys/contextual-survey-metadata.json'); + + survey_validator.checkJson(contextualSurveyFile); +} diff --git a/surveys/validator/json-validator.dart b/surveys/survey-validator/lib/survey_validator.dart similarity index 87% rename from surveys/validator/json-validator.dart rename to surveys/survey-validator/lib/survey_validator.dart index 02ffbda..b531f00 100644 --- a/surveys/validator/json-validator.dart +++ b/surveys/survey-validator/lib/survey_validator.dart @@ -1,8 +1,58 @@ import 'dart:convert'; import 'dart:io'; -void main() { - final contextualSurveyFile = File('surveys/contextual-survey-metadata.json'); +import 'package:unified_analytics/unified_analytics.dart'; + +/// The allowed action strings for a given button +const allowedButtonActions = { + 'accept', + 'dismiss', + 'snooze', +}; + +/// The allowed operators for a given condition item +const allowedConditionOperators = { + '>=', + '<=', + '>', + '<', + '==', + '!=', +}; + +/// Required keys for the button object +const buttonRequiredKeys = [ + 'buttonText', + 'action', + 'url', + 'promptRemainsVisible', +]; + +/// Required keys for the condition object +const conditionRequiredKeys = [ + 'field', + 'operator', + 'value', +]; + +/// The top level keys that must exist for each json object +/// in the array +const requiredKeys = { + 'uniqueId', + 'startDate', + 'endDate', + 'description', + 'snoozeForMinutes', + 'samplingRate', + 'conditions', + 'buttons', + 'excludeDashTools', +}; + +/// The valid dash tools stored in the [DashTool] enum +List get validDashTools => DashTool.values.map((e) => e.label).toList(); + +void checkJson(File contextualSurveyFile) { final jsonContents = jsonDecode(contextualSurveyFile.readAsStringSync()); if (jsonContents is! List) { @@ -35,6 +85,7 @@ void main() { final description = surveyObject['description'] as String; final snoozeForMinutes = surveyObject['snoozeForMinutes'] as int; final samplingRate = surveyObject['samplingRate'] as double; + final excludeDashToolsList = surveyObject['excludeDashTools'] as List; final conditionList = surveyObject['conditions'] as List; final buttonList = surveyObject['buttons'] as List; @@ -62,6 +113,20 @@ void main() { throw ArgumentError('Sampling rate must be between 0 and 1 inclusive'); } + // Validation on the array containing dash tools to exclude + for (final excludeDashTool in excludeDashToolsList) { + if (excludeDashTool is! String) { + throw ArgumentError( + 'Each dash tool in the exclude list must be a string'); + } + + if (!validDashTools.contains(excludeDashTool)) { + throw ArgumentError( + 'The excluded dash tool: "$excludeDashTool" is not valid\n' + 'Valid dash tools are: ${validDashTools.join(', ')}'); + } + } + // Validation on the condition array for (final conditionObject in conditionList) { if (conditionObject is! Map) { @@ -136,48 +201,3 @@ void main() { } } } - -/// The allowed action strings for a given button -const allowedButtonActions = { - 'accept', - 'dismiss', - 'snooze', -}; - -/// The allowed operators for a given condition item -const allowedConditionOperators = { - '>=', - '<=', - '>', - '<', - '==', - '!=', -}; - -/// Required keys for the button object -const buttonRequiredKeys = [ - 'buttonText', - 'action', - 'url', - 'promptRemainsVisible', -]; - -/// Required keys for the condition object -const conditionRequiredKeys = [ - 'field', - 'operator', - 'value', -]; - -/// The top level keys that must exist for each json object -/// in the array -const requiredKeys = { - 'uniqueId', - 'startDate', - 'endDate', - 'description', - 'snoozeForMinutes', - 'samplingRate', - 'conditions', - 'buttons', -}; diff --git a/surveys/survey-validator/pubspec.lock b/surveys/survey-validator/pubspec.lock new file mode 100644 index 0000000..8b11a1e --- /dev/null +++ b/surveys/survey-validator/pubspec.lock @@ -0,0 +1,405 @@ +# Generated by pub +# See https://dart.dev/tools/pub/glossary#lockfile +packages: + _fe_analyzer_shared: + dependency: transitive + description: + name: _fe_analyzer_shared + sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 + url: "https://pub.dev" + source: hosted + version: "64.0.0" + analyzer: + dependency: transitive + description: + name: analyzer + sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" + url: "https://pub.dev" + source: hosted + version: "6.2.0" + args: + dependency: transitive + description: + name: args + sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596 + url: "https://pub.dev" + source: hosted + version: "2.4.2" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" + boolean_selector: + dependency: transitive + description: + name: boolean_selector + sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + clock: + dependency: transitive + description: + name: clock + sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf + url: "https://pub.dev" + source: hosted + version: "1.1.1" + collection: + dependency: transitive + description: + name: collection + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" + source: hosted + version: "1.18.0" + convert: + dependency: transitive + description: + name: convert + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" + source: hosted + version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097" + url: "https://pub.dev" + source: hosted + version: "1.6.3" + crypto: + dependency: transitive + description: + name: crypto + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" + source: hosted + version: "3.0.3" + file: + dependency: transitive + description: + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" + source: hosted + version: "7.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + sha256: "408e3ca148b31c20282ad6f37ebfa6f4bdc8fede5b74bc2f08d9d92b55db3612" + url: "https://pub.dev" + source: hosted + version: "3.2.0" + glob: + dependency: transitive + description: + name: glob + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" + source: hosted + version: "2.1.2" + http: + dependency: transitive + description: + name: http + sha256: "759d1a329847dd0f39226c688d3e06a6b8679668e350e2891a6474f8b4bb8525" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + http_multi_server: + dependency: transitive + description: + name: http_multi_server + sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" + intl: + dependency: transitive + description: + name: intl + sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d" + url: "https://pub.dev" + source: hosted + version: "0.18.1" + io: + dependency: transitive + description: + name: io + sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + js: + dependency: transitive + description: + name: js + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + lints: + dependency: "direct dev" + description: + name: lints + sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + logging: + dependency: transitive + description: + name: logging + sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + matcher: + dependency: transitive + description: + name: matcher + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + url: "https://pub.dev" + source: hosted + version: "0.12.16" + meta: + dependency: transitive + description: + name: meta + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + url: "https://pub.dev" + source: hosted + version: "1.10.0" + mime: + dependency: transitive + description: + name: mime + sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e + url: "https://pub.dev" + source: hosted + version: "1.0.4" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" + package_config: + dependency: transitive + description: + name: package_config + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" + source: hosted + version: "2.1.0" + path: + dependency: transitive + description: + name: path + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + url: "https://pub.dev" + source: hosted + version: "1.8.3" + pool: + dependency: transitive + description: + name: pool + sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a" + url: "https://pub.dev" + source: hosted + version: "1.5.1" + pub_semver: + dependency: transitive + description: + name: pub_semver + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" + source: hosted + version: "2.1.4" + shelf: + dependency: transitive + description: + name: shelf + sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4 + url: "https://pub.dev" + source: hosted + version: "1.4.1" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" + source: hosted + version: "1.1.2" + shelf_web_socket: + dependency: transitive + description: + name: shelf_web_socket + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" + url: "https://pub.dev" + source: hosted + version: "1.0.4" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + stack_trace: + dependency: transitive + description: + name: stack_trace + sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b" + url: "https://pub.dev" + source: hosted + version: "1.11.1" + stream_channel: + dependency: transitive + description: + name: stream_channel + sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7 + url: "https://pub.dev" + source: hosted + version: "2.1.2" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" + test: + dependency: "direct dev" + description: + name: test + sha256: "9b0dd8e36af4a5b1569029949d50a52cb2a2a2fdaa20cebb96e6603b9ae241f9" + url: "https://pub.dev" + source: hosted + version: "1.24.6" + test_api: + dependency: transitive + description: + name: test_api + sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b" + url: "https://pub.dev" + source: hosted + version: "0.6.1" + test_core: + dependency: transitive + description: + name: test_core + sha256: "4bef837e56375537055fdbbbf6dd458b1859881f4c7e6da936158f77d61ab265" + url: "https://pub.dev" + source: hosted + version: "0.5.6" + typed_data: + dependency: transitive + description: + name: typed_data + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" + source: hosted + version: "1.3.2" + unified_analytics: + dependency: "direct main" + description: + name: unified_analytics + sha256: "4d22115b83778592e606508072454209fbf8aa31e061ace8dd36f6bf3ba9e4b8" + url: "https://pub.dev" + source: hosted + version: "3.0.0" + vm_service: + dependency: transitive + description: + name: vm_service + sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583 + url: "https://pub.dev" + source: hosted + version: "11.10.0" + watcher: + dependency: transitive + description: + name: watcher + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + web_socket_channel: + dependency: transitive + description: + name: web_socket_channel + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b + url: "https://pub.dev" + source: hosted + version: "2.4.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" +sdks: + dart: ">=3.2.0-97.0.dev <4.0.0" diff --git a/surveys/survey-validator/pubspec.yaml b/surveys/survey-validator/pubspec.yaml new file mode 100644 index 0000000..455f4c6 --- /dev/null +++ b/surveys/survey-validator/pubspec.yaml @@ -0,0 +1,15 @@ +name: survey_validator +description: A sample command-line application. +version: 1.0.0 +# repository: https://github.com/my_org/my_repo + +environment: + sdk: ^3.2.0-97.0.dev + +# Add regular dependencies here. +dependencies: + unified_analytics: ^3.0.0 + +dev_dependencies: + lints: ^2.1.0 + test: ^1.24.0 From f681cd8e367c14c7101d909cc51e2d3c29065128 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:10:33 -0400 Subject: [PATCH 2/7] Run pub get for analyze job --- .github/workflows/contextual-json-validator.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/contextual-json-validator.yml b/.github/workflows/contextual-json-validator.yml index 833c587..263e795 100644 --- a/.github/workflows/contextual-json-validator.yml +++ b/.github/workflows/contextual-json-validator.yml @@ -29,6 +29,8 @@ jobs: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f + - run: dart pub get + - name: Verify formatting run: dart format --output=none --set-exit-if-changed . From 0d9f8b0c84b62fd44aa17086e9471b7ed234de0b Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:13:46 -0400 Subject: [PATCH 3/7] Update to dart sdk version --- surveys/survey-validator/pubspec.lock | 2 +- surveys/survey-validator/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/surveys/survey-validator/pubspec.lock b/surveys/survey-validator/pubspec.lock index 8b11a1e..8b7983a 100644 --- a/surveys/survey-validator/pubspec.lock +++ b/surveys/survey-validator/pubspec.lock @@ -402,4 +402,4 @@ packages: source: hosted version: "3.1.2" sdks: - dart: ">=3.2.0-97.0.dev <4.0.0" + dart: ">=3.0.0 <4.0.0" diff --git a/surveys/survey-validator/pubspec.yaml b/surveys/survey-validator/pubspec.yaml index 455f4c6..b0b514f 100644 --- a/surveys/survey-validator/pubspec.yaml +++ b/surveys/survey-validator/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0 # repository: https://github.com/my_org/my_repo environment: - sdk: ^3.2.0-97.0.dev + sdk: '>=3.0.0 <4.0.0' # Add regular dependencies here. dependencies: From 5b04e3e604d62971506fcefa54fe03fe0cfa346c Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 13 Sep 2023 13:32:48 -0400 Subject: [PATCH 4/7] Fix to path to json file --- .github/workflows/contextual-json-validator.yml | 6 +++++- surveys/survey-validator/bin/survey_validator.dart | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/contextual-json-validator.yml b/.github/workflows/contextual-json-validator.yml index 263e795..90c67b5 100644 --- a/.github/workflows/contextual-json-validator.yml +++ b/.github/workflows/contextual-json-validator.yml @@ -14,11 +14,15 @@ permissions: jobs: contextual-json-validate: runs-on: ubuntu-latest + defaults: + run: + working-directory: surveys/survey-validator steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 - uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f - - run: dart surveys/validator/json-validator.dart + - run: dart pub get + - run: dart run analyze: runs-on: ubuntu-latest diff --git a/surveys/survey-validator/bin/survey_validator.dart b/surveys/survey-validator/bin/survey_validator.dart index a7ee421..a872035 100644 --- a/surveys/survey-validator/bin/survey_validator.dart +++ b/surveys/survey-validator/bin/survey_validator.dart @@ -3,8 +3,7 @@ import 'dart:io'; import 'package:survey_validator/survey_validator.dart' as survey_validator; void main(List arguments) { - final contextualSurveyFile = - File('${Directory.current.path}/surveys/contextual-survey-metadata.json'); + final contextualSurveyFile = File('../contextual-survey-metadata.json'); survey_validator.checkJson(contextualSurveyFile); } From 67cab9248988c1ddbb68bb8ad163f8a8b56ff4fd Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:17:10 -0400 Subject: [PATCH 5/7] Fix nits in pubspec --- surveys/survey-validator/pubspec.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/surveys/survey-validator/pubspec.yaml b/surveys/survey-validator/pubspec.yaml index b0b514f..6272ec4 100644 --- a/surveys/survey-validator/pubspec.yaml +++ b/surveys/survey-validator/pubspec.yaml @@ -1,7 +1,9 @@ name: survey_validator -description: A sample command-line application. +description: | + Small application for validating the survey + metadata file which is used by package:unified_analytics version: 1.0.0 -# repository: https://github.com/my_org/my_repo +publish_to: none environment: sdk: '>=3.0.0 <4.0.0' From 4d24a40061e1e44ecf3740d8d7e44720aada00ac Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 13 Sep 2023 14:18:15 -0400 Subject: [PATCH 6/7] Use set instead of list for valid tools --- surveys/survey-validator/lib/survey_validator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surveys/survey-validator/lib/survey_validator.dart b/surveys/survey-validator/lib/survey_validator.dart index b531f00..e5b741c 100644 --- a/surveys/survey-validator/lib/survey_validator.dart +++ b/surveys/survey-validator/lib/survey_validator.dart @@ -50,7 +50,7 @@ const requiredKeys = { }; /// The valid dash tools stored in the [DashTool] enum -List get validDashTools => DashTool.values.map((e) => e.label).toList(); +Set get validDashTools => DashTool.values.map((e) => e.label).toSet(); void checkJson(File contextualSurveyFile) { final jsonContents = jsonDecode(contextualSurveyFile.readAsStringSync()); From 5a1456a98c8d793b5ed3d120eb58f7d543011e8d Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Thu, 14 Sep 2023 10:43:36 -0400 Subject: [PATCH 7/7] Print out the required keys per survey object --- surveys/survey-validator/lib/survey_validator.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/surveys/survey-validator/lib/survey_validator.dart b/surveys/survey-validator/lib/survey_validator.dart index e5b741c..25f08a7 100644 --- a/surveys/survey-validator/lib/survey_validator.dart +++ b/surveys/survey-validator/lib/survey_validator.dart @@ -68,7 +68,8 @@ void checkJson(File contextualSurveyFile) { // Ensure that the number of keys found in each object is correct if (surveyObject.keys.length != requiredKeys.length) { throw ArgumentError( - 'There should only be ${requiredKeys.length} keys per survey object'); + 'There should only be ${requiredKeys.length} keys per survey object\n' + 'The required keys are: ${requiredKeys.join(', ')}'); } // Ensure that the keys themselves match what has been defined