Skip to content

Sandcastle Reborn #12574

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

Merged
merged 22 commits into from
May 9, 2025
Merged

Sandcastle Reborn #12574

merged 22 commits into from
May 9, 2025

Conversation

jjspace
Copy link
Contributor

@jjspace jjspace commented Apr 18, 2025

Description

Starting work on rebuilding Sandcastle. Currently this branch has the scrapped together hackathon code. This branch and PR will act as a staging branch for the work involved in the whole process. See #12566 for more details

  • Added a new package packages/sandcastle to encapsulate the new Vite + React + Typescript project
  • Set up the Vite build to output into Apps/Sandcastle2 (temporary path)
    • Running both the vite dev server and the static files from the normal CesiumJS dev server should behave the same. This requires a bit of extra config to make sure routes for assets and sample data line up. Should be working now but may require some finagling later if we change routes.

TODO:

  • Set up CI deployment

Issue number and link

Fixes #12566

Testing plan

From the top level

  • Run npm run build-sandcastle
  • Run npm start
  • Navigate to http://localhost:8080/Apps/Sandcastle2/index.html

From inside packages/sandcastle for direct development of sandcastle

  • Run npm run dev for the dev server build
  • Navigate to http://localhost:5173/

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@jjspace jjspace requested a review from ggetz April 18, 2025 15:37
Copy link

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

@jjspace jjspace marked this pull request as draft April 18, 2025 15:43
@ggetz
Copy link
Contributor

ggetz commented Apr 24, 2025

Wahoo! @jjspace could you get this PR targeting to a feature branch for sandcastle v2? That way we can have smaller, iterative PRs as needed.

Copy link
Contributor

@ggetz ggetz left a comment

Choose a reason for hiding this comment

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

Works great so far! I haven't reviewed any of the app code itself, since as I understand it is very much in flux. But I do have some thoughts on the overall configuration.

@jjspace
Copy link
Contributor Author

jjspace commented Apr 24, 2025

could you get this PR targeting to a feature branch for sandcastle v2? That way we can have smaller, iterative PRs as needed.

@ggetz I was expecting this branch/PR to be that feature branch. I was thinking of developing directly here until the build system is mostly sorted then do smaller PRs into this branch for review as needed. Where you thinking differently?

@ggetz
Copy link
Contributor

ggetz commented Apr 24, 2025

To keep things clean, let's target a new staging branch. That way we can merge this and keep the PR list tidy. Well... tidier.

@jjspace jjspace changed the base branch from main to sandcastle-v2 May 2, 2025 16:18
@jjspace
Copy link
Contributor Author

jjspace commented May 5, 2025

@ggetz CI is now working properly on this branch https://ci-builds.cesium.com/cesium/sandcastle-reborn/Apps/Sandcastle2/index.html

There may be some more things to clean up but I believe that everything with the builds is set up to work in whatever environment we put it in, CI being the hardest. Might be able to make it "nicer" but what's there should work so I think it's good enough for now. Please take a peek at the new vite configs specifically and make sure CI, local (through build-app then npm start) and dev (through run dev) all work.

@jjspace
Copy link
Contributor Author

jjspace commented May 6, 2025

For testing I found it really helpful to mimic the way it's set up on the CI server to avoid having to push it up and wait for the actual CI deploy every change.

In whatever starting directory you want:

mkdir local-ci-test && cd local-ci-test
mkdir cesium && cd cesium
mkdir branch && cd branch
ln -s [path to cesium]/Apps
ln -s [path to cesium]/Build
ln -s [path to cesium]/Source
cd ../../
npx http-server --port 8081

Then navigate to http://localhost:8081/cesium/branch/Apps/Sandcastle2/

(a --base-dir setting has been added to http-server which would be super helpful here but it's not been released yet)

@ggetz
Copy link
Contributor

ggetz commented May 7, 2025

Thanks or the updates @jjspace! I'll take a review pass on this shortly. I assume this PR is good to be marked "Ready for review"?

@jjspace jjspace mentioned this pull request May 7, 2025
6 tasks
@jjspace
Copy link
Contributor Author

jjspace commented May 8, 2025

@ggetz yes I think for now this is good to review, I can make further changes in subsequent PRs

@jjspace jjspace marked this pull request as ready for review May 8, 2025 15:34
Copy link
Contributor

@ggetz ggetz left a comment

Choose a reason for hiding this comment

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

@jjspace Nice, this all looks like a solid base to build on top of. I have a few comments, but have indicated where I wouldn't expect some them to hold up this PR getting merged.

@@ -34,6 +35,9 @@ packages/widgets/Build/**
packages/widgets/index.js
packages/widgets/Source/ThirdParty/**

packages/sandcastle/node_modules/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Would a blanket **/node_modules/** rule work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

technically yes but I think we specifically want it to be obvious when dependencies are messed up and it creates a node_modules inside the other two packages since that's undesired.

@@ -34,6 +35,9 @@ packages/widgets/Build/**
packages/widgets/index.js
packages/widgets/Source/ThirdParty/**

packages/sandcastle/node_modules/**
Apps/Sandcastle2/**
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we signal that this is built output by putting it in a Build folder?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly but potentially not very easily given how files are accessed, specifically the sample data. I'd like to leave it here for now to mimic the existing sandcastle as much as possible.

rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be "warn" or "error"? Right now, warnings will not be indicating when running our eslint command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly. This was a direct copy out of the generated file from the vite setup just to make it work with the flat eslint config. I honestly didn't really look at what was set or not set yet, completely open to review if you want to take a stab at changing this and extracting like you mention in the other comment.

Comment on lines +82 to +105
...[...tseslint.configs.recommended].map((config) => ({
// This is needed to restrict to a specific path unless using the tseslint.config function
// https://typescript-eslint.io/packages/typescript-eslint#config
...config,
files: ["packages/sandcastle/**/*.{ts,tsx}"],
})),
{
// This config came from the vite project generation
files: ["packages/sandcastle/**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder... To help isolate things a bit more, can we defined the following config in a standalone file and just import it here? I may look into this a bit. No need to hold up the PR.

export default defineConfig(() => {
const cesiumBaseUrl = `${process.env.BASE_URL}Build/CesiumUnminified`;

console.log("Building Sandcastle with base url:", cesiumBaseUrl);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this console.log left here intentionally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought it was helpful to be able to see in the CI output if/when there are issues. Maybe not needed but also don't think it hurts?

@jjspace
Copy link
Contributor Author

jjspace commented May 9, 2025

@ggetz ready again

@ggetz
Copy link
Contributor

ggetz commented May 9, 2025

Awesome, thanks @jjspace!

@ggetz ggetz merged commit 0e3c658 into sandcastle-v2 May 9, 2025
9 checks passed
@ggetz ggetz deleted the sandcastle-reborn branch May 9, 2025 20:39
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.

Rebuilding Sandcastle: Technical Implementation
2 participants