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

Handle additional yarn workspace definition formats #463

Merged
merged 2 commits into from Mar 11, 2020
Merged

Handle additional yarn workspace definition formats #463

merged 2 commits into from Mar 11, 2020

Conversation

BarryThePenguin
Copy link
Contributor

@BarryThePenguin BarryThePenguin commented Mar 3, 2020

Yarn workspaces can have two different definitions

"workspaces": [
  "packages/*"
]

and

"workspaces": {
  "packages": ["packages/*"],
  "nohoist": ["**/react-native", "**/react-native/**"]
}

This PR adds support for the second definition

Comment on lines +199 to +202
if (fs.existsSync(path.join(this.cwd, this.nodeModulesBackupLocation))) {
restoreTasks.push(copy(path.join(this.cwd, this.nodeModulesBackupLocation),
path.join(this.cwd, this.nodeModules), { clobber: true }));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yarn workspaces can hoist packages in such a way that a node_modules folder may never be created. This checks the existence of the directory before trying to restore it

if (fs.existsSync(path.join(this.cwd, this.nodeModules))) {
backupTasks.push(copy(path.join(this.cwd, this.nodeModules),
path.join(this.cwd, this.nodeModulesBackupLocation), { clobber: true }));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to above, but when backing up packages

@BarryThePenguin BarryThePenguin marked this pull request as ready for review March 3, 2020 05:49
@codecov
Copy link

codecov bot commented Mar 3, 2020

Codecov Report

Merging #463 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #463      +/-   ##
==========================================
+ Coverage   96.88%   96.91%   +0.03%     
==========================================
  Files          17       17              
  Lines         577      584       +7     
==========================================
+ Hits          559      566       +7     
  Misses         18       18
Impacted Files Coverage Δ
lib/dependency-manager-adapters/npm.js 100% <100%> (ø) ⬆️
lib/dependency-manager-adapters/workspace.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bff5859...8e31b46. Read the comment docs.

@BarryThePenguin
Copy link
Contributor Author

Is there anything else I need to do? Any information that's missing that I could provide?

Comment on lines 31 to 35
let workspaceGlobs = packageJSON.workspaces

if (workspaceGlobs && workspaceGlobs.packages) {
workspaceGlobs = workspaceGlobs.packages
}
Copy link
Member

Choose a reason for hiding this comment

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

Can you tweak this to be specific about what we expect? I'm thinking of something like:

let workspaceGlobs = Array.isArray(packageJSON.workspaces) ? packageJSON.workspaces : packageJSON.workspaces.packages;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure! Ended up with

if (Array.isArray(packageJSON.workspaces)) {
  workspaceGlobs = packageJSON.workspaces
}

if (packageJSON.workspaces && Array.isArray(packageJSON.workspaces.packages)) {
  workspaceGlobs = packageJSON.workspaces.packages
}

so it's specific about each case

@rwjblue rwjblue changed the title fix: handle additional workspace packages Handle additional yarn workspace definition formats Mar 11, 2020
@rwjblue rwjblue added the bug label Mar 11, 2020
@rwjblue rwjblue merged commit aa4e3ff into ember-cli:master Mar 11, 2020
@rwjblue
Copy link
Member

rwjblue commented Mar 11, 2020

Thank you @BarryThePenguin!

@BarryThePenguin BarryThePenguin deleted the fix/workspace-packages branch March 11, 2020 02:25
@BarryThePenguin
Copy link
Contributor Author

No worries!

The latest ember times talked about using mono-repos to manage large ember apps. It mentions ember-try at the end, so it was a good reminder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants