Skip to content

Setup lerna#1291

Merged
ang-zeyu merged 9 commits into
MarkBind:masterfrom
ang-zeyu:setup-lerna
Jul 31, 2020
Merged

Setup lerna#1291
ang-zeyu merged 9 commits into
MarkBind:masterfrom
ang-zeyu:setup-lerna

Conversation

@ang-zeyu

@ang-zeyu ang-zeyu commented Jul 27, 2020

Copy link
Copy Markdown
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [x] Other, please explain:

Resolves #1285

What is the rationale for this request?
See #1285

What changes did you make? (Give an overview)
Commit order:

  • Move all cli files to packages/cli 5a56a69
    • and update .gitignore ignore path accordingly
  • Add.npmignore for core package d7ca8bc
  • Setup lerna (gitignore update + lerna init + lerna bootstrap) 7979698
  • Update font awesome test files (the previous step caused some package-lock versions to change, which caused font awesome to update 605a4e2
  • Adapt test scripts f7c16e3
  • Adapt linting configs, scripts c3c22bc
    • this commit also unifies the linting into one call to eslint ., and ditches separately running eslint . in all packages. This allows vue-components' eslint to properly extend the root config
  • Move vue-components script to root private package 823e9ec
  • Adapt CI and setup (install) scripts b0d33ca
  • Update devguide bbe4bec (wip)
    • the publishing process is yet to be tested here

Is there anything you'd like reviewers to focus on?

  • bbe4bec 's publishing process is yet to be dummy tested

Testing instructions:

  • no change -- npm run test
    • under the hood this now runs eslint & stylelint, then the test npm script in all packages separately

Proposed commit message: (wrap lines at 72 characters)
The cli and core packages uses relative file specifiers to link
dependencies in the mono repo. This causes a published cli package to
fail to install.

Besides site generation, the core package also houses several other
things like templates, assets and plugins, which can be moved into
separate packages for better separation of concerns.

Let's extract the main cli package into packages/cli as such, resulting
in a flat package structure.
The multi package structure implies publishing all packages
independently, which fixes the usage of relative file specifiers.

Let's also setup lerna, which is a multi-package monorepo development
and dependency management helper.
This greatly reduces the amount of work needed to manage multiple
independent packages.

@marvinchin marvinchin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did some poking around and things seem to work fine! Now to see if publishing works as we expect.

Some questions/thoughts:

  • Do you know why the FontAwesome version was bumped? Ideally, we should retain the original version in this PR to keep these concerns separate and avoid unnecessary diffs.
  • I feel that we should keep the README.md in the root. This can help new devs who first visit our repo some information on the project and how to get started at first glance. Maybe we should set up a new README for cli and each of the other leaf packages, with a short explanation on what each package does.

Comment thread .eslintignore Outdated

!.eslintrc.js

# vue-components

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just wondering - is there any reason why we don't just use packages/vue-components here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

👍 fixed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Some questions/thoughts:

  • Do you know why the FontAwesome version was bumped? Ideally, we should retain the original version in this PR to keep these concerns separate and avoid unnecessary diffs.

we previously installed the core package transitively via the cli package, so there was no package-lock there. so the latest semantic ver gets installed.

I'll get out a separate pr to update it though, then rebase this one on top of that

  • I feel that we should keep the README.md in the root. This can help new devs who first visit our repo some information on the project and how to get started at first glance. Maybe we should set up a new README for cli and each of the other leaf packages, with a short explanation on what each package does.

🤦‍♂️ unintentional. Will revert and add some brief readmes for cli/core after the npmignore commit during the rebase above

Comment thread docs/devGuide/settingUp.md Outdated
<popover header="Why **2** `ci` commands?" content="Our components subpackage depends on `node-sass` indirectly, which depends on `fsevents`.<br><br> `fsevents` is not needed nor compatible with Windows, and `npm ci` does not respect this since it uses `package-lock.json`.">(`ciwin:all` if you are on a Windows machine)</popover>
in the root folder of your cloned repo.
1. **To bind your cloned version of MarkBind to your console** (instead of the released version of MarkBind), run `npm link` in the root folder of the cloned repo.
1. **Install dependencies** by running <popover content="Under the hood, this calls `npm ci` and `lerna bootstrap`">`npm run setup`</popover> in the root folder of your cloned repo.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I had some issues due to existing node_modules directories in the existing packages. Do you think it's worth adding a note here for existing markbind devs to first run lerna clean before running npm run setup?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

lerna clean won't work unless you have it installed globally or have run npm ci (which npm run setup does) first unfortunately. I think the devguide should be written in the perspective of new developers always though. Experienced developers could always drop an issue / ping, and have a likely have a better understanding of node already 😁

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ah fair enough!

Comment thread docs/devGuide/settingUp.md Outdated
MarkBind uses <md>[lerna](https://github.com/lerna/lerna)</md>, a popular multi-package development tool, to manage it's dependencies. It is essentially a high level wrapper over node and npm's functionalities
</box>

1. **To bind your cloned version of MarkBind to your console** (instead of the released version of MarkBind), run `npm link` in the `packages/cli` folder of the cloned repo.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does this work for you now? I'm getting errors because our internal packages haven't been published yet.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

got that too, you could get around it by temporarily removing the @markbind/core dependency and npm link then undoing it

@ang-zeyu

Copy link
Copy Markdown
Contributor Author

Updated:

  • reverted README.md movement 502041c
  • add README for cli / core package 6360743
  • dropped font awesome commit

https://github.com/lerna/lerna/blob/master/doc/hoist.md

Also switched over to lerna bootstrap --hoist in npm run setup (package-lock changes in 502041c & d6b62c3 only), which is compatible with the current setup and should install faster + take up less space.

the second disadvantage mentioned isn't applicable either as eslint-plugin-import guards against it

@@ -21,9 +21,9 @@ export default {
}
const pages = [];
const regexes = this.value.split(' ')
.filter((searchKeyword) => searchKeyword !== '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are these diffs intentional?

Ideally, fixing linting errors would be done in a separate PR, but if these new errors are introduced because of the changes we make to the eslint config to support lerna then I'm happy to keep it in this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yup the vue eslintrc now properly extends the previous root config

@@ -0,0 +1,4683 @@
{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I presume that these package-lock changes are done by lerna bootstrap? Ideally we'd be able to verify that our dependency versions are still the same, but these diffs seem a little too large to manually verify 🙁

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yep, I think that if our functional tests stay the same we should be good though, since package-lock is only effective in development environment

if there are changes (like the font awesome bundles), we can then investigate them and deal with the diff in a separate pr

@ang-zeyu ang-zeyu changed the title [WIP] Setup lerna Setup lerna Jul 31, 2020
@ang-zeyu

Copy link
Copy Markdown
Contributor Author

Updated @marvinchin, seems to work. Travis seems to be broken on all prs though, likely unrelated to the changes here

494ba03 - rename the packages with markbind- prefix
4dc983d - changed lerna publish to -> lerna publish from-git ( tells lerna to use the version commit from lerna version instead of running lerna version again )

@ang-zeyu ang-zeyu added this to the v2.15.0 milestone Jul 31, 2020
@marvinchin

Copy link
Copy Markdown
Contributor

This is a big PR with multiple steps. I feel that we should do a merge commit, rather than squashing the commit history here.

I also think we should add some detail to commit 494ba03 explaining why we are doing the renaming.

@ang-zeyu

Copy link
Copy Markdown
Contributor Author

This is a big PR with multiple steps. I feel that we should do a merge commit, rather than squashing the commit history here.

yup that's the plan

I also think we should add some detail to commit 494ba03 explaining why we are doing the renaming.

Just received npm permissions from @yamgent, will revert back to @markbind/xx!

ang-zeyu added 9 commits July 31, 2020 23:24
Development linting dependencies and configuration are duplicated
throughout the packages.

Let's hoist these to the root package as much as possible, removing
such duplication.

In doing so, some style standards are also corrected in the
vue-components package.
Let's fix the style violations resulting from this.
@ang-zeyu

Copy link
Copy Markdown
Contributor Author

reverted to @markbind, should be ready to merge now. Thanks @marvinchin @yamgent!

@marvinchin marvinchin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 🌵

@ang-zeyu ang-zeyu merged commit 155b918 into MarkBind:master Jul 31, 2020
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.

v2.15.0 fails to install entirely

2 participants