Code Monkey home page Code Monkey logo

hardhat-spdx-license-identifier's Introduction

Hardhat SPDX License Identifier

Prepend Solidity source files in Hardhat projects with the SPDX License Identifier specified in package.json.

Versions of this plugin prior to 2.0.0 were released as buidler-spdx-license-identifier.

Installation

npm install --save-dev hardhat-spdx-license-identifier
# or
yarn add --dev hardhat-spdx-license-identifier

Usage

Load plugin in Hardhat config:

require('hardhat-spdx-license-identifier');

Add configuration under the spdxLicenseIdentifier key:

option description default
overwrite whether to overwrite existing SPDX license identifiers false
runOnCompile whether to automatically prepend identifiers during compilation false
only Array of String matchers used to select included paths, defaults to all contracts if length is 0 []
except Array of String matchers used to exclude paths []
spdxLicenseIdentifier: {
  overwrite: true,
  runOnCompile: true,
  except: ['vendor/']
}

The included Hardhat task may be run manually:

npx hardhat prepend-spdx-license
# or
yarn run hardhat prepend-spdx-license

Files which do not contain a license identifier will be prepended with one. Files with a license identifier which does not match that which is specified in package.json may be updated, depending on configuration.

hardhat-spdx-license-identifier's People

Contributors

6str avatar dependabot[bot] avatar itsnickbarry avatar qwinsi avatar tomafrench avatar zouguangxian avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

hardhat-spdx-license-identifier's Issues

Looking for some help in using the plugin "'spdxLicenseIdentifier' does not exist in type 'BuidlerConfig'." ...

Hi,

Looking for some support regarding howto use the plugin ...

Plz find my buidler.config.ts file

import { usePlugin, BuidlerConfig } from '@nomiclabs/buidler/config'

import {
  DEFAULT_ACCOUNTS_BUIDLER,
  GAS_LIMIT,
} from './test/test-helpers/constants'

usePlugin('@nomiclabs/buidler-ethers')
usePlugin('@nomiclabs/buidler-waffle')
usePlugin('@nomiclabs/buidler-solpp')
usePlugin('solidity-coverage')
usePlugin('buidler-spdx-license-identifier');

const parseSolppFlags = (): { [flag: string]: boolean } => {
  const flags: { [flag: string]: boolean } = {}

  const solppEnv = process.env.SOLPP_FLAGS
  if (!solppEnv) {
    return flags
  }

  for (const flag of solppEnv.split(',')) {
    flags[flag] = true
  }

  return flags
}

const config: BuidlerConfig = {
  networks: {
    buidlerevm: {
      accounts: DEFAULT_ACCOUNTS_BUIDLER,
      blockGasLimit: GAS_LIMIT * 2,
      allowUnlimitedContractSize: true, // TEMPORARY: Will be fixed by AddressResolver PR.
    },
    coverage: {
      url: 'http://localhost:8555',
    },
  },
  mocha: {
    timeout: 50000,
  },
  solc: {
    version: "0.6.8",
    optimizer: { enabled: true, runs: 200 },
  },
  spdxLicenseIdentifier: {
    overwrite: true,
    runOnCompile: true,
  }
}

export default config

Error log

> npx buidler compile

An unexpected error occurred:

buidler.config.ts:47:3 - error TS2322: Type '{ networks: { buidlerevm: { accounts: { balance: string; privateKey: string; }[]; blockGasLimit: number; allowUnlimitedContractSize: true; }; coverage: { url: string; }; }; mocha: { timeout: number; }; solc: { ...; }; spdxLicenseIdentifier: { ...; }; }' is not assignable to type 'BuidlerConfig'.
  Object literal may only specify known properties, and 'spdxLicenseIdentifier' does not exist in type 'BuidlerConfig'.

47   spdxLicenseIdentifier: {
     ~~~~~~~~~~~~~~~~~~~~~~~~
48     overwrite: true,
   ~~~~~~~~~~~~~~~~~~~~
49     runOnCompile: true,
   ~~~~~~~~~~~~~~~~~~~~~~~
50   }
   ~~~

Thanks

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.