-
Notifications
You must be signed in to change notification settings - Fork 115
Introduce Pioneer into monorepo #469
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
Introduce Pioneer into monorepo #469
Conversation
SetStorageRoleParamsForm + FormField
…mint Proposal form: Content Working Group Mint Capacity (from MintCapacityForm)
Proposal form: Runtime upgrade
Proposal form: SetMaxValidatorCount
Proposal forms: Refactoring
add missing types to @joystream/types
some variables got a bit stronger typing. The build errors went down to 18 from 40.
Choose Proposal Type screen
…ains References to older chains
Constantinople Release
…nuation Reintorduce explorer and bring back to "light"/"full" mode
Council - identify candidates/members by membership
Constantinople Deployment
…s-fix Media schemas and links fix
…to pioneer-migration
|
Brilliant work on this migration. I hope when/if we pull from upstream The only issue I have is that Can we improve on When working in old Pioneer repo, one didn't need to think about having to build dependencies before the main build, it was automatic. Here as you pointed out we have to remember to rebuild @joystream/types and then the project that depends on it. I'm guess webpack was always taking care of rebuilding dependencies so you could just modify types and run yarn start and code would be automatically transpiled. Is there a way to get a similar behavior in this new repo. What I'm imagining is that after someone clones the repo, they just need to run I see you are using We should remove pioneer/yarn.lock and cli/yarn.lock now that only the top .lock file is required. I don't quite understand the resolutions section in the package.json but doesn't the one in pioneer/package.json need to be moved to the root package.json? It does seem to be relevant to any app that is depending on the polkadot/api to ensure they all use the same versions. |
|
I was able to build pioneer and also run it with development Just wondering why is |
|
I wasn't able to make it all work the way we would want for now, but at least manged to make the workflow with Pioneer as simple as it was before, while maintaining I configured Optimally we would want something like that for the CLI (and potentially other projects) too, but I couldn't find a way to make it work for now, so the CLI and Having that in mind I added One more thing to keep in mind is that this gets us back to the disparity of how I think this may be a good-enough setup for now, it could definitely be improved, but that would require some more research on my part and we'd have to probably change the way we're handling the process of building and publishing I also resolved a few of the smaller issues mentioned:
|
This PR is an attempt to move Pioneer from the repository at https://github.com/Joystream/apps into this monorepo.
Moving Pioneer into subfolder and merging
I created a
monorepo-migrationbranch in the Pioneer repository (https://github.com/Joystream/apps/tree/monorepo-migration), where I moved all the files intopioneerfolder. This branch was then merged intopioneer-migraton(this one) using--allow-unrelated-historiesThe entire flow was like this:
The 3k+ commits in this PR are the result of moving the entire Pioneer history. All the configuration work described below is introducted in the last commit of this PR: 643c08c
Workspaces
In order to have all current Pioneer's workspaces available among other monorepo workspaces, I landed on this configuration in the root directory
packages.json:As you can see, I made a few adjustments there, ie.:
Moved
joy-typespackage from the Pioneer'spackagesdirectory into the root monorepo directorytypes. I think it doesn't make much sense to havejoy-typesnested inside Pioneer anymore. It is a quite universal library, which is used by many projects, like the CLI, query node, Atlas (?) etc. therefore I think it makes sense for it to be at least at the same level in the directory structure as all those other projects. It allso allows as to consume it inside Pioneer the same way it is consumed by other projects (ie. we have to specify@joystream/types/libas an import, instead of@joystream/types.I removed the nested workspaces in
pioneer/packages.jsonas I figured we don't need to define them twice if they are already defined in rootpackage.jsonviapioneer/packages/*. It seems more clear and less error-prone to have all workspaces defined only once (in the root folder).Defined
clias one of the workspaces in order to test the effect of using shared@joystream/typesamong Pioneer and CLI.The idea behid this structure is that we can run
yarn installin the root directory in order to install and link dependencies for all the workspaces at once and then execute any command in Pioneer workspace ie. by running:yarn workspace pioneer COMMANDWhere COMMAND can be ie.:
build,start,storybooketc.Because Pioneer was very dependent on beeing a monorepo itself (instead of beeing part of a larger monorepo), this turned out not to be possible before making a few adjustments described below.
Yarn, webpack and other issues
In order to make Pioneer work as part of a larger monorepo (with commands like
start,build,storybookandlintremaining usable) I needed to:1 Fix the issue with
yarn.lockbeeing ignoredIf Pioneer's lockfile is removed/ignored, yarn installs some conflicting versions of packages like
multicodec(v0.5andv1.0), which causes Pioneer'sstartscript to fail. When Pioneer becomes just a workspace in a monerepo, it'syarn.lockis no longer respected unless moved into the root directory. This forced me to includeyarn.lockin the root folder as part of the commit.It's probably not good that
yarn.lockis required in order for the Pioneer to work, so we might want to investigate this issue further, this isn't strictly related to the process of moving into the monorepo though (it happens if we removeyarn.lockin the original repository too) and there were a lot of other issues that needed fixing as well, so I decided not to tackle this one now.3.8.3)If we don't specify the exact version of
typescriptin the Pioneer'spackage.json, we might get some newer version due to hoisting, which causes Pioneer build to fail. I fixed it by specifying"typescript": "3.7.2"in Pioneer'spackage.json(this is the version it was using when installed from it's own repository).node_modulesBinaries from some sub-dependency packages like
webpack,@babel/clietc. are not beeing linked in thepioneer/node_modules/.binafter runningyarn installin the root directory unless those packages are specified as direct dependencies of Pioneer. This required adding packages like:@babel/cli,@polkadot/dev,webpack.cpxto Pioneer'spackages.json(I tried using the same versions that would normally get installed).package.json(cannot be found when hoisted)There was some issue with
eslintnot beeing able to find plugins (which were sub-dependencies of ie.@polkadot/dev-react) hoisted to rootnode_modulesalso, so those needed to be specified as direct dev dependencies in Pioneer'spackage.jsontoo. Those include:eslint-config-semistandard,eslint-config-standard,eslint-plugin-import,eslint-plugin-node,eslint-plugin-promiseandeslint-plugin-standardtsconfiglooking for files in./node_modulesAnother issue was that due to relative path to some
node_modulesin Pioneer'stsconfig.json, some files could not be found by the TypeScript compiler. Those paths needed to be changed from./node_modulesto../node_modules.@joystream/typesvs@joystream/types/libBecause
@joystream/typeswas moved to separate workspace, independent from Pioneer, the imports from@joystream/typesneeded to be replaced to imports from@joystream/types/lib. This was also mentioned in: #321I fixed it by executing following replace-by-regex's for all project files:
Replace
from '@joystream/types(?!/lib)tofrom '@joystream/types/libReplace
from "@joystream/types(?!/lib)tofrom "@joystream/types/libReplace
require\('@joystream/types(?!/lib)torequire('@joystream/types/libStrangely enough I noticed that, for example, the
cliwas succesfully using import from@joystream/types(withoutlib) before, even though it was always consuming@joystream/typesexternally. Perhaps it's due tomainbeeing specified intypes/package.json. This may require some further investigating in order to make sure it's resolved correctly.I moved the
.yarncleanfile frompioneerfolder into root folder.I also needed to add
@polkadot/ts/node_modulesthere, because for some reason Yarn was creatingnode_modulesfolder inside@polkadot/ts, which was causing TypeSciprt error and a failure while trying to build Pioneer.Current
.yarncleanlooks as follows:"types": ["node"]in@joystream/typestsconfigThere was a need to add
"types": ["node"]intypes/tsconfig.json. Otherwise some type conflicts betweenjestandmochawere preventingyarn workspace @joystream/types buildfrom running succesfully.pioneer/.storybook/webpack.config.js- needed to add ".js" extensionThere was an error while trying to run
yarn workspace pioneer storybookprobably due to the fact that@joystream/typesworkspace was moved outside Pioneer and webpack wans't configured to process.jsfiles that were coming from there.How to test
While testing this branch I was so far mostly focused on those 3 things:
build,start,storybook,lint)@joystream/typesworkspace between Pioneer and CLI?CLIandPioneerwork correctly?In order to initialize the monorepo (before trying to test anything) there are 2 steps required:
yarn installin the root directory (remove allnode_modulesbefore that if needed).yarn workspace @joystream/types build(in order to build the types, so that the other workspaces can succesfully import them).After that, commands like this should execute succesfully:
yarn workspace pioneer startyarn workspace pioneer buildyarn workspace pioneer storybookyarn workspace pioneer lintIn order to try CLI commands, you can run them like this (from the root directory):
./cli/bin/run council:info