From 50e17acfac5bba87ac55eb83b5e20033b06070fe Mon Sep 17 00:00:00 2001 From: lizschwab Date: Wed, 26 Aug 2026 12:17:36 -0700 Subject: [PATCH 1/4] chore: update plugin copy and predeploy scripts to point to new location --- package.json | 2 +- scripts/copy-blockly.js | 2 +- scripts/gh-predeploy.js | 39 +++++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index b8a8217f8..86e0ed2ca 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "clean": "lerna run clean --scope '@blockly/*'", "deploy:prepare": "npm run deploy:prepare:plugins && npm run deploy:prepare:examples && gulp predeploy", "deploy:prepare:examples": "npm install --workspace=examples && npm run prepare-examples && npm run predeploy --if-present --workspace=examples", - "deploy:prepare:plugins": "npm run clean && npm run build && lerna run predeploy --scope '@blockly/*'", + "deploy:prepare:plugins": "cd ../blockly && npx nx reset && lerna run clean --scope '@blockly/*' && lerna run build --scope '@blockly/*' && lerna run predeploy --scope '@blockly/*'", "deploy": "npm run deploy:prepare && gulp deploy", "deploy:upstream": "npm run deploy:prepare && gulp deployUpstream", "format": "prettier --write .", diff --git a/scripts/copy-blockly.js b/scripts/copy-blockly.js index cd466413c..dc188d24d 100644 --- a/scripts/copy-blockly.js +++ b/scripts/copy-blockly.js @@ -49,7 +49,7 @@ const {copyDirectoryContents} = require('./copy-helpers'); // Also copy local workspace plugins from the `plugins/` directory (this repo). try { - const pluginsDir = path.resolve(__dirname, '..', 'plugins'); + const pluginsDir = path.resolve(__dirname, '..', '..', 'blockly', 'packages', 'plugins'); const pluginDirs = await fs.readdir(pluginsDir, {withFileTypes: true}); const copiedLocal = []; for (const d of pluginDirs) { diff --git a/scripts/gh-predeploy.js b/scripts/gh-predeploy.js index a5f5e1ec7..4b37b7e53 100644 --- a/scripts/gh-predeploy.js +++ b/scripts/gh-predeploy.js @@ -20,6 +20,8 @@ const {copyFilesWithBase, copyDirectoryContents} = require('./copy-helpers'); const appDirectory = fs.realpathSync(process.cwd()); const resolveApp = (relativePath) => path.resolve(appDirectory, relativePath); +const PLUGIN_FOLDER_PATH = path.join('..', 'blockly', 'packages', 'plugins'); + /** * Inject head HTML for a plugin or example page on gh-pages. * @param {string} initialContents The initial page HTML, as a string. @@ -209,8 +211,9 @@ function createExampleTabs(pageRoot, pages, isLocal) { * building for gh-pages. */ function createPluginPage(pluginDir, isLocal) { - const packageJson = require(resolveApp(`plugins/${pluginDir}/package.json`)); - const initialPath = path.join('plugins', pluginDir, 'test', 'index.html'); + const pluginPath = path.join(PLUGIN_FOLDER_PATH, pluginDir); + const packageJson = require(resolveApp(path.join(pluginPath, 'package.json'))); + const initialPath = path.join(pluginPath, 'test', 'index.html'); const initialContents = fs.readFileSync(initialPath).toString(); let contents = injectHeader( @@ -236,9 +239,9 @@ function createPluginPage(pluginDir, isLocal) { * building for gh-pages. */ function createReadmePage(pluginDir, isLocal) { - const packageJson = require(resolveApp(`plugins/${pluginDir}/package.json`)); + const packageJson = require(resolveApp(path.join(PLUGIN_FOLDER_PATH, pluginDir, 'package.json'))); const initialContents = fs - .readFileSync(`./plugins/${pluginDir}/README.md`) + .readFileSync(path.join(PLUGIN_FOLDER_PATH, pluginDir, 'README.md')) .toString(); const converter = new showdown.Converter(); @@ -279,9 +282,9 @@ function createReadmePage(pluginDir, isLocal) { modifiedContents = injectFooter(modifiedContents); // Make sure the directory exists, then write to it. - const dirString = `./gh-pages/plugins/${pluginDir}/`; - fs.mkdirSync(dirString, {recursive: true}); - fs.writeFileSync(`${dirString}/README.html`, modifiedContents, 'utf-8'); + const dirPath = path.join('gh-pages', 'plugins', pluginDir); + fs.mkdirSync(dirPath, {recursive: true}); + fs.writeFileSync(path.join(dirPath, 'README.html'), modifiedContents, 'utf-8'); } /** @@ -295,11 +298,12 @@ function preparePlugin(pluginDir, isLocal) { console.log(`Preparing ${pluginDir} plugin for deployment.`); createPluginPage(pluginDir, isLocal); createReadmePage(pluginDir, isLocal); - copyFilesWithBase( - [path.join('plugins', pluginDir, 'build', 'test_bundle.js')], - 'plugins', - path.join('gh-pages', 'plugins'), - ); + const testBundleFilePath = path.join(PLUGIN_FOLDER_PATH, pluginDir, 'build', 'test_bundle.js'); + const destinationFilePath = path.join('gh-pages', 'plugins', pluginDir, 'build', 'test_bundle.js'); + if (fs.existsSync(testBundleFilePath) && fs.statSync(testBundleFilePath).isFile()) { + fs.mkdirSync(path.dirname(destinationFilePath), {recursive: true}); + fs.copyFileSync(testBundleFilePath, destinationFilePath); + } } /** @@ -308,13 +312,12 @@ function preparePlugin(pluginDir, isLocal) { * for deployment to GitHub Pages. */ function getPluginFolders() { - const dir = 'plugins'; - return fs.readdirSync(dir).filter(function (file) { + return fs.readdirSync(PLUGIN_FOLDER_PATH).filter(function (file) { return ( - fs.statSync(path.join(dir, file)).isDirectory() && - fs.existsSync(path.join(dir, file, 'package.json')) && + fs.statSync(path.join(PLUGIN_FOLDER_PATH, file)).isDirectory() && + fs.existsSync(path.join(PLUGIN_FOLDER_PATH, file, 'package.json')) && // Only prepare plugins with test pages. - fs.existsSync(path.join(dir, file, '/test/index.html')) + fs.existsSync(path.join(PLUGIN_FOLDER_PATH, file, '/test/index.html')) ); }); } @@ -483,7 +486,7 @@ function prepareExample(exampleDir, isLocal, done) { const pages = fileList.filter((f) => pageRegex.test(f)); // Add headers and footers to HTML pages. pages.forEach((page) => - createExamplePage(`${baseDir}/${exampleDir}`, page, demoConfig, isLocal), + createExamplePage(path.join(baseDir, exampleDir), page, demoConfig, isLocal), ); // Copy over all other files mentioned in the demoConfig to the From 6087b555a0d4b14cd59db144db4ad749fa38b060 Mon Sep 17 00:00:00 2001 From: lizschwab Date: Wed, 26 Aug 2026 12:30:32 -0700 Subject: [PATCH 2/4] chore: update github actions workflow --- .github/workflows/update_gh_pages.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/update_gh_pages.yml b/.github/workflows/update_gh_pages.yml index f4ad1dcfb..6c723b0bb 100644 --- a/.github/workflows/update_gh_pages.yml +++ b/.github/workflows/update_gh_pages.yml @@ -5,8 +5,13 @@ name: Update GitHub Pages on: workflow_dispatch: # Manually trigger. Colon is required. inputs: - branch: - description: 'Branch to publish from' + samples_branch: + description: 'Blockly-Samples branch to publish from (for examples)' + required: true + default: 'main' + type: string + core_branch: + description: 'Blockly core branch to publish from for (plugins)' required: true default: 'main' type: string @@ -20,10 +25,18 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout Blockly-Samples + uses: actions/checkout@v3 + with: + ref: ${{ inputs.samples_branch || 'main' }} + path: blockly-samples + + - name: Checkout Blockly uses: actions/checkout@v3 with: - ref: ${{ inputs.branch || 'main' }} + repository: 'RaspberryPiFoundation/blockly' + ref: ${{ inputs.core_branch || 'main' }} + path: blockly - name: Setup Node uses: actions/setup-node@v3 From 0b5c8bedfaaf1a284dffbe015abfd1a81b59050a Mon Sep 17 00:00:00 2001 From: lizschwab Date: Wed, 26 Aug 2026 12:42:14 -0700 Subject: [PATCH 3/4] chore: formatting --- scripts/copy-blockly.js | 9 ++++++++- scripts/gh-predeploy.js | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/scripts/copy-blockly.js b/scripts/copy-blockly.js index dc188d24d..3b555a0b8 100644 --- a/scripts/copy-blockly.js +++ b/scripts/copy-blockly.js @@ -49,7 +49,14 @@ const {copyDirectoryContents} = require('./copy-helpers'); // Also copy local workspace plugins from the `plugins/` directory (this repo). try { - const pluginsDir = path.resolve(__dirname, '..', '..', 'blockly', 'packages', 'plugins'); + const pluginsDir = path.resolve( + __dirname, + '..', + '..', + 'blockly', + 'packages', + 'plugins', + ); const pluginDirs = await fs.readdir(pluginsDir, {withFileTypes: true}); const copiedLocal = []; for (const d of pluginDirs) { diff --git a/scripts/gh-predeploy.js b/scripts/gh-predeploy.js index 4b37b7e53..146af1994 100644 --- a/scripts/gh-predeploy.js +++ b/scripts/gh-predeploy.js @@ -212,7 +212,9 @@ function createExampleTabs(pageRoot, pages, isLocal) { */ function createPluginPage(pluginDir, isLocal) { const pluginPath = path.join(PLUGIN_FOLDER_PATH, pluginDir); - const packageJson = require(resolveApp(path.join(pluginPath, 'package.json'))); + const packageJson = require( + resolveApp(path.join(pluginPath, 'package.json')), + ); const initialPath = path.join(pluginPath, 'test', 'index.html'); const initialContents = fs.readFileSync(initialPath).toString(); @@ -239,7 +241,9 @@ function createPluginPage(pluginDir, isLocal) { * building for gh-pages. */ function createReadmePage(pluginDir, isLocal) { - const packageJson = require(resolveApp(path.join(PLUGIN_FOLDER_PATH, pluginDir, 'package.json'))); + const packageJson = require( + resolveApp(path.join(PLUGIN_FOLDER_PATH, pluginDir, 'package.json')), + ); const initialContents = fs .readFileSync(path.join(PLUGIN_FOLDER_PATH, pluginDir, 'README.md')) .toString(); @@ -284,7 +288,11 @@ function createReadmePage(pluginDir, isLocal) { // Make sure the directory exists, then write to it. const dirPath = path.join('gh-pages', 'plugins', pluginDir); fs.mkdirSync(dirPath, {recursive: true}); - fs.writeFileSync(path.join(dirPath, 'README.html'), modifiedContents, 'utf-8'); + fs.writeFileSync( + path.join(dirPath, 'README.html'), + modifiedContents, + 'utf-8', + ); } /** @@ -298,9 +306,23 @@ function preparePlugin(pluginDir, isLocal) { console.log(`Preparing ${pluginDir} plugin for deployment.`); createPluginPage(pluginDir, isLocal); createReadmePage(pluginDir, isLocal); - const testBundleFilePath = path.join(PLUGIN_FOLDER_PATH, pluginDir, 'build', 'test_bundle.js'); - const destinationFilePath = path.join('gh-pages', 'plugins', pluginDir, 'build', 'test_bundle.js'); - if (fs.existsSync(testBundleFilePath) && fs.statSync(testBundleFilePath).isFile()) { + const testBundleFilePath = path.join( + PLUGIN_FOLDER_PATH, + pluginDir, + 'build', + 'test_bundle.js', + ); + const destinationFilePath = path.join( + 'gh-pages', + 'plugins', + pluginDir, + 'build', + 'test_bundle.js', + ); + if ( + fs.existsSync(testBundleFilePath) && + fs.statSync(testBundleFilePath).isFile() + ) { fs.mkdirSync(path.dirname(destinationFilePath), {recursive: true}); fs.copyFileSync(testBundleFilePath, destinationFilePath); } @@ -486,7 +508,12 @@ function prepareExample(exampleDir, isLocal, done) { const pages = fileList.filter((f) => pageRegex.test(f)); // Add headers and footers to HTML pages. pages.forEach((page) => - createExamplePage(path.join(baseDir, exampleDir), page, demoConfig, isLocal), + createExamplePage( + path.join(baseDir, exampleDir), + page, + demoConfig, + isLocal, + ), ); // Copy over all other files mentioned in the demoConfig to the From a0e98496bf94a38c0a021e074d4cca537687e615 Mon Sep 17 00:00:00 2001 From: lizschwab Date: Wed, 26 Aug 2026 12:44:06 -0700 Subject: [PATCH 4/4] chore: grammar --- .github/workflows/update_gh_pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update_gh_pages.yml b/.github/workflows/update_gh_pages.yml index 6c723b0bb..101a2c3b5 100644 --- a/.github/workflows/update_gh_pages.yml +++ b/.github/workflows/update_gh_pages.yml @@ -11,7 +11,7 @@ on: default: 'main' type: string core_branch: - description: 'Blockly core branch to publish from for (plugins)' + description: 'Blockly core branch to publish from (for plugins)' required: true default: 'main' type: string