Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli.js): allow configuring tauri app path on package.json #2752 #3035

Merged
merged 5 commits into from
Dec 9, 2021

Conversation

lucasfernog
Copy link
Member

package.json > tauri > appPath defines the path to the tauri crate and cli.js sets the proper CWD when running cli.rs

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Docs
  • New Binding Issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes. Issue #___
  • No

The PR fulfills these requirements:

  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix: #xxx[,#xxx], where "xxx" is the issue number)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.

If adding a new feature, the PR's description includes:

  • A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

Other information:

`package.json > tauri > appPath` defines the path to the tauri crate and cli.js sets the proper CWD when running cli.rs
@lucasfernog lucasfernog requested a review from a team as a code owner December 6, 2021 23:07
@lucasfernog lucasfernog requested a review from a team December 6, 2021 23:07
@amrbashir
Copy link
Member

amrbashir commented Dec 6, 2021

if we are gonna add this, then we should probably add the other way around too.
So package.json has a key to link to tauri.conf.json (the file itself is better than the directory) and tauri.conf.json has link to package.json, it probably better to bake that in the rust cli, so rust users can have its benefits too.

@lucasfernog
Copy link
Member Author

lucasfernog commented Dec 6, 2021

if we are gonna add this, then we should probably add the other way around too. So package.json has a key to link to tauri.conf.json (the file itself is better than the directory) and the other way around.

I think the Rust CLI won't even know about Node.js or the frontend application. Currently it only needs this information for tauri info and beforeDev/beforeBuildCommand, and my idea was to allow defining the cwd for the scripts and letting cli.js pass information to cli.rs. This keeps the cli.rs code clean, avoiding this back and forth path information, and makes it easier to have new bindings in the future.

@amrbashir
Copy link
Member

amrbashir commented Dec 6, 2021

Currently it only needs this information for tauri info and beforeDev/beforeBuildCommand, and my idea was to allow defining the cwd for the scripts and letting cli.js pass information to cli.rs.

yeah you're right, this makes more sense.

We also had some reports about some people not able to use the rust cli with a cargo workspace but that's for another PR I guess.

@lucasfernog
Copy link
Member Author

Can you link that issue? Last time I checked it worked fine, maybe it's some special setup.

@amrbashir
Copy link
Member

don't remember exactly, maybe it was this #2765 (comment) .

@@ -74,10 +75,21 @@ ${chalk.yellow('Options')}
if (process.argv && process.env.NODE_ENV !== 'test') {
process.argv.splice(0, 3)
}
let cwd = null
if (existsSync('package.json')) {
Copy link
Member

@amrbashir amrbashir Dec 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could enhance this a bit using https://github.com/sindresorhus/pkg-up , I know I sometimes run npm clis in a nested directory. this would be a cool addition IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea, gonna do it tomorrow

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg-up is literally just calling findUp('package.json', {cwd}) from https://github.com/sindresorhus/find-up, so I'd say use find-up directly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

tooling/cli.js/bin/tauri.js Outdated Show resolved Hide resolved
lucasfernog and others added 2 commits December 7, 2021 10:28
Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants