hem-tasks-composer_auth 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rubocop.yml +5 -0
- data/Gemfile +4 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/hem-tasks-composer_auth.gemspec +26 -0
- data/lib/hem/tasks/composer_auth/auth.rb +63 -0
- data/lib/hem/tasks/composer_auth/version.rb +7 -0
- data/lib/hem/tasks/composer_auth.rb +11 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d0e52480c92af4cec06e8bc7cf64a6ab42d02fe
|
4
|
+
data.tar.gz: 33bc18e10fa64d7f02c7b56ce5077f055fa29df6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 672b143f7c7fcf332f896182a2accd1f42ea1c6eb2840f797e0be0bf612eedd1c96f9480fb013a29579fd1c8befe59b88ec0d3f373df6d138f616c9a2c6bc45c
|
7
|
+
data.tar.gz: 4e3ab44840eb26fb74759ab4d7837fe1bb7f098c57628a1218c261df958cc16ca87556e3ec0a4940fa2be455dc323d92a4ef9591554e4c38f5f9e6b75ec74d6a
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Hem::Tasks::ComposerAuth
|
2
|
+
|
3
|
+
Contains tasks for [Hem](https://github.com/inviqa/hem) to set up authentication for composer.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add these lines to your application's Hemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
plugins do
|
11
|
+
gem 'hem-tasks-composer_auth', '~> 1.0.0'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
then either:
|
16
|
+
```ruby
|
17
|
+
after 'tools:composer', 'deps:auth:composer:file'
|
18
|
+
```
|
19
|
+
or:
|
20
|
+
```ruby
|
21
|
+
after 'tools:composer', 'deps:auth:composer:config'
|
22
|
+
```
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Run the following to see usage:
|
27
|
+
|
28
|
+
```bash
|
29
|
+
hem deps auth composer
|
30
|
+
```
|
31
|
+
|
32
|
+
## Development
|
33
|
+
|
34
|
+
After checking out the repo, run `bundle install` to install dependencies.
|
35
|
+
|
36
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/inviqa/hem-tasks-composer_auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# ^ Syntax hint
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'hem/tasks/composer_auth/version'
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = 'hem-tasks-composer_auth'
|
11
|
+
spec.version = Hem::Tasks::ComposerAuth::VERSION
|
12
|
+
spec.authors = ['Kieren Evans']
|
13
|
+
spec.email = ['kevans+hem_tasks@inviqa.com']
|
14
|
+
|
15
|
+
spec.summary = 'Composer Authentication task for Hem'
|
16
|
+
spec.description = 'Composer Authentication task for Hem'
|
17
|
+
spec.homepage = ''
|
18
|
+
spec.licenses = ['MIT']
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|\.rubocop\.yml|Rakefile)/}) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rubocop', '~> 0.55.0'
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# ^ Syntax hint
|
3
|
+
|
4
|
+
desc 'Authentication for dependencies'
|
5
|
+
namespace :auth do
|
6
|
+
desc 'Authentication for composer dependencies'
|
7
|
+
namespace :composer do
|
8
|
+
desc 'Ask for a composer authentication token for fetching private repositories inside the VM'
|
9
|
+
task :config, [:domain, :username, :token] do |_task_name, args|
|
10
|
+
domain = args[:domain] || 'github-oauth.github.com'
|
11
|
+
Hem.ui.section 'Composer Configuration' do
|
12
|
+
# strip first subdomain off for checking in auth.json as composer puts the first part as a top level key
|
13
|
+
# for example "http-basic" from "http-basic.example.com"
|
14
|
+
auth_domain = domain.sub(/^[^\.]+\./, '')
|
15
|
+
has_auth_exitcode = run "grep -q '#{auth_domain}' ~/.composer/auth.json",
|
16
|
+
ignore_errors: true, exit_status: true
|
17
|
+
has_auth = has_auth_exitcode.zero?
|
18
|
+
if has_auth
|
19
|
+
Hem.ui.success 'Detected that domain present in ~/.composer/auth.json already, skipping'
|
20
|
+
else
|
21
|
+
username = Hem.ui.ask('Username for ' + domain, default: args[:username]).to_s unless domain =~ /github/
|
22
|
+
|
23
|
+
question = 'Authentication Token for ' + domain
|
24
|
+
if domain =~ /github/
|
25
|
+
question = 'Github OAuth Token [This can be generated at https://github.com/settings/tokens ]'
|
26
|
+
end
|
27
|
+
token = Hem.ui.ask(question, default: args[:token]).to_s
|
28
|
+
|
29
|
+
if !username.empty? && !token.empty?
|
30
|
+
run php_command("php bin/composer.phar config --global '#{domain}' '#{username}' '#{token}'")
|
31
|
+
elsif !token.empty?
|
32
|
+
run php_command("php bin/composer.phar config --global '#{domain}' '#{token}'")
|
33
|
+
end
|
34
|
+
|
35
|
+
if !token.empty?
|
36
|
+
Hem.ui.success 'Set composer config token in ~/.composer/auth.json'
|
37
|
+
else
|
38
|
+
Hem.ui.info 'Skipped composer config as no token provided'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Ask for a composer auth file as JSON, or pick from COMPOSER_AUTH in the environment, '\
|
45
|
+
'for fetching private repositories inside the VM'
|
46
|
+
task :file do
|
47
|
+
Hem.ui.section 'Composer Configuration' do
|
48
|
+
auth = ''
|
49
|
+
auth = ENV['COMPOSER_AUTH'] if ENV['COMPOSER_AUTH']
|
50
|
+
auth = Hem.ui.ask('Composer Auth JSON', default: auth).to_s
|
51
|
+
if auth
|
52
|
+
require 'shellwords'
|
53
|
+
escaped_composer_auth = auth.gsub('"', '\"')
|
54
|
+
Hem.ui.section 'Setting up Composer Authentication in ~/.composer/auth.json' do
|
55
|
+
run 'mkdir -p ~/.composer/', realtime: true, indent: 2
|
56
|
+
run "echo '#{escaped_composer_auth}' > ~/.composer/auth.json", realtime: true, indent: 2
|
57
|
+
Hem.ui.success 'Done'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hem-tasks-composer_auth
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kieren Evans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rubocop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.55.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.55.0
|
55
|
+
description: Composer Authentication task for Hem
|
56
|
+
email:
|
57
|
+
- kevans+hem_tasks@inviqa.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rubocop.yml"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- hem-tasks-composer_auth.gemspec
|
68
|
+
- lib/hem/tasks/composer_auth.rb
|
69
|
+
- lib/hem/tasks/composer_auth/auth.rb
|
70
|
+
- lib/hem/tasks/composer_auth/version.rb
|
71
|
+
homepage: ''
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.4.8
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Composer Authentication task for Hem
|
95
|
+
test_files: []
|