-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2098 from demergent-labs/install_global_dependencies
Install global dependencies
- Loading branch information
Showing
19 changed files
with
296 additions
and
126 deletions.
There are no files selected for viewing
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,16 @@ | ||
name: Get dfx version | ||
description: Determines Azle's dfx version | ||
outputs: | ||
dfx-version: | ||
description: Returns the version of dfx that Azle will test against and use to generate its Wasm binary templates | ||
value: ${{ steps.get-dfx-version.outputs.dfx-version }} | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: get-dfx-version | ||
run: | | ||
DFX_VERSION=$(jq -r '.azle.globalDependencies.dfx // error("dfx version not found")' "package.json") | ||
echo "dfx-version=${DFX_VERSION}" >> "$GITHUB_OUTPUT" | ||
shell: bash |
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,16 @@ | ||
name: Get node version | ||
description: Determines Azle's node version | ||
outputs: | ||
node-version: | ||
description: Returns the version of node that Azle will test against and use to generate its Wasm binary templates | ||
value: ${{ steps.get-node-version.outputs.node-version }} | ||
runs: | ||
using: composite | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: get-node-version | ||
run: | | ||
NODE_VERSION=$(jq -r '.azle.globalDependencies.node // error("node version not found")' "package.json") | ||
echo "node-version=${NODE_VERSION}" >> "$GITHUB_OUTPUT" | ||
shell: bash |
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 was deleted.
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
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
33 changes: 33 additions & 0 deletions
33
src/build/stable/commands/install_global_dependencies/index.ts
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,33 @@ | ||
import { IOType } from 'child_process'; | ||
|
||
import { azle } from '../../../../../package.json'; | ||
import { execSyncPretty } from '../../utils/exec_sync_pretty'; | ||
import { AZLE_PACKAGE_PATH } from '../../utils/global_paths'; | ||
|
||
type DependencyName = 'node' | 'dfx' | 'rust' | 'wasi2ic'; | ||
|
||
type DependencyInstallInfo = { | ||
[key in DependencyName]: boolean; | ||
}; | ||
|
||
export async function runCommand( | ||
dependenciesToInstall: DependencyInstallInfo, | ||
ioType: IOType | ||
): Promise<void> { | ||
for (const key in dependenciesToInstall) { | ||
const dependency = key as DependencyName; | ||
if (dependenciesToInstall[dependency] === true) { | ||
installDependency(dependency, ioType); | ||
} | ||
} | ||
} | ||
|
||
function installDependency(dependency: DependencyName, ioType: IOType): void { | ||
console.info(`Installing ${dependency}...`); | ||
const version = azle.globalDependencies[dependency]; | ||
const script = `install_${dependency}.sh`; | ||
execSyncPretty( | ||
`${AZLE_PACKAGE_PATH}/src/build/stable/commands/install_global_dependencies/${script} ${version}`, | ||
ioType | ||
); | ||
} |
16 changes: 16 additions & 0 deletions
16
src/build/stable/commands/install_global_dependencies/install_dfx.sh
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,16 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "Error: No DFX version specified." | ||
echo "Usage: ./install_dfx.sh <DFX_VERSION>" | ||
exit 1 | ||
fi | ||
|
||
DFX_VERSION=$1 | ||
|
||
# Install or update dfx using the official installation script | ||
echo "Installing dfx version $DFX_VERSION..." | ||
DFXVM_INIT_YES=true DFX_VERSION=$DFX_VERSION sh -ci "$(curl -fsSL https://sdk.dfinity.org/install.sh)" | ||
|
||
echo "dfx $DFX_VERSION installation completed." | ||
exit 0 |
25 changes: 25 additions & 0 deletions
25
src/build/stable/commands/install_global_dependencies/install_node.sh
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,25 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "Error: No Node.js version specified." | ||
echo "Usage: ./install_node.sh <NODE_VERSION>" | ||
exit 1 | ||
fi | ||
|
||
NODE_VERSION=$1 | ||
|
||
source "$HOME/.nvm/nvm.sh" | ||
|
||
if nvm ls "$NODE_VERSION" &> /dev/null; then | ||
echo "Node.js version $NODE_VERSION is already installed. Skipping installation." | ||
nvm use "$NODE_VERSION" | ||
else | ||
echo "Installing Node.js version $NODE_VERSION..." | ||
nvm install "$NODE_VERSION" | ||
nvm use "$NODE_VERSION" | ||
nvm alias default "$NODE_VERSION" | ||
echo "Node.js $NODE_VERSION installation completed." | ||
fi | ||
|
||
node --version | ||
exit 0 |
24 changes: 24 additions & 0 deletions
24
src/build/stable/commands/install_global_dependencies/install_rust.sh
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,24 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$1" ]; then | ||
echo "Error: No Rust version specified." | ||
echo "Usage: ./install_rust.sh <RUST_VERSION>" | ||
exit 1 | ||
fi | ||
|
||
RUST_VERSION=$1 | ||
|
||
# Install Rust | ||
echo "Installing Rust version $RUST_VERSION..." | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain "$RUST_VERSION" | ||
source $HOME/.cargo/env | ||
|
||
# Add the WASM target for WebAssembly | ||
rustup target add wasm32-wasi | ||
|
||
echo "Rust $RUST_VERSION installation completed." | ||
rustc --version | ||
cargo --version | ||
rustup target list --installed | grep wasm32-wasi | ||
|
||
exit 0 |
Oops, something went wrong.