invertase / melos

🌋 A tool for managing Dart projects with multiple packages. With IntelliJ and Vscode IDE support. Supports automated versioning, changelogs & publishing via Conventional Commits.
https://melos.invertase.dev/~melos-latest
Apache License 2.0
1.08k stars 193 forks source link

Melos scripts not parsing args fully #643

Open shmink opened 5 months ago

shmink commented 5 months ago

Is there an existing issue for this?

Version

3.2.0

Description

There's similar issues but I don't think they're exact in the same issues I'm seeing.

It seems to be that one can pass arguments to a melos script just as you would a bash script but the issue is that melos isn't working out where one argument begins and ends correctly.

Steps to reproduce

For example, from my melos.yaml file I have the following

  translations:test:
    run: $MELOS_ROOT_PATH/scripts/translations/test.sh

That test.sh file is below

echo "arg 1: "$1
echo "arg 2: "$2
echo "arg 3: "$3

If I run the script directly I get the following

~/work/app
❯ ./scripts/translations/test.sh "Hey there" "how" "are you?" 
arg 1: Hey there
arg 2: how
arg 3: are you?

If I run the melos version which is just pointing at the same script it does accept the arguments but I don't think it takes " " speech marks into account.

~/work/app                                                                                            
❯ melos translations:test "Hey there" "how" "are you?"
melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> RUNNING

arg 1: Hey
arg 2: there
arg 3: how

melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> SUCCESS

It looks like it sees ANY space as a separation in arguments.

Expected behavior

I would expect

~/work/app                                                                                            
❯ melos translations:test "Hey there" "how" "are you?"
melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> RUNNING

arg 1: Hey there
arg 2: how
arg 3: are you?

melos run translations:test
  └> $MELOS_ROOT_PATH/scripts/translations/test.sh Hey there how are you?
     └> SUCCESS

Screenshots

No response

Additional context and comments

No response

spydon commented 5 months ago

Not that there should be any difference, but could you just verify that it is the same in the latest version (v4.1.0)?

shmink commented 5 months ago

Unfortunately, I cannot due to dependency conflicts with the repo I work on. I was kind of hoping that some kind soul could just copy and paste my examples above as even creating a new project I run into other issues.

spydon commented 5 months ago

You most likely have your monorepo set up in the wrong way if you get a dependency conflict with melos, check the recommended structure here (only melos should be in the root workspace pubspec): https://melos.invertase.dev/getting-started#recommended-directory-structure

shmink commented 5 months ago

That structure looks like what I have but I'd rather stay on topic please.

spydon commented 5 months ago

It is on topic, because if you can't test with the latest version it is much harder for us to debug.

shmink commented 5 months ago

Fair enough. Finally managed to do it and yes the results are the same for v4.1

~/example                                                                                                                              
❯ melos --version
4.1.0

~/example                                                                                                                              
❯ ./test.sh "Hey there" "are" "you okay?"
arg 1: Hey there
arg 2: are
arg 3: you okay?

~/example                                                                                                                              
❯ cat melos.yaml 
name: example
sdkPath: .fvm/flutter_sdk

packages:
  - "*"

scripts:
  test:
    run: $MELOS_ROOT_PATH/test.sh

~/example                                                                                                                              
❯ melos test "Hey there" "are" "you okay?"
melos run test
  └> $MELOS_ROOT_PATH/test.sh Hey there are you okay?
     └> RUNNING

arg 1: Hey
arg 2: there
arg 3: are

melos run test
  └> $MELOS_ROOT_PATH/test.sh Hey there are you okay?
     └> SUCCESS

Still seems to be that melos sees any space as a separation in arguments ignoring cases where anything surrounded by speech marks should count as 1 argument.

In fact, in the final output it looks like " has been stripped out all together.

melos run test
  └> $MELOS_ROOT_PATH/test.sh Hey there are you okay?
     └> SUCCESS
spydon commented 3 months ago

Can you try just doing MELOS_ROOT_PATH, without the $?