Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into feat/init
Browse files Browse the repository at this point in the history
  • Loading branch information
exaby73 committed Nov 24, 2024
2 parents d4dece6 + 83909a7 commit 8a3793f
Show file tree
Hide file tree
Showing 36 changed files with 1,072 additions and 494 deletions.
2 changes: 1 addition & 1 deletion bin/melos_dev.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '../packages/melos/bin/melos.dart' as melos;
// A copy of packages/melos/bin/melos.dart
// This allows us to use melos on itself during development.
void main(List<String> arguments) async {
if (arguments.contains('--help')) {
if (arguments.contains('-h') || arguments.contains('--help')) {
// ignore_for_file: avoid_print
print('---------------------------------------------------------');
print('| You are running a local development version of melos. |');
Expand Down
3 changes: 2 additions & 1 deletion docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The following projects are using Melos:
- [ApptiveGrid/apptive_grid_flutter](https://github.com/ApptiveGrid/apptive_grid_flutter)
- [flutternetwork/WiFiFlutter](https://github.com/flutternetwork/WiFiFlutter)
- [iapicca/yak_packages](https://github.com/iapicca/yak_packages)
- [atsign-foundation/at_app](https://github.com/atsign-foundation/at_app)
- [atsign-foundation/at_mono](https://github.com/atsign-foundation/at_mono)
- [sub6resources/flutter_html](https://github.com/sub6resources/flutter_html)
- [ferraridamiano/ConverterNOW](https://github.com/ferraridamiano/ConverterNOW)
- [rrifafauzikomara/youtube_video](https://github.com/rrifafauzikomara/youtube_video)
Expand All @@ -67,6 +67,7 @@ The following projects are using Melos:
- [heftapp/graphql_codegen](https://github.com/heftapp/graphql_codegen)
- [leonardocustodio/polkadart](https://github.com/leonardocustodio/polkadart)
- [powersync/powersync.dart](https://github.com/powersync-ja/powersync.dart)
- [foss42/apidash](https://github.com/foss42/apidash)

<Info>

Expand Down
3 changes: 1 addition & 2 deletions melos.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Melos
repository: https://github.com/invertase/melos
packages:
- .
- packages/*
ignore:
- packages/melos_flutter_deps_check
Expand Down Expand Up @@ -32,7 +31,7 @@ command:
prompts: ^2.0.0
pub_semver: ^2.1.4
pub_updater: ^0.4.0
pubspec: ^2.3.0
pubspec_parse: ^1.3.0
string_scanner: ^1.2.0
yaml: ^3.1.2
yaml_edit: ^2.1.1
Expand Down
20 changes: 20 additions & 0 deletions melos.yaml.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,26 @@
}
}
]
},
{
"type": "object",
"required": ["steps"],
"additionalProperties": false,
"properties": {
"name": {
"type": "string",
"description": "A unique identifier for the script."
},
"description": {
"type": "string",
"description": "A short description, shown when using `melos run` with no argument."
},
"steps": {
"type": "array",
"description": "A list of commands to execute sequentially, enabling complex workflows.",
"items": { "type": "string" }
}
}
}
]
},
Expand Down
1 change: 1 addition & 0 deletions packages/melos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ The following projects are using Melos:
- [jhomlala/alice](https://github.com/jhomlala/alice)
- [powersync/powersync.dart](https://github.com/powersync-ja/powersync.dart)
- [rodydavis/signals.dart](https://github.com/rodydavis/signals.dart)
- [foss42/apidash](https://github.com/foss42/apidash)

> Submit a PR if you'd like to add your project to the list. Update the
> [README.md](https://github.com/invertase/melos/edit/main/packages/melos/README.md)
Expand Down
69 changes: 23 additions & 46 deletions packages/melos/lib/src/command_configs/bootstrap.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:collection/collection.dart';
import 'package:glob/glob.dart';
import 'package:meta/meta.dart';
import 'package:pubspec/pubspec.dart';
import 'package:pubspec_parse/pubspec_parse.dart';

import '../common/extensions/dependency.dart';
import '../common/extensions/environment.dart';
import '../common/glob.dart';
import '../common/glob_equality.dart';
import '../common/utils.dart';
import '../common/validation.dart';
import '../lifecycle_hooks/lifecycle_hooks.dart';

Expand Down Expand Up @@ -48,29 +49,11 @@ class BootstrapCommandConfigs {
) ??
false;

final environment = assertKeyIsA<Map<Object?, Object?>?>(
key: 'environment',
map: yaml,
).let(Environment.fromJson);

final dependencies = assertKeyIsA<Map<Object?, Object?>?>(
key: 'dependencies',
map: yaml,
)?.map(
(key, value) => MapEntry(
key.toString(),
DependencyReference.fromJson(value),
),
);

final devDependencies = assertKeyIsA<Map<Object?, Object?>?>(
key: 'dev_dependencies',
map: yaml,
)?.map(
(key, value) => MapEntry(
key.toString(),
DependencyReference.fromJson(value),
),
// Create a dummy pubspec name to be able to extract the constraints using
// the pubspec parser.
final bootstrapConstraints = Pubspec.fromJson(
{'name': 'bootstrap', ...yaml},
lenient: true,
);

final dependencyOverridePaths = assertListIsA<String>(
Expand All @@ -93,13 +76,17 @@ class BootstrapCommandConfigs {
? LifecycleHooks.fromYaml(hooksMap, workspacePath: workspacePath)
: LifecycleHooks.empty;

final environment = bootstrapConstraints.environment ?? {};
final dependencies = bootstrapConstraints.dependencies;
final devDependencies = bootstrapConstraints.devDependencies;

return BootstrapCommandConfigs(
runPubGetInParallel: runPubGetInParallel,
runPubGetOffline: runPubGetOffline,
enforceLockfile: enforceLockfile,
environment: environment,
dependencies: dependencies,
devDependencies: devDependencies,
environment: environment.isEmpty ? null : environment,
dependencies: dependencies.isEmpty ? null : dependencies,
devDependencies: devDependencies.isEmpty ? null : devDependencies,
dependencyOverridePaths: dependencyOverridePaths
.map(
(override) =>
Expand Down Expand Up @@ -134,10 +121,10 @@ class BootstrapCommandConfigs {
final Environment? environment;

/// Dependencies to be synced between all packages.
final Map<String, DependencyReference>? dependencies;
final Map<String, Dependency>? dependencies;

/// Dev dependencies to be synced between all packages.
final Map<String, DependencyReference>? devDependencies;
final Map<String, Dependency>? devDependencies;

/// A list of [Glob]s for paths that contain packages to be used as dependency
/// overrides for all packages managed in the Melos workspace.
Expand All @@ -152,14 +139,9 @@ class BootstrapCommandConfigs {
'runPubGetOffline': runPubGetOffline,
'enforceLockfile': enforceLockfile,
if (environment != null) 'environment': environment!.toJson(),
if (dependencies != null)
'dependencies': dependencies!.map(
(key, value) => MapEntry(key, value.toJson()),
),
if (dependencies != null) 'dependencies': dependencies!.toJson(),
if (devDependencies != null)
'dev_dependencies': devDependencies!.map(
(key, value) => MapEntry(key, value.toJson()),
),
'dev_dependencies': devDependencies!.toJson(),
if (dependencyOverridePaths.isNotEmpty)
'dependencyOverridePaths':
dependencyOverridePaths.map((path) => path.toString()).toList(),
Expand All @@ -175,11 +157,8 @@ class BootstrapCommandConfigs {
other.runPubGetOffline == runPubGetOffline &&
other.enforceLockfile == enforceLockfile &&
// Extracting equality from environment here as it does not implement ==
other.environment?.sdkConstraint == environment?.sdkConstraint &&
const DeepCollectionEquality().equals(
other.environment?.unParsedYaml,
environment?.unParsedYaml,
) &&
other.environment.sdkConstraint == environment.sdkConstraint &&
const DeepCollectionEquality().equals(other.environment, environment) &&
const DeepCollectionEquality().equals(other.dependencies, dependencies) &&
const DeepCollectionEquality()
.equals(other.devDependencies, devDependencies) &&
Expand All @@ -195,10 +174,8 @@ class BootstrapCommandConfigs {
enforceLockfile.hashCode ^
// Extracting hashCode from environment here as it does not implement
// hashCode
(environment?.sdkConstraint).hashCode ^
const DeepCollectionEquality().hash(
environment?.unParsedYaml,
) ^
environment.sdkConstraint.hashCode ^
const DeepCollectionEquality().hash(environment) ^
const DeepCollectionEquality().hash(dependencies) ^
const DeepCollectionEquality().hash(devDependencies) ^
const DeepCollectionEquality(GlobEquality())
Expand Down
27 changes: 22 additions & 5 deletions packages/melos/lib/src/commands/analyze.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,25 @@ mixin _AnalyzeMixin on _Melos {
concurrency: concurrency,
).join(' ');
final useGroupBuffer = concurrency != 1 && packages.length != 1;
final dartPackageCount = packages.where((e) => !e.isFlutterPackage).length;
final flutterPackageCount =
packages.where((e) => e.isFlutterPackage).length;

logger.command('melos analyze', withDollarSign: true);

logger
.child(targetStyle(analyzeArgsString))
.child('$runningLabel (in ${packages.length} packages)')
.newLine();
if (dartPackageCount > 0) {
logger
.child(targetStyle(analyzeArgsString))
.child('$runningLabel (in $dartPackageCount packages)')
.newLine();
}

if (flutterPackageCount > 0) {
logger
.child(targetStyle(analyzeArgsString.replaceFirst('dart', 'flutter')))
.child('$runningLabel (in $flutterPackageCount packages)')
.newLine();
}

await pool.forEach<Package, void>(packages, (package) async {
final group = useGroupBuffer ? package.name : null;
Expand All @@ -55,6 +67,7 @@ mixin _AnalyzeMixin on _Melos {
workspace,
package,
_getAnalyzeArgs(
package: package,
workspace: workspace,
fatalInfos: fatalInfos,
fatalWarnings: fatalWarnings,
Expand Down Expand Up @@ -101,6 +114,7 @@ mixin _AnalyzeMixin on _Melos {
List<String> _getAnalyzeArgs({
required MelosWorkspace workspace,
required bool fatalInfos,
Package? package,
bool? fatalWarnings,
// Note: The `concurrency` argument is intentionally set to a default value
// of 1 to prevent its direct use by the `startCommand` function. It is
Expand All @@ -110,7 +124,10 @@ mixin _AnalyzeMixin on _Melos {
}) {
final options = _getOptionsArgs(fatalInfos, fatalWarnings, concurrency);
return <String>[
workspace.sdkTool('dart'),
if (package?.isFlutterPackage ?? false)
workspace.sdkTool('flutter')
else
workspace.sdkTool('dart'),
'analyze',
options,
];
Expand Down
Loading

0 comments on commit 8a3793f

Please sign in to comment.