From 0c751447978d14f027509696d676a84dba755ee1 Mon Sep 17 00:00:00 2001 From: defelmnq Date: Thu, 10 Apr 2025 17:43:13 +0200 Subject: [PATCH 01/15] add devcontainers-cli module --- .icons/devcontainers.svg | 2 ++ devcontainers-cli/README.md | 24 +++++++++++++ devcontainers-cli/main.test.ts | 66 ++++++++++++++++++++++++++++++++++ devcontainers-cli/main.tf | 23 ++++++++++++ devcontainers-cli/run.sh | 22 ++++++++++++ 5 files changed, 137 insertions(+) create mode 100644 .icons/devcontainers.svg create mode 100644 devcontainers-cli/README.md create mode 100644 devcontainers-cli/main.test.ts create mode 100644 devcontainers-cli/main.tf create mode 100755 devcontainers-cli/run.sh diff --git a/.icons/devcontainers.svg b/.icons/devcontainers.svg new file mode 100644 index 00000000..fb0443bd --- /dev/null +++ b/.icons/devcontainers.svg @@ -0,0 +1,2 @@ + +file_type_devcontainer \ No newline at end of file diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md new file mode 100644 index 00000000..76fd4f77 --- /dev/null +++ b/devcontainers-cli/README.md @@ -0,0 +1,24 @@ +--- +display_name: devcontainers-cli +description: devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace +icon: ../.icons/devcontainers.svg +verified: true +tags: [helper] +--- + +# devcontainers-cli + +The devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace. It can be used within any workspace as it runs only if +@devcontainers/cli is not installed yet. +npm is required and should be installed in order for the module to work. + + +## Examples + +```tf +module "devcontainers-cli" { + source = "registry.coder.com/modules/devcontainers-cli/coder" + version = "1.0.0" + agent_id = coder_agent.example.id +} +``` \ No newline at end of file diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts new file mode 100644 index 00000000..65856da4 --- /dev/null +++ b/devcontainers-cli/main.test.ts @@ -0,0 +1,66 @@ +import { describe, expect, it } from "bun:test"; +import { + execContainer, + executeScriptInContainer, + findResourceInstance, + runContainer, + runTerraformApply, + runTerraformInit, + testRequiredVariables, + type TerraformState, +} from "../test"; + +const executeScriptInContainerWithNPM = async ( + state: TerraformState, + image: string, + shell = "sh", +): Promise<{ + exitCode: number; + stdout: string[]; + stderr: string[]; +}> => { + const instance = findResourceInstance(state, "coder_script"); + const id = await runContainer(image); + const respPipx = await execContainer(id, [shell, "-c", "apk add nodejs npm"]); + const resp = await execContainer(id, [shell, "-c", instance.script]); + const stdout = resp.stdout.trim().split("\n"); + const stderr = resp.stderr.trim().split("\n"); + return { + exitCode: resp.exitCode, + stdout, + stderr, + }; +}; + +describe("devcontainers-cli", async () => { + await runTerraformInit(import.meta.dir); + + testRequiredVariables(import.meta.dir, { + agent_id: "some-agent-id", + }); + + it("missing npm", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "some-agent-id", + }); + const output = await executeScriptInContainer(state, "alpine"); + expect(output.exitCode).toBe(1); + expect(output.stdout).toEqual([ + "Installing @devcontainers/cli ...", + "npm is not installed, please install npm first", + ]); + }); + + it("installs devcontainers-cli", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "some-agent-id", + }); + + const output = await executeScriptInContainerWithNPM(state, "alpine"); + expect(output.exitCode).toBe(0); + + expect(output.stdout[0]).toEqual("Installing @devcontainers/cli ..."); + expect(output.stdout[1]).toEqual("Running npm install -g @devcontainers/cli ..."); + expect(output.stdout[4]).toEqual("🥳 @devcontainers/cli has been installed !"); + }); +}); diff --git a/devcontainers-cli/main.tf b/devcontainers-cli/main.tf new file mode 100644 index 00000000..4e368e76 --- /dev/null +++ b/devcontainers-cli/main.tf @@ -0,0 +1,23 @@ +terraform { + required_version = ">= 1.0" + + required_providers { + coder = { + source = "coder/coder" + version = ">= 0.17" + } + } +} + +variable "agent_id" { + type = string + description = "The ID of a Coder agent." +} + +resource "coder_script" "devcontainers-cli" { + agent_id = var.agent_id + display_name = "devcontainers-cli" + icon = "/icon/devcontainers.svg" + script = templatefile("${path.module}/run.sh", {}) + run_on_start = true +} diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh new file mode 100755 index 00000000..ac83265d --- /dev/null +++ b/devcontainers-cli/run.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env sh + +echo "Installing @devcontainers/cli ..." + +# If @devcontainers/cli is already installed, we can skip +if command -v devcontainers > /dev/null 2>&1; then + echo "🥳 @devcontainers/cli is already installed" + exit 1 +fi + +# If npm is not installed, we should skip +if ! command -v npm > /dev/null 2>&1; then + echo "npm is not installed, please install npm first" + exit 1 +fi + +# If @devcontainers/cli is not installed, we should install it +echo "Running npm install -g @devcontainers/cli ..." +npm install -g @devcontainers/cli \ + && echo "🥳 @devcontainers/cli has been installed !" + +exit 0 \ No newline at end of file From 6f513153ef737d890d64f891e80caa0cd33193ba Mon Sep 17 00:00:00 2001 From: defelmnq Date: Thu, 10 Apr 2025 17:58:02 +0200 Subject: [PATCH 02/15] small fixes on readme and test name --- devcontainers-cli/README.md | 2 +- devcontainers-cli/main.test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md index 76fd4f77..dd479cd5 100644 --- a/devcontainers-cli/README.md +++ b/devcontainers-cli/README.md @@ -3,7 +3,7 @@ display_name: devcontainers-cli description: devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace icon: ../.icons/devcontainers.svg verified: true -tags: [helper] +tags: [devcontainers] --- # devcontainers-cli diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts index 65856da4..ddccda6e 100644 --- a/devcontainers-cli/main.test.ts +++ b/devcontainers-cli/main.test.ts @@ -39,7 +39,7 @@ describe("devcontainers-cli", async () => { agent_id: "some-agent-id", }); - it("missing npm", async () => { + it("misses npm", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "some-agent-id", }); From cda311d5f467113460318813e2ac414f0d894dff Mon Sep 17 00:00:00 2001 From: defelmnq Date: Thu, 10 Apr 2025 18:01:32 +0200 Subject: [PATCH 03/15] run prettier --- devcontainers-cli/README.md | 11 +++++------ devcontainers-cli/main.test.ts | 8 ++++++-- devcontainers-cli/run.sh | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md index dd479cd5..dd04a8d2 100644 --- a/devcontainers-cli/README.md +++ b/devcontainers-cli/README.md @@ -8,17 +8,16 @@ tags: [devcontainers] # devcontainers-cli -The devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace. It can be used within any workspace as it runs only if +The devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace. It can be used within any workspace as it runs only if @devcontainers/cli is not installed yet. npm is required and should be installed in order for the module to work. - ## Examples ```tf module "devcontainers-cli" { - source = "registry.coder.com/modules/devcontainers-cli/coder" - version = "1.0.0" - agent_id = coder_agent.example.id + source = "registry.coder.com/modules/devcontainers-cli/coder" + version = "1.0.0" + agent_id = coder_agent.example.id } -``` \ No newline at end of file +``` diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts index ddccda6e..b7bcb872 100644 --- a/devcontainers-cli/main.test.ts +++ b/devcontainers-cli/main.test.ts @@ -60,7 +60,11 @@ describe("devcontainers-cli", async () => { expect(output.exitCode).toBe(0); expect(output.stdout[0]).toEqual("Installing @devcontainers/cli ..."); - expect(output.stdout[1]).toEqual("Running npm install -g @devcontainers/cli ..."); - expect(output.stdout[4]).toEqual("🥳 @devcontainers/cli has been installed !"); + expect(output.stdout[1]).toEqual( + "Running npm install -g @devcontainers/cli ...", + ); + expect(output.stdout[4]).toEqual( + "🥳 @devcontainers/cli has been installed !", + ); }); }); diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh index ac83265d..0784b0d1 100755 --- a/devcontainers-cli/run.sh +++ b/devcontainers-cli/run.sh @@ -19,4 +19,4 @@ echo "Running npm install -g @devcontainers/cli ..." npm install -g @devcontainers/cli \ && echo "🥳 @devcontainers/cli has been installed !" -exit 0 \ No newline at end of file +exit 0 From d1684e2fe1b20ae2a183151fa26064a9ec680d4d Mon Sep 17 00:00:00 2001 From: defelmnq Date: Thu, 10 Apr 2025 18:05:12 +0200 Subject: [PATCH 04/15] fmt --- devcontainers-cli/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devcontainers-cli/main.tf b/devcontainers-cli/main.tf index 4e368e76..a2aee348 100644 --- a/devcontainers-cli/main.tf +++ b/devcontainers-cli/main.tf @@ -18,6 +18,6 @@ resource "coder_script" "devcontainers-cli" { agent_id = var.agent_id display_name = "devcontainers-cli" icon = "/icon/devcontainers.svg" - script = templatefile("${path.module}/run.sh", {}) + script = templatefile("${path.module}/run.sh", {}) run_on_start = true } From f0b707a0c70e8bed2fd3dd6878ab8ba1355d97ca Mon Sep 17 00:00:00 2001 From: defelmnq Date: Thu, 10 Apr 2025 18:26:46 +0200 Subject: [PATCH 05/15] lint --- devcontainers-cli/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md index dd04a8d2..27104b15 100644 --- a/devcontainers-cli/README.md +++ b/devcontainers-cli/README.md @@ -3,6 +3,7 @@ display_name: devcontainers-cli description: devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace icon: ../.icons/devcontainers.svg verified: true +maintainer_github: coder tags: [devcontainers] --- @@ -12,8 +13,6 @@ The devcontainers-cli module provides an easy way to install @devcontainers/cli @devcontainers/cli is not installed yet. npm is required and should be installed in order for the module to work. -## Examples - ```tf module "devcontainers-cli" { source = "registry.coder.com/modules/devcontainers-cli/coder" From 0c086c6d7172f8fab214bca389edded6b1819d94 Mon Sep 17 00:00:00 2001 From: defelmnq Date: Fri, 11 Apr 2025 04:09:16 +0200 Subject: [PATCH 06/15] update-version --- devcontainers-cli/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md index 27104b15..ea7b62dd 100644 --- a/devcontainers-cli/README.md +++ b/devcontainers-cli/README.md @@ -16,7 +16,7 @@ npm is required and should be installed in order for the module to work. ```tf module "devcontainers-cli" { source = "registry.coder.com/modules/devcontainers-cli/coder" - version = "1.0.0" + version = "release/claude-code/1.0.32" agent_id = coder_agent.example.id } ``` From 7d7ae8bcf0f566dc871515936714783e30b98a5a Mon Sep 17 00:00:00 2001 From: defelmnq Date: Mon, 14 Apr 2025 19:40:13 +0200 Subject: [PATCH 07/15] fix tests and add more package manager --- devcontainers-cli/main.test.ts | 46 +++++++++++++++++++++++----------- devcontainers-cli/run.sh | 34 ++++++++++++++++--------- 2 files changed, 53 insertions(+), 27 deletions(-) diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts index b7bcb872..3cf4d2c7 100644 --- a/devcontainers-cli/main.test.ts +++ b/devcontainers-cli/main.test.ts @@ -10,9 +10,10 @@ import { type TerraformState, } from "../test"; -const executeScriptInContainerWithNPM = async ( +const executeScriptInContainerWithPackageManager = async ( state: TerraformState, image: string, + packageManager: string, shell = "sh", ): Promise<{ exitCode: number; @@ -21,7 +22,16 @@ const executeScriptInContainerWithNPM = async ( }> => { const instance = findResourceInstance(state, "coder_script"); const id = await runContainer(image); - const respPipx = await execContainer(id, [shell, "-c", "apk add nodejs npm"]); + + // Install the specified package manager + if (packageManager === "npm") { + await execContainer(id, [shell, "-c", "apk add nodejs npm"]); + } else if (packageManager === "pnpm") { + await execContainer(id, [shell, "-c", "apk add nodejs npm && npm install -g pnpm"]); + } else if (packageManager === "yarn") { + await execContainer(id, [shell, "-c", "apk add nodejs npm && npm install -g yarn"]); + } + const resp = await execContainer(id, [shell, "-c", instance.script]); const stdout = resp.stdout.trim().split("\n"); const stderr = resp.stderr.trim().split("\n"); @@ -39,32 +49,38 @@ describe("devcontainers-cli", async () => { agent_id: "some-agent-id", }); - it("misses npm", async () => { + it("misses all package managers", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "some-agent-id", }); const output = await executeScriptInContainer(state, "alpine"); expect(output.exitCode).toBe(1); expect(output.stdout).toEqual([ - "Installing @devcontainers/cli ...", - "npm is not installed, please install npm first", + "No supported package manager (npm, pnpm, yarn) is installed. Please install one first.", ]); }); - it("installs devcontainers-cli", async () => { + it("installs devcontainers-cli with npm", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "some-agent-id", + }); + + const output = await executeScriptInContainerWithPackageManager(state, "alpine", "npm"); + expect(output.exitCode).toBe(0); + + expect(output.stdout[0]).toEqual("Installing @devcontainers/cli using npm ..."); + expect(output.stdout[output.stdout.length-1]).toEqual("🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!"); + }); + + it("installs devcontainers-cli with yarn", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "some-agent-id", }); - const output = await executeScriptInContainerWithNPM(state, "alpine"); + const output = await executeScriptInContainerWithPackageManager(state, "alpine", "yarn"); expect(output.exitCode).toBe(0); - expect(output.stdout[0]).toEqual("Installing @devcontainers/cli ..."); - expect(output.stdout[1]).toEqual( - "Running npm install -g @devcontainers/cli ...", - ); - expect(output.stdout[4]).toEqual( - "🥳 @devcontainers/cli has been installed !", - ); + expect(output.stdout[0]).toEqual("Installing @devcontainers/cli using yarn ..."); + expect(output.stdout[output.stdout.length-1]).toEqual("🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!"); }); -}); +}); \ No newline at end of file diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh index 0784b0d1..71e469f3 100755 --- a/devcontainers-cli/run.sh +++ b/devcontainers-cli/run.sh @@ -1,22 +1,32 @@ #!/usr/bin/env sh -echo "Installing @devcontainers/cli ..." - # If @devcontainers/cli is already installed, we can skip -if command -v devcontainers > /dev/null 2>&1; then +if command -v devcontainer > /dev/null 2>&1; then echo "🥳 @devcontainers/cli is already installed" - exit 1 + exit 0 fi -# If npm is not installed, we should skip -if ! command -v npm > /dev/null 2>&1; then - echo "npm is not installed, please install npm first" +# Determine the package manager to use: npm, pnpm, or yarn +if command -v pnpm > /dev/null 2>&1; then + PACKAGE_MANAGER="pnpm" +elif command -v yarn > /dev/null 2>&1; then + PACKAGE_MANAGER="yarn" +elif command -v npm > /dev/null 2>&1; then + PACKAGE_MANAGER="npm" +else + echo "No supported package manager (npm, pnpm, yarn) is installed. Please install one first." exit 1 fi -# If @devcontainers/cli is not installed, we should install it -echo "Running npm install -g @devcontainers/cli ..." -npm install -g @devcontainers/cli \ - && echo "🥳 @devcontainers/cli has been installed !" +echo "Installing @devcontainers/cli using $PACKAGE_MANAGER ..." + +# Install @devcontainers/cli using the selected package manager +if [ "$PACKAGE_MANAGER" = "npm" ] || [ "$PACKAGE_MANAGER" = "pnpm" ]; then + $PACKAGE_MANAGER install -g @devcontainers/cli \ + && echo "🥳 @devcontainers/cli has been installed into $(which devcontainer)!" +elif [ "$PACKAGE_MANAGER" = "yarn" ]; then + $PACKAGE_MANAGER global add @devcontainers/cli \ + && echo "🥳 @devcontainers/cli has been installed into $(which devcontainer)!" +fi -exit 0 +exit 0 \ No newline at end of file From f269de553a6e19871f07323b20a69a85855345ce Mon Sep 17 00:00:00 2001 From: defelmnq Date: Mon, 14 Apr 2025 19:44:16 +0200 Subject: [PATCH 08/15] add docker detection and lint --- devcontainers-cli/main.test.ts | 42 ++++++++++++++++++++++++++-------- devcontainers-cli/run.sh | 8 ++++++- 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts index 3cf4d2c7..b89a1285 100644 --- a/devcontainers-cli/main.test.ts +++ b/devcontainers-cli/main.test.ts @@ -27,9 +27,17 @@ const executeScriptInContainerWithPackageManager = async ( if (packageManager === "npm") { await execContainer(id, [shell, "-c", "apk add nodejs npm"]); } else if (packageManager === "pnpm") { - await execContainer(id, [shell, "-c", "apk add nodejs npm && npm install -g pnpm"]); + await execContainer(id, [ + shell, + "-c", + "apk add nodejs npm && npm install -g pnpm", + ]); } else if (packageManager === "yarn") { - await execContainer(id, [shell, "-c", "apk add nodejs npm && npm install -g yarn"]); + await execContainer(id, [ + shell, + "-c", + "apk add nodejs npm && npm install -g yarn", + ]); } const resp = await execContainer(id, [shell, "-c", instance.script]); @@ -65,11 +73,19 @@ describe("devcontainers-cli", async () => { agent_id: "some-agent-id", }); - const output = await executeScriptInContainerWithPackageManager(state, "alpine", "npm"); + const output = await executeScriptInContainerWithPackageManager( + state, + "alpine", + "npm", + ); expect(output.exitCode).toBe(0); - expect(output.stdout[0]).toEqual("Installing @devcontainers/cli using npm ..."); - expect(output.stdout[output.stdout.length-1]).toEqual("🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!"); + expect(output.stdout[0]).toEqual( + "Installing @devcontainers/cli using npm ...", + ); + expect(output.stdout[output.stdout.length - 1]).toEqual( + "🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!", + ); }); it("installs devcontainers-cli with yarn", async () => { @@ -77,10 +93,18 @@ describe("devcontainers-cli", async () => { agent_id: "some-agent-id", }); - const output = await executeScriptInContainerWithPackageManager(state, "alpine", "yarn"); + const output = await executeScriptInContainerWithPackageManager( + state, + "alpine", + "yarn", + ); expect(output.exitCode).toBe(0); - expect(output.stdout[0]).toEqual("Installing @devcontainers/cli using yarn ..."); - expect(output.stdout[output.stdout.length-1]).toEqual("🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!"); + expect(output.stdout[0]).toEqual( + "Installing @devcontainers/cli using yarn ...", + ); + expect(output.stdout[output.stdout.length - 1]).toEqual( + "🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!", + ); }); -}); \ No newline at end of file +}); diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh index 71e469f3..c7d037ec 100755 --- a/devcontainers-cli/run.sh +++ b/devcontainers-cli/run.sh @@ -6,6 +6,12 @@ if command -v devcontainer > /dev/null 2>&1; then exit 0 fi +# Check if docker is installed +if ! command -v docker > /dev/null 2>&1; then + echo "Docker is required." + exit 1 +fi + # Determine the package manager to use: npm, pnpm, or yarn if command -v pnpm > /dev/null 2>&1; then PACKAGE_MANAGER="pnpm" @@ -29,4 +35,4 @@ elif [ "$PACKAGE_MANAGER" = "yarn" ]; then && echo "🥳 @devcontainers/cli has been installed into $(which devcontainer)!" fi -exit 0 \ No newline at end of file +exit 0 From 4f7cd1e5f25dba47987d006b0919a2779e004b67 Mon Sep 17 00:00:00 2001 From: defelmnq Date: Mon, 14 Apr 2025 22:36:11 +0200 Subject: [PATCH 09/15] improve log and docker handling --- devcontainers-cli/run.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh index c7d037ec..d3446c1a 100755 --- a/devcontainers-cli/run.sh +++ b/devcontainers-cli/run.sh @@ -2,14 +2,13 @@ # If @devcontainers/cli is already installed, we can skip if command -v devcontainer > /dev/null 2>&1; then - echo "🥳 @devcontainers/cli is already installed" + echo "🥳 @devcontainers/cli is already installed into $(which devcontainer)!" exit 0 fi # Check if docker is installed if ! command -v docker > /dev/null 2>&1; then - echo "Docker is required." - exit 1 + echo "WARNING: Docker was not found but is required to use @devcontainers/cli, please make sure it is available." fi # Determine the package manager to use: npm, pnpm, or yarn From 47e28bccf49372ac16f76ec277dd07f33375de74 Mon Sep 17 00:00:00 2001 From: defelmnq Date: Mon, 14 Apr 2025 23:15:25 +0200 Subject: [PATCH 10/15] fix missing tests --- devcontainers-cli/main.test.ts | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts index b89a1285..f58d10d6 100644 --- a/devcontainers-cli/main.test.ts +++ b/devcontainers-cli/main.test.ts @@ -61,12 +61,12 @@ describe("devcontainers-cli", async () => { const state = await runTerraformApply(import.meta.dir, { agent_id: "some-agent-id", }); - const output = await executeScriptInContainer(state, "alpine"); + const output = await executeScriptInContainer(state, "docker:dind"); expect(output.exitCode).toBe(1); expect(output.stdout).toEqual([ "No supported package manager (npm, pnpm, yarn) is installed. Please install one first.", ]); - }); + }, 15000); it("installs devcontainers-cli with npm", async () => { const state = await runTerraformApply(import.meta.dir, { @@ -75,7 +75,7 @@ describe("devcontainers-cli", async () => { const output = await executeScriptInContainerWithPackageManager( state, - "alpine", + "docker:dind", "npm", ); expect(output.exitCode).toBe(0); @@ -95,7 +95,7 @@ describe("devcontainers-cli", async () => { const output = await executeScriptInContainerWithPackageManager( state, - "alpine", + "docker:dind", "yarn", ); expect(output.exitCode).toBe(0); @@ -107,4 +107,24 @@ describe("devcontainers-cli", async () => { "🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!", ); }); + + it("displays warning if docker is not installed", async () => { + const state = await runTerraformApply(import.meta.dir, { + agent_id: "some-agent-id", + }); + + const output = await executeScriptInContainerWithPackageManager( + state, + "alpine", + "npm", + ); + expect(output.exitCode).toBe(0); + + expect(output.stdout[0]).toEqual( + "WARNING: Docker was not found but is required to use @devcontainers/cli, please make sure it is available.", + ); + expect(output.stdout[output.stdout.length - 1]).toEqual( + "🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!", + ); + }); }); From 67dd5ea84a9281b8fddcb9a7f4a4d649ee9ae1ae Mon Sep 17 00:00:00 2001 From: Vincent Vielle Date: Tue, 15 Apr 2025 13:27:50 +0200 Subject: [PATCH 11/15] Update devcontainers-cli/run.sh Co-authored-by: Mathias Fredriksson --- devcontainers-cli/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh index d3446c1a..617c8874 100755 --- a/devcontainers-cli/run.sh +++ b/devcontainers-cli/run.sh @@ -23,7 +23,7 @@ else exit 1 fi -echo "Installing @devcontainers/cli using $PACKAGE_MANAGER ..." +echo "Installing @devcontainers/cli using $PACKAGE_MANAGER..." # Install @devcontainers/cli using the selected package manager if [ "$PACKAGE_MANAGER" = "npm" ] || [ "$PACKAGE_MANAGER" = "pnpm" ]; then From 8936b9aeae80075e43ce0be4e416629e74e7af37 Mon Sep 17 00:00:00 2001 From: Vincent Vielle Date: Tue, 15 Apr 2025 13:27:58 +0200 Subject: [PATCH 12/15] Update devcontainers-cli/run.sh Co-authored-by: Mathias Fredriksson --- devcontainers-cli/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devcontainers-cli/run.sh b/devcontainers-cli/run.sh index 617c8874..dce7a20e 100755 --- a/devcontainers-cli/run.sh +++ b/devcontainers-cli/run.sh @@ -19,7 +19,7 @@ elif command -v yarn > /dev/null 2>&1; then elif command -v npm > /dev/null 2>&1; then PACKAGE_MANAGER="npm" else - echo "No supported package manager (npm, pnpm, yarn) is installed. Please install one first." + echo "ERROR: No supported package manager (npm, pnpm, yarn) is installed. Please install one first." 1>&2 exit 1 fi From 89cca9c7b6ddfb2910979bfd30d07616a0144fca Mon Sep 17 00:00:00 2001 From: defelmnq Date: Tue, 15 Apr 2025 15:22:02 +0200 Subject: [PATCH 13/15] fix tests due to log changes --- devcontainers-cli/main.test.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/devcontainers-cli/main.test.ts b/devcontainers-cli/main.test.ts index f58d10d6..8872f181 100644 --- a/devcontainers-cli/main.test.ts +++ b/devcontainers-cli/main.test.ts @@ -63,8 +63,8 @@ describe("devcontainers-cli", async () => { }); const output = await executeScriptInContainer(state, "docker:dind"); expect(output.exitCode).toBe(1); - expect(output.stdout).toEqual([ - "No supported package manager (npm, pnpm, yarn) is installed. Please install one first.", + expect(output.stderr).toEqual([ + "ERROR: No supported package manager (npm, pnpm, yarn) is installed. Please install one first.", ]); }, 15000); @@ -81,7 +81,7 @@ describe("devcontainers-cli", async () => { expect(output.exitCode).toBe(0); expect(output.stdout[0]).toEqual( - "Installing @devcontainers/cli using npm ...", + "Installing @devcontainers/cli using npm...", ); expect(output.stdout[output.stdout.length - 1]).toEqual( "🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!", @@ -101,7 +101,7 @@ describe("devcontainers-cli", async () => { expect(output.exitCode).toBe(0); expect(output.stdout[0]).toEqual( - "Installing @devcontainers/cli using yarn ...", + "Installing @devcontainers/cli using yarn...", ); expect(output.stdout[output.stdout.length - 1]).toEqual( "🥳 @devcontainers/cli has been installed into /usr/local/bin/devcontainer!", From e6b4ac74d77427694f149524cd5ec579f245c968 Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 16 Apr 2025 13:39:48 +0500 Subject: [PATCH 14/15] update version --- devcontainers-cli/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md index ea7b62dd..11d910b3 100644 --- a/devcontainers-cli/README.md +++ b/devcontainers-cli/README.md @@ -6,17 +6,17 @@ verified: true maintainer_github: coder tags: [devcontainers] --- - +ß # devcontainers-cli -The devcontainers-cli module provides an easy way to install @devcontainers/cli into a workspace. It can be used within any workspace as it runs only if +The devcontainers-cli module provides an easy way to install [`@devcontainers/cli`](https://github.com/devcontainers/cli) into a workspace. It can be used within any workspace as it runs only if @devcontainers/cli is not installed yet. npm is required and should be installed in order for the module to work. ```tf module "devcontainers-cli" { source = "registry.coder.com/modules/devcontainers-cli/coder" - version = "release/claude-code/1.0.32" + version = "1.0.0" agent_id = coder_agent.example.id } ``` From 1928e960ffc4e3ecbb373a78ddb4fdae34d3be5d Mon Sep 17 00:00:00 2001 From: Muhammad Atif Ali Date: Wed, 16 Apr 2025 13:40:24 +0500 Subject: [PATCH 15/15] Fix typo and clarify npm requirement wording --- devcontainers-cli/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devcontainers-cli/README.md b/devcontainers-cli/README.md index 11d910b3..5ed3aed8 100644 --- a/devcontainers-cli/README.md +++ b/devcontainers-cli/README.md @@ -6,12 +6,12 @@ verified: true maintainer_github: coder tags: [devcontainers] --- -ß + # devcontainers-cli The devcontainers-cli module provides an easy way to install [`@devcontainers/cli`](https://github.com/devcontainers/cli) into a workspace. It can be used within any workspace as it runs only if @devcontainers/cli is not installed yet. -npm is required and should be installed in order for the module to work. +`npm` is required and should be pre-installed in order for the module to work. ```tf module "devcontainers-cli" {