Skip to content

Commit

Permalink
Add step serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mosuem committed Nov 30, 2023
1 parent 217a340 commit d7bae1a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pkgs/native_assets_cli/lib/src/model/asset.dart
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,14 @@ class Asset {
String? id,
Target? target,
AssetPath? path,
RunStep? step,
}) =>
Asset(
id: id ?? this.id,
linkMode: linkMode ?? this.linkMode,
target: target ?? this.target,
path: path ?? this.path,
step: step ?? this.step,
);

@override
Expand All @@ -253,17 +255,19 @@ class Asset {
return other.id == id &&
other.linkMode == linkMode &&
other.target == target &&
other.path == path;
other.path == path &&
other.step == step;
}

@override
int get hashCode => Object.hash(id, linkMode, target, path);
int get hashCode => Object.hash(id, linkMode, target, path, step);

Map<String, Object> toYaml() => {
_idKey: id,
_linkModeKey: linkMode.name,
_pathKey: path.toYaml(),
_targetKey: target.toString(),
_step: step.toYaml(),
};

Map<String, List<String>> toDartConst() => {
Expand All @@ -276,6 +280,7 @@ class Asset {
static const _linkModeKey = 'link_mode';
static const _pathKey = 'path';
static const _targetKey = 'target';
static const _step = 'step';

Future<bool> exists() => path.exists();

Expand Down
5 changes: 5 additions & 0 deletions pkgs/native_assets_cli/lib/src/model/build_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ sealed class RunStep {
List<String> args(Uri configFile, Uri buildOutput, Uri? resources);

const RunStep();

Map<String, Object> toYaml() => {
'script': scriptName,
'output': outputName,
};
}

final class LinkStep extends RunStep {
Expand Down

0 comments on commit d7bae1a

Please sign in to comment.