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

Ensure that npm pack correctly packages workspaces with exposed executable #4

Merged
merged 3 commits into from
Jun 27, 2024

Conversation

stalgiag
Copy link
Collaborator

@stalgiag stalgiag commented Jun 20, 2024

Addresses #3

This PR restructures this repo to accomplish the goals outlined in issue #3:

The bundle created by these commands should include the shared code as well as the relevant platform-specific code, and each should expose at-driver as an executable entry point with an identical command-line interface:

$ npm pack --workspace packages/macos-at-driver-server
$ npm pack --workspace packages/windows-at-driver-server

There were a few issues

  • The bin location was defined in the wrong package.json
  • Workspaces cannot reference files outside of the folder that holds the workspace's package.json for security reasons. As a previous workaround, I attempted to have a third private repo for the shared code. This causes npm to symlink the files in the workspace dependency to the parent workspace in node_modules. Unfortunately, these symlinked files are not included in any pack or publish output. As a further workaround, I am using the prepack step to copy the shared files into the workspaces and the postpack to remove any files copied this way.
  • Lerna was included though it is not needed yet.

Remaining questions:

  • The workaround for including the shared files in workspace output uses Unix commands. This prevents publishing on Windows. I can replace these with node scripts or another cross-platform solution if the overall direction is acceptable.

@stalgiag stalgiag requested a review from jugglinmike June 24, 2024 17:18
Copy link
Member

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

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

This looks great, Stalgia! I really appreciate the simplicity and the care you're giving to the process. Let's go ahead with the cross-platform version.

"author": "",
"license": "MIT",
"devDependencies": {
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.17",
"@types/ws": "^8.5.10",
"@types/yargs": "^17.0.32",
"lerna": "^8.1.3",
Copy link
Member

Choose a reason for hiding this comment

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

It's incredible what this removal does to the project's dependency tree.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I know! Lerna can do a whole lot. None of which are needed here yet.

@stalgiag
Copy link
Collaborator Author

stalgiag commented Jun 26, 2024

Thanks! Added the node scripts to make the prepack and postpack cross-platform with this commit.

@stalgiag stalgiag requested a review from jugglinmike June 26, 2024 17:59
Copy link
Member

@jugglinmike jugglinmike left a comment

Choose a reason for hiding this comment

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

The code looks good to me, and it works for both packages on both platforms. Nice going!

@jugglinmike jugglinmike merged commit 820f5d9 into main Jun 27, 2024
8 checks passed
@jugglinmike jugglinmike deleted the correct-pack branch June 27, 2024 01:34
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.

2 participants