Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 32-improve-app-metadata
  • master
  • Release_0.0.10_10
  • Release_0.0.11_11
  • Release_0.0.12_12
  • Release_0.0.13_13
  • Release_0.0.14_14
  • Release_0.0.15_15
  • Release_0.0.16_16
  • Release_0.0.17_17
  • Release_0.0.18_18
  • Release_0.0.19_19
  • Release_0.0.20_20
  • Release_0.0.21_21
  • Release_0.0.22_22
  • Release_0.0.23_23
  • Release_0.0.24_24
  • Release_0.0.25_25
  • Release_0.0.26_26
  • Release_0.0.2_2
  • Release_0.0.3_3
  • Release_0.0.4_4
  • Release_0.0.5_5
  • Release_0.0.6_6
  • Release_0.0.7_7
  • Release_0.0.8_8
  • Release_0.0.9_9
  • Release_0.1.0_27
  • Release_0.1.1_28
  • Release_0.1.2_29
  • Release_0.2.0_30
  • Release_0.2.1_31
  • Release_0.3.0_32
  • Release_0.3.1_33
  • Release_0.4.0_34
  • Release_0.4.1_35
  • Release_0.4.2_36
  • Release_0.5.0_37
  • Release_0.6.0_38
  • Release_0.7.0_39
  • Release_0.8.0_40
  • Release_0.8.1_41
  • Release_0.8.2_42
  • Release_0.9.0_43
  • Release_0.9.1_44
45 results

Target

Select target project
  • android/org.benoitharrault.sortgame
1 result
Select Git revision
  • 32-improve-app-metadata
  • master
  • Release_0.0.10_10
  • Release_0.0.11_11
  • Release_0.0.12_12
  • Release_0.0.13_13
  • Release_0.0.14_14
  • Release_0.0.15_15
  • Release_0.0.16_16
  • Release_0.0.17_17
  • Release_0.0.18_18
  • Release_0.0.19_19
  • Release_0.0.20_20
  • Release_0.0.21_21
  • Release_0.0.22_22
  • Release_0.0.23_23
  • Release_0.0.24_24
  • Release_0.0.25_25
  • Release_0.0.26_26
  • Release_0.0.2_2
  • Release_0.0.3_3
  • Release_0.0.4_4
  • Release_0.0.5_5
  • Release_0.0.6_6
  • Release_0.0.7_7
  • Release_0.0.8_8
  • Release_0.0.9_9
  • Release_0.1.0_27
  • Release_0.1.1_28
  • Release_0.1.2_29
  • Release_0.2.0_30
  • Release_0.2.1_31
  • Release_0.3.0_32
  • Release_0.3.1_33
  • Release_0.4.0_34
  • Release_0.4.1_35
  • Release_0.4.2_36
  • Release_0.5.0_37
  • Release_0.6.0_38
  • Release_0.7.0_39
  • Release_0.8.0_40
  • Release_0.8.1_41
  • Release_0.8.2_42
  • Release_0.9.0_43
  • Release_0.9.1_44
