Compare commits
No commits in common. "0.0.1" and "main" have entirely different histories.
2
.gitignore
vendored
2
.gitignore
vendored
@ -140,7 +140,7 @@ dist
|
|||||||
/readmevalidation
|
/readmevalidation
|
||||||
|
|
||||||
# Terraform files generated during testing
|
# Terraform files generated during testing
|
||||||
# .terraform*
|
.terraform*
|
||||||
*.tfstate
|
*.tfstate
|
||||||
*.tfstate.lock.info
|
*.tfstate.lock.info
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@ node_modules/
|
|||||||
*.tfvars
|
*.tfvars
|
||||||
|
|
||||||
# Ignore generated and temporary files
|
# Ignore generated and temporary files
|
||||||
# .terraform/
|
.terraform/
|
||||||
*.tfstate
|
*.tfstate
|
||||||
*.tfstate.backup
|
*.tfstate.backup
|
||||||
*.tfstate.lock.info
|
*.tfstate.lock.info
|
||||||
|
|||||||
@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
display_name: Node.js
|
|
||||||
description: Install Node.js via nvm
|
|
||||||
icon: ../../../../.icons/node.svg
|
|
||||||
maintainer_github: TheZoker
|
|
||||||
verified: false
|
|
||||||
tags: [helper, nodejs]
|
|
||||||
---
|
|
||||||
|
|
||||||
# nodejs
|
|
||||||
|
|
||||||
Automatically installs [Node.js](https://github.com/nodejs/node) via [`nvm`](https://github.com/nvm-sh/nvm). It can also install multiple versions of node and set a default version. If no options are specified, the latest version is installed.
|
|
||||||
|
|
||||||
```tf
|
|
||||||
module "nodejs" {
|
|
||||||
count = data.coder_workspace.me.start_count
|
|
||||||
source = "registry.coder.com/thezoker/nodejs/coder"
|
|
||||||
version = "1.0.13"
|
|
||||||
agent_id = coder_agent.example.id
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install multiple versions
|
|
||||||
|
|
||||||
This installs multiple versions of Node.js:
|
|
||||||
|
|
||||||
```tf
|
|
||||||
module "nodejs" {
|
|
||||||
count = data.coder_workspace.me.start_count
|
|
||||||
source = "registry.coder.com/thezoker/nodejs/coder"
|
|
||||||
version = "1.0.13"
|
|
||||||
agent_id = coder_agent.example.id
|
|
||||||
node_versions = [
|
|
||||||
"18",
|
|
||||||
"20",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
default_node_version = "1.0.13"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Full example
|
|
||||||
|
|
||||||
A example with all available options:
|
|
||||||
|
|
||||||
```tf
|
|
||||||
module "nodejs" {
|
|
||||||
count = data.coder_workspace.me.start_count
|
|
||||||
source = "registry.coder.com/thezoker/nodejs/coder"
|
|
||||||
version = "1.0.13"
|
|
||||||
agent_id = coder_agent.example.id
|
|
||||||
nvm_version = "1.0.13"
|
|
||||||
nvm_install_prefix = "/opt/nvm"
|
|
||||||
node_versions = [
|
|
||||||
"16",
|
|
||||||
"18",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
default_node_version = "1.0.13"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import { describe } from "bun:test";
|
|
||||||
import { runTerraformInit, testRequiredVariables } from "~test";
|
|
||||||
|
|
||||||
describe("nodejs", async () => {
|
|
||||||
await runTerraformInit(import.meta.dir);
|
|
||||||
|
|
||||||
testRequiredVariables(import.meta.dir, {
|
|
||||||
agent_id: "foo",
|
|
||||||
});
|
|
||||||
|
|
||||||
// More tests depend on shebang refactors
|
|
||||||
});
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "agent_id" {
|
|
||||||
type = string
|
|
||||||
description = "The ID of a Coder agent."
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "coder_script" "python3" {
|
|
||||||
agent_id = var.agent_id
|
|
||||||
display_name = "python3:"
|
|
||||||
script = templatefile("${path.module}/run.sh")
|
|
||||||
run_on_start = true
|
|
||||||
start_blocks_login = true
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
|
|
||||||
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
|
|
||||||
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
|
|
||||||
|
|
||||||
curl https://pyenv.run | bash
|
|
||||||
|
|
||||||
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
|
||||||
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
|
||||||
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
|
|
||||||
|
|
||||||
source ~/.bashrc # or source ~/.zshrc
|
|
||||||
|
|
||||||
pyenv install 3.9
|
|
||||||
|
|
||||||
pyenv global 3.9
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
NVM_VERSION='${NVM_VERSION}'
|
|
||||||
NODE_VERSIONS='${NODE_VERSIONS}'
|
|
||||||
INSTALL_PREFIX='${INSTALL_PREFIX}'
|
|
||||||
DEFAULT='${DEFAULT}'
|
|
||||||
BOLD='\033[0;1m'
|
|
||||||
CODE='\033[36;40;1m'
|
|
||||||
RESET='\033[0m'
|
|
||||||
|
|
||||||
printf "$${BOLD}Installing nvm!$${RESET}\n"
|
|
||||||
|
|
||||||
export NVM_DIR="$HOME/$${INSTALL_PREFIX}/nvm"
|
|
||||||
mkdir -p "$NVM_DIR"
|
|
||||||
|
|
||||||
script="$(curl -sS -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$${NVM_VERSION}/install.sh" 2>&1)"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to download nvm installation script: $script"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
output="$(bash <<< "$script" 2>&1)"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to install nvm: $output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "🥳 nvm has been installed\n\n"
|
|
||||||
|
|
||||||
# Set up nvm for the rest of the script.
|
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
||||||
|
|
||||||
# Install each node version...
|
|
||||||
IFS=',' read -r -a VERSIONLIST <<< "$${NODE_VERSIONS}"
|
|
||||||
# shellcheck disable=SC2066
|
|
||||||
for version in "$${VERSIONLIST[@]}"; do
|
|
||||||
if [ -z "$version" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
printf "🛠️ Installing node version $${CODE}$version$${RESET}...\n"
|
|
||||||
output=$(nvm install "$version" 2>&1)
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to install version: $version: $output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Set default if provided
|
|
||||||
# shellcheck disable=SC2157
|
|
||||||
if [ -n "$${DEFAULT}" ]; then
|
|
||||||
printf "🛠️ Setting default node version $${CODE}$DEFAULT$${RESET}...\n"
|
|
||||||
output=$(nvm alias default $DEFAULT 2>&1)
|
|
||||||
fi
|
|
||||||
@ -1,61 +0,0 @@
|
|||||||
---
|
|
||||||
display_name: Node.js
|
|
||||||
description: Install Node.js via nvm
|
|
||||||
icon: ../../../../.icons/node.svg
|
|
||||||
maintainer_github: TheZoker
|
|
||||||
verified: false
|
|
||||||
tags: [helper, nodejs]
|
|
||||||
---
|
|
||||||
|
|
||||||
# nodejs
|
|
||||||
|
|
||||||
Automatically installs [Node.js](https://github.com/nodejs/node) via [`nvm`](https://github.com/nvm-sh/nvm). It can also install multiple versions of node and set a default version. If no options are specified, the latest version is installed.
|
|
||||||
|
|
||||||
```tf
|
|
||||||
module "nodejs" {
|
|
||||||
count = data.coder_workspace.me.start_count
|
|
||||||
source = "registry.coder.com/thezoker/nodejs/coder"
|
|
||||||
version = "1.0.13"
|
|
||||||
agent_id = coder_agent.example.id
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Install multiple versions
|
|
||||||
|
|
||||||
This installs multiple versions of Node.js:
|
|
||||||
|
|
||||||
```tf
|
|
||||||
module "nodejs" {
|
|
||||||
count = data.coder_workspace.me.start_count
|
|
||||||
source = "registry.coder.com/thezoker/nodejs/coder"
|
|
||||||
version = "1.0.13"
|
|
||||||
agent_id = coder_agent.example.id
|
|
||||||
node_versions = [
|
|
||||||
"18",
|
|
||||||
"20",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
default_node_version = "1.0.13"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Full example
|
|
||||||
|
|
||||||
A example with all available options:
|
|
||||||
|
|
||||||
```tf
|
|
||||||
module "nodejs" {
|
|
||||||
count = data.coder_workspace.me.start_count
|
|
||||||
source = "registry.coder.com/thezoker/nodejs/coder"
|
|
||||||
version = "1.0.13"
|
|
||||||
agent_id = coder_agent.example.id
|
|
||||||
nvm_version = "1.0.13"
|
|
||||||
nvm_install_prefix = "/opt/nvm"
|
|
||||||
node_versions = [
|
|
||||||
"16",
|
|
||||||
"18",
|
|
||||||
"node"
|
|
||||||
]
|
|
||||||
default_node_version = "1.0.13"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@ -1,12 +0,0 @@
|
|||||||
import { describe } from "bun:test";
|
|
||||||
import { runTerraformInit, testRequiredVariables } from "~test";
|
|
||||||
|
|
||||||
describe("nodejs", async () => {
|
|
||||||
await runTerraformInit(import.meta.dir);
|
|
||||||
|
|
||||||
testRequiredVariables(import.meta.dir, {
|
|
||||||
agent_id: "foo",
|
|
||||||
});
|
|
||||||
|
|
||||||
// More tests depend on shebang refactors
|
|
||||||
});
|
|
||||||
@ -1,17 +0,0 @@
|
|||||||
terraform {
|
|
||||||
required_version = ">= 1.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "agent_id" {
|
|
||||||
type = string
|
|
||||||
description = "The ID of a Coder agent."
|
|
||||||
}
|
|
||||||
|
|
||||||
resource "coder_script" "python3" {
|
|
||||||
agent_id = var.agent_id
|
|
||||||
display_name = "python3:"
|
|
||||||
script = templatefile("${path.module}/run.sh")
|
|
||||||
run_on_start = true
|
|
||||||
start_blocks_login = true
|
|
||||||
}
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
sudo apt update
|
|
||||||
sudo apt install -y make build-essential libssl-dev zlib1g-dev \
|
|
||||||
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \
|
|
||||||
libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev
|
|
||||||
|
|
||||||
curl https://pyenv.run | bash
|
|
||||||
|
|
||||||
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
|
|
||||||
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
|
|
||||||
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
|
|
||||||
|
|
||||||
source ~/.bashrc # or source ~/.zshrc
|
|
||||||
|
|
||||||
pyenv install 3.9
|
|
||||||
|
|
||||||
pyenv global 3.9
|
|
||||||
@ -1,53 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
NVM_VERSION='${NVM_VERSION}'
|
|
||||||
NODE_VERSIONS='${NODE_VERSIONS}'
|
|
||||||
INSTALL_PREFIX='${INSTALL_PREFIX}'
|
|
||||||
DEFAULT='${DEFAULT}'
|
|
||||||
BOLD='\033[0;1m'
|
|
||||||
CODE='\033[36;40;1m'
|
|
||||||
RESET='\033[0m'
|
|
||||||
|
|
||||||
printf "$${BOLD}Installing nvm!$${RESET}\n"
|
|
||||||
|
|
||||||
export NVM_DIR="$HOME/$${INSTALL_PREFIX}/nvm"
|
|
||||||
mkdir -p "$NVM_DIR"
|
|
||||||
|
|
||||||
script="$(curl -sS -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$${NVM_VERSION}/install.sh" 2>&1)"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to download nvm installation script: $script"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
output="$(bash <<< "$script" 2>&1)"
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to install nvm: $output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "🥳 nvm has been installed\n\n"
|
|
||||||
|
|
||||||
# Set up nvm for the rest of the script.
|
|
||||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
||||||
|
|
||||||
# Install each node version...
|
|
||||||
IFS=',' read -r -a VERSIONLIST <<< "$${NODE_VERSIONS}"
|
|
||||||
# shellcheck disable=SC2066
|
|
||||||
for version in "$${VERSIONLIST[@]}"; do
|
|
||||||
if [ -z "$version" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
printf "🛠️ Installing node version $${CODE}$version$${RESET}...\n"
|
|
||||||
output=$(nvm install "$version" 2>&1)
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
echo "Failed to install version: $version: $output"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Set default if provided
|
|
||||||
# shellcheck disable=SC2157
|
|
||||||
if [ -n "$${DEFAULT}" ]; then
|
|
||||||
printf "🛠️ Setting default node version $${CODE}$DEFAULT$${RESET}...\n"
|
|
||||||
output=$(nvm alias default $DEFAULT 2>&1)
|
|
||||||
fi
|
|
||||||
Loading…
x
Reference in New Issue
Block a user