From 7ecd3ebf8d6c138112d555303fb047d2e568fa8c Mon Sep 17 00:00:00 2001 From: TJ Date: Wed, 17 Dec 2025 10:59:39 +0900 Subject: [PATCH 1/4] chore: Add Bundler plugin with GitHub Packages support - Implemented the Bundler CLI executable with authentication requirements. - Created Personal Access Token credential type with environment variable mapping. - Added tests for provisioning and importing Personal Access Tokens. --- plugins/bundler/bundle.go | 25 +++++++++++ plugins/bundler/personal_access_token.go | 42 +++++++++++++++++++ plugins/bundler/personal_access_token_test.go | 41 ++++++++++++++++++ plugins/bundler/plugin.go | 22 ++++++++++ 4 files changed, 130 insertions(+) create mode 100644 plugins/bundler/bundle.go create mode 100644 plugins/bundler/personal_access_token.go create mode 100644 plugins/bundler/personal_access_token_test.go create mode 100644 plugins/bundler/plugin.go diff --git a/plugins/bundler/bundle.go b/plugins/bundler/bundle.go new file mode 100644 index 00000000..d8955747 --- /dev/null +++ b/plugins/bundler/bundle.go @@ -0,0 +1,25 @@ +package bundler + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" +) + +func BundleCLI() schema.Executable { + return schema.Executable{ + Name: "Bundler CLI", + Runs: []string{"bundle"}, + DocsURL: sdk.URL("https://bundler.io/man/bundle-install.1.html"), + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.ForCommand("install"), + ), + Uses: []schema.CredentialUsage{ + { + Name: credname.PersonalAccessToken, + }, + }, + } +} diff --git a/plugins/bundler/personal_access_token.go b/plugins/bundler/personal_access_token.go new file mode 100644 index 00000000..5d40f0a2 --- /dev/null +++ b/plugins/bundler/personal_access_token.go @@ -0,0 +1,42 @@ +package bundler + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/importer" + "github.com/1Password/shell-plugins/sdk/provision" + "github.com/1Password/shell-plugins/sdk/schema" + "github.com/1Password/shell-plugins/sdk/schema/credname" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func PersonalAccessToken() schema.CredentialType { + return schema.CredentialType{ + Name: credname.PersonalAccessToken, + DocsURL: sdk.URL("https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token"), + ManagementURL: sdk.URL("https://github.com/settings/tokens"), + Fields: []schema.CredentialField{ + { + Name: fieldname.Token, + MarkdownDescription: "GitHub Personal Access Token used to authenticate to GitHub Package Registry for Bundler.", + Secret: true, + Composition: &schema.ValueComposition{ + Length: 40, + Prefix: "ghp_", + Charset: schema.Charset{ + Uppercase: true, + Lowercase: true, + Digits: true, + }, + }, + }, + }, + DefaultProvisioner: provision.EnvVars(defaultEnvVarMapping), + Importer: importer.TryAll( + importer.TryEnvVarPair(defaultEnvVarMapping), + ), + } +} + +var defaultEnvVarMapping = map[string]sdk.FieldName{ + "BUNDLE_RUBYGEMS__PKG__GITHUB__COM": fieldname.Token, +} diff --git a/plugins/bundler/personal_access_token_test.go b/plugins/bundler/personal_access_token_test.go new file mode 100644 index 00000000..4604cdfe --- /dev/null +++ b/plugins/bundler/personal_access_token_test.go @@ -0,0 +1,41 @@ +package bundler + +import ( + "testing" + + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/plugintest" + "github.com/1Password/shell-plugins/sdk/schema/fieldname" +) + +func TestPersonalAccessTokenProvisioner(t *testing.T) { + plugintest.TestProvisioner(t, PersonalAccessToken().DefaultProvisioner, map[string]plugintest.ProvisionCase{ + "default": { + ItemFields: map[sdk.FieldName]string{ + fieldname.Token: "ghp_1234567890123456789012345678901234567890", + }, + ExpectedOutput: sdk.ProvisionOutput{ + Environment: map[string]string{ + "BUNDLE_RUBYGEMS__PKG__GITHUB__COM": "ghp_1234567890123456789012345678901234567890", + }, + }, + }, + }) +} + +func TestPersonalAccessTokenImporter(t *testing.T) { + plugintest.TestImporter(t, PersonalAccessToken().Importer, map[string]plugintest.ImportCase{ + "environment": { + Environment: map[string]string{ + "BUNDLE_RUBYGEMS__PKG__GITHUB__COM": "ghp_1234567890123456789012345678901234567890", + }, + ExpectedCandidates: []sdk.ImportCandidate{ + { + Fields: map[sdk.FieldName]string{ + fieldname.Token: "ghp_1234567890123456789012345678901234567890", + }, + }, + }, + }, + }) +} diff --git a/plugins/bundler/plugin.go b/plugins/bundler/plugin.go new file mode 100644 index 00000000..62890a96 --- /dev/null +++ b/plugins/bundler/plugin.go @@ -0,0 +1,22 @@ +package bundler + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func New() schema.Plugin { + return schema.Plugin{ + Name: "bundler", + Platform: schema.PlatformInfo{ + Name: "Ruby Bundler", + Homepage: sdk.URL("https://bundler.io"), + }, + Credentials: []schema.CredentialType{ + PersonalAccessToken(), + }, + Executables: []schema.Executable{ + BundleCLI(), + }, + } +} From e17e11364aa321ec4c7f7f996bcabc5ff3ccc8cb Mon Sep 17 00:00:00 2001 From: TJ Date: Wed, 17 Dec 2025 11:22:20 +0900 Subject: [PATCH 2/4] GitHub Packages only supports authentication using a personal access token (classic). For more information, see Managing your personal access tokens. --- plugins/bundler/personal_access_token.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/bundler/personal_access_token.go b/plugins/bundler/personal_access_token.go index 5d40f0a2..7dfdc541 100644 --- a/plugins/bundler/personal_access_token.go +++ b/plugins/bundler/personal_access_token.go @@ -17,7 +17,7 @@ func PersonalAccessToken() schema.CredentialType { Fields: []schema.CredentialField{ { Name: fieldname.Token, - MarkdownDescription: "GitHub Personal Access Token used to authenticate to GitHub Package Registry for Bundler.", + MarkdownDescription: "GitHub Personal Access Token (classic) used to authenticate to GitHub Package Registry for Bundler. Note: GitHub Packages only supports authentication using a personal access token (classic). For more information, see [Managing your personal access tokens](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens).", Secret: true, Composition: &schema.ValueComposition{ Length: 40, From 79fa4cb8213a5b0087d26c2f8a16adc6b7157d9b Mon Sep 17 00:00:00 2001 From: TJ Date: Wed, 17 Dec 2025 11:48:44 +0900 Subject: [PATCH 3/4] trigger github actions --- plugins/bundler/plugin.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/bundler/plugin.go b/plugins/bundler/plugin.go index 62890a96..d9567084 100644 --- a/plugins/bundler/plugin.go +++ b/plugins/bundler/plugin.go @@ -5,6 +5,7 @@ import ( "github.com/1Password/shell-plugins/sdk/schema" ) +// github action bug func New() schema.Plugin { return schema.Plugin{ Name: "bundler", From 24922b68e967b18bdfb5bc75627635b5e9f1c3a8 Mon Sep 17 00:00:00 2001 From: TJ Date: Wed, 17 Dec 2025 11:51:12 +0900 Subject: [PATCH 4/4] remove debug code --- plugins/bundler/plugin.go | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/bundler/plugin.go b/plugins/bundler/plugin.go index d9567084..62890a96 100644 --- a/plugins/bundler/plugin.go +++ b/plugins/bundler/plugin.go @@ -5,7 +5,6 @@ import ( "github.com/1Password/shell-plugins/sdk/schema" ) -// github action bug func New() schema.Plugin { return schema.Plugin{ Name: "bundler",