From 681a70678c719fc6834e6dfe3c3ea3a3a4be6759 Mon Sep 17 00:00:00 2001 From: Amanuel Sisay Date: Fri, 16 Jan 2026 16:16:07 +0100 Subject: [PATCH 1/4] feat: allow consuming permutations view from build-tools --- .gitignore | 1 + package.json | 6 ++++-- pages/alert/permutations.page.tsx | 9 ++++++--- scripts/setup-build-tools.js | 33 +++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100755 scripts/setup-build-tools.js diff --git a/.gitignore b/.gitignore index db3d62b944..7b45ddd722 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ vendor/generated-*.txt .vscode # System .DS_Store +shared/ \ No newline at end of file diff --git a/package.json b/package.json index a1e0af2f3d..46b0df1ecb 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,8 @@ "start:integ": "cross-env NODE_ENV=development webpack serve --config pages/webpack.config.integ.cjs", "start:react18": "npm-run-all --parallel start:watch start:react18:dev", "start:react18:dev": "cross-env NODE_ENV=development REACT_VERSION=18 webpack serve --config pages/webpack.config.cjs", - "prepare": "husky" + "prepare": "husky", + "preinstall": "node ./scripts/setup-build-tools" }, "dependencies": { "@cloudscape-design/collection-hooks": "^1.0.0", @@ -53,7 +54,8 @@ "@babel/core": "^7.23.7", "@babel/plugin-syntax-typescript": "^7.23.3", "@cloudscape-design/browser-test-tools": "^3.0.0", - "@cloudscape-design/build-tools": "github:cloudscape-design/build-tools#main", + "@cloudscape-design/build-tools-repo": "github:cloudscape-design/build-tools#add-test-pages-util-permutation-view", + "@cloudscape-design/build-tools": "file:./shared/build-tools", "@cloudscape-design/documenter": "^1.0.0", "@cloudscape-design/global-styles": "^1.0.0", "@cloudscape-design/jest-preset": "^2.0.0", diff --git a/pages/alert/permutations.page.tsx b/pages/alert/permutations.page.tsx index 0521f7a537..a5d4626852 100644 --- a/pages/alert/permutations.page.tsx +++ b/pages/alert/permutations.page.tsx @@ -2,13 +2,13 @@ // SPDX-License-Identifier: Apache-2.0 import React from 'react'; +import { createPermutations, PermutationsView } from '@cloudscape-design/build-tools/lib/dev-pages-utils'; + import Alert, { AlertProps } from '~components/alert'; import Button from '~components/button'; import ExpandableSection from '~components/expandable-section'; import Link from '~components/link'; -import createPermutations from '../utils/permutations'; -import PermutationsView from '../utils/permutations-view'; import ScreenshotArea from '../utils/screenshot-area'; import { i18nStrings } from './common'; @@ -111,7 +111,10 @@ export default function AlertScenario() {

Alert permutations

- } /> + } + />
); diff --git a/scripts/setup-build-tools.js b/scripts/setup-build-tools.js new file mode 100755 index 0000000000..7b5acce4e1 --- /dev/null +++ b/scripts/setup-build-tools.js @@ -0,0 +1,33 @@ +#!/usr/bin/env node +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 + +// Can be used in postinstall script like so: +// "postinstall": "node ./scripts/install-peer-dependency.js collection-hooks:property-filter-token-groups" +// where "collection-hooks" is the package to fetch and "property-filter-token-groups" is the branch name in GitHub. + +import { execSync } from 'child_process'; +import process from 'node:process'; +import path from 'path'; + +const branch = 'add-test-pages-util-permutation-view'; +const packageName = 'build-tools'; +const targetRepository = `https://github.com/cloudscape-design/${packageName}.git`; +const copyBuildToolsPath = path.join(process.cwd(), 'shared', 'build-tools'); +execCommand(`mkdir -p ${copyBuildToolsPath}`); +execCommand(`rm -rf ${copyBuildToolsPath}`); +execCommand(`git clone --branch ${branch} --single-branch ${targetRepository} ${copyBuildToolsPath}`); + +console.log(`build-tools has been successfully installed!`); + +function execCommand(command, options = {}) { + try { + execSync(command, { stdio: 'inherit', ...options }); + } catch (error) { + console.error(`Error executing command: ${command}`); + console.error(`Error message: ${error.message}`); + console.error(`Stdout: ${error.stdout && error.stdout.toString()}`); + console.error(`Stderr: ${error.stderr && error.stderr.toString()}`); + throw error; + } +} From 324816ba03b683fce111df75170f6cb456144177 Mon Sep 17 00:00:00 2001 From: Amanuel Sisay Date: Tue, 20 Jan 2026 09:22:53 +0100 Subject: [PATCH 2/4] fix: consume build tools directly from github and copy during build --- .gitignore | 3 +-- build-tools/tasks/copy-build-tools.js | 11 +++++++++ build-tools/tasks/index.js | 1 + gulpfile.js | 11 ++++++++- package.json | 6 ++--- scripts/setup-build-tools.js | 33 --------------------------- 6 files changed, 25 insertions(+), 40 deletions(-) create mode 100644 build-tools/tasks/copy-build-tools.js delete mode 100755 scripts/setup-build-tools.js diff --git a/.gitignore b/.gitignore index 7b45ddd722..87043652d0 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,4 @@ vendor/generated-*.txt # IDEs .vscode # System -.DS_Store -shared/ \ No newline at end of file +.DS_Store \ No newline at end of file diff --git a/build-tools/tasks/copy-build-tools.js b/build-tools/tasks/copy-build-tools.js new file mode 100644 index 0000000000..00df5e5f02 --- /dev/null +++ b/build-tools/tasks/copy-build-tools.js @@ -0,0 +1,11 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +const { copyTask } = require('../utils/gulp-utils'); + +const copyBuildTools = copyTask( + 'build-tools', + 'node_modules/@cloudscape-design/build-tools/**/*', + 'lib/dev-pages/internal/build-tools' +); + +module.exports = copyBuildTools; diff --git a/build-tools/tasks/index.js b/build-tools/tasks/index.js index 982a8f6a72..49a3f5861f 100644 --- a/build-tools/tasks/index.js +++ b/build-tools/tasks/index.js @@ -18,6 +18,7 @@ module.exports = { integ: require('./integ'), motion: require('./motion'), copyFiles: require('./copy-files'), + copyBuildTools: require('./copy-build-tools'), themeableSource: require('./themeable-source'), bundleVendorFiles: require('./bundle-vendor-files'), sizeLimit: require('./size-limit'), diff --git a/gulpfile.js b/gulpfile.js index 9d290b74f1..8bf64fd71c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -20,6 +20,7 @@ const { integ, motion, copyFiles, + copyBuildTools, themeableSource, bundleVendorFiles, sizeLimit, @@ -27,7 +28,15 @@ const { const quickBuild = series( clean, - parallel(packageJSON, generateI18nMessages, generateEnvironment, generateIcons, generateIndexFile, copyFiles), + parallel( + packageJSON, + generateI18nMessages, + generateEnvironment, + generateIcons, + generateIndexFile, + copyFiles, + copyBuildTools + ), parallel(generateCustomCssPropertiesMap, styles, typescript, testUtils), bundleVendorFiles ); diff --git a/package.json b/package.json index 46b0df1ecb..a1e0af2f3d 100644 --- a/package.json +++ b/package.json @@ -25,8 +25,7 @@ "start:integ": "cross-env NODE_ENV=development webpack serve --config pages/webpack.config.integ.cjs", "start:react18": "npm-run-all --parallel start:watch start:react18:dev", "start:react18:dev": "cross-env NODE_ENV=development REACT_VERSION=18 webpack serve --config pages/webpack.config.cjs", - "prepare": "husky", - "preinstall": "node ./scripts/setup-build-tools" + "prepare": "husky" }, "dependencies": { "@cloudscape-design/collection-hooks": "^1.0.0", @@ -54,8 +53,7 @@ "@babel/core": "^7.23.7", "@babel/plugin-syntax-typescript": "^7.23.3", "@cloudscape-design/browser-test-tools": "^3.0.0", - "@cloudscape-design/build-tools-repo": "github:cloudscape-design/build-tools#add-test-pages-util-permutation-view", - "@cloudscape-design/build-tools": "file:./shared/build-tools", + "@cloudscape-design/build-tools": "github:cloudscape-design/build-tools#main", "@cloudscape-design/documenter": "^1.0.0", "@cloudscape-design/global-styles": "^1.0.0", "@cloudscape-design/jest-preset": "^2.0.0", diff --git a/scripts/setup-build-tools.js b/scripts/setup-build-tools.js deleted file mode 100755 index 7b5acce4e1..0000000000 --- a/scripts/setup-build-tools.js +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env node -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: Apache-2.0 - -// Can be used in postinstall script like so: -// "postinstall": "node ./scripts/install-peer-dependency.js collection-hooks:property-filter-token-groups" -// where "collection-hooks" is the package to fetch and "property-filter-token-groups" is the branch name in GitHub. - -import { execSync } from 'child_process'; -import process from 'node:process'; -import path from 'path'; - -const branch = 'add-test-pages-util-permutation-view'; -const packageName = 'build-tools'; -const targetRepository = `https://github.com/cloudscape-design/${packageName}.git`; -const copyBuildToolsPath = path.join(process.cwd(), 'shared', 'build-tools'); -execCommand(`mkdir -p ${copyBuildToolsPath}`); -execCommand(`rm -rf ${copyBuildToolsPath}`); -execCommand(`git clone --branch ${branch} --single-branch ${targetRepository} ${copyBuildToolsPath}`); - -console.log(`build-tools has been successfully installed!`); - -function execCommand(command, options = {}) { - try { - execSync(command, { stdio: 'inherit', ...options }); - } catch (error) { - console.error(`Error executing command: ${command}`); - console.error(`Error message: ${error.message}`); - console.error(`Stdout: ${error.stdout && error.stdout.toString()}`); - console.error(`Stderr: ${error.stderr && error.stderr.toString()}`); - throw error; - } -} From b5bb960cf145a16f0b688f155025e2e7971b9f76 Mon Sep 17 00:00:00 2001 From: Amanuel Sisay Date: Tue, 20 Jan 2026 09:33:05 +0100 Subject: [PATCH 3/4] fix: remove annotated param --- .gitignore | 2 +- pages/alert/permutations.page.tsx | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 87043652d0..db3d62b944 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ vendor/generated-*.txt # IDEs .vscode # System -.DS_Store \ No newline at end of file +.DS_Store diff --git a/pages/alert/permutations.page.tsx b/pages/alert/permutations.page.tsx index a5d4626852..920e3ec971 100644 --- a/pages/alert/permutations.page.tsx +++ b/pages/alert/permutations.page.tsx @@ -111,10 +111,7 @@ export default function AlertScenario() {

