Socket
Socket
Sign inDemoInstall

@lerna/project

Package Overview
Dependencies
9
Maintainers
4
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0-beta.9 to 3.0.0-beta.10

lib/apply-extends.js

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

<a name="3.0.0-beta.10"></a>
# [3.0.0-beta.10](https://github.com/lerna/lerna/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2018-03-27)
### Features
* **project:** Inherit configuration with yargs-like "extends" ([0b28ef5](https://github.com/lerna/lerna/commit/0b28ef5)), closes [#1281](https://github.com/lerna/lerna/issues/1281)
<a name="3.0.0-beta.9"></a>

@@ -8,0 +20,0 @@ # [3.0.0-beta.9](https://github.com/lerna/lerna/compare/v3.0.0-beta.8...v3.0.0-beta.9) (2018-03-24)

78

index.js

@@ -13,5 +13,4 @@ "use strict";

const Package = require("@lerna/package");
const applyExtends = require("./lib/apply-extends");
const DEFAULT_PACKAGE_GLOB = "packages/*";
class Project {

@@ -24,3 +23,14 @@ constructor(cwd) {

sync: true,
transform: obj => {
transform(obj) {
// cosmiconfig returns null when nothing is found
if (!obj) {
return {
// No need to distinguish between missing and empty,
// saves a lot of noisy guards elsewhere
config: {},
// path.resolve(".", ...) starts from process.cwd()
filepath: path.resolve(cwd || ".", "lerna.json"),
};
}
// normalize command-specific config namespace

@@ -32,2 +42,4 @@ if (obj.config.commands) {

obj.config = applyExtends(obj.config, path.dirname(obj.filepath));
return obj;

@@ -42,17 +54,11 @@ },

} catch (err) {
// don't swallow syntax errors
// redecorate JSON syntax errors, avoid debug dump
if (err.name === "JSONError") {
throw new ValidationError(err.name, err.message);
}
// re-throw other errors, could be ours or third-party
throw err;
}
// cosmiconfig returns null when nothing is found
loaded = loaded || {
// No need to distinguish between missing and empty,
// saves a lot of noisy guards elsewhere
config: {},
// path.resolve(".", ...) starts from process.cwd()
filepath: path.resolve(cwd || ".", "lerna.json"),
};
this.config = loaded.config;

@@ -89,3 +95,3 @@ this.rootPath = path.dirname(loaded.filepath);

return this.config.packages || [DEFAULT_PACKAGE_GLOB];
return this.config.packages || [Project.DEFAULT_PACKAGE_GLOB];
}

@@ -98,29 +104,33 @@

get packageJson() {
if (!this._packageJson) {
try {
this._packageJson = loadJsonFile.sync(this.packageJsonLocation);
let packageJson;
if (!this._packageJson.name) {
// npm-lifecycle chokes if this is missing, so default like npm init does
this._packageJson.name = path.basename(path.dirname(this.packageJsonLocation));
}
} catch (err) {
// don't swallow syntax errors
if (err.name === "JSONError") {
throw new ValidationError(err.name, err.message);
}
// try again next time
this._packageJson = null;
try {
packageJson = loadJsonFile.sync(this.packageJsonLocation);
if (!packageJson.name) {
// npm-lifecycle chokes if this is missing, so default like npm init does
packageJson.name = path.basename(path.dirname(this.packageJsonLocation));
}
// redefine getter to lazy-loaded value
Object.defineProperty(this, "packageJson", {
value: packageJson,
});
} catch (err) {
// syntax errors are already caught and reported by constructor
// try again next time
}
return this._packageJson;
return packageJson;
}
get package() {
if (!this._package) {
this._package = new Package(this.packageJson, this.rootPath);
}
const pkg = new Package(this.packageJson, this.rootPath);
return this._package;
// redefine getter to lazy-loaded value
Object.defineProperty(this, "package", {
value: pkg,
});
return pkg;
}

@@ -140,2 +150,4 @@

Project.DEFAULT_PACKAGE_GLOB = "packages/*";
module.exports = Project;
{
"name": "@lerna/project",
"version": "3.0.0-beta.9",
"description": "TODO",
"version": "3.0.0-beta.10",
"description": "Lerna project configuration",
"keywords": [

@@ -16,3 +16,4 @@ "lerna",

"files": [
"index.js"
"index.js",
"lib"
],

@@ -35,3 +36,3 @@ "main": "index.js",

"@lerna/package": "^3.0.0-beta.0",
"@lerna/validation-error": "^3.0.0-beta.0",
"@lerna/validation-error": "^3.0.0-beta.10",
"cosmiconfig": "^4.0.0",

@@ -42,5 +43,6 @@ "dedent": "^0.7.0",

"npmlog": "^4.1.2",
"resolve-from": "^4.0.0",
"write-json-file": "^2.3.0"
},
"gitHead": "70528f23cad0186fdf7529fe32148cc1eff21272"
"gitHead": "c52f8713303b246e6d701950cd78ca6f9bd55503"
}
# `@lerna/project`
> description TODO
> Lerna project configuration
## Usage
## Configuration Resolution
TODO
Lerna's file-based configuration is located in `lerna.json` or the `lerna` property of `package.json`.
Wherever this configuration is found is considered the "root" of the lerna-managed multi-package repository.
A minimum-viable configuration only needs a `version` property; the following examples are equivalent:
```json
{
"version": "1.2.3"
}
```
```json
{
"name": "my-monorepo",
"version": "0.0.0-root",
"private": true,
"lerna": {
"version": "1.2.3"
}
}
```
Any other properties on this configuration object will be used as defaults for CLI options of _all_ lerna subcommands. That is to say, CLI options _always_ override values found in configuration files (a standard practice for CLI applications).
### Command-Specific Configuration
To focus configuration on a particular subcommand, use the `command` subtree. Each subproperty of `command` corresponds to a lerna subcommand (`publish`, `create`, `run`, `exec`, etc).
```json
{
"version": "1.2.3",
"command": {
"publish": {
"loglevel": "verbose"
}
},
"loglevel": "success"
}
```
In the example above, `lerna publish` will act as if `--loglevel verbose` was passed.
All other subcommands will receive the equivalent of `--loglevel success` (much much quieter).
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc