How to use the lerna.json function in lerna

To help you get started, we’ve selected a few lerna examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github accordproject / concerto / scripts / pkgcheck.js View on Github external
const child_process = require('child_process');
const colors = require('colors');
const fs = require('fs');
const path = require('path');
const semver = require('semver')

const packages = {};
const fix = (process.argv.indexOf('--fix') !== -1);

const lernaDirectory = path.resolve('.');
const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json');
const lernaConfig = require(lernaConfigFile);
const targetVersion = lernaConfig.version;
const targetDependency = `${targetVersion}`;
packages['lerna.json'] = lernaConfig;

if (!semver.valid(targetVersion)) {
    console.error(`Error: the version "${targetVersion}" in "${lernaConfigFile}" is invalid!`);
    process.exit(1);
}

const masterPackageFile = path.resolve(lernaDirectory, 'package.json');
const masterPackage = require(masterPackageFile);
packages['package.json'] = masterPackage;

const packagesDirectory = path.resolve(lernaDirectory, 'packages');
const packageNames = fs.readdirSync(packagesDirectory);
packageNames.forEach((packageName) => {
    const packageFile = path.resolve(packagesDirectory, packageName, 'package.json');
    const thisPackage = require(packageFile);
    packages[packageName] = thisPackage;
github hyperledger / composer-sample-models / scripts / pkgcheck.js View on Github external
const child_process = require('child_process');
const colors = require('colors');
const fs = require('fs');
const path = require('path');
const semver = require('semver')

const packages = {};
const fix = (process.argv.indexOf('--fix') !== -1);

const lernaDirectory = path.resolve('.');
const lernaConfigFile = path.resolve(lernaDirectory, 'lerna.json');
const lernaConfig = require(lernaConfigFile);
const targetVersion = lernaConfig.version;
const targetDependency = `^${targetVersion}`;
packages['lerna.json'] = lernaConfig;

if (!semver.valid(targetVersion)) {
    console.error(`Error: the version "${targetVersion}" in "${lernaConfigFile}" is invalid!`);
    process.exit(1);
}

const masterPackageFile = path.resolve(lernaDirectory, 'package.json');
const masterPackage = require(masterPackageFile);
packages['package.json'] = masterPackage;

const packagesDirectory = path.resolve(lernaDirectory, 'packages');
const packageNames = fs.readdirSync(packagesDirectory);
packageNames.forEach((packageName) => {
    const packageFile = path.resolve(packagesDirectory, packageName, 'package.json');
    const thisPackage = require(packageFile);
    packages[packageName] = thisPackage;
github aurelia / aurelia / scripts / bump-version.ts View on Github external
const pkg = await loadPackageJson('packages', name.kebab);
    pkg.version = newVersion;
    if ('dependencies' in pkg) {
      const deps = pkg.dependencies;
      for (const depName in deps) {
        if (depName.startsWith("@aurelia")) {
          log(`  dep ${name.npm} ${c.yellow(deps[depName])} -> ${c.greenBright(newVersion)}`);
          deps[depName] = newVersion;
        }
      }
    }
    await savePackageJson(pkg, 'packages', name.kebab);
  }
  const lernaJson = JSON.parse(readFileSync(project['lerna.json'].path, { encoding: 'utf8' }));
  lernaJson.version = newVersion;
  writeFileSync(project['lerna.json'].path, `${JSON.stringify(lernaJson, null, 2)}\n`, { encoding: 'utf8' });
}
github aurelia / aurelia / scripts / bump-version.ts View on Github external
for (const { name } of project.packages) {
    log(`updating dependencies for ${c.magentaBright(name.npm)}`);
    const pkg = await loadPackageJson('packages', name.kebab);
    pkg.version = newVersion;
    if ('dependencies' in pkg) {
      const deps = pkg.dependencies;
      for (const depName in deps) {
        if (depName.startsWith("@aurelia")) {
          log(`  dep ${name.npm} ${c.yellow(deps[depName])} -> ${c.greenBright(newVersion)}`);
          deps[depName] = newVersion;
        }
      }
    }
    await savePackageJson(pkg, 'packages', name.kebab);
  }
  const lernaJson = JSON.parse(readFileSync(project['lerna.json'].path, { encoding: 'utf8' }));
  lernaJson.version = newVersion;
  writeFileSync(project['lerna.json'].path, `${JSON.stringify(lernaJson, null, 2)}\n`, { encoding: 'utf8' });
}