Giter Club home page Giter Club logo

mono0926 / licenseplist Goto Github PK

View Code? Open in Web Editor NEW
2.4K 22.0 142.0 32.69 MB

A license list generator of all your dependencies for iOS applications

Home Page: https://www.slideshare.net/mono0926/licenseplist-a-license-list-generator-of-all-your-dependencies-for-ios-applications

License: MIT License

Swift 85.33% Makefile 0.62% Shell 1.53% HTML 12.40% Ruby 0.13%
license license-management licenses ios settings swift-package-manager cli commandline xcode automation

licenseplist's Introduction

LicensePlist Logo LicensePlist

platforms GitHub license Language: Swift 5.3 Swift Package Manager compatible

Lint Test

LicensePlist is a command-line tool that automatically generates a Plist of all your dependencies, including files added manually(specified by YAML config file) or using Carthage or CocoaPods. All these licenses then show up in the Settings app.

Flow

Demo

App Setting Root License List License Detail

Installation

Warning
SPM(Swift Package Manager) are not supported.

CocoaPods (Recommended)

pod 'LicensePlist'
# Installation path: `${PODS_ROOT}/LicensePlist/license-plist`

Homebrew (Also Recommended)

brew install licenseplist

Mint (Also Recommended)

mint run mono0926/LicensePlist

Xcode project - SPM

In Project Settings, on the tab "Package Dependencies", click "+" and add https://github.com/mono0926/LicensePlist.

Click "Add Package" without selecting any package products.

Download the executable binary from Releases

Download from Releases, then copy to /usr/local/bin/license-plist etc.

Or you can also download the latest binary and install it with a one-liner.

curl -fsSL https://raw.githubusercontent.com/mono0926/LicensePlist/master/install.sh | sh

From Source

Clone the master branch of the repository, then run make install.

git clone https://github.com/mono0926/LicensePlist.git
make install

Usage

  1. When you are in the directory that contains your Cartfile or Pods, simply execute license-plist.
  2. com.mono0926.LicensePlist.Output directory will be generated.
  3. Move the files in the output directory into your app's Settings.bundle.
Settings.bundle
├── Root.plist
├── com.mono0926.LicensePlist
│   ├── APIKit.plist
│   ├── Alamofire.plist
│   └── EditDistance.plist
├── com.mono0926.LicensePlist.plist
├── en.lproj
│   └── Root.strings
└── ja.lproj
    └── Root.strings

Options

You can see options by license-plist --help.

--cartfile-path

  • Default: Cartfile

--mintfile-path

  • Default: Mintfile

--pods-path

  • Default: Pods

--package-path

  • Default: Package.swift
  • LicensePlist tries to find YourProjectName.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved and YourProjectName.xcworkspace/xcshareddata/swiftpm/Package.resolved, then uses new one.

--package-paths

  • Support for multiple Package.swift
  • Example: license-plist --package-paths /path/to/package1/Package.swift /path/to/package2/Package.swift

--package-sources-path

  • Default: None.
  • The directory with cloned Swift package sources. If specified LicensePlist uses cloned files instead of GitHub API. For more information, see parameter -clonedSourcePackagesDirPath of xcodebuild.
  • Example: license-plist --package-sources-path ./SourcePackages

--xcodeproj-path

  • Default: "*.xcodeproj"
  • By specifiying the path to the .xcodeproj LicensePlist will attempt to load the Package.resolved from that Xcode project. If you specify somedir/*.xcodeproj then LicensePlist will load from the first xcodeproj it finds in somedir.

--xcworkspace-path

  • Default: "*.xcworkspace"
  • By specifying the path to the .xcworkspace LicensePlist will load the Package.resolved from that Xcode workspace. If you specify somedir/*.xcworkspace then LicensePlist will load from the first xcworkspace it finds in somedir.
  • --xcworkspace-path supersedes any provided --xcodeproj-path.

--output-path

  • Default: com.mono0926.LicensePlist.Output
  • Recommended: --output-path YOUR_PRODUCT_DIR/Settings.bundle

--github-token

  • Default: None.
  • LicensePlist uses GitHub API, so sometimes API limit errors occur. You can avoid those errors by specifying a GitHub token.
  • You can generate a token here
    • repo scope is needed.
  • You can also pass the GitHub token via the LICENSE_PLIST_GITHUB_TOKEN environment variable.

--config-path

  • Default: license_plist.yml
  • You can specify GitHub libraries(introduced by hand) and excluded libraries

--prefix

  • Default: com.mono0926.LicensePlist
  • You can specify output file names instead of default one.

--html-path

  • Default: None.
  • If this path is specified, a html acknowledgements file will be generated.

--markdown-path

  • Default: None.
  • If this path is specified, a markdown acknowledgements file will be generated.

--csv-path

  • Default: None.
  • If this path is specified, a csv acknowledgements file will be generated.

--license-file-names

  • Default: LICENSE, LICENSE.*.
  • License file name variants for cloned Swift packages.
    • Case insensitive.
    • Supports any non-empty path extensions if FILENAME.* is specified.
    • Used only in combination with --package-sources-path.

--force

  • Default: false
  • LicensePlist saves latest result summary, so if there are no changes, the program interrupts.
    • In this case, execution time is less than 100ms for the most case, so you can run LicensePlist at Run Script Phase every time 🎉
  • You can run all the way anyway, by using --force flag.

--add-version-numbers

  • Default: false
  • When the library name is SomeLibrary, by adding --add-version-numbers flag, the name will be changed to SomeLibrary (X.Y.Z).
    • X.Y.Z is parsed from CocoaPods and Cartfile information, and GitHub libraries specified at Config YAML also support this flag.

License list with versions

--add-sources

  • Default: false
  • Adds the source of the library to the output if there is one. The source for GitHub and CocoaPods libraries is generated. Manual libraries use the optional source field.

--suppress-opening-directory

  • Default: false
  • Only when the files are created or updated, the terminal or the finder opens. By adding --suppress-opening-directory flag, this behavior is suppressed.
  • Automatically enabled if --sandbox-mode is specified.

--single-page

  • Default: false
  • All licenses are listed on a single page, not separated pages.

--fail-if-missing-license

  • Default: false
  • If there is even one package for which a license cannot be found, LicensePlist returns exit code 1.

--silence-mode / --verbose

  • By adding the --silence-mode flag, the logger's output will not print.
  • The logger's output will be more detailed than the average log level by adding the --verbose flag.
  • LicencePlist uses the latter option if you simultaneously set the --silence-mode option and the --verbose option.
  • Default: average log level

--no-color / --color

  • The logger's output is printed in monochrome by adding the --no-color flag. If any escape characters in CI/CD log bother you, the --no-color option will help.
  • By adding the --color flag, LicensePlist will always print the logger's output in color.
  • LicencePlist uses the latter option if you simultaneously set the --no-color option and the --color option.
  • If neither option is specified, LicensePlist will look for the NO_COLOR environment variable. If you set the NO_COLOR environment variable to "1", LicensePlist runs without colors.
  • Default: auto - LicensePlist decides its color mode depending on the terminal type.

--sandbox-mode / --no-sandbox-mode

  • Default: false
  • Enables or disables the "sandbox" mode.
  • In the sandbox mode, LicensePlist avoids network requests. That means Swift package licenses can not be fetched with GitHub API. To parse Swift package licenses --package-sources-path must be specified.

Integrate into build - run script

Add a Run Script Phase to Build Phases:

if [ $CONFIGURATION = "Debug" ]; then
/usr/local/bin/license-plist --output-path $PRODUCT_NAME/Settings.bundle --github-token YOUR_GITHUB_TOKEN
fi

Run Script Phase

Alternatively, if you've installed LicensePlist via CocoaPods the script should look like this:

if [ $CONFIGURATION = "Debug" ]; then
${PODS_ROOT}/LicensePlist/license-plist --output-path $PRODUCT_NAME/Settings.bundle --github-token YOUR_GITHUB_TOKEN
fi

Integrate into build - build tool plugin

LicensePlist build tool plugins requires Swift package installation.

Choose package plugins

Select your target, on the tab "Build Phases", in the section "Run Build Tool Plug-ins", click "+" and add LicensePlistBuildTool.

Run build tool plug-ins

In the case of using the build tool plugin, define all the settings in license_plist.yml at the root of your project.

license_plist.yml example:

options:
  xcworkspacePath: "*.xcworkspace"
  prefix: Acknowledgements
  singlePage: true

Important: to process Swift Package licenses, the config must include one of the following parameters:

  • xcworkspacePath,
  • xcodeprojPath,
  • packagePaths.

Note: outputPath and packageSourcesPath config parameters are ignored by the build tool plugin.

See the configuration section for more information.

If you need to put license files to Settings.bundle or any other specific place add the following script to build phases:

echo "Will copy acknowledgements"
ACKNOWLEDGEMENTS_DIR=${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/com.mono0926.LicensePlist.Output
DESTINATION_PATH=${BUILT_PRODUCTS_DIR}/${CONTENTS_FOLDER_PATH}/Settings.bundle/
cp -r "${ACKNOWLEDGEMENTS_DIR}"/* "${DESTINATION_PATH}"
rm -rf "${ACKNOWLEDGEMENTS_DIR}"

Or in project contextual menu click "AddAcknowledgementsCopyScriptCommand" and select application target to create the build phase automatically.

AddAcknowledgementsCopyScriptCommand

Build the app. At the first run, Xcode asks a permission to run the plugin. Click "Trust & Enable All"

Trust & Enable All

For unattended use (e.g. on CI), you can disable the package validation dialog by

  • individually passing -skipPackagePluginValidation to xcodebuild or
  • globally setting defaults write com.apple.dt.Xcode IDESkipPackagePluginFingerprintValidatation -bool YES for that user.

Note: This implicitly trusts all Xcode package plugins and bypasses Xcode's package validation dialogs, which has security implications.

Contextual menu command

LicensePlist command requires Swift package installation.

In the project contextual menu click "GenerateAcknowledgementsCommand".

Generate Acknowledgements menu command in Xcode

The command dialog allows to specify command line arguments. Since Xcode doesn't save the arguments for future use, it's recommended to use a configuration file.

Click "Run" to run LicensePlist.

Generate Acknowledgements command dialog in Xcode

Click "Allow Command to Change files". This action provides LicensePlist write access to your project directory.

"Don't ask again" option prevents showing this dialog in the future.

Allow command to change files dialog in Xcode

Note: --package-sources-path option and packageSourcesPath config parameter are ignored by the command plugin.

Configuration

General options

The main parameters from the Options can be defined in the configuration file.

All the parameters are optional.

The tool uses the command line value if both the command line and the config specify values for the same attribute.

Example

options:
  outputPath: "./com.mono0926.LicensePlist.Output"
  cartfilePath: Cartfile
  mintfilePath: Mintfile
  podsPath: Pods
  packagePaths:
    - Package.swift
  packageSourcesPath: "./SourcePackages"
  xcodeprojPath: "*.xcodeproj"
  xcworkspacePath: "*.xcworkspace"
  prefix: com.mono0926.LicensePlist
  gitHubToken: YOUR_GITHUB_TOKEN
  htmlPath: acknowledgements.html
  markdownPath: acknowledgements.md
  licenseFileNames:
    - LICENSE
    - LICENSE.*
  force: false
  addVersionNumbers: false
  suppressOpeningDirectory: false
  singlePage: false
  failIfMissingLicense: false
  addSources: false
  sandboxMode: false

Manual GitHub source

A GitHub source can be explicitly defined to include the license in the scenario where it can't be inferred from your dependency files.

Examples

github:
  - owner: mono0926
    name: LicensePlist
    version: 1.2.0

Manual License Body

If you need to include a license that isn't available on GitHub, you can place the license text in the config file to be included in the output. The license text can also be read from a local file, to keep the config file clean.

Examples

License body directly in the config file:

manual:
  - source: https://webrtc.googlesource.com/src
    name: WebRTC
    version: M61
    body: |-
      Copyright (c) 2011, The WebRTC project authors. All rights reserved.
      ...
      ...
      ...

License body in local file:

manual:
  - name: "Dummy License File"
    file: "dummy_license.txt"

Excludes

Excludes can be defined to exclude matching libraries from the final output. An exclude is a dictionary containing any combination of name, source, owner, or licenseType.

When using the dictionary format:

  • The exclusion rule is only applied if all properties match for a dependency. eg, (name: LicensePlist) AND (owner: mono0926)
  • Any property can be either a string or a regular expression.

Examples

Exclude a package by name:

exclude:
  - name: LicensePlist

Exclude packages using a specific license:

exclude:
  - licenseType: "Apache 2.0"

Exclude packages using any matching licenses:

exclude:
  - licenseType: /BSD/

Exclude packages from a specific github owner:

exclude:
  - owner: mycompany

Exclude packages from a specific github owner containing matching licenses:

exclude:
  - owner: mycompany
    licenseType: /^(?!.*MIT).*$/ # this regex excludes packages that do NOT use the MIT license

Exclude a package from a specific github owner and repo:

exclude:
  - owner: mycompany
    name: private-repo

Rename

If a library name is unsuitable for the output bundle, you can explicitly rename it. This can be used when a library name is too vague, or if more human-readable names are needed.

Examples

rename:
  LicensePlist: License Plist # Rename LicensePlist to "License Plist"
  WebRTC: Web RTC # Rename WebRTC to "Web RTC" (which is faulty, but used for test)

Q&A

How to generate Xcode project?

Execute swift package generate-xcodeproj or make xcode.


Related Articles


Stargazers over time

Stargazers over time


寄付(Donation)

Donations are welcome if you like LicensePlist🤗

Kyash

licenseplist's People

Contributors

acevif avatar andlang avatar bennokress avatar cyberbeni avatar defagos avatar divadretlaw avatar econa77 avatar ejensen avatar funzin avatar hugehoge avatar jpmartha avatar kitwtnb avatar mbuchetics avatar mono0926 avatar nandodelauni avatar newfieldforme avatar orj avatar ryunen344 avatar shimastripe avatar simorgh3196 avatar sohichiro avatar stmitt avatar treastrain avatar uhooi avatar umireon avatar vladvlasov256 avatar watanavex avatar yassram avatar ykyouhei avatar yosshi4486 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

licenseplist's Issues

Enhance log

  • Simplify by default
    • Add --verbose option
  • Reduce raw error

Remap Name

Certain pod/repo names are not exactly the most readable, would it be possible to add something to the config which would allow remapping of names?

rename:
  - randomLib
    name: New Name

Or even maybe just for GitHub repos:

github:
  - sharethrough/iOS-SDK
    name: "Sharethrough"
  - mono0926/LicensePlist

(Where the latter wouldn't be changed as it doesn't have a name node)

Delete and Ignore `LicensePlist.xcodeproj`

Problem: #29 (comment)

swift package generate-xcodeproj generates these files:

➜  hoge cat .gitignore 
.DS_Store
/.build
/Packages
/*.xcodeproj

/*.xcodeproj should be ignored generally.

TODO:

  • Delete and Ignore LicensePlist.xcodeproj
  • Add how to generate Xcode project file to README
    • swift package generate-xcodeproj or make xcode

Brew installation error 1.6.1

Resolving https://github.com/kylef/Commander.git at 0.6.1
Compile Swift Module 'Yaml' (6 sources)
Compile Swift Module 'Spectre' (8 sources)
Compile Swift Module 'Result' (2 sources)
Compile Swift Module 'LoggerAPI' (1 sources)
Compile Swift Module 'Himotoki' (11 sources)
Compile Swift Module 'HeliumLogger' (2 sources)
Compile Swift Module 'APIKit' (22 sources)
Compile Swift Module 'Commander' (9 sources)
Compile Swift Module 'LicensePlistCore' (23 sources)
Compile Swift Module 'LicensePlist' (1 sources)
Linking ./.build/release/LicensePlist
cp -f ".build/release/LicensePlist" "/usr/local/Cellar/license-plist/1.6.1/bin/license-plist"
cp: /usr/local/Cellar/license-plist/1.6.1/bin/license-plist: No such file or directory
make: *** [install] Error 1

seems to be caused by this 2e3abcc

Cannot install by `brew install license-plist` on Xcode 9 / High Sierra (currently beta)

Cannot install by brew install license-plist on Xcode 9 / High Sierra (currently beta).

~ brew install license-plist                                           
==> Installing license-plist from mono0926/license-plist
==> Downloading https://github.com/mono0926/LicensePlist/archive/1.6.0.tar.gz
==> Downloading from https://codeload.github.com/mono0926/LicensePlist/tar.gz/1.6.0
######################################################################## 100.0%
==> make install PREFIX=/usr/local/Cellar/license-plist/1.6.0
Last 15 lines from /Users/mono/Library/Logs/Homebrew/license-plist/01.make:
2017-08-18 12:29:25 +0900

make
install
PREFIX=/usr/local/Cellar/license-plist/1.6.0

swift build -c release -Xswiftc -static-stdlib
error: manifest parse error(s):
sandbox-exec: sandbox_apply_container: Operation not permitted
make: *** [build] Error 1

error: manifest parse error(s): is weird.

make build(swift build -c release -Xswiftc -static-stdlib) command succeeds, so I cannot figured out how to resolve this issue 🤔

Exclude libraries using regex

Currently the excluded libraries from the Config are checked with a strict 'contains' check. Here.

It would be pretty handy if this could also take a regex, for example: /^Core.*$/ would exclude anything which started with "Core" - potentially useful for internal frameworks.

Support for manually entering license

Hi!
Is there any support for adding license information manually, for example in the configuration file or from a standalone plist-file?

I want to include third-party licences that is not in cocoapods or carthage.

Support CocoaPods distribution

It would be great if you distribute the tool through CocoaPods for easier installation and version management, which is similar to what SwiftGen and SwiftLint do.

All generated plist files contain 404 not found

I use the current version 1.4.5.

I generate using license-plist. It does find all the use pods as it created all the .plist files e.g. Alamofire.plist.

However all these pod plist files which should include the licenses just include 404 not found.

I tried to fix it by using a github token, but this was not the issue and did not help. Any ideas?

(Yes I have a working internet connection and I can see the license file of alamofire in my browser without any problem)

Support ViewController

Support ViewController Output like AcknowList.


It is better to support as another library.

  1. Read plists from XXX.bundle.
  2. Present it as list/detail view controllers.

XXX.bundle can be accessed like this:

let plistDir = URL(fileURLWithPath: Bundle.main.path(forResource: "Settings", ofType: "bundle")!)
    .appendingPathComponent("com.mono0926.LicensePlist")
try! FileManager.default.contentsOfDirectory(at: plistDir, includingPropertiesForKeys: [], options: [])
    .forEach { print($0) }

xcode 8.3 mandatory ?

Why is xcode 8.3 mandatory for homebrew installation?
I assume this has to do with specific commands used by the tool?
Is there any way to use this with xcode 8.2.1 or will i have to upgrade?

Version Numbers

Would it be possible to add a way to automatically add the version number of a library to it's title?

This isn't really feasible for GitHub licenses so maybe they'd need to be a way to manually set this as so: (Not having it just wouldn't add the version)

github:
  - account/library
    version: 1.0.1

but for CocoaPods/Carthage it should be possible to get the version number from the relevant files?

"LicensePlist (v1.0.1)"

Why github api needed?

Is there a version of this app that doesn't hit the github APIs at all? I'd like to avoid having to deal with api limits and tokens, and just have it crawl the bundles for existing local licenses like cocoapods does.

A terminal window is launched when run by xcode

When licenseplist is run by xcode it launches a terminal window in the Settings.bundle directory. Is it possible to stop this window from appearing?

I am running as a build action...

cd $SRCROOT
license-plist --output-path Settings.bundle

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.