-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Experiment wdiov9 isDisplayed on display:contents
- Loading branch information
Showing
23 changed files
with
2,868 additions
and
453 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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,65 @@ | ||
#!/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. | ||
|
||
const { execSync } = require('child_process'); | ||
const path = require('path'); | ||
const os = require('os'); | ||
|
||
const artifactPathMap = { | ||
components: '/lib/components/*', | ||
'board-components': '/lib/components/*', | ||
}; | ||
|
||
const args = process.argv.slice(2); | ||
if (args.length < 1) { | ||
console.error('Usage: install-peer-dependency.js <package-name>:<target-branch>'); | ||
process.exit(1); | ||
} | ||
const [packageName, targetBranch] = args[0].split(':'); | ||
const targetRepository = `https://github.com/cloudscape-design/${packageName}.git`; | ||
const nodeModulesPackagePath = path.join(process.cwd(), 'node_modules', '@cloudscape-design', packageName); | ||
const tempDir = path.join(os.tmpdir(), `temp-${packageName}`); | ||
const artifactPath = artifactPathMap[packageName] ?? '/lib/*'; | ||
|
||
// Clone the repository and checkout the branch | ||
console.log(`Cloning ${packageName}:${targetBranch}...`); | ||
execCommand(`git clone ${targetRepository} ${tempDir}`); | ||
process.chdir(tempDir); | ||
execCommand(`git checkout ${targetBranch}`); | ||
|
||
// Install dependencies and build | ||
console.log(`Installing dependencies and building ${packageName}...`); | ||
execCommand('npm install'); | ||
execCommand('npm run build'); | ||
|
||
// Remove existing peer dependency in node_modules | ||
console.log(`Removing existing ${packageName} from node_modules...`); | ||
execCommand(`rm -rf ${nodeModulesPackagePath}`); | ||
|
||
// Copy built peer dependency to node_modules | ||
console.log(`Copying build ${targetRepository} to node_modules...`); | ||
execCommand(`mkdir -p ${nodeModulesPackagePath}`); | ||
execCommand(`cp -R ${tempDir}${artifactPath} ${nodeModulesPackagePath}`); | ||
|
||
// Clean up | ||
console.log('Cleaning up...'); | ||
execCommand(`rm -rf ${tempDir}`); | ||
|
||
console.log(`${packageName} has been successfully installed from branch ${targetBranch}!`); | ||
|
||
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; | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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