From a37d9a3edc4d3813dee82b5154fcb5033997d477 Mon Sep 17 00:00:00 2001 From: hankei6km Date: Thu, 2 May 2024 10:13:51 +0000 Subject: [PATCH 1/3] feat: Add clasp feature --- .github/labeler.yml | 6 +++ .github/workflows/lint.yml | 1 + .github/workflows/test.yaml | 2 + scripts/init-labels.sh | 1 + src/google-clasp/devcontainer-feature.json | 24 +++++++++++ src/google-clasp/install.sh | 40 +++++++++++++++++ test/google-clasp/scenarios.json | 50 ++++++++++++++++++++++ test/google-clasp/test.sh | 21 +++++++++ test/google-clasp/types_none.sh | 17 ++++++++ test/google-clasp/types_v1.0.0.sh | 17 ++++++++ test/google-clasp/v2.4.0.sh | 18 ++++++++ 11 files changed, 197 insertions(+) create mode 100644 src/google-clasp/devcontainer-feature.json create mode 100644 src/google-clasp/install.sh create mode 100644 test/google-clasp/scenarios.json create mode 100644 test/google-clasp/test.sh create mode 100644 test/google-clasp/types_none.sh create mode 100644 test/google-clasp/types_v1.0.0.sh create mode 100644 test/google-clasp/v2.4.0.sh diff --git a/.github/labeler.yml b/.github/labeler.yml index 4af61ea..8b5fcd5 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -10,3 +10,9 @@ - any-glob-to-any-file: - "src/semver-tool/**" - "test/semver-tool/**" +"scope: google-clasp": + - all: + - changed-files: + - any-glob-to-any-file: + - "src/google-clasp/**" + - "test/google-clasp/**" diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b04299b..862d279 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -15,6 +15,7 @@ jobs: features: - prepare-commit-msg-context - semver-tool + - google-clasp steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index bc5f354..1f20cf3 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -15,6 +15,7 @@ jobs: features: - prepare-commit-msg-context - semver-tool + # - google-clasp baseImage: - debian:latest - ubuntu:latest @@ -36,6 +37,7 @@ jobs: features: - prepare-commit-msg-context - semver-tool + - google-clasp steps: - uses: actions/checkout@v4 diff --git a/scripts/init-labels.sh b/scripts/init-labels.sh index 610388b..63f3046 100755 --- a/scripts/init-labels.sh +++ b/scripts/init-labels.sh @@ -17,6 +17,7 @@ LABELS_TEXT_COLOR_DESCRIPTIOM=( "sem-pr: breaking change,#e99695,This change may affect existing functionality or APIs" "scope: prepare-commit-msg-context,#C2E0C6,prepare-commit-msg-context-related changes" "scope: semver-tool,#FEF2C0,semver-tool changes" + "scope: google-clasp,#63559F,clasp changes" ) for label_color_description in "${LABELS_TEXT_COLOR_DESCRIPTIOM[@]}"; do diff --git a/src/google-clasp/devcontainer-feature.json b/src/google-clasp/devcontainer-feature.json new file mode 100644 index 0000000..a23c733 --- /dev/null +++ b/src/google-clasp/devcontainer-feature.json @@ -0,0 +1,24 @@ +{ + "name": "@google/clasp (via npm)", + "id": "google-clasp", + "version": "1.0.0", + "description": "Install the @google/clasp with @types/google-apps-script package via NPM registry", + "options": { + "version": { + "type": "string", + "proposals": ["latest"], + "default": "latest", + "description": "Select or enter a @google/clasp version." + }, + "types": { + "type": "string", + "proposals": ["latest"], + "default": "latest", + "description": "Select or enter a @types/google-apps-script version(pass blank to not install)." + } + }, + "installsAfter": [ + "ghcr.io/devcontainers/features/common-utils", + "ghcr.io/devcontainers/features/node" + ] +} diff --git a/src/google-clasp/install.sh b/src/google-clasp/install.sh new file mode 100644 index 0000000..38c4633 --- /dev/null +++ b/src/google-clasp/install.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash + +TARGET_PACKAGE="@google/clasp" +TARGET_VERSION=${VERSION:-"latest"} +TARGET_TYPES_PACKAGE="@types/google-apps-script" +TARGET_TYPES_VERSION=${TYPES:-"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}" + if test "${TARGET_TYPES_PACKAGE}" != ""; then + echo "Installing npm package: ${TARGET_TYPES_PACKAGE}@${TARGET_TYPES_VERSION}" + npm install --global --omit=dev --no-progress --cache "${TEMP_CACHE}" "${TARGET_TYPES_PACKAGE}@${TARGET_TYPES_VERSION}" + fi +} + +# 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 diff --git a/test/google-clasp/scenarios.json b/test/google-clasp/scenarios.json new file mode 100644 index 0000000..180ef46 --- /dev/null +++ b/test/google-clasp/scenarios.json @@ -0,0 +1,50 @@ +{ + "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" + }, + "types_v1.0.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": { + "types": "1.0.0" + } + }, + "remoteUser": "node" + }, + "types_none": { + "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": { + "types": "" + } + }, + "remoteUser": "node" + } +} diff --git a/test/google-clasp/test.sh b/test/google-clasp/test.sh new file mode 100644 index 0000000..62ae4dd --- /dev/null +++ b/test/google-clasp/test.sh @@ -0,0 +1,21 @@ +#!/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 +check "Check types(@types/google-apps-script) is installed" npm list --global --depth 0 | grep -q "@types/google-apps-script@" + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults \ No newline at end of file diff --git a/test/google-clasp/types_none.sh b/test/google-clasp/types_none.sh new file mode 100644 index 0000000..bd8fd7c --- /dev/null +++ b/test/google-clasp/types_none.sh @@ -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. +check "Check @google/clasp is installed" clasp --version +check "Check types(@types/google-apps-script) is not installed" npm list --global --depth 0 | grep -v -q "@types/google-apps-script@" + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/google-clasp/types_v1.0.0.sh b/test/google-clasp/types_v1.0.0.sh new file mode 100644 index 0000000..554c6ce --- /dev/null +++ b/test/google-clasp/types_v1.0.0.sh @@ -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. +check "Check @google/clasp is installed" clasp --version +check "Check types(@types/google-apps-script) is installed" npm list --global --depth 0 | grep -q "@types/google-apps-script@1.0.0" + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/google-clasp/v2.4.0.sh b/test/google-clasp/v2.4.0.sh new file mode 100644 index 0000000..cf99055 --- /dev/null +++ b/test/google-clasp/v2.4.0.sh @@ -0,0 +1,18 @@ +#!/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" +check "Check types(@types/google-apps-script) is installed" npm list --global --depth 0 | grep -q "@types/google-apps-script@" + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults From a731aed0fba9c843305e2bcb0744bfa872dd8abf Mon Sep 17 00:00:00 2001 From: hankei6km Date: Thu, 2 May 2024 16:24:52 +0000 Subject: [PATCH 2/3] feat: Remove the installation of the @types/google-apps-script package --- src/google-clasp/devcontainer-feature.json | 8 +----- src/google-clasp/install.sh | 6 ---- test/google-clasp/scenarios.json | 32 ---------------------- test/google-clasp/test.sh | 1 - test/google-clasp/types_none.sh | 17 ------------ test/google-clasp/types_v1.0.0.sh | 17 ------------ test/google-clasp/v2.4.0.sh | 1 - 7 files changed, 1 insertion(+), 81 deletions(-) delete mode 100644 test/google-clasp/types_none.sh delete mode 100644 test/google-clasp/types_v1.0.0.sh diff --git a/src/google-clasp/devcontainer-feature.json b/src/google-clasp/devcontainer-feature.json index a23c733..010fa3a 100644 --- a/src/google-clasp/devcontainer-feature.json +++ b/src/google-clasp/devcontainer-feature.json @@ -2,19 +2,13 @@ "name": "@google/clasp (via npm)", "id": "google-clasp", "version": "1.0.0", - "description": "Install the @google/clasp with @types/google-apps-script package via NPM registry", + "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." - }, - "types": { - "type": "string", - "proposals": ["latest"], - "default": "latest", - "description": "Select or enter a @types/google-apps-script version(pass blank to not install)." } }, "installsAfter": [ diff --git a/src/google-clasp/install.sh b/src/google-clasp/install.sh index 38c4633..2bd4ff9 100644 --- a/src/google-clasp/install.sh +++ b/src/google-clasp/install.sh @@ -2,8 +2,6 @@ TARGET_PACKAGE="@google/clasp" TARGET_VERSION=${VERSION:-"latest"} -TARGET_TYPES_PACKAGE="@types/google-apps-script" -TARGET_TYPES_VERSION=${TYPES:-"latest"} set -e @@ -21,10 +19,6 @@ install_packages() { echo "Installing npm package: ${TARGET_PACKAGE}@${TARGET_VERSION}" npm install --global --omit=dev --no-progress --cache "${TEMP_CACHE}" "${TARGET_PACKAGE}@${TARGET_VERSION}" - if test "${TARGET_TYPES_PACKAGE}" != ""; then - echo "Installing npm package: ${TARGET_TYPES_PACKAGE}@${TARGET_TYPES_VERSION}" - npm install --global --omit=dev --no-progress --cache "${TEMP_CACHE}" "${TARGET_TYPES_PACKAGE}@${TARGET_TYPES_VERSION}" - fi } # Check if npm is installed diff --git a/test/google-clasp/scenarios.json b/test/google-clasp/scenarios.json index 180ef46..35abea6 100644 --- a/test/google-clasp/scenarios.json +++ b/test/google-clasp/scenarios.json @@ -14,37 +14,5 @@ } }, "remoteUser": "node" - }, - "types_v1.0.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": { - "types": "1.0.0" - } - }, - "remoteUser": "node" - }, - "types_none": { - "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": { - "types": "" - } - }, - "remoteUser": "node" } } diff --git a/test/google-clasp/test.sh b/test/google-clasp/test.sh index 62ae4dd..9f61c94 100644 --- a/test/google-clasp/test.sh +++ b/test/google-clasp/test.sh @@ -14,7 +14,6 @@ source dev-container-features-test-lib # The 'check' command comes from the dev-container-features-test-lib. check "Check @google/clasp is installed" clasp --version -check "Check types(@types/google-apps-script) is installed" npm list --global --depth 0 | grep -q "@types/google-apps-script@" # Report result # If any of the checks above exited with a non-zero exit code, the test will fail. diff --git a/test/google-clasp/types_none.sh b/test/google-clasp/types_none.sh deleted file mode 100644 index bd8fd7c..0000000 --- a/test/google-clasp/types_none.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/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. -check "Check @google/clasp is installed" clasp --version -check "Check types(@types/google-apps-script) is not installed" npm list --global --depth 0 | grep -v -q "@types/google-apps-script@" - -# Report result -# If any of the checks above exited with a non-zero exit code, the test will fail. -reportResults diff --git a/test/google-clasp/types_v1.0.0.sh b/test/google-clasp/types_v1.0.0.sh deleted file mode 100644 index 554c6ce..0000000 --- a/test/google-clasp/types_v1.0.0.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/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. -check "Check @google/clasp is installed" clasp --version -check "Check types(@types/google-apps-script) is installed" npm list --global --depth 0 | grep -q "@types/google-apps-script@1.0.0" - -# Report result -# If any of the checks above exited with a non-zero exit code, the test will fail. -reportResults diff --git a/test/google-clasp/v2.4.0.sh b/test/google-clasp/v2.4.0.sh index cf99055..fed1cab 100644 --- a/test/google-clasp/v2.4.0.sh +++ b/test/google-clasp/v2.4.0.sh @@ -11,7 +11,6 @@ source dev-container-features-test-lib # 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" -check "Check types(@types/google-apps-script) is installed" npm list --global --depth 0 | grep -q "@types/google-apps-script@" # Report result # If any of the checks above exited with a non-zero exit code, the test will fail. From 47754fe0016863988485dcff76cb9de65a1906fe Mon Sep 17 00:00:00 2001 From: hankei6km Date: Fri, 3 May 2024 00:08:46 +0000 Subject: [PATCH 3/3] feature_google-clasp_1.0.1 --- src/google-clasp/devcontainer-feature.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/google-clasp/devcontainer-feature.json b/src/google-clasp/devcontainer-feature.json index 010fa3a..c15ebb2 100644 --- a/src/google-clasp/devcontainer-feature.json +++ b/src/google-clasp/devcontainer-feature.json @@ -1,12 +1,14 @@ { "name": "@google/clasp (via npm)", "id": "google-clasp", - "version": "1.0.0", + "version": "1.0.1", "description": "Install the @google/clasp package via NPM registry", "options": { "version": { "type": "string", - "proposals": ["latest"], + "proposals": [ + "latest" + ], "default": "latest", "description": "Select or enter a @google/clasp version." }