licensed 3.2.3 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e2043fe7541ca6458302eab4e81fabdc22d874d5e80498eaac0f1551d7796e8
4
- data.tar.gz: abe1b03af0e02be363661d357e82cac6b53a127a6fd01cfef2c7ba2b6c174116
3
+ metadata.gz: f452bd7c6a58fdaa9a56cf7085b20fe4ff3a8f3eb214835ba82a52b2ed1ac71c
4
+ data.tar.gz: 8b3aff33c001623780455c68d23c014746e988b82a44db0fa243829c2be34cd5
5
5
  SHA512:
6
- metadata.gz: 8555b427c46ab7e0198cf4ac71ed02fae65a230576057bd6d2cbf38e5d26491479444cfc4ed6ec78549e615c5b8cf6d71ce762b31552bf7bfd1d348e228b1055
7
- data.tar.gz: 30da66cc1abb37677768dab09d79f93c17df25a7d0a73e06dbfdcb51ce7bb3ea66af5962e97631a019a8119498f4b0ebdeaca46667cb8b2b3d3fe0a2bb63c254
6
+ metadata.gz: e0bb95e3496257986e52294a7788824043697d8f99d2745c65e30e3a5c255843bc1471cf47ab3f3cd407d597c658b2d82e1bc27a76e6f985b45af6803d0e98a5
7
+ data.tar.gz: 93eb593c4389bff724a0a41be7c583e96541bfc308a9c331bf5d34c35217c98160e026733a49cc07b93b654b23e4507a447dbd5ab9ef8f1596a0e38139187757
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## 3.3.0
10
+
11
+ 2021-09-18
12
+
13
+ ### Added
14
+
15
+ - New cargo source enumerates rust dependencies (https://github.com/github/licensed/pull/404)
16
+
17
+ ### Changed
18
+
19
+ - Removed non-functional files from gem builds (https://github.com/github/licensed/pull/405)
20
+
9
21
  ## 3.2.3
10
22
 
11
23
  2021-09-14
@@ -497,4 +509,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
497
509
 
498
510
  Initial release :tada:
499
511
 
500
- [Unreleased]: https://github.com/github/licensed/compare/3.2.3...HEAD
512
+ [Unreleased]: https://github.com/github/licensed/compare/3.3.0...HEAD
@@ -0,0 +1,19 @@
1
+ # Cargo
2
+
3
+ The cargo source will detect dependencies when `Cargo.toml` is found at an apps `source_path`. The source uses the `cargo metadata` CLI and reports on all dependencies that are listed in the output in `resolve.nodes`, excluding packages that are listed in `workspace_members`.
4
+
5
+ ## Metadata CLI options
6
+
7
+ Licensed by default runs `cargo metadata --format-version=1`. You can specify additional CLI options by specifying them in your licensed configuration file under `cargo.metadata_options`. The configuration can be set as a string, or as an array of strings for multiple options.
8
+
9
+ ```yml
10
+ cargo:
11
+ metadata_options: '--all-features'
12
+ ```
13
+
14
+ ```yml
15
+ cargo:
16
+ metadata_options:
17
+ - '--all-features'
18
+ - '--filter-platform x86_64-pc-windows-msvc'
19
+ ```
@@ -0,0 +1,70 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+
5
+ module Licensed
6
+ module Sources
7
+ class Cargo < Source
8
+ # Source is enabled when the cargo tool and Cargo.toml manifest file are available
9
+ def enabled?
10
+ return false unless Licensed::Shell.tool_available?("cargo")
11
+ config.pwd.join("Cargo.toml").exist?
12
+ end
13
+
14
+ def enumerate_dependencies
15
+ packages.map do |package|
16
+ Dependency.new(
17
+ name: "#{package["name"]}-#{package["version"]}",
18
+ version: package["version"],
19
+ path: File.dirname(package["manifest_path"]),
20
+ metadata: {
21
+ "name" => package["name"],
22
+ "type" => Cargo.type,
23
+ "summary" => package["description"],
24
+ "homepage" => package["homepage"]
25
+ }
26
+ )
27
+ end
28
+ end
29
+
30
+ # Returns the package data for all dependencies used to build the current package
31
+ def packages
32
+ cargo_metadata_resolved_node_ids.map { |id| cargo_metadata_packages[id] }
33
+ end
34
+
35
+ # Returns the ids of all resolved nodes used to build the current package
36
+ def cargo_metadata_resolved_node_ids
37
+ cargo_metadata.dig("resolve", "nodes")
38
+ .map { |node| node["id"] }
39
+ .reject { |id| cargo_metadata_workspace_members.include?(id) }
40
+
41
+ end
42
+
43
+ # Returns a hash of id => package pairs sourced from the "packages" cargo metadata property
44
+ def cargo_metadata_packages
45
+ @cargo_metadata_packages ||= cargo_metadata["packages"].each_with_object({}) do |package, hsh|
46
+ hsh[package["id"]] = package
47
+ end
48
+ end
49
+
50
+ # Returns a set of the ids of packages in the current workspace
51
+ def cargo_metadata_workspace_members
52
+ @cargo_metadata_workspace_members ||= Set.new(Array(cargo_metadata["workspace_members"]))
53
+ end
54
+
55
+ # Returns parsed JSON metadata returned from the cargo CLI
56
+ def cargo_metadata
57
+ @cargo_metadata ||= JSON.parse(cargo_metadata_command)
58
+ rescue JSON::ParserError => e
59
+ message = "Licensed was unable to parse the output from 'cargo metadata'. JSON Error: #{e.message}"
60
+ raise Licensed::Sources::Source::Error, message
61
+ end
62
+
63
+ # Runs a command to get cargo metadata for the current package
64
+ def cargo_metadata_command
65
+ options = Array(config.dig("cargo", "metadata_options")).flat_map(&:split)
66
+ Licensed::Shell.execute("cargo", "metadata", "--format-version=1", *options)
67
+ end
68
+ end
69
+ end
70
+ end
@@ -5,6 +5,7 @@ module Licensed
5
5
  require "licensed/sources/bower"
6
6
  require "licensed/sources/bundler"
7
7
  require "licensed/sources/cabal"
8
+ require "licensed/sources/cargo"
8
9
  require "licensed/sources/composer"
9
10
  require "licensed/sources/dep"
10
11
  require "licensed/sources/git_submodule"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  module Licensed
3
- VERSION = "3.2.3".freeze
3
+ VERSION = "3.3.0".freeze
4
4
 
5
5
  def self.previous_major_versions
6
6
  major_version = Gem::Version.new(Licensed::VERSION).segments.first
data/licensed.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = "https://github.com/github/licensed"
17
17
  spec.license = "MIT"
18
18
 
19
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test/|script/|docker/|\..+)}) }
20
20
  spec.bindir = "exe"
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: licensed
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitHub
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-14 00:00:00.000000000 Z
11
+ date: 2021-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: licensee
@@ -238,13 +238,6 @@ executables:
238
238
  extensions: []