Alert permutations

- } - /> + } />
); From 7081b45c6beadd9b50f74e0e897b078004c1eb41 Mon Sep 17 00:00:00 2001 From: Amanuel Sisay Date: Wed, 21 Jan 2026 14:55:41 +0100 Subject: [PATCH 4/4] fix: run copyBuildTools only during full build, not quick-build --- gulpfile.js | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8bf64fd71c..8e4ce22c44 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -28,15 +28,7 @@ const { const quickBuild = series( clean, - parallel( - packageJSON, - generateI18nMessages, - generateEnvironment, - generateIcons, - generateIndexFile, - copyFiles, - copyBuildTools - ), + parallel(packageJSON, generateI18nMessages, generateEnvironment, generateIcons, generateIndexFile, copyFiles), parallel(generateCustomCssPropertiesMap, styles, typescript, testUtils), bundleVendorFiles ); @@ -44,7 +36,7 @@ const quickBuild = series( exports.clean = clean; exports['quick-build'] = quickBuild; exports.i18n = generateI18nMessages; -exports.build = series(quickBuild, parallel(buildPages, themeableSource, docs, sizeLimit)); +exports.build = series(quickBuild, parallel(buildPages, themeableSource, docs, sizeLimit, copyBuildTools)); exports.test = series(unit, integ, a11y); exports['test:unit'] = unit; exports['test:integ'] = integ;