-
Notifications
You must be signed in to change notification settings - Fork 394
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,28 +6,14 @@ What if you need to make changes to [TerriaJS](https://github.com/TerriaJS/terri | |
|
|
||
| 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. | ||
|
|
||
| First, install `yarn` globally: | ||
| To use `yarn` workspaces you need to have `yarn` installed globally, and you can install it by running | ||
|
|
||
| ``` | ||
| npm install -g yarn | ||
| ``` | ||
|
|
||
| If you already have yarn installed, make sure it is at least v1.0 (we recommend using the latest version). Older versions do not support the workspace feature. | ||
|
|
||
| Then, enable workspaces by editing the TerriaMap `package.json` file, adding these lines to the top, just after the opening `{`: | ||
|
|
||
| ```json | ||
| "private": true, | ||
| "workspaces": { | ||
| "packages": ["packages/*"], | ||
| "nohoist": ["**/husky"] | ||
| }, | ||
| ``` | ||
|
|
||
| Do _not_ commit this change. | ||
|
|
||
| Now, you can clone any package (such as `terriajs` or `terriajs-cesium`) into the `packages` directory: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be more helpful to keep a mention of the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
|
||
| ``` | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Comment for next line: For discoverability: can a
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,22 +2,58 @@ | |
|
|
||
| What if you need to make changes to [Cesium](https://github.com/AnalyticalGraphicsInc/cesium) while working on TerriaJS? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? |
||
|
|
||
| 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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "of Cesium monorepo" => "of the Cesium monorepo" |
||
|
|
||
| - [terriajs-cesium](https://www.npmjs.com/package/terriajs-cesium) corresponds to the upstream [@cesium/engine](https://www.npmjs.com/package/@cesium/engine/) | ||
| - [terriajs-cesium-widgets](https://www.npmjs.com/package/terriajs-cesium-widgets) corresponds to the upstream [@cesium/widgets](https://www.npmjs.com/package/@cesium/widgets/) | ||
|
|
||
| The process of using a custom version of Cesium is much the same as using a custom version of TerriaJS. See the [Development Environment](development-environment.md#building-a-terriamap-against-a-modified-terriajs) for information on setting up and using `yarn`. To clone Cesium, do: | ||
|
|
||
| ``` | ||
| ```sh | ||
| cd packages | ||
| git clone -b terriajs https://github.com/TerriaJS/cesium.git | ||
| cd .. | ||
| git clone https://github.com/TerriaJS/cesium.git terriajs-cesium | ||
zoran995 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| It is important that you use the `terriajs` branch of [TerriaJS/cesium](https://github.com/TerriaJS/cesium) because it contains important changes to Cesium that are necessary for it to work with TerriaJS. If you need to use a different branch of Cesium, you will need to merge that branch with the changes in the `terriajs` branch. | ||
| After cloning the repository, navigate to the `terriajs-cesium` directory and run the following commands to build the Cesium packages and generate TypeScript definitions: | ||
|
|
||
| And then run: | ||
| ```sh | ||
| npm run release | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you add a |
||
|
|
||
| # OR | ||
|
|
||
| npm install | ||
| npm run build | ||
| npm run build-ts | ||
| ``` | ||
|
|
||
| Make sure that the `terriamap/package.json` workspaces list contains the following packages: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this paragraph be removed after your TerriaMap-PR is merged? |
||
|
|
||
| - "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. | ||
|
Comment on lines
+29
to
+34
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 $ 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nanda @na9da clarified that we should run Given that I have struggled a lot to grasp that, and I am not alone, perhaps we should explain this in the documentation.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a section above for building cesium packages |
||
|
|
||
| Then run: | ||
|
|
||
| ``` | ||
| yarn install | ||
| ``` | ||
|
Comment on lines
+36
to
40
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zoran995 does running I think before cd packages/terriajs-cesium
npm install
npm run releaseand then: yarn install # from terriamapEither that, or fix
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a section for installing cesium dependencies and building the package |
||
|
|
||
| ## Making the changes in cesium | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.) |
||
|
|
||
| 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: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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:
|
||
|
|
||
| ```sh | ||
| npm run release | ||
|
|
||
| # OR | ||
|
|
||
| npm run build | ||
| 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) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Typescript types definitions" => "TypeScript type definitions" |
||
|
|
||
| ## Committing modifications | ||
|
|
||
| If you make changes to Cesium and TerriaJS together, here's the process for getting them to production. | ||
|
|
@@ -38,4 +74,4 @@ Replace `branchName` with the name of the Cesium branch you want to use. You may | |
|
|
||
| Once your Cesium pull request has been merged and a new version of the `terriajs-cesium` npm module has been published, please remember to update `package.json` to point to an official `terriajs-cesium` version instead of a branch in a GitHub repo. | ||
|
|
||
| The `package.json` in the `master` branch should always point to official releases of `terriajs-cesium` on npm, NOT GitHub branches. | ||
| The `package.json` in the `main` branch should always point to official releases of `terriajs-cesium` on npm, NOT GitHub branches. | ||

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:
?