239
239
  extra_rdoc_files: []
240
240
  files:
241
- - ".github/dependabot.yml"
242
- - ".github/workflows/release.yml"
243
- - ".github/workflows/test.yml"
244
- - ".gitignore"
245
- - ".licensed.yml"
246
- - ".rubocop.yml"
247
- - ".ruby-version"
248
241
  - CHANGELOG.md
249
242
  - CODE_OF_CONDUCT.md
250
243
  - CONTRIBUTING.md
@@ -252,7 +245,6 @@ files:
252
245
  - LICENSE
253
246
  - README.md
254
247
  - Rakefile
255
- - docker/Dockerfile.build-linux
256
248
  - docs/adding_a_new_source.md
257
249
  - docs/commands/README.md
258
250
  - docs/commands/cache.md
@@ -280,6 +272,7 @@ files:
280
272
  - docs/sources/bower.md
281
273
  - docs/sources/bundler.md
282
274
  - docs/sources/cabal.md
275
+ - docs/sources/cargo.md
283
276
  - docs/sources/composer.md
284
277
  - docs/sources/dep.md
285
278
  - docs/sources/git_submodule.md
@@ -326,6 +319,7 @@ files:
326
319
  - lib/licensed/sources/bundler/definition.rb
327
320
  - lib/licensed/sources/bundler/missing_specification.rb
328
321
  - lib/licensed/sources/cabal.rb
322
+ - lib/licensed/sources/cargo.rb
329
323
  - lib/licensed/sources/composer.rb
330
324
  - lib/licensed/sources/dep.rb
331
325
  - lib/licensed/sources/git_submodule.rb
@@ -344,28 +338,6 @@ files:
344
338
  - lib/licensed/ui/shell.rb
345
339
  - lib/licensed/version.rb
346
340
  - licensed.gemspec
