licensed 3.1.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +28 -11
- data/CHANGELOG.md +19 -0
- data/README.md +25 -80
- data/docs/adding_a_new_source.md +11 -8
- data/docs/commands/README.md +59 -0
- data/docs/commands/cache.md +35 -0
- data/docs/commands/env.md +10 -0
- data/docs/commands/list.md +23 -0
- data/docs/commands/migrate.md +10 -0
- data/docs/commands/notices.md +12 -0
- data/docs/commands/status.md +73 -0
- data/docs/commands/version.md +3 -0
- data/docs/configuration.md +9 -173
- data/docs/configuration/README.md +11 -0
- data/docs/configuration/allowed_licenses.md +17 -0
- data/docs/configuration/application_name.md +63 -0
- data/docs/configuration/application_source.md +64 -0
- data/docs/configuration/configuration_root.md +27 -0
- data/docs/configuration/configuring_multiple_apps.md +58 -0
- data/docs/configuration/dependency_source_enumerators.md +28 -0
- data/docs/configuration/ignoring_dependencies.md +19 -0
- data/docs/configuration/metadata_cache.md +106 -0
- data/docs/configuration/reviewing_dependencies.md +18 -0
- data/lib/licensed.rb +1 -0
- data/lib/licensed/cli.rb +2 -2
- data/lib/licensed/commands/cache.rb +19 -20
- data/lib/licensed/commands/command.rb +104 -72
- data/lib/licensed/commands/environment.rb +12 -11
- data/lib/licensed/commands/list.rb +0 -19
- data/lib/licensed/commands/notices.rb +0 -19
- data/lib/licensed/commands/status.rb +13 -15
- data/lib/licensed/configuration.rb +77 -7
- data/lib/licensed/report.rb +44 -0
- data/lib/licensed/reporters/cache_reporter.rb +48 -64
- data/lib/licensed/reporters/json_reporter.rb +19 -21
- data/lib/licensed/reporters/list_reporter.rb +45 -58
- data/lib/licensed/reporters/notices_reporter.rb +33 -46
- data/lib/licensed/reporters/reporter.rb +37 -104
- data/lib/licensed/reporters/status_reporter.rb +58 -56
- data/lib/licensed/reporters/yaml_reporter.rb +19 -21
- data/lib/licensed/sources/bundler.rb +1 -1
- data/lib/licensed/sources/gradle.rb +2 -2
- data/lib/licensed/sources/npm.rb +4 -3
- data/lib/licensed/version.rb +1 -1
- data/script/source-setup/go +1 -1
- metadata +21 -3
- data/docs/commands.md +0 -95
@@ -0,0 +1,10 @@
|
|
1
|
+
# `licensed env`
|
2
|
+
|
3
|
+
Prints the runtime environment used by licensed after loading a configuration file. This can be different from the configuration file inputs, for example all paths will be given as absolute file paths and glob paths may be expanded.
|
4
|
+
|
5
|
+
## Options
|
6
|
+
|
7
|
+
- `--config`/`-c`: the path to the licensed configuration file
|
8
|
+
- default value: `./.licensed.yml`
|
9
|
+
- `--format`/`-f`: the output format
|
10
|
+
- default value: `yaml`
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# `licensed list`
|
2
|
+
|
3
|
+
The list command finds and prints the dependencies for all sources in all configured applications. No additional actions are taken on dependencies.
|
4
|
+
|
5
|
+
## Options
|
6
|
+
|
7
|
+
- `--config`/`-c`: the path to the licensed configuration file
|
8
|
+
- default value: `./.licensed.yml`
|
9
|
+
- `--sources`/`-s`: runtime filter on which dependency sources are run. Sources must also be enabled in the licensed configuration file.
|
10
|
+
- default value: not set, all configured sources
|
11
|
+
- `--format`/`-f`: the output format
|
12
|
+
- default value: `yaml`
|
13
|
+
- `--licenses`/`-l`: if set, includes each dependency's detected license in the output
|
14
|
+
- default value: not set
|
15
|
+
|
16
|
+
### Reported Data
|
17
|
+
|
18
|
+
The following data is reported for each dependency when the YAML or JSON report formats are used
|
19
|
+
|
20
|
+
- name: the licensed recognized name for the dependency including the app and source name
|
21
|
+
- e.g. the full name for the `thor` bundler dependency used by this tool is `licensed.bundler.thor`
|
22
|
+
- version: the version of the enumerated dependency
|
23
|
+
- license: (optional) the dependency's SPDX license identifier
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# `licensed migrate`
|
2
|
+
|
3
|
+
Migrates the licensed configuration and cached metadata files from a previous version to the most recent version. This is not required for all major version updates. See [migrations documentation](../migrations) for details on the migrations needed for each major version.
|
4
|
+
|
5
|
+
## Options
|
6
|
+
|
7
|
+
- `--config`/`-c`: the path to the licensed configuration file
|
8
|
+
- default value: `./.licensed.yml`
|
9
|
+
- `--from`/`-f`: the licensed version to migrate from
|
10
|
+
- required
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# `licensed notices`
|
2
|
+
|
3
|
+
Outputs license and notice text for all dependencies in each app into a `NOTICE` file in the app's `cache_path`. If an app uses a shared cache path, the file name will contain the app name as well, e.g. `NOTICE.my_app`.
|
4
|
+
|
5
|
+
`NOTICE` file contents are retrieved from cached records, with the assumption that cached records have already been reviewed in a compliance workflow.
|
6
|
+
|
7
|
+
## Options
|
8
|
+
|
9
|
+
- `--config`/`-c`: the path to the licensed configuration file
|
10
|
+
- default value: `./.licensed.yml`
|
11
|
+
- `--sources`/`-s`: runtime filter on which dependency sources are run. Sources must also be enabled in the licensed configuration file.
|
12
|
+
- default value: not set, all configured sources
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# `licensed status`
|
2
|
+
|
3
|
+
The status command finds all dependencies and checks whether each dependency has a valid cached record.
|
4
|
+
|
5
|
+
A dependency will fail the status checks if:
|
6
|
+
|
7
|
+
1. No cached record is found
|
8
|
+
2. The cached record's version is different than the current dependency's version
|
9
|
+
3. The cached record's `licenses` data is empty
|
10
|
+
4. The cached record's `license` metadata doesn't match an `allowed` license from the dependency's application configuration.
|
11
|
+
- If `license: other` is specified and all of the `licenses` entries match an `allowed` license a failure will not be logged
|
12
|
+
5. The cached record is flagged for re-review.
|
13
|
+
- This occurs when the record's license text has changed since the record was reviewed.
|
14
|
+
|
15
|
+
## Options
|
16
|
+
|
17
|
+
- `--config`/`-c`: the path to the licensed configuration file
|
18
|
+
- default value: `./.licensed.yml`
|
19
|
+
- `--sources`/`-s`: runtime filter on which dependency sources are run. Sources must also be enabled in the licensed configuration file.
|
20
|
+
- default value: not set, all configured sources
|
21
|
+
- `--format`/`-f`: the output format
|
22
|
+
- default value: `yaml`
|
23
|
+
- `--force`: if set, forces all dependency metadata files to be recached
|
24
|
+
- default value: not set
|
25
|
+
|
26
|
+
## Reported Data
|
27
|
+
|
28
|
+
The following data is reported for each dependency when the YAML or JSON report formats are used
|
29
|
+
|
30
|
+
- name: the licensed recognized name for the dependency including the app and source name
|
31
|
+
- e.g. the full name for the `thor` bundler dependency used by this tool is `licensed.bundler.thor`
|
32
|
+
- allowed: true if the dependency has passed all checks, false otherwise
|
33
|
+
- version: the version of the enumerated dependency
|
34
|
+
- license: the dependency's SPDX license identifier
|
35
|
+
- filename: the full path on disk to the dependency's cached metadata file, if available
|
36
|
+
- errors: any error messages from failed status checks, if available
|
37
|
+
|
38
|
+
## Status errors and resolutions
|
39
|
+
|
40
|
+
### cached dependency record not found
|
41
|
+
|
42
|
+
**Cause:** A dependency was found while running `licensed status` that does not have a corresponding cached metadata file
|
43
|
+
**Resolution:** Run `licensed cache` to update the metadata cache and create the missing metadata file
|
44
|
+
|
45
|
+
### cached dependency record out of date
|
46
|
+
|
47
|
+
**Cause:** A dependency was found while running `licensed status` with a different version than is contained in the dependency's cached metadata file
|
48
|
+
**Resolution:** Run `licensed cache` to update the out-of-date metadata files
|
49
|
+
|
50
|
+
### missing license text
|
51
|
+
|
52
|
+
**Cause:** A license determination was made, e.g. from package metadata, but no license text was found.
|
53
|
+
**Resolution:** Manually verify whether the dependency includes a file containing license text. If the dependency code that was downloaded locally does not contain the license text, please check the dependency source at the version listed in the dependency's cached metadata file to see if there is license text that can be used.
|
54
|
+
|
55
|
+
If the dependency does not include license text but does specify that it uses a specific license, please copy the standard license text from a [well known source](https://opensource.org/licenses).
|
56
|
+
|
57
|
+
### license text has changed and needs re-review. if the new text is ok, remove the `review_changed_license` flag from the cached record
|
58
|
+
|
59
|
+
**Cause:** A dependency that is set as [reviewed] in the licensed configuration file has substantially changed and should be re-reviewed.
|
60
|
+
**Resolution:** Review the changes to the license text and classification, along with other metadata contained in the cached file for the dependency. If the dependency is still allowable for use in your project, remove the `review_changed_license` key from the cached record file.
|
61
|
+
|
62
|
+
### license needs review
|
63
|
+
|
64
|
+
**Cause:** A dependency is using a license that is not in the configured [allowed list of licenses][allowed], and the dependency has not been marked [ignored] or [reviewed].
|
65
|
+
**Resolution:** Review the dependency's usage and specified license with someone familiar with OSS licensing and compliance rules to determine whether the dependency is allowable. Some common resolutions:
|
66
|
+
|
67
|
+
1. The dependency's specified license text differed enough from the standard license text that it was not recognized and classified as `other`. If, with human review, the license text is recognizable then update the `license: other` value in the cached metadata file to the correct license.
|
68
|
+
1. The dependency might need to be marked as [ignored] or [reviewed] if either of those scenarios are applicable.
|
69
|
+
1. If the used license should be allowable without review (if your entity has a legal team, they may want to review this assessment), ensure the license SPDX is set as [allowed] in the licensed configuration file.
|
70
|
+
|
71
|
+
[allowed]: ../configuration/allowed_licenses.md
|
72
|
+
[ignored]: ../configuration/ignoring_dependencies.md
|
73
|
+
[reviewed]: ../configuration/reviewing_dependencies.md
|
data/docs/configuration.md
CHANGED
@@ -2,87 +2,12 @@
|
|
2
2
|
|
3
3
|
A configuration file specifies the details of enumerating and operating on license metadata for apps.
|
4
4
|
|
5
|
-
Configuration can be specified in either YML or JSON formats
|
5
|
+
Configuration can be specified in either YML or JSON formats, with examples given in YML. The example
|
6
|
+
below describes common configuration values and their purposes. See [configuration options documentation](./configuration)
|
7
|
+
for in depth information.
|
6
8
|
|
7
|
-
|
9
|
+
Additionally, some dependency sources have their own specific configuration options. See the [source documentation](./sources) for details.
|
8
10
|
|
9
|
-
`licensed` requires a path to enumerate dependencies at (`source_path`) and a path to store cached metadata (`cache_path`).
|
10
|
-
|
11
|
-
To determine these paths across multiple environments where absolute paths will differ, a known root path is needed to evaluate relative paths against.
|
12
|
-
In using a root, relative source and cache paths can be specified in the configuration file.
|
13
|
-
|
14
|
-
When using a configuration file, the root property can be set as either a path that can be expanded from the configuration file directory using `File.expand_path`, or the value `true` to use the configuration file directory as the root.
|
15
|
-
|
16
|
-
When creating a `Licensed::Dependency` manually with a `root` property, the property must be an absolute path - no path expansion will occur.
|
17
|
-
|
18
|
-
If a root path is not specified, it will default to using the following, in order of precedence
|
19
|
-
1. the root of the local git repository, if run inside a git repository
|
20
|
-
2. the current directory
|
21
|
-
|
22
|
-
### Source paths
|
23
|
-
|
24
|
-
A source path is the directory in which licensed should run to enumerate dependencies. This is often dependent on the project type, for example the bundler source should be run from the directory containing a `Gemfile` or `gems.rb` while the go source should be run from the directory containing an entrypoint function.
|
25
|
-
|
26
|
-
#### Using glob patterns
|
27
|
-
|
28
|
-
The `source_path` property can use one or more glob patterns to share configuration properties across multiple application entrypoints.
|
29
|
-
|
30
|
-
For example, there is a common pattern in Go projects to include multiple executable entrypoints under folders in `cmd`. Using a glob pattern allows users to avoid manually configuring and maintaining multiple licensed application `source_path`s. Using a glob pattern will also ensure that any new entrypoints matching the pattern are automatically picked up by licensed commands as they are added.
|
31
|
-
|
32
|
-
```yml
|
33
|
-
sources:
|
34
|
-
go: true
|
35
|
-
|
36
|
-
# treat all directories under `cmd` as separate apps
|
37
|
-
source_path: cmd/*
|
38
|
-
```
|
39
|
-
|
40
|
-
In order to better filter the results from glob patterns, the `source_path` property also accepts an array of inclusion and exclusion glob patterns similar to gitignore files. Inclusion patterns will add matching directory paths to resulting set of source paths, while exclusion patterns will remove matching directory paths.
|
41
|
-
|
42
|
-
```yml
|
43
|
-
source_path:
|
44
|
-
- "projects/*" # include by default all directories under "projects"
|
45
|
-
- "!projects/*Test" # exclude all projects ending in "Test"
|
46
|
-
```
|
47
|
-
|
48
|
-
Glob patterns are syntactic sugar for, and provide the same functionality as, manually specifying multiple `source_path` values. See the instructions on [specifying multiple apps](./#specifying-multiple-apps) below for additional considerations when using multiple apps.
|
49
|
-
|
50
|
-
## Restricting sources
|
51
|
-
|
52
|
-
The `sources` configuration property specifies which sources `licensed` will use to enumerate dependencies.
|
53
|
-
By default, `licensed` will generally try to enumerate dependencies from all sources. As a result,
|
54
|
-
the configuration property should be used to explicitly disable sources rather than to enable a particular source.
|
55
|
-
|
56
|
-
Be aware that this configuration is separate from an individual sources `#enabled?` method, which determines
|
57
|
-
whether the source is valid for the current project. Even if a source is enabled in the configuration
|
58
|
-
it may still determine that it can't enumerate dependencies for a project.
|
59
|
-
|
60
|
-
```yml
|
61
|
-
sources:
|
62
|
-
bower: true
|
63
|
-
bundler: false
|
64
|
-
```
|
65
|
-
|
66
|
-
`licensed` determines which sources will try to enumerate dependencies based on the following rules:
|
67
|
-
1. If no sources are configured, all sources are enabled
|
68
|
-
2. If no sources are set to true, any unconfigured sources are enabled
|
69
|
-
```yml
|
70
|
-
sources:
|
71
|
-
bower: false
|
72
|
-
# all other sources are enabled by default since there are no sources set to true
|
73
|
-
```
|
74
|
-
3. If any sources are set to true, any unconfigured sources are disabled
|
75
|
-
```yml
|
76
|
-
sources:
|
77
|
-
bower: true
|
78
|
-
# all other sources are disabled by default because a source was set to true
|
79
|
-
```
|
80
|
-
|
81
|
-
## Applications
|
82
|
-
|
83
|
-
What is an "app"? In the context of `licensed`, an app is a combination of a source path and a cache path.
|
84
|
-
|
85
|
-
Configuration can be set up for single or multiple applications in the same repo. There are a number of settings available for each app:
|
86
11
|
```yml
|
87
12
|
# If not set, defaults to the directory name of `source_path`
|
88
13
|
name: 'My application'
|
@@ -141,100 +66,11 @@ reviewed:
|
|
141
66
|
bower:
|
142
67
|
- classlist # public domain
|
143
68
|
- octicons
|
144
|
-
```
|
145
|
-
|
146
|
-
### Specifying a single app
|
147
|
-
To specify a single app, either include a single app with `source_path` in the `apps` configuration, or remove the `apps` setting entirely.
|
148
|
-
|
149
|
-
If the configuration does not contain an `apps` value, the root configuration will be used as an app definition. In this scenario, the `source_path` is not a required value and will default to the directory that `licensed` was executed from.
|
150
69
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
The configuration file can specify multiple source paths to enumerate metadata, each with their own configuration.
|
155
|
-
|
156
|
-
Nearly all configuration settings can be inherited from root configuration to app configuration. Only `source_path` is required to define an app.
|
157
|
-
|
158
|
-
Here are some examples:
|
159
|
-
|
160
|
-
#### Inheriting configuration
|
161
|
-
```yml
|
162
|
-
sources:
|
163
|
-
go: true
|
164
|
-
bundler: false
|
165
|
-
|
166
|
-
ignored:
|
167
|
-
bundler:
|
168
|
-
- some-internal-gem
|
169
|
-
|
170
|
-
reviewed:
|
171
|
-
bundler:
|
172
|
-
- bcrypt-ruby
|
173
|
-
|
174
|
-
cache_path: 'path/to/cache'
|
175
|
-
apps:
|
176
|
-
- source_path: 'path/to/app1'
|
177
|
-
- source_path: 'path/to/app2'
|
178
|
-
sources:
|
179
|
-
bundler: true
|
180
|
-
go: false
|
181
|
-
```
|
182
|
-
|
183
|
-
In this example, two apps have been declared. The first app, with `source_path` `path/to/app1`, inherits all configuration settings from the root configuration. The second app, with `source_path` `path/to/app2`, overrides the `sources` configuration and inherits all other settings.
|
184
|
-
|
185
|
-
#### Default app names
|
186
|
-
An app will not inherit a name set from the root configuration. If not provided, the `name` value will default to the directory name from `source_path`.
|
187
|
-
```yml
|
70
|
+
# A single configuration file can be used to enumerate dependencies for multiple
|
71
|
+
# projects. Each configuration is referred to as an "application" and must include
|
72
|
+
# a source path, at a minimum
|
188
73
|
apps:
|
189
|
-
- source_path:
|
190
|
-
- source_path:
|
74
|
+
- source_path: path/to/application1
|
75
|
+
- source_path: path/to/application2
|
191
76
|
```
|
192
|
-
|
193
|
-
In this example, the apps have names of `app1` and `app2`, respectively.
|
194
|
-
|
195
|
-
#### Inherited cache_path values
|
196
|
-
When an app inherits a `cache_path` from the root configuration, it will automatically append it's name to the end of the path to separate it's metadata from other apps. To force multiple apps to use the same path to cached metadata, explicitly set the `cache_path` value for each app.
|
197
|
-
```yml
|
198
|
-
cache_path: 'path/to/cache'
|
199
|
-
apps:
|
200
|
-
- source_path: 'path/to/app1'
|
201
|
-
name: 'app1'
|
202
|
-
- source_path: 'path/to/app2'
|
203
|
-
name: 'app2'
|
204
|
-
- source_path: 'path/to/app3'
|
205
|
-
name: 'app3'
|
206
|
-
cache_path: 'path/to/app3/cache'
|
207
|
-
```
|
208
|
-
|
209
|
-
In this example `app1` and `app2` have `cache_path` values of `path/to/cache/app1` and `path/to/cache/app2`, respectively. `app3` has an explicit path set to `path/to/app3/cache`
|
210
|
-
|
211
|
-
```yml
|
212
|
-
apps:
|
213
|
-
- source_path: 'path/to/app1'
|
214
|
-
```
|
215
|
-
|
216
|
-
In this example, the root configuration will contain a default cache path of `.licenses`. `app1` will inherit this value and append it's name, resulting in a cache path of `.licenses/app1`.
|
217
|
-
|
218
|
-
### Sharing caches between apps
|
219
|
-
|
220
|
-
Dependency caches can be shared between apps by setting the same cache path on each app.
|
221
|
-
|
222
|
-
```yaml
|
223
|
-
apps:
|
224
|
-
- source_path: "path/to/app1"
|
225
|
-
cache_path: ".licenses/apps"
|
226
|
-
- source_path: "path/to/app2"
|
227
|
-
cache_path: ".licenses/apps"
|
228
|
-
```
|
229
|
-
|
230
|
-
When using a source path with a glob pattern, the apps created from the glob pattern can share a dependency by setting an explicit cache path and setting `shared_cache` to true.
|
231
|
-
|
232
|
-
```yaml
|
233
|
-
source_path: "path/to/apps/*"
|
234
|
-
cache_path: ".licenses/apps"
|
235
|
-
shared_cache: true
|
236
|
-
```
|
237
|
-
|
238
|
-
## Source specific configuration
|
239
|
-
|
240
|
-
See the [source documentation](./sources) for details on any source specific configuration.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Configuration options
|
2
|
+
|
3
|
+
1. [Application source path](./application_source.md)
|
4
|
+
1. [Dependency metadata cache](./metadata_cache.md)
|
5
|
+
1. [Configuring multiple applications / monorepo support](./configuring_multiple_apps.md)
|
6
|
+
1. [Configuration root](./configuration_root.md)
|
7
|
+
1. [Application name](./application_name.md)
|
8
|
+
1. [Dependency source enumerators](./dependency_source_enumerators.md)
|
9
|
+
1. [Allowed licenses](./allowed_licenses.md)
|
10
|
+
1. [Ignoring dependencies](./ignoring_dependencies.md)
|
11
|
+
1. [Reviewing dependencies](./reviewing_dependencies.md)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Allowed licenses
|
2
|
+
|
3
|
+
**Key**: allowed
|
4
|
+
**Default Value**: none
|
5
|
+
|
6
|
+
The list of allowed licenses is used with the [status command](../commands/status.md) to detail which licenses are allowable for use in the current project and do not need further review. If a dependency uses a license that is not included in the allowed list, and the dependency is not on the ignored or reviewed dependency lists, it will be flagged and the status command will fail.
|
7
|
+
|
8
|
+
This configuration value accepts an array of lower-cased [open source license SPDX identifiers](https://spdx.org/licenses/).
|
9
|
+
|
10
|
+
```yml
|
11
|
+
# accepts lowercase SPDX license identifiers
|
12
|
+
allowed:
|
13
|
+
- mit
|
14
|
+
- bsd-2-clause
|
15
|
+
- bsd-3-clause
|
16
|
+
- isc
|
17
|
+
```
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Application name
|
2
|
+
|
3
|
+
**Key**: name
|
4
|
+
**Default value**: The directory name of the application's source path
|
5
|
+
|
6
|
+
The name of the application is primarily used for organizational and display purposes. Application names are not included with
|
7
|
+
dependency metadata information included in cached files.
|
8
|
+
|
9
|
+
```yml
|
10
|
+
source_path: path/to/application1
|
11
|
+
name: application1
|
12
|
+
```
|
13
|
+
|
14
|
+
## Dynamically generated application names
|
15
|
+
|
16
|
+
### Source path directory name
|
17
|
+
|
18
|
+
When not specified, an application's name will be the directory name from the application's source path.
|
19
|
+
|
20
|
+
```yml
|
21
|
+
# if not explicitly set the name will be inferred from the source path
|
22
|
+
source_path: path/to/application1
|
23
|
+
# name: application1
|
24
|
+
|
25
|
+
# or, use the `directory_name` name generator to explicitly set this behavior
|
26
|
+
source_path: path/to/application1
|
27
|
+
name:
|
28
|
+
generator: directory_name
|
29
|
+
# name: application1
|
30
|
+
```
|
31
|
+
|
32
|
+
### Relative path from configuration root
|
33
|
+
|
34
|
+
Application names can be created from the path from the configuration root to the application source path.
|
35
|
+
This can be useful when specifying multiple applications using a glob pattern in a directory structure where directory names
|
36
|
+
are not unique.
|
37
|
+
|
38
|
+
As an example, given the following directory structure and configuration YML, the resulting application names
|
39
|
+
would be `linux.installer`, `windows.installer` and `mac.installer`. The optional arguments `separator` and `depth` are used
|
40
|
+
to better control the resulting application name.
|
41
|
+
|
42
|
+
```text
|
43
|
+
path
|
44
|
+
|_to
|
45
|
+
|_linux
|
46
|
+
|_installer
|
47
|
+
|_windows
|
48
|
+
|_installer
|
49
|
+
|_mac
|
50
|
+
|_installer
|
51
|
+
```
|
52
|
+
|
53
|
+
```yml
|
54
|
+
source_path: '**/installer'
|
55
|
+
name:
|
56
|
+
generator: relative_path
|
57
|
+
# separator controls what character separates path parts in the application name
|
58
|
+
# default: "-"
|
59
|
+
separator: '.'
|
60
|
+
# depth controls how many of the path parts are used in the application name
|
61
|
+
# default: 0 / all path parts
|
62
|
+
depth: 2
|
63
|
+
```
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Application source path
|
2
|
+
|
3
|
+
**Key**: source_path
|
4
|
+
**Default value**:
|
5
|
+
|
6
|
+
- if the `apps` key is not present, then the current working directory where `licensed` was executed
|
7
|
+
- if the `apps` key is present, then `nil`
|
8
|
+
|
9
|
+
The source path is the directory in which licensed should run to enumerate dependencies. This is often dependent
|
10
|
+
on the project type, for example the bundler source should be run from the directory containing a `Gemfile` or `gems.rb`
|
11
|
+
while the go source should be run from the directory containing an entrypoint function.
|
12
|
+
|
13
|
+
The source path is required to run `licensed`. A default value is available only when the configuration file specifies a single application.
|
14
|
+
When multiple applications are configured, each application must specify a source path.
|
15
|
+
|
16
|
+
Paths can be given as absolute or relative paths, and can use special path identifiers. If a relative path is given, it will be based on the application's root path.
|
17
|
+
|
18
|
+
```yml
|
19
|
+
# when apps is not set, a source path does not need to be specified. it will default to the users current directory
|
20
|
+
sources:
|
21
|
+
bundler: true
|
22
|
+
|
23
|
+
# ------
|
24
|
+
# or a path can be given as either an absolute or relative path
|
25
|
+
sources:
|
26
|
+
bundler: true
|
27
|
+
source_path: path/to/application1
|
28
|
+
|
29
|
+
# ------
|
30
|
+
# when apps is set, each application must specify a source_path
|
31
|
+
sources:
|
32
|
+
bundler: true
|
33
|
+
apps:
|
34
|
+
- source_path: relative/path/to/application1
|
35
|
+
- source_path: /absolute/path/to/application2
|
36
|
+
- source_path: ~/path/from/home/to/application3
|
37
|
+
```
|
38
|
+
|
39
|
+
## Expanding source paths with glob patterns
|
40
|
+
|
41
|
+
The `source_path` property can use one or more glob patterns to share configuration properties across multiple application entrypoints.
|
42
|
+
|
43
|
+
For example, there is a common pattern in Go projects to include multiple executable entrypoints under folders in `cmd`. Using a glob pattern allows users to avoid manually configuring and maintaining multiple licensed application `source_path`s. Using a glob pattern will also ensure that any new entrypoints matching the pattern are automatically picked up by licensed commands as they are added.
|
44
|
+
|
45
|
+
```yml
|
46
|
+
sources:
|
47
|
+
go: true
|
48
|
+
|
49
|
+
# treat all directories under `cmd` as separate apps
|
50
|
+
source_path: cmd/*
|
51
|
+
```
|
52
|
+
|
53
|
+
In order to better filter the results from glob patterns, the `source_path` property also accepts an array of
|
54
|
+
inclusion and exclusion glob patterns similar to gitignore files. Inclusion patterns will add matching directory
|
55
|
+
paths to resulting set of source paths, while exclusion patterns will remove matching directory paths.
|
56
|
+
|
57
|
+
```yml
|
58
|
+
source_path:
|
59
|
+
- "projects/*" # include by default all directories under "projects"
|
60
|
+
- "!projects/*Test" # exclude all projects ending in "Test"
|
61
|
+
```
|
62
|
+
|
63
|
+
Glob patterns are syntactic sugar for, and provide the same functionality as, manually specifying multiple `source_path` values.
|
64
|
+
See the instructions on [specifying multiple apps](../configuration.md#specifying-multiple-apps) below for additional considerations when using multiple apps.
|