npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@ciderjs/clasp-auth

v0.2.0

Published

Manage clasp credential data to use GitHub Actions secrets

Downloads

223

Readme

@ciderjs/clasp-auth

License npm version GitHub Marketplace GitHub issues

Google Apps Script (GAS) を GitHub Actions で CI/CD するための clasp 認証補助ツール
ローカルで clasp login した認証情報を GitHub Secrets にアップロード/削除し、CI/CD 環境で .clasprc.json を自動生成します。


⚠️ Prerequisites

このツールを利用するには以下が必要です:

  • GitHub CLI (gh)

    • インストール してください
    • gh auth login を実行し、GitHub にログインしておく必要があります
  • Google Apps Script CLI (clasp)

    • インストール してください
    • clasp login を実行し、Google アカウントでログインしておく必要があります
  • 注意事項

    • CI/CD は 実行者の Google アカウント情報 を利用して行われます
    • Secrets をアップロードするリポジトリは十分に注意してください
      (誤ったリポジトリにアップロードすると、意図しない環境で認証情報が利用される可能性があります)

✨ Features

  • CLI

    • upload: ローカルの ~/.clasprc.json を読み込み、JSON 文字列として GitHub Secrets (CLASPRC_JSON) にアップロード
    • delete: 登録済みの Secret (CLASPRC_JSON) を削除
    • --yes オプションで確認プロンプトをスキップ可能
    • 実行前に リポジトリの存在確認編集権限チェック を自動で行う
  • GitHub Action

    • Secrets (CLASPRC_JSON) から .clasprc.json を生成し、CI/CD 環境で clasp push を実行可能にする

📦 Installation

グローバルインストール:

npm install -g @ciderjs/clasp-auth

プロジェクトローカル:

npm install --save-dev @ciderjs/clasp-auth

🚀 Usage

1. Secrets をアップロード (CLI)

まずローカルで clasp login を実行し、~/.clasprc.json を生成します。
その後、以下のコマンドで GitHub Secrets にアップロードします:

npx @ciderjs/clasp-auth upload <owner/repo>

例:

npx @ciderjs/clasp-auth upload ciderjs/city-gas

登録される Secret:

  • CLASPRC_JSON.clasprc.json の内容を JSON 文字列としてBase64エンコードし保存

2. Secrets を削除 (CLI)

登録済みの Secret を削除するには:

npx @ciderjs/clasp-auth delete <owner/repo>

確認プロンプトをスキップする場合:

npx @ciderjs/clasp-auth delete <owner/repo> --yes

3. GitHub Actions で利用 (Action)

Workflow 内で Secret をファイルに復元し、clasp が利用できるようにします。

 name: Deploy GAS
 on:
   push:
     branches: [ "main" ]

 jobs:
   deploy:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
       - uses: actions/setup-node@v4
         with:
           node-version: 20
 
+      - name: Setup clasp auth
+        uses: ciderjs/[email protected]
+        with:
+          json: {{ secrets.CLASPRC_JSON }}

       - name: Install clasp
         run: npm install -g @google/clasp

       - name: Push to GAS
         run: clasp push

📖 Examples

プライベートリポジトリで使用

# Secrets をアップロード
clasp-auth upload myorg/private-gas-project

# GitHub Actions で使用
# (workflow 例を参照)

複数プロジェクトの管理

# プロジェクトごとに異なるリポジトリにアップロード
clasp-auth upload myorg/project-a
clasp-auth upload myorg/project-b

🛠 Development

# ビルド
pnpm build

# テスト (Vitest)
pnpm test

# ローカルで CLI を試す
npm link
clasp-auth upload <owner/repo>

🔒 Security Considerations

  • Secrets は 1 つ (CLASPRC_JSON) のみを利用するため、管理が容易
  • .clasprc.json の内部構造変更にも強い
  • 公開リポジトリではなくプライベートリポジトリでの利用を推奨
  • Secrets を参照できるジョブを限定するために permissions を明示的に設定すること
  • .clasprc.json の内容をログに出力しないこと
  • 定期的に clasp login をやり直し、Secrets をローテーションすること

🔧 Troubleshooting

gh: command not found

GitHub CLI がインストールされていません。こちらからインストールしてください。

No .clasprc.json found

clasp login を実行して認証情報を生成してください。

Permission denied

gh auth login を実行し、適切な権限でログインしてください。

Repository not found

リポジトリ名が正しいか確認してください (形式: owner/repo)。


🔄 Release

  • タグを手動で付与してリリースをトリガーします(例: v0.1.0
  • リリースノートは GitHub の自動生成ノート を利用
  • npm publish は CI により実行されます(NPM_TOKEN が必要)

📄 License

MIT