-
Notifications
You must be signed in to change notification settings - Fork 187
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
PDE-4678 fix(cli): zapier build
fails with npm workspaces
#738
Conversation
zapier build
fails with npm workspaceszapier build
fails with npm workspaces
@rnegron this is ready for review. Thanks! |
@@ -309,3 +311,189 @@ describe('build (runs slowly)', function () { | |||
should.equal(buildExists, true); | |||
}); | |||
}); | |||
|
|||
describe('build in workspaces', function () { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great and easy to follow tests! 👍🏻
@@ -38,27 +37,137 @@ describe('files', () => { | |||
.catch(done); | |||
}); | |||
|
|||
// TODO: this is broken in travis - works locally though |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏻
|
||
startSpinner('Building app definition.json'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this spinner was removed intentionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a mistake. Added it back in 52fba09. Thanks!
Returns a promise that copies a directory recursively. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻 Always appreciate these descriptive comments
[PDE-4679] fix(cli): better handling of broken symlinks while copying files to temp directory during build process
fse.readlinkSync(src) | ||
); | ||
for (const workspace of workspaces) { | ||
if (minimatch(realPath, workspace)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eliangcs Could we add a comment here explaining what this minimatch
line is doing? I believe it's true
if the src
symlink resolves (points to) to a workspace path, in which case we want to filter out (return false
) this particular src
. So that we don't copy over any symlinks that point to workspace folders.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You interpretation is correct. Since the workspaces
array in the root package.json
can contain glob patterns, like packages/*
, I use minimatch to help us do glob pattern matching. For example, minimatch('/path/to/packages/app-1', '/path/to/packages/*')
returns true.
I'll add a comment in a separate PR. Thanks!
Fixes #648.
Some developers may choose to structure their project using npm workpaces or yarn workspaces. An example project structure might look like:
If you run
npm install
in the above example,app-1
andapp-2
will share their dependencies in the project root'snode_modules
. Only the dependencies with version discrepancies will be placed intoapp-1/node_modules
orapp-2/node_modules
.The current implementation of
zapier build
doesn't support workspaces. It always assume it can always findzapier-platform-core
in the working directory'snode_modules
.This PR fixes that by finding
zapier-platform-core
in the working directory and all the parent directories.