-
Notifications
You must be signed in to change notification settings - Fork 393
update development environment guide #7612
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
base: main
Are you sure you want to change the base?
Conversation
niktayv
left a comment
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 hoped that it would work, but I was unlucky again.
Perhaps I missed something important.
| To use `yarn` workspaces you need to have `yarn` installed globally, recommended version is 1.18.0, and you can install it by running | ||
|
|
||
| ``` | ||
| npm install -g yarn | ||
| npm install -g yarn@^1.19.0 | ||
| ``` |
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.
AFAIK, the version of Yarn is locked in TerriaMap/.yarn/releases/yarn-1.18.0.js, so running just npm install -g yarn would suffice.
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.
We should revisit the version of yarn we use as terriajs CI uses 1.19.0
|
|
||
| Do _not_ commit this change. | ||
|
|
||
| Now, you can clone any package (such as `terriajs` or `terriajs-cesium`) into the `packages` directory: |
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.
Would it be more helpful to keep a mention of the "workspaces" property here?
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.
Not sure what to add here, we already mentioned yarn workspaces and the user should get familiar with what it is to be able to work with it effectively
| Make sure that the `terriamap/package.json` workspaces list contains the following packages: | ||
|
|
||
| - "packages/terriajs-cesium/packages/engine", | ||
| - "packages/terriajs-cesium/packages/widgets" | ||
|
|
||
| Check the versions of `terriajs-cesium` and `terriajs-cesium-widgets` in `terriamap/package.json` and `terriamap/packages/terriajs/package.json` and make sure they are the same so yarn can properly create symlinks. |
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.
This is very illuminating and I hoped that it would resolve my issues, but despite all my efforts, such as double-checking all the versions and package names alignment in the package.json files, running yarn install runs into an error:
$ yarn install
yarn install v1.18.0
[1/5] 🔍 Validating package.json...
[2/5] 🔍 Resolving packages...
[3/5] 🚚 Fetching packages...
[...]
[5/5] 🔨 Building fresh packages...
error /Users/yuri.vyatkin/Terria/TerriaMap/node_modules/terriajs: Command failed.
Exit code: 1
Command: gulp post-npm-install
Arguments:
Directory: /Users/yuri.vyatkin/Terria/TerriaMap/node_modules/terriajs
Output:
[14:51:56] Using gulpfile ~/Terria/TerriaMap/packages/terriajs/gulpfile.js
[14:51:56] Starting 'post-npm-install'...
[14:51:56] Starting 'copy-cesium-assets'...
[14:51:56] Starting 'copy-cesium-source-assets'...
[14:51:56] Finished 'copy-cesium-source-assets' after 68 ms
[14:51:56] Starting 'copy-cesium-workers'...
[14:51:56] 'copy-cesium-workers' errored after 1.31 ms
[14:51:56] Error: ENOENT: no such file or directory, scandir '/Users/yuri.vyatkin/Terria/TerriaMap/packages/terriajs-cesium/packages/engine/Build/Workers'
[14:51:56] 'copy-cesium-assets' errored after 70 ms
[14:51:56] 'post-npm-install' errored after 71 ms
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
$I tried to delete node_modules in all the repos, and tried again, ending up with the same error.
Am I missing something?
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.
Nanda @na9da clarified that we should run npm run release within packages/terriajs-cesium before running yarn install in TerriaMap.
Now, both yarn install and yarn gulp build work fine in TerriaMap.
Given that I have struggled a lot to grasp that, and I am not alone, perhaps we should explain this in the documentation.
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.
added a section above for building cesium packages
| Then run: | ||
|
|
||
| ``` | ||
| yarn install | ||
| ``` |
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.
@zoran995 does running yarn install before building the cesium repo below give an error for you, because post-install terria tries to copy the cesium workers and other assets which it cannot find?
I think before yarn install from terriamap, we need to do:
cd packages/terriajs-cesium
npm install
npm run releaseand then:
yarn install # from terriamapEither that, or fix post-npm-install step in terriajs/gulpfile to not fail when it cannot find the cesium assets.
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.
added a section for installing cesium dependencies and building the package
|
I have no idea about these things so I would like to try to follow the documentation and give some comments. I'm busy tomorrow and Monday, but I will try it on Tuesday. Sorry for not noticing the PR sooner, too many things on my plate right now. |
| In the process described in [Cloning and Building](../customizing/cloning-and-building.md), the [TerriaJS package](https://www.npmjs.com/package/terriajs) is installed to the `node_modules` directory by `yarn install`. Please do not edit TerriaJS directly in the `node_modules` directory, because changes will be clobbered the next time you run `yarn install`. | ||
|
|
||
| Instead, we want to clone TerriaJS from its [GitHub repo](https://github.com/TerriaJS/terriajs) and use that in our TerriaMap build. Traditionally, `npm link` is the way to do this. However, we do not recommend use of `npm link` because it frequently leads to multiple copies of some libraries being installed, which in turn leads to all sorts of frustrating build problems. Instead, we recommend [yarn](https://yarnpkg.com) and its [workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) feature. `yarn` workspaces let us safely clone a git repo into the `packages` directory and wire it into any other packages that use it. | ||
| Instead, we want to clone TerriaJS from its [GitHub repo](https://github.com/TerriaJS/terriajs) and use that in our TerriaMap build. Traditionally, `npm link` is the way to do this. However, we do not recommend use of `npm link` because it frequently leads to multiple copies of some libraries being installed, which in turn leads to all sorts of frustrating build problems. Instead, we recommend and use [yarn](https://yarnpkg.com) and its [workspaces](https://yarnpkg.com/lang/en/docs/workspaces/) feature. `yarn` workspaces let us safely clone a git repo into the `packages` directory and wire it into any other packages that use it. |
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 paragraph reflects the state of things when it was written, but of the projects I've come across from looking at TerriaMap it's quite common of them to use yarn or pnpm so I would guess the average JavaScript developer are already somewhat aware of these tools existence. Can the (old?) npm link-stuff be removed, and the first sentence in this section start with:
To [something] we use yarn workspaces which lets us safely clone a git repository into the packages directory and wire it into any other packages that use it
?
| yarn install | ||
| ``` | ||
|
|
||
| ## Making the changes in cesium |
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.
Just grabbing a random point in the diff: Cesium is a name, so it should have capital C in text/headings. (They call it CesiumJS in their own documentation, so maybe that is the name that should be used here as well.)
|
|
||
| And then run: | ||
| ```sh | ||
| npm run release |
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.
If you add a cd terriajs-cesium on the first line in this block, it's harder for a tunnel-visioning user to miss the instruction in the text.
| npm run build-ts | ||
| ``` | ||
|
|
||
| Make sure that the `terriamap/package.json` workspaces list contains the following packages: |
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.
Can this paragraph be removed after your TerriaMap-PR is merged?
|
|
||
| ## Making the changes in cesium | ||
|
|
||
| Cesium uses npm so you should use it instead of yarn when installing dependencies and running commands inside cesium repo. After making the changes you will need to run: |
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.
If the text doesn't mention yarn, it reduces the risk that a user might skim the text quickly and remember the wrong words:
Cesium uses npm, so use
npmwhen installing dependencies and running commands inside the Cesium repository. After making changes you will need to run:
| npm run build-ts | ||
| ``` | ||
|
|
||
| to build the code and generate Typescript types definitions required for Terria to work correctly. For more details on building the cesium and coding guidelines consult the [cesium documentation](https://github.com/CesiumGS/cesium/tree/main/Documentation) |
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.
"Typescript types definitions" => "TypeScript type definitions"
"on building the cesium" => "on building Cesium"
|
|
||
| What if you need to make changes to [Cesium](https://github.com/AnalyticalGraphicsInc/cesium) while working on TerriaJS? | ||
|
|
||
| TerriaJS is using a fork of Cesium monorepo located at https://github.com/terriajs/cesium, and similar to the upstream repo it consists of two packages: |
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.
"of Cesium monorepo" => "of the Cesium monorepo"
|
|
||
| Now, you can clone any package (such as `terriajs` or `terriajs-cesium`) into the `packages` directory: | ||
|
|
||
| ``` |
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.
Comment for next line:
For discoverability: can a packages directory containing a README.md be added to the TerriaMap repository? The directory is already in TerriaMap's .gitignore so people will not mistakenly git add more things there. The README can just contain:
This is the directory for yarn workspaces used during development. See [link to this documentation] for how to configure workspaces for TerriaMap.
|
I know nothing about JavaScript/TypeScript development, but I tested following the I managed to build TerriaJS/TerriaMap, and could run Line 23: Line 29: Line 51: Yarn v1 doesn't de-duplicate things completely, so unless Terria is about to upgrade to Yarn v2, it would be nice to weaken that sentence so the user doesn't believe they did something wrong when there are (some) duplicates in Line 55: discusses verifying that |
| @@ -1,23 +1,59 @@ | |||
| ## Working on TerriaJS and Cesium | |||
|
|
|||
| What if you need to make changes to [Cesium](https://github.com/AnalyticalGraphicsInc/cesium) while working on TerriaJS? | |||
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.
Should this link be updated to point to the Cesium in the CesiumGS project?

What this PR does
Depends on TerriaJS/TerriaMap#746
TerriaMap has been configured with workspaces for some time, so we should update the docs to reflect this.
Test me
How should reviewers test this? (Hint: If you want to provide a test catalog item, create a Gist of its catalog JSON, add its url and your branch name to this url:
http://ci.terria.io/<branch name>/#clean&<raw url of your gist>, and then paste that in the body of this PR)Checklist
There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)doc/.