generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #36 from hankei6km/topic/clasp
feat: Add clasp feature
- Loading branch information
Showing
9 changed files
with
119 additions
and
0 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@google/clasp (via npm)", | ||
"id": "google-clasp", | ||
"version": "1.0.1", | ||
"description": "Install the @google/clasp package via NPM registry", | ||
"options": { | ||
"version": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest" | ||
], | ||
"default": "latest", | ||
"description": "Select or enter a @google/clasp version." | ||
} | ||
}, | ||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils", | ||
"ghcr.io/devcontainers/features/node" | ||
] | ||
} |
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,34 @@ | ||
#!/usr/bin/env bash | ||
|
||
TARGET_PACKAGE="@google/clasp" | ||
TARGET_VERSION=${VERSION:-"latest"} | ||
|
||
set -e | ||
|
||
|
||
# https://github.com/Balazs23/devcontainers-features/blob/main/src/nx/install.sh | ||
command_exists() { | ||
command -v "$@" > /dev/null 2>&1 | ||
} | ||
install_packages() { | ||
# Use a custom cache since it is unclear how the cache is handled in the feature. | ||
# (whether it should be deleted or kept) | ||
local TEMP_CACHE | ||
TEMP_CACHE=$(mktemp -d) | ||
trap 'rm -rf "${TEMP_CACHE}"' EXIT | ||
|
||
echo "Installing npm package: ${TARGET_PACKAGE}@${TARGET_VERSION}" | ||
npm install --global --omit=dev --no-progress --cache "${TEMP_CACHE}" "${TARGET_PACKAGE}@${TARGET_VERSION}" | ||
} | ||
|
||
# Check if npm is installed | ||
if ! command_exists npm; then | ||
echo -e 'Feature requires npm to be installed. Please use a node-based image like:' | ||
# shellcheck disable=SC2016 | ||
echo -e ' - mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT}' | ||
echo -e 'You can also add as feature like:' | ||
echo -e ' - "ghcr.io/devcontainers/features/node:1": {}' | ||
fi | ||
|
||
# Instal pacakges | ||
install_packages |
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,18 @@ | ||
{ | ||
"v2.4.0": { | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:1": { | ||
"installZsh": false, | ||
"installOhMyZsh": false, | ||
"upgradePackages": false, | ||
"username": "node" | ||
}, | ||
"ghcr.io/devcontainers/features/node:1": {}, | ||
"google-clasp": { | ||
"version": "2.4.0" | ||
} | ||
}, | ||
"remoteUser": "node" | ||
} | ||
} |
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,20 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# -i で npm が使えるイメージを指定する必要がある。 | ||
# test-autogenerated ジョブでは matrix から外す。 | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
# Provides the 'check' and 'reportResults' commands. | ||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
# The 'check' command comes from the dev-container-features-test-lib. | ||
|
||
check "Check @google/clasp is installed" clasp --version | ||
|
||
# Report result | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |
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,17 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library bundled with the devcontainer CLI | ||
# Provides the 'check' and 'reportResults' commands. | ||
# shellcheck source=/dev/null | ||
source dev-container-features-test-lib | ||
|
||
# Feature-specific tests | ||
# The 'check' command comes from the dev-container-features-test-lib. | ||
# clasp 2.4.0 は動作しないので、パッケージの存在確認のみ行う。 | ||
check "Check @google/clasp@2.4.0 is installed" npm list --global --depth 0 | grep -q "@google/clasp@2.4.0" | ||
|
||
# Report result | ||
# If any of the checks above exited with a non-zero exit code, the test will fail. | ||
reportResults |