-
Notifications
You must be signed in to change notification settings - Fork 12
1287 library assets url #1479
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
1287 library assets url #1479
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
4d61522
feat: change to get the library host url prop working
DNR500 eb9dc48
feat: use library temple from env for scratch assets
DNR500 afbad2f
docs: update README with details for working with scratch editor locally
DNR500 b13863d
docs: update the readme to use the correct scratch commands
DNR500 3c58cf5
feat: use RPF scratch editor with image assets
DNR500 5d235c2
build: make sure the CDN is used on all environments
DNR500 d1cdca5
build: ensure use of NPM_AUTH_TOKEN
DNR500 b372476
chore: clean up github workflows
DNR500 6f0287c
docs: update PAT section
DNR500 5b1120d
docs: move scratch instructions
DNR500 0039d63
chore: remove library url from env vars
DNR500 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| @RaspberryPiFoundation:registry=https://npm.pkg.github.com | ||
| //npm.pkg.github.com/:_authToken=${NPM_AUTH_TOKEN} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| # Linking a local scratch-editor (Scratch GUI) | ||
|
|
||
| When you are working on the [Raspberry Pi Foundation scratch-editor](https://github.com/RaspberryPiFoundation/scratch-editor) fork (for example changes to `scratch-gui`), you may want editor-ui to load that build instead of the `@RaspberryPiFoundation/scratch-gui` version from GitHub Packages. | ||
|
|
||
| **Use the `code-classroom` branch** in scratch-editor as your base for editor-ui work. That branch is the integration line for this editor (RPF packaging, publish, and GUI props such as `libraryAssetUrlTemplate`). Check it out before you link or build: | ||
|
|
||
| ```bash | ||
| cd ../scratch-editor | ||
| git fetch origin | ||
| git checkout code-classroom | ||
| ``` | ||
|
|
||
| Feature work should branch from `code-classroom`, not from upstream `main` or `code-classroom-base`. | ||
|
|
||
| editor-ui does not bundle Scratch GUI into the main webpack app. It copies a prebuilt `dist/scratch-gui.js` (and static assets) from `node_modules` into the dev server output. Pointing the dependency at your local clone is enough to test GUI changes in the Scratch iframe. | ||
|
|
||
| **Do not commit these linking changes.** They are temporary for local development only. These changes to `package.json`, `yarn.lock`, and `docker-compose.yml` are for local development only. | ||
|
|
||
| ## Repository layout | ||
|
|
||
| Clone both repositories as siblings: | ||
|
|
||
| ```text | ||
| Development/ | ||
| editor-ui/ | ||
| scratch-editor/ ← github.com/RaspberryPiFoundation/scratch-editor | ||
| ``` | ||
|
|
||
| ## Temporary changes in editor-ui | ||
|
|
||
| **1. `package.json`** — replace the GitHub Packages dependency with a file link (the name must match the package in scratch-editor): | ||
|
|
||
| ```json | ||
| "@RaspberryPiFoundation/scratch-gui": "file:../scratch-editor/packages/scratch-gui" | ||
| ``` | ||
|
|
||
| **2. `docker-compose.yml`** — mount the scratch-editor repo into the container (read-only): | ||
|
|
||
| ```yaml | ||
| volumes: | ||
| - .:/app | ||
| - ../scratch-editor:/scratch-editor:ro | ||
| - node_modules:/app/node_modules | ||
| ``` | ||
|
|
||
| From `/app` in the container, `file:../scratch-editor/packages/scratch-gui` resolves to `/scratch-editor/packages/scratch-gui` on the mounted volume. | ||
|
|
||
| **3. `yarn.lock`** — run `yarn install` inside Docker (see below) and commit nothing; the lockfile will change while the link is active. Revert it when you restore the GitHub Packages version in `package.json`. | ||
|
|
||
| ## Build scratch-gui | ||
|
|
||
| Build on your machine (the `scratch-editor` mount is read-only inside the editor-ui container): | ||
|
|
||
| ```bash | ||
| cd ../scratch-editor | ||
| nvm install | ||
| nvm use | ||
| NODE_ENV=development npm ci | ||
| npm run build | ||
| ``` | ||
|
|
||
| After every scratch-gui code change, run the build again, then restart the editor-ui container so webpack copies the new `dist/scratch-gui.js`. | ||
|
|
||
| ## Run with Docker | ||
|
|
||
| **editor-api** (Scratch projects and assets API): | ||
|
|
||
| ```bash | ||
| cd ../editor-api | ||
| docker compose up | ||
| ``` | ||
|
|
||
| **editor-ui**: | ||
|
|
||
| ```bash | ||
| cd ../editor-ui | ||
| docker compose up | ||
| ``` | ||
|
|
||
| The container runs `yarn install` then `yarn start` on each start. The first start after switching to the file link may take longer while dependencies are linked. | ||
|
|
||
| ## Verify in the browser | ||
|
|
||
| Scratch runs in an iframe served from editor-ui (port **3011**), not from the main web-component bundle alone. | ||
|
|
||
| - Web component test page: open a **Scratch** sample, e.g. | ||
| `http://localhost:3011/web-component.html` | ||
| then choose **cool-scratch**. | ||
| - **editor-standalone** (port **3012**): also loads the web component from `http://localhost:3011`; open a Scratch project under `/en-US/projects/…` with editor-ui and editor-api running. | ||
|
|
||
| ## Revert when finished | ||
|
|
||
| 1. Restore the GitHub Packages pin in `package.json`, for example: | ||
|
|
||
| ```json | ||
| "@RaspberryPiFoundation/scratch-gui": "13.7.3-code-classroom.20260522151700" | ||
| ``` | ||
|
|
||
| Use the version your branch pins (see [scratch-gui on GitHub Packages](https://github.com/RaspberryPiFoundation/scratch-editor/pkgs/npm/scratch-gui)). | ||
| 2. Remove the `../scratch-editor:/scratch-editor:ro` volume from `docker-compose.yml`. | ||
| 3. Revert `yarn.lock` (e.g. `git checkout -- yarn.lock`) or run `yarn install` again after restoring `package.json`. | ||
| 4. Restart `docker compose up` in editor-ui. | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.