45 results
Show changes
import 'package:flutter/foundation.dart';
void printlog(String message) {
if (!kReleaseMode) {
debugPrint(message);
}
}
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
args:
dependency: transitive
description:
name: args
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
url: "https://pub.dev"
source: hosted
version: "2.5.0"
bloc:
dependency: transitive
description:
name: bloc
sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e"
url: "https://pub.dev"
source: hosted
version: "8.1.4"
characters:
dependency: transitive
description:
......@@ -9,35 +25,149 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.0"
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: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
url: "https://pub.dev"
source: hosted
version: "1.18.0"
crypto:
dependency: transitive
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
url: "https://pub.dev"
source: hosted
version: "3.0.3"
easy_localization:
dependency: "direct main"
description:
name: easy_localization
sha256: c145aeb6584aedc7c862ab8c737c3277788f47488bfdf9bae0fe112bd0a4789c
url: "https://pub.dev"
source: hosted
version: "1.17.2"
version: "3.0.5"
easy_logger:
dependency: transitive
description:
name: easy_logger
sha256: c764a6e024846f33405a2342caf91c62e357c24b02c04dbc712ef232bf30ffb7
url: "https://pub.dev"
source: hosted
version: "0.0.2"
equatable:
dependency: "direct main"
description:
name: equatable
sha256: c2b87cb7756efdf69892005af546c56c0b5037f54d2a88269b4f347a505e3ca2
url: "https://pub.dev"
source: hosted
version: "2.0.5"
ffi:
dependency: transitive
description:
name: ffi
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
file:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "7.0.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_bloc:
dependency: "direct main"
description:
name: flutter_bloc
sha256: f0ecf6e6eb955193ca60af2d5ca39565a86b8a142452c5b24d96fb477428f4d2
url: "https://pub.dev"
source: hosted
version: "8.1.5"
flutter_lints:
dependency: "direct dev"
description:
name: flutter_lints
sha256: "9e8c3858111da373efc5aa341de011d9bd23e2c5c5e0c62bccf32438e192d7b1"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
flutter_localizations:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
hive:
dependency: "direct main"
description:
name: hive
sha256: "8dcf6db979d7933da8217edcec84e9df1bdb4e4edc7fc77dbd5aa74356d6d941"
url: "https://pub.dev"
source: hosted
version: "2.2.3"
hydrated_bloc:
dependency: "direct main"
description:
name: hydrated_bloc
sha256: af35b357739fe41728df10bec03aad422cdc725a1e702e03af9d2a41ea05160c
url: "https://pub.dev"
source: hosted
version: "9.1.5"
intl:
dependency: transitive
description:
name: intl
sha256: "3bc132a9dbce73a7e4a21a17d06e1878839ffbf975568bc875c60537824b0c4d"
url: "https://pub.dev"
source: hosted
version: "0.18.1"
lints:
dependency: transitive
description:
name: lints
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
url: "https://pub.dev"
source: hosted
version: "3.0.0"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: transitive
description:
name: meta
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.9.1"
version: "1.11.0"
nested:
dependency: transitive
description:
......@@ -46,19 +176,171 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.0"
provider:
path:
dependency: transitive
description:
name: path
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
path_provider:
dependency: "direct main"
description:
name: path_provider
sha256: c9e7d3a4cd1410877472158bee69963a4579f78b68c65a2b7d40d1a7a88bb161
url: "https://pub.dev"
source: hosted
version: "2.1.3"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
sha256: a248d8146ee5983446bf03ed5ea8f6533129a12b11f12057ad1b4a67a2b3b41d
url: "https://pub.dev"
source: hosted
version: "2.2.4"
path_provider_foundation:
dependency: transitive
description:
name: path_provider_foundation
sha256: "5a7999be66e000916500be4f15a3633ebceb8302719b47b9cc49ce924125350f"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
sha256: f7a1fe3a634fe7734c8d3f2766ad746ae2a2884abe22e241a8b301bf5cac3279
url: "https://pub.dev"
source: hosted
version: "2.2.1"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
sha256: "88f5779f72ba699763fa3a3b06aa4bf6de76c8e5de842cf6f29e2e06476c2334"
url: "https://pub.dev"
source: hosted
version: "2.1.2"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
sha256: "8bc9f22eee8690981c22aa7fc602f5c85b497a6fb2ceb35ee5a5e5ed85ad8170"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
platform:
dependency: transitive
description:
name: platform
sha256: "12220bb4b65720483f8fa9450b4332347737cf8213dd2840d8b2c823e47243ec"
url: "https://pub.dev"
source: hosted
version: "3.1.4"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
url: "https://pub.dev"
source: hosted
version: "2.1.8"
provider:
dependency: transitive
description:
name: provider
sha256: cdbe7530b12ecd9eb455bdaa2fcb8d4dad22e80b8afb4798b41479d5ce26847f
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
url: "https://pub.dev"
source: hosted
version: "6.1.2"
shared_preferences:
dependency: transitive
description:
name: shared_preferences
sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180
url: "https://pub.dev"
source: hosted
version: "2.2.3"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "7708d83064f38060c7b39db12aefe449cb8cdc031d6062280087bc4cdb988f5c"
url: "https://pub.dev"
source: hosted
version: "2.3.5"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "9f2cbcf46d4270ea8be39fa156d86379077c8a5228d9dfdb1164ae0bb93f1faa"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: "22e2ecac9419b4246d7c22bfbbda589e3acf5c0351137d87dd2939d984d37c3b"
url: "https://pub.dev"
source: hosted
version: "6.0.5"
version: "2.3.2"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: "9aee1089b36bd2aafe06582b7d7817fd317ef05fc30e6ba14bff247d0933042a"
url: "https://pub.dev"
source: hosted
version: "2.3.0"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "841ad54f3c8381c480d0c9b508b89a34036f512482c407e6df7a9c4aa2ef8f59"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
synchronized:
dependency: transitive
description:
name: synchronized
sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558"
url: "https://pub.dev"
source: hosted
version: "3.1.0+1"
typed_data:
dependency: transitive
description:
name: typed_data
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
url: "https://pub.dev"
source: hosted
version: "1.3.2"
unicons:
dependency: "direct main"
description:
name: unicons
sha256: dbfcf93ff4d4ea19b324113857e358e4882115ab85db04417a4ba1c72b17a670
url: "https://pub.dev"
source: hosted
version: "2.1.1"
vector_math:
dependency: transitive
description:
......@@ -71,10 +353,26 @@ packages:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
url: "https://pub.dev"
source: hosted
version: "0.5.1"
win32:
dependency: transitive
description:
name: win32
sha256: "0a989dc7ca2bb51eac91e8fd00851297cfffd641aa7538b165c62637ca0eaa4a"
url: "https://pub.dev"
source: hosted
version: "5.4.0"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
version: "1.0.4"
sdks:
dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=1.16.0"
dart: ">=3.3.0 <4.0.0"
flutter: ">=3.19.0"
name: sortgame
description: A sorting game application.
publish_to: 'none'
version: 1.0.0+1
version: 0.0.25+25
environment:
sdk: '^3.0.0'
......@@ -9,9 +11,31 @@ environment:
dependencies:
flutter:
sdk: flutter
provider: ^6.0.5
easy_localization: ^3.0.1
equatable: ^2.0.5
flutter_bloc: ^8.1.1
hive: ^2.2.3
hydrated_bloc: ^9.0.0
path_provider: ^2.0.11
unicons: ^2.1.1
dev_dependencies:
flutter_lints: ^3.0.1
flutter:
uses-material-design: true
uses-material-design: false
assets:
- assets/files/
- assets/icons/
- assets/translations/
fonts:
- family: Nunito
fonts:
- asset: assets/fonts/Nunito-Bold.ttf
weight: 700
- asset: assets/fonts/Nunito-Medium.ttf
weight: 500
- asset: assets/fonts/Nunito-Regular.ttf
weight: 400
- asset: assets/fonts/Nunito-Light.ttf
weight: 300
This diff is collapsed.
<?php
function dump(string $string)
{
echo $string . PHP_EOL;
}
function write_data(array $data, string $filename)
{
\file_put_contents($filename, \json_encode($data));
}
function array_clean(array $array)
{
$output = \array_unique($array);
\sort($output);
return $output;
}
function ask(string $prompt)
{
dump($prompt);
$input = \rtrim(\fgets(STDIN));
return $input;
}
function find_missing_associations(array $mappingItems, array $categories, array $items)
{
$missing = [];
foreach ($items as $item) {
$set = \array_merge(
$mappingItems[$item]['is'],
$mappingItems[$item]['isnot'],
$mappingItems[$item]['na'],
);
foreach ($categories as $category) {
if (!\in_array($category, $set)) {
$missing[] = [
'item' => $item,
'category' => $category,
];
}
}
}
return $missing;
}
function find_exclusions(array $exclusions, string $searchedCategory)
{
$output = [];
foreach ($exclusions as $exclusionSet) {
if (\is_array($exclusionSet) && \in_array($searchedCategory, $exclusionSet)) {
foreach ($exclusionSet as $candidate) {
if ($candidate !== $searchedCategory) {
$output[] = $candidate;
}
}
}
}
return $output;
}
function clean_item_mappings(array $itemMappings)
{
$itemMappings['is'] = array_clean($itemMappings['is']);
$itemMappings['isnot'] = array_clean($itemMappings['isnot']);
$itemMappings['na'] = array_clean($itemMappings['na']);
// remove duplicates
$itemMappings['is'] = array_clean($itemMappings['is']);
$tmpArray = [];
foreach (array_clean($itemMappings['isnot']) as $itemIsNot) {
if (!\in_array($itemIsNot, $itemMappings['is'])) {
$tmpArray[] = $itemIsNot;
}
}
$itemMappings['isnot'] = $tmpArray;
$tmpArray = [];
foreach (array_clean($itemMappings['na']) as $itemNa) {
if (!\in_array($itemNa, $itemMappings['is']) && !\in_array($itemNa, $itemMappings['isnot'])) {
$tmpArray[] = $itemNa;
}
}
$itemMappings['na'] = $tmpArray;
return $itemMappings;
}
if ($argc != 2) {
dump('Need data json file as parameter.');
die;
}
$jsonDataFile = $argv[1];
$data = [];
if (is_file($jsonDataFile)) {
$data = \json_decode(\file_get_contents($jsonDataFile), true);
}
if (!is_writable($jsonDataFile)) {
dump('Output data json file is not writable.');
die;
}
$categories = (\array_key_exists('categories', $data) && \is_array($data['categories'])) ? $data['categories'] : [];
$items = (\array_key_exists('items', $data) && \is_array($data['items'])) ? $data['items'] : [];
// Manage categories exclusions
$exclusions = (\array_key_exists('exclusions', $data) && \is_array($data['exclusions'])) ? $data['exclusions'] : [];
// Merge categories with categories found in exclusions
foreach ($exclusions as $exclusionSet) {
foreach ($exclusionSet as $category) {
$categories[] = $category;
}
}
$categories = array_clean($categories);
$items = array_clean($items);
$themes = (\array_key_exists('themes', $data) && \is_array($data['themes'])) ? $data['themes'] : [];
$resources = (\array_key_exists('resources', $data) && \is_array($data['resources'])) ? $data['resources'] : [];
$data['categories'] = $categories;
$data['items'] = $items;
$data['exclusions'] = $exclusions;
$data['themes'] = $themes;
$data['resources'] = $resources;
dump('');
dump('Found ' . \count($categories) . ' unique categories.');
dump('Found ' . \count($items) . ' unique items.');
dump('Found ' . \count($exclusions) . ' exclusions sets.');
dump('Found ' . \count($themes) . ' themes.');
// Get/init mapping data
$mapping = (\array_key_exists('mapping', $data) && \is_array($data['mapping'])) ? $data['mapping'] : [];
$mappingItems = (\array_key_exists('items', $mapping) && \is_array($mapping['items'])) ? $mapping['items'] : [];
foreach ($items as $item) {
if (!\array_key_exists($item, $mappingItems)) {
$mappingItems[$item] = [];
}
if (!\array_key_exists('is', $mappingItems[$item]) || !\is_array($mappingItems[$item])) {
$mappingItems[$item]['is'] = [];
}
if (!\array_key_exists('isnot', $mappingItems[$item]) || !\is_array($mappingItems[$item])) {
$mappingItems[$item]['isnot'] = [];
}
if (!\array_key_exists('na', $mappingItems[$item]) || !\is_array($mappingItems[$item])) {
$mappingItems[$item]['na'] = [];
}
$mappingItems[$item] = clean_item_mappings($mappingItems[$item]);
}
// TODO: Should check/add unkown items from current mapping
\ksort($mappingItems);
$data['mapping'] = [
'items' => $mappingItems,
];
function showCategories($categories)
{
dump(\join("\n", $categories));
}
function showItems($items)
{
dump(\join("\n", $items));
}
function showExclusions($exclusions)
{
foreach ($exclusions as $exclusionSet) {
dump(\join(', ', $exclusionSet));
}
}
function showThemes($theme)
{
foreach ($theme as $name => $categories) {
dump($name . ': ' . \join(', ', $categories));
}
}
function showMappings($mappingItems)
{
$columnsWidths = [
'items' => 0,
];
$items = \array_keys($mappingItems);
$categories = [];
foreach ($mappingItems as $item => $mapping) {
if ($columnsWidths['items'] < \mb_strlen($item)) {
$columnsWidths['items'] = \mb_strlen($item);
}
foreach (\array_merge($mapping['is'], $mapping['isnot'], $mapping['na']) as $category) {
if (!\in_array($category, $categories)) {
$categories[] = $category;
if (!\array_key_exists($category, $columnsWidths)) {
$columnsWidths[$category] = 0;
}
if ($columnsWidths[$category] < \mb_strlen($category)) {
$columnsWidths[$category] = \mb_strlen($category);
}
}
}
}
$strIs = '✅';
$strIsNot = '❌';
$strNa = '⛔';
// separator
$line = [
\mb_str_pad('', $columnsWidths['items'], '-', STR_PAD_BOTH),
];
foreach ($categories as $category) {
$line[] = \mb_str_pad('', $columnsWidths[$category], '-', STR_PAD_BOTH);
}
dump('--' . \join('---', $line) . '--');
// header
$line = [
\mb_str_pad('', $columnsWidths['items'], ' ', STR_PAD_BOTH),
];
foreach ($categories as $category) {
$line[] = \mb_str_pad($category, $columnsWidths[$category], ' ', STR_PAD_BOTH);
}
dump('| ' . \join(' | ', $line) . ' |');
// separator
$line = [
\mb_str_pad('', $columnsWidths['items'], '-', STR_PAD_BOTH),
];
foreach ($categories as $category) {
$line[] = \mb_str_pad('', $columnsWidths[$category], '-', STR_PAD_BOTH);
}
dump('|-' . \join('-|-', $line) . '-|');
foreach ($items as $item) {
$line = [
\mb_str_pad($item, $columnsWidths['items'], ' ', STR_PAD_RIGHT),
];
foreach ($categories as $category) {
$value = '';
if (\in_array($category, $mappingItems[$item]['is'])) {
$value = $strIs;
} elseif (\in_array($category, $mappingItems[$item]['isnot'])) {
$value = $strIsNot;
} elseif (\in_array($category, $mappingItems[$item]['na'])) {
$value = $strNa;
}
$line[] = \mb_str_pad($value, $columnsWidths[$category], ' ', STR_PAD_BOTH);
}
dump('| ' . \join(' | ', $line) . ' |');
}
// separator
$line = [
\mb_str_pad('', $columnsWidths['items'], '-', STR_PAD_BOTH),
];
foreach ($categories as $category) {
$line[] = \mb_str_pad('', $columnsWidths[$category], '-', STR_PAD_BOTH);
}
dump('--' . \join('---', $line) . '--');
}
function editMappings($mappingItems, $categories, $items, $exclusions)
{
// Set missing associations
$exitEditMappings = false;
$missing = find_missing_associations($mappingItems, $categories, $items);
while ((\count($missing) !== 0) && ($exitEditMappings === false)) {
dump('');
dump('Missing associations: ' . \count($missing));
dump('');
$picked = $missing[mt_rand(0, \count($missing) - 1)];
$item = $picked['item'];
$category = $picked['category'];
$question = 'Is "' . $item . '" can be categorised as "' . $category . '"?';
$ex = find_exclusions($exclusions, $category);
if (\count($ex) !== 0) {
$question .= ' (and apply accordingly to "' . join('" and "', $ex) . '")';
}
dump($question);
$answer = ask('1: yes ; 2: no ; 3: n/a ; 0: exit');
switch ($answer) {
case '0':
$exitEditMappings = true;
break;
case '1':
dump(' -> "' . $item . '" is "' . $category . '"');
$mappingItems[$item]['is'][] = $category;
// apply "is not" to each other
foreach ($ex as $exclusion) {
dump(' -> "' . $item . '" is not "' . $exclusion . '"');
$mappingItems[$item]['isnot'][] = $exclusion;
}
break;
case '2':
dump(' -> "' . $item . '" is not "' . $category . '"');
$mappingItems[$item]['isnot'][] = $category;
// apply "is" only if one exclusion
if (\count($ex) === 1) {
foreach ($ex as $exclusion) {
dump(' -> "' . $item . '" is "' . $exclusion . '"');
$mappingItems[$item]['is'][] = $exclusion;
}
}
break;
case '3':
dump(' -> "' . $item . '" does not apply as "is or is not" "' . $category . '"');
$mappingItems[$item]['na'][] = $category;
foreach ($ex as $excludedCategory) {
dump(' -> "' . $item . '" does not apply as "is or is not" "' . $excludedCategory . '"');
$mappingItems[$item]['na'][] = $excludedCategory;
}
break;
default:
dump('wut? skipping...');
break;
}
$mappingItems[$item] = clean_item_mappings($mappingItems[$item]);
$missing = find_missing_associations($mappingItems, $categories, $items);
}
return $mappingItems;
}
// Main loop
$exitMainLoop = false;
while ($exitMainLoop === false) {
dump('');
$missing = find_missing_associations($mappingItems, $categories, $items);
$menu = [
'0: save and exit',
'',
'1: show categories (' . \count($categories) . ' found)',
'2: show items (' . \count($items) . ' found)',
'3: show exclusions (' . \count($exclusions) . ' found)',
'4: show themes (' . \count($themes) . ' found)',
'5: show mappings (' . \count($mappingItems) . ' found)',
'',
'6: complete mappings (' . \count($missing) . ' missing)',
];
$answer = ask(\join("\n", $menu));
switch ($answer) {
case '0':
$exitMainLoop = true;
break;
case '1':
showCategories($categories);
break;
case '2':
showItems($items);
break;
case '3':
showExclusions($exclusions);
break;
case '4':
showThemes($themes);
break;
case '5':
showMappings($mappingItems);
break;
case '6':
$data['mapping']['items'] = editMappings($mappingItems, $categories, $items, $exclusions);
break;
default:
break;
}
}
write_data($data, $jsonDataFile);
echo "ok, done." . PHP_EOL;
#!/usr/bin/env bash
command -v jq >/dev/null 2>&1 || { echo >&2 "I require jq (json parser) but it's not installed. Aborting."; exit 1; }
CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
BASE_DIR="$(dirname "${CURRENT_DIR}")"
DATA_FILE="${CURRENT_DIR}/data.json"
touch "${DATA_FILE}"
# backup current file
# NOW="$(date '+%Y%m%d_%H%M%S')"
# cp "${DATA_FILE}" "${DATA_FILE}.bak_${NOW}.json"
cd "${CURRENT_DIR}"
php manage_data.php "${DATA_FILE}"
# format json file
cat "${DATA_FILE}" | jq >"${DATA_FILE}.tmp"
mv "${DATA_FILE}.tmp" "${DATA_FILE}"
# inject json file in app code
GAME_DATA_DART_FILE="${BASE_DIR}/lib/data/game_data.dart"
echo "class GameData {" >"${GAME_DATA_DART_FILE}"
echo " static const Map<String, dynamic> data = $(cat "${DATA_FILE}");" >>"${GAME_DATA_DART_FILE}"
echo "}" >>"${GAME_DATA_DART_FILE}"
dart format "${GAME_DATA_DART_FILE}"
# cat "${DATA_FILE}"
\ No newline at end of file