Skip to content

Commit 57e920a

Browse files
authored
Merge branch 'main' into refactor/use-pubspec-parse
2 parents 1502aff + 7f96e02 commit 57e920a

File tree

11 files changed

+207
-25
lines changed

11 files changed

+207
-25
lines changed

bin/melos_dev.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import '../packages/melos/bin/melos.dart' as melos;
33
// A copy of packages/melos/bin/melos.dart
44
// This allows us to use melos on itself during development.
55
void main(List<String> arguments) async {
6-
if (arguments.contains('--help')) {
6+
if (arguments.contains('-h') || arguments.contains('--help')) {
77
// ignore_for_file: avoid_print
88
print('---------------------------------------------------------');
99
print('| You are running a local development version of melos. |');

docs/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ The following projects are using Melos:
4949
- [ApptiveGrid/apptive_grid_flutter](https://github.com/ApptiveGrid/apptive_grid_flutter)
5050
- [flutternetwork/WiFiFlutter](https://github.com/flutternetwork/WiFiFlutter)
5151
- [iapicca/yak_packages](https://github.com/iapicca/yak_packages)
52-
- [atsign-foundation/at_app](https://github.com/atsign-foundation/at_app)
52+
- [atsign-foundation/at_mono](https://github.com/atsign-foundation/at_mono)
5353
- [sub6resources/flutter_html](https://github.com/sub6resources/flutter_html)
5454
- [ferraridamiano/ConverterNOW](https://github.com/ferraridamiano/ConverterNOW)
5555
- [rrifafauzikomara/youtube_video](https://github.com/rrifafauzikomara/youtube_video)
@@ -67,6 +67,7 @@ The following projects are using Melos:
6767
- [heftapp/graphql_codegen](https://github.com/heftapp/graphql_codegen)
6868
- [leonardocustodio/polkadart](https://github.com/leonardocustodio/polkadart)
6969
- [powersync/powersync.dart](https://github.com/powersync-ja/powersync.dart)
70+
- [foss42/apidash](https://github.com/foss42/apidash)
7071

7172
<Info>
7273

melos.yaml.schema.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,26 @@
421421
}
422422
}
423423
]
424+
},
425+
{
426+
"type": "object",
427+
"required": ["steps"],
428+
"additionalProperties": false,
429+
"properties": {
430+
"name": {
431+
"type": "string",
432+
"description": "A unique identifier for the script."
433+
},
434+
"description": {
435+
"type": "string",
436+
"description": "A short description, shown when using `melos run` with no argument."
437+
},
438+
"steps": {
439+
"type": "array",
440+
"description": "A list of commands to execute sequentially, enabling complex workflows.",
441+
"items": { "type": "string" }
442+
}
443+
}
424444
}
425445
]
426446
},

packages/melos/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ The following projects are using Melos:
164164
- [jhomlala/alice](https://github.com/jhomlala/alice)
165165
- [powersync/powersync.dart](https://github.com/powersync-ja/powersync.dart)
166166
- [rodydavis/signals.dart](https://github.com/rodydavis/signals.dart)
167+
- [foss42/apidash](https://github.com/foss42/apidash)
167168

168169
> Submit a PR if you'd like to add your project to the list. Update the
169170
> [README.md](https://github.com/invertase/melos/edit/main/packages/melos/README.md)

packages/melos/lib/src/commands/analyze.dart

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,25 @@ mixin _AnalyzeMixin on _Melos {
3737
concurrency: concurrency,
3838
).join(' ');
3939
final useGroupBuffer = concurrency != 1 && packages.length != 1;
40+
final dartPackageCount = packages.where((e) => !e.isFlutterPackage).length;
41+
final flutterPackageCount =
42+
packages.where((e) => e.isFlutterPackage).length;
4043

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

43-
logger
44-
.child(targetStyle(analyzeArgsString))
45-
.child('$runningLabel (in ${packages.length} packages)')
46-
.newLine();
46+
if (dartPackageCount > 0) {
47+
logger
48+
.child(targetStyle(analyzeArgsString))
49+
.child('$runningLabel (in $dartPackageCount packages)')
50+
.newLine();
51+
}
52+
53+
if (flutterPackageCount > 0) {
54+
logger
55+
.child(targetStyle(analyzeArgsString.replaceFirst('dart', 'flutter')))
56+
.child('$runningLabel (in $flutterPackageCount packages)')
57+
.newLine();
58+
}
4759

4860
await pool.forEach<Package, void>(packages, (package) async {
4961
final group = useGroupBuffer ? package.name : null;
@@ -55,6 +67,7 @@ mixin _AnalyzeMixin on _Melos {
5567
workspace,
5668
package,
5769
_getAnalyzeArgs(
70+
package: package,
5871
workspace: workspace,
5972
fatalInfos: fatalInfos,
6073
fatalWarnings: fatalWarnings,
@@ -101,6 +114,7 @@ mixin _AnalyzeMixin on _Melos {
101114
List<String> _getAnalyzeArgs({
102115
required MelosWorkspace workspace,
103116
required bool fatalInfos,
117+
Package? package,
104118
bool? fatalWarnings,
105119
// Note: The `concurrency` argument is intentionally set to a default value
106120
// of 1 to prevent its direct use by the `startCommand` function. It is
@@ -110,7 +124,10 @@ mixin _AnalyzeMixin on _Melos {
110124
}) {
111125
final options = _getOptionsArgs(fatalInfos, fatalWarnings, concurrency);
112126
return <String>[
113-
workspace.sdkTool('dart'),
127+
if (package?.isFlutterPackage ?? false)
128+
workspace.sdkTool('flutter')
129+
else
130+
workspace.sdkTool('dart'),
114131
'analyze',
115132
options,
116133
];

packages/melos/lib/src/common/intellij_project.dart

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,12 +284,15 @@ class IntellijProject {
284284
await Future.forEach(_workspace.filteredPackages.values, (package) async {
285285
if (!package.isFlutterApp) return;
286286

287-
final generatedRunConfiguration =
288-
injectTemplateVariables(flutterTestTemplate, {
289-
'flutterRunName': "Flutter Run -&gt; '${package.name}'",
290-
'flutterRunMainDartPathRelative':
291-
p.join(package.pathRelativeToWorkspace, 'lib', 'main.dart'),
292-
});
287+
final generatedRunConfiguration = injectTemplateVariables(
288+
flutterTestTemplate,
289+
{
290+
'flutterRunName': "Flutter Run -&gt; '${package.name}'",
291+
'flutterRunMainDartPathRelative': p
292+
.join(package.pathRelativeToWorkspace, 'lib', 'main.dart')
293+
.replaceAll(r'\', '/'),
294+
},
295+
);
293296
final outputFile = p.join(
294297
pathDotIdea,
295298
'runConfigurations',
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<!-- Generated by Melos -->
22
<component name="ProjectRunConfigurationManager">
33
<configuration default="false" name="{{#scriptName}}" type="ShConfigurationType">
4+
<option name="EXECUTE_SCRIPT_FILE" value="false" />
45
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
5-
<option name="SCRIPT_PATH" value="{{#scriptPath}}" />
6-
<option name="SCRIPT_OPTIONS" value="{{#scriptArgs}}" />
76
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="false" />
87
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
8+
<option name="SCRIPT_TEXT" value="melos {{#scriptArgs}}" />
99
<method v="2" />
1010
</configuration>
1111
</component>

packages/melos/test/commands/analyze_test.dart

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,106 @@ $ melos analyze
275275
expect(regex.hasMatch(logger.output.normalizeNewLines()), isTrue);
276276
});
277277

278+
test('should run analysis using flutter & dart', () async {
279+
final workspaceDir = await createTemporaryWorkspace();
280+
281+
await createProject(
282+
workspaceDir,
283+
const PubSpec(
284+
name: 'a',
285+
dependencies: {
286+
'flutter': SdkReference('flutter'),
287+
},
288+
),
289+
);
290+
291+
await createProject(
292+
workspaceDir,
293+
PubSpec(
294+
name: 'b',
295+
dependencies: {
296+
'a': HostedReference(VersionConstraint.any),
297+
},
298+
),
299+
);
300+
301+
final config = await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir);
302+
303+
final melos = Melos(
304+
logger: logger,
305+
config: config,
306+
);
307+
await melos.analyze(concurrency: 2);
308+
309+
expect(
310+
logger.output
311+
.normalizeNewLines()
312+
.contains('flutter analyze --concurrency 2'),
313+
isTrue,
314+
);
315+
316+
final dartRegex =
317+
RegExp(r'\$ melos analyze\s+└> dart analyze --concurrency 2');
318+
319+
expect(dartRegex.hasMatch(logger.output.normalizeNewLines()), isTrue);
320+
});
321+
322+
test('should run analysis using flutter', () async {
323+
final workspaceDir = await createTemporaryWorkspace();
324+
325+
await createProject(
326+
workspaceDir,
327+
const PubSpec(
328+
name: 'a',
329+
dependencies: {
330+
'flutter': SdkReference('flutter'),
331+
},
332+
),
333+
);
334+
335+
final config = await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir);
336+
337+
final melos = Melos(
338+
logger: logger,
339+
config: config,
340+
);
341+
await melos.analyze(concurrency: 2);
342+
343+
final flutterRegex =
344+
RegExp(r'\$ melos analyze\s+└> flutter analyze --concurrency 2');
345+
346+
expect(flutterRegex.hasMatch(logger.output.normalizeNewLines()), isTrue);
347+
});
348+
349+
test('should run analysis using dart', () async {
350+
final workspaceDir = await createTemporaryWorkspace();
351+
await createProject(
352+
workspaceDir,
353+
const PubSpec(
354+
name: 'a',
355+
),
356+
);
357+
358+
final config = await MelosWorkspaceConfig.fromWorkspaceRoot(workspaceDir);
359+
360+
final melos = Melos(
361+
logger: logger,
362+
config: config,
363+
);
364+
await melos.analyze(concurrency: 2);
365+
366+
expect(
367+
logger.output
368+
.normalizeNewLines()
369+
.contains('flutter analyze --concurrency 2'),
370+
isFalse,
371+
);
372+
373+
final dartRegex =
374+
RegExp(r'\$ melos analyze\s+└> dart analyze --concurrency 2');
375+
expect(dartRegex.hasMatch(logger.output.normalizeNewLines()), isTrue);
376+
});
377+
278378
test('should run analysis with --concurrency 2 flag', () async {
279379
await melos.analyze(concurrency: 2);
280380

packages/melos/test/common/intellij_project_test.dart

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import 'dart:io';
2+
13
import 'package:melos/src/common/intellij_project.dart';
24
import 'package:melos/src/common/io.dart';
5+
import 'package:path/path.dart' as p;
6+
import 'package:pubspec/pubspec.dart';
37
import 'package:test/test.dart';
48

59
import '../utils.dart';
@@ -54,4 +58,47 @@ void main() {
5458
expect(modulesXml, contains(r'file://$PROJECT_DIR$/test/melos_test.iml'));
5559
},
5660
);
61+
62+
// https://github.com/invertase/melos/issues/788
63+
test(
64+
'Use / in relative path for Windows',
65+
() async {
66+
final tempDir = createTestTempDir();
67+
await createProject(
68+
tempDir,
69+
const PubSpec(
70+
name: 'test',
71+
dependencies: {
72+
'flutter': SdkReference('flutter'),
73+
},
74+
),
75+
path: 'packages/test',
76+
);
77+
File(
78+
p.join(tempDir.path, 'packages', 'test', 'lib', 'main.dart'),
79+
).createSync(recursive: true);
80+
81+
final workspaceBuilder = VirtualWorkspaceBuilder(
82+
path: tempDir.path,
83+
'''
84+
packages:
85+
- packages/test
86+
''',
87+
);
88+
workspaceBuilder.addPackage(
89+
File(p.join(tempDir.path, 'packages', 'test', 'pubspec.yaml'))
90+
.readAsStringSync(),
91+
);
92+
final workspace = workspaceBuilder.build();
93+
final project = IntellijProject.fromWorkspace(workspace);
94+
await project.generate();
95+
final runXml = readTextFile(
96+
p.join(project.runConfigurationsDir.path, 'melos_flutter_run_test.xml'),
97+
);
98+
expect(
99+
runXml,
100+
contains(r'$PROJECT_DIR$/packages/test/lib/main.dart'),
101+
);
102+
},
103+
);
57104
}

packages/melos/test/package_filter_test.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import 'package:glob/glob.dart';
22
import 'package:melos/melos.dart';
33
import 'package:melos/src/common/glob.dart';
44
import 'package:melos/src/common/io.dart';
5-
import 'package:melos/src/common/platform.dart';
65
import 'package:path/path.dart' as p;
76
import 'package:pubspec_parse/pubspec_parse.dart';
87
import 'package:test/test.dart';
@@ -137,9 +136,7 @@ void main() {
137136
Glob('packages/ab*'),
138137
],
139138
},
140-
path: currentPlatform.isWindows
141-
? p.windows.normalize(path).replaceAll(r'\', r'\\')
142-
: path,
139+
path: path,
143140
);
144141
}
145142

0 commit comments

Comments
 (0)