Cloud Defense Logo

Products

Solutions

Company

Book A Live Demo

Top 5 Examples of "spdx-license-list in functional component" in JavaScript

Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'spdx-license-list' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.

module.exports = async function licenseTask(app, options, project) {
    const licenseFile = project.file('LICENSE');
    const licenseCode = (project.get('license') || 'unlicensed').toLowerCase();

    if (licenseCode === 'unlicensed') {
        // Package is unlicensed.
        if (licenseFile.exists()) {
            licenseFile.unlink();
        }
        app.logger.warn('no license found', project.localPath);
        return;
    }
    // Package actually is licensed.
    const list = require('spdx-license-list/spdx-full.json');
    const licenses = Object.keys(list).reduce((obj, key) => {
        obj[key.toLowerCase()] = list[key].licenseText;
        return obj;
    }, {});

    if (!(licenseCode in licenses)) {
        // We don't have a license document for the specified license code.
        app.logger.error('invalid license', project.localPath);
        return;
    }

    // Replace placeholders with actual values.
    const text = licenses[licenseCode]
        .replace(//gi, (new Date()).getFullYear())
        .replace(/<(owner|author|copyright\sholders)>/gi, () => {
            if (project.get('author')) {
                return project.get('author');
}
  }

  if (!packageJson.license) {
    let bowerLicenses = new Array();
    if (typeof bowerJson.license === 'string') {
      bowerLicenses = [bowerJson.license];
    } else if (Array.isArray(bowerJson.license)) {
      bowerLicenses = bowerJson.license;
    }

    if (bowerLicenses.length === 1) {
      packageJson.license = bowerLicenses[0];
      if (packageJson.license.includes('polymer.github.io/LICENSE')) {
        packageJson.license = 'BSD-3-Clause';
      } else if (!spdxLicenseList.has(bowerLicenses[0])) {
        console.warn(
            `${bowerJson.name}: ` +
            `'${bowerJson.license}' is not a valid SPDX license. ` +
            `You can find a list of valid licenses at ` +
            `https://spdx.org/licenses/`);
      }

    } else if (bowerLicenses.length > 1) {
      console.warn(
          `${bowerJson.name}: Found multiple licenses in bower.json, ` +
          `but package.json must have only one.`);

    } else {
      console.warn(
          `${bowerJson.name}: ` +
          `Could not automatically find appropriate license. ` +
}
  }

  if (!packageJson.license) {
    let bowerLicenses = new Array();
    if (typeof bowerJson.license === 'string') {
      bowerLicenses = [bowerJson.license];
    } else if (Array.isArray(bowerJson.license)) {
      bowerLicenses = bowerJson.license;
    }

    if (bowerLicenses.length === 1) {
      packageJson.license = bowerLicenses[0];
      if (packageJson.license.includes('polymer.github.io/LICENSE')) {
        packageJson.license = 'BSD-3-Clause';
      } else if (!spdxLicenseList.has(bowerLicenses[0])) {
        console.warn(
            `${bowerJson.name}: ` +
            `'${bowerJson.license}' is not a valid SPDX license. ` +
            `You can find a list of valid licenses at ` +
            `https://spdx.org/licenses/`);
      }

    } else if (bowerLicenses.length > 1) {
      console.warn(
          `${bowerJson.name}: Found multiple licenses in bower.json, ` +
          `but package.json must have only one.`);

    } else {
      console.warn(
          `${bowerJson.name}: ` +
          `Could not automatically find appropriate license. ` +
function _validateLicense(id: string): string {
  if (id === 'UNLICENSED') { return id; }
  if (!spdx.has(id)) {
    throw new Error(`Invalid license identifier "${id}", see valid license identifiers at https://spdx.org/licenses/`);
  }
  return id;
}
const camelCase = require('camelcase');
const licensesInformation = require('spdx-license-list/spdx-simple.json')
const licenses = licensesInformation.map(name => ({
  name,
  value: name
}));

const prompts = module.exports = [
  {
    type: 'input',
    name: 'componentName',
    message: 'Enter the component name (in PascalCase- no hyphen nor dash):'
  },
  {
    type: 'confirm',
    name: 'useComponentFixture',
    message: 'Use componentFixture to build example?',
    default: true,
    group: 'Example',

Is your System Free of Underlying Vulnerabilities?
Find Out Now