Open 2ZeroSix opened 3 years ago
Would writing a dart script not be easier and cleaner for cross-platform execution, we have an example on the melos repo itself:
https://github.com/invertase/melos/blob/master/melos.yaml#L40 https://github.com/invertase/melos/blob/master/scripts/generate_version.dart
You could even add a pubspec.yaml at the root of your monorepo for any dev dependencies you may need for your scripts:
https://github.com/invertase/melos/blob/master/melos.yaml#L4 https://github.com/invertase/melos/blob/master/pubspec.yaml#L11-L12
I wanted to originally add something like you've mentioned before but opted not to since we can just write a cross-platform script using a single Dart file
Thanks for nice example!
Probably for most cases dart script would be a perfect solution.
Then run
section docs must properly state that it's not intended to be used for full-featured scripts.
As I can see &&
for chains and \
, ^
for line continuations are "safe" expressions
We are going through and updating the docs to have more examples and information on cross-platform scripts 🙈 sorry it's not fully documented yet
Then run section docs must properly state that it's not intended to be used for full-featured scripts. As I can see && for chains and \, ^ for line continuations are "safe" expressions
Is there any code improvements to Melos you would suggest we make to improve this?
I was thinking about this over the weekend, and I can say that this problem is much more complicated than I initially expected
Here is long running issue in npm (this is what lerna use in lerna run <script>
by default): https://github.com/npm/npm/issues/4040
issue in yarn caused by some custom escape character parsing: https://github.com/yarnpkg/yarn/issues/7732
and there is many more in the wild
It seems critical to choose appropriate solution as soon as possible while most of the users are early adopters
Possible solutions:
&&
or multiple lines for chains. It should behave the same way, exit on first error\
for line continuations (remove ^
support to avoid confusion and simplify parser)$ENV_VAR
for environment variablesI think this is a must feature for cross-platform, because I met a line break issue on windows quickly.
test:
run: |
flutter test --exclude-tags "integration" && \
flutter pub run melos exec -c 1 --fail-fast -- \
"flutter test --no-pub --exclude-tags "integration"
description: Run `flutter test` for a specific package.
select-package:
dir-exists:
- test
test:windows:
run: |
flutter test --exclude-tags "integration" && ^
flutter pub run melos exec -c 1 --fail-fast -- \
"flutter test --no-pub --exclude-tags "integration"
description: Run `flutter test` for a specific package.
select-package:
dir-exists:
- test
Line break is different on windows (cmd), so can't be used easily, but almost the same code.
Edit
Nevermind, Line break can be resolved by changing YAML syntax from |
to >-
.
Problem:
It seems impossible to properly support multi-platform parsing of command in
run
section without invention of its own scripting languageFor example this issue #15 is caused and cannot be easily and fully fixed because of custom
cmd
andsh
handlingProposal:
allow platform specific scripts
for example
or
then it would be possible to pass script in
run
section as-is to underlying interpreter without any custom parsing