347
- - script/bootstrap
348
- - script/cibuild
349
- - script/console
350
- - script/package
351
- - script/packages/build
352
- - script/packages/linux
353
- - script/packages/mac
354
- - script/setup
355
- - script/source-setup/bower
356
- - script/source-setup/bundler
357
- - script/source-setup/cabal
358
- - script/source-setup/composer
359
- - script/source-setup/git_submodule
360
- - script/source-setup/go
361
- - script/source-setup/mix
362
- - script/source-setup/npm
363
- - script/source-setup/nuget
364
- - script/source-setup/pip
365
- - script/source-setup/pipenv
366
- - script/source-setup/swift
367
- - script/source-setup/yarn
368
- - script/test
369
341
  homepage: https://github.com/github/licensed
370
342
  licenses:
371
343
  - MIT
@@ -1,19 +0,0 @@
1
- # To get started with Dependabot version updates, you'll need to specify which
2
- # package ecosystems to update and where the package manifests are located.
3
- # Please see the documentation for all configuration options:
4
- # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5
-
6
- version: 2
7
- updates:
8
- - package-ecosystem: github-actions
9
- directory: /
10
- schedule:
11
- interval: daily
12
- - package-ecosystem: bundler
13
- directory: /
14
- schedule:
15
- interval: weekly
16
- - package-ecosystem: docker
17
- directory: docker
18
- schedule:
19
- interval: weekly
@@ -1,213 +0,0 @@
1
- name: Build and publish release assets
2
-
3
- on:
4
- release:
5
- types: [created]
6
- workflow_dispatch:
7
- inputs:
8
- version:
9
- description: 'Commit-like version of github/licensed to build package at'
10
- required: true
11
- release_tag:
12
- description: 'Release tag to upload built packages to'
13
- required: false
14
-
15
- jobs:
16
- vars:
17
- name: "Gather values for remainder of steps"
18
- runs-on: ubuntu-latest
19
- outputs:
20
- version: ${{ steps.get_version.outputs.result }}
21
- upload_url: ${{ steps.get_url.outputs.result }}
22
- ref: ${{ steps.get_ref.outputs.result }}
23
- steps:
24
- - id: get_version
25
- name: Get package version
26
- uses: actions/github-script@v4.1
27
- with:
28
- github-token: ${{ secrets.GITHUB_TOKEN }}
29
- result-encoding: string
30
- script: |
31
- let version = "${{ github.event.release.tag_name }}"
32
- if (!version) {
33
- version = "${{ github.event.inputs.version }}"
34
- }
35
-
36
- if (!version) {
37
- throw new Error("unable to find package build version")
38
- }
39
-
40
- return version
41
-
42
- - id: get_url
43
- name: Get release upload url
44
- uses: actions/github-script@v4.1
45
- with:
46
- github-token: ${{ secrets.GITHUB_TOKEN }}
47
- result-encoding: string
48
- script: |
49
- let uploadUrl = "${{ github.event.release.upload_url}}"
50
- const tag = "${{ github.event.inputs.release_tag }}"
51
- if (!uploadUrl && tag) {
52
- const { data: release } = await github.repos.getReleaseByTag({
53
- ...context.repo,
54
- tag
55
- })
56
-
57
- if (!release.upload_url) {
58
- throw new Error("unable to find a release upload url")
59
- }
60
-
61
- uploadUrl = release.upload_url
62
- }
63
-
64
- return uploadUrl
65
-
66
- - id: get_ref
67
- name: Get checkout ref for custom build scripts
68
- uses: actions/github-script@v4.1
69
- with:
70
- github-token: ${{ secrets.GITHUB_TOKEN }}
71
- result-encoding: string
72
- script: |
73
- let ref = "${{ github.event.release.tag_name }}"
74
- if (!ref) {
75
- ref = "${{ github.event.ref }}".replace(/refs\/[^\/]+\//, '')
76
- }
77
-
78
- if (!ref) {
79
- throw new Error("unable to find a ref for action")
80
- }
81
-
82
- return ref
83
-
84
- package_linux:
85
- needs: vars
86
- runs-on: ubuntu-18.04
87
- steps:
88
- - uses: actions/checkout@v2
89
- with:
90
- # checkout at the ref for the action, separate from the target build version
91
- # this allows running build scripts independent of the target version
92
- ref: ${{needs.vars.outputs.ref}}
93
- fetch-depth: 0
94
-
95
- - name: Set up Ruby 2.6
96
- uses: ruby/setup-ruby@v1
97
- with:
98
- ruby-version: 2.6
99
-
100
- - name: Build package
101
- run: script/packages/linux
102
- env:
103
- VERSION: ${{needs.vars.outputs.version}}
104
-
105
- - uses: actions/upload-artifact@v2
106
- with:
107
- name: ${{needs.vars.outputs.version}}-linux
108
- path: pkg/${{needs.vars.outputs.version}}/licensed-${{needs.vars.outputs.version}}-linux-x64.tar.gz
109
-
110
- package_mac:
111
- needs: vars
112
- runs-on: macOS-latest
113
- steps:
114
- - uses: actions/checkout@v2
115
- with:
116
- # checkout at the ref for the action, separate from the target build version
117
- # this allows running build scripts independent of the target version
118
- ref: ${{needs.vars.outputs.ref}}
119
- fetch-depth: 0
120
-
121
- - name: Set up Ruby 2.6
122
- uses: ruby/setup-ruby@v1
123
- with:
124
- ruby-version: 2.6
125
-
126
- - name: Build package
127
- run: script/packages/mac
128
- env:
129
- VERSION: ${{needs.vars.outputs.version}}
130
-
131
- - uses: actions/upload-artifact@v2
132
- with:
133
- name: ${{needs.vars.outputs.version}}-darwin
134
- path: pkg/${{needs.vars.outputs.version}}/licensed-${{needs.vars.outputs.version}}-darwin-x64.tar.gz
135
-
136
- build_gem:
137
- needs: vars
138
- runs-on: ubuntu-latest
139
- steps:
140
- - uses: actions/checkout@v2
141
- with:
142
- # building a gem doesn't use a different ref from the version input
143
- ref: ${{needs.vars.outputs.version}}
144
-
145
- - name: Set up Ruby 2.6
146
- uses: ruby/setup-ruby@v1
147
- with:
148
- ruby-version: 2.6
149
-
150
- - name: Build gem
151
- run: gem build licensed.gemspec -o licensed-${{needs.vars.outputs.version}}.gem
152
-
153
- - uses: actions/upload-artifact@v2
154
- with:
155
- name: ${{needs.vars.outputs.version}}-gem
156
- path: licensed-${{needs.vars.outputs.version}}.gem
157
-
158
- upload_packages:
159
- if: ${{ needs.vars.outputs.upload_url != '' }}
160
- runs-on: ubuntu-latest
161
- needs: [vars, package_linux, package_mac, build_gem]
162
-
163
- steps:
164
- - name: Set up Ruby 2.6
165
- uses: ruby/setup-ruby@v1
166
- with:
167
- ruby-version: 2.6
168
-
169
- - name: Download linux package
170
- uses: actions/download-artifact@v2
171
- with:
172
- name: ${{needs.vars.outputs.version}}-linux
173
-
174
- - name: Download macOS package
175
- uses: actions/download-artifact@v2
176
- with:
177
- name: ${{needs.vars.outputs.version}}-darwin
178
-
179
- - name: Download gem
180
- uses: actions/download-artifact@v2
181
- with:
182
- name: ${{needs.vars.outputs.version}}-gem
183
-
184
- - name: Publish linux package
185
- uses: actions/upload-release-asset@v1
186
- env:
187
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
188
- with:
189
- upload_url: ${{ needs.vars.outputs.upload_url }}
190
- asset_path: ./licensed-${{needs.vars.outputs.version}}-linux-x64.tar.gz
191
- asset_name: licensed-${{needs.vars.outputs.version}}-linux-x64.tar.gz
192
- asset_content_type: application/gzip
193
-
194
- - name: Publish mac package
195
- uses: actions/upload-release-asset@v1
196
- env:
197
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
198
- with:
199
- upload_url: ${{ needs.vars.outputs.upload_url }}
200
- asset_path: ./licensed-${{needs.vars.outputs.version}}-darwin-x64.tar.gz
201
- asset_name: licensed-${{needs.vars.outputs.version}}-darwin-x64.tar.gz
202
- asset_content_type: application/gzip
203
-
204
- - name: Publish gem to RubyGems
205
- run: |
206
- mkdir -p $HOME/.gem
207
- touch $HOME/.gem/credentials
208
- chmod 0600 $HOME/.gem/credentials
209
- printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials
210
- gem push $GEM
211
- env:
212
- RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
213
- GEM: licensed-${{needs.vars.outputs.version}}.gem