lerna-update-wizard
Advanced tools
Comparing version 0.11.1 to 0.12.0
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.11.1", | ||
"version": "0.12.0", | ||
"main": "index.js", | ||
@@ -9,0 +9,0 @@ "license": "MIT", |
@@ -43,8 +43,24 @@ const path = require("path"); | ||
const { name: projectName } = require(projectPackageJsonPath); | ||
ui.logBottom("Resolving package locations..."); | ||
// Read `lerna.json` config file | ||
let lernaConfig = {}; | ||
let packagesConfig = ["packages/*"]; | ||
const { name: projectName, workspaces } = require(projectPackageJsonPath); | ||
// Attempt to get `packages` config from project package.json | ||
if (workspaces && Array.isArray(workspaces.packages)) { | ||
packagesConfig = workspaces.packages; | ||
ui.logBottom( | ||
"Found `packages` config in `package.json['workspaces']['packages']`" | ||
); | ||
} | ||
// Attempt to get `packages` config from lerna.json | ||
try { | ||
lernaConfig = require(resolve(projectDir, "lerna.json")); | ||
const lernaConfig = require(resolve(projectDir, "lerna.json")); | ||
if (Array.isArray(lernaConfig.packages)) { | ||
packagesConfig = lernaConfig.packages; | ||
ui.logBottom("Found `packages` config in `lerna.json['packages']`"); | ||
} | ||
} catch (e) {} | ||
@@ -62,3 +78,3 @@ | ||
? flags.packages.split(",") | ||
: lernaConfig.packages || ["packages/*"]; | ||
: packagesConfig; | ||
@@ -78,3 +94,10 @@ const packagesRead = await globby( | ||
invariant(packages.length > 0, "No packages found. Is this a Lerna project?"); | ||
invariant( | ||
packages.length > 0, | ||
"No packages found. Please specify via:", | ||
"", | ||
" package.json: ['workspaces']['packages']", | ||
" lerna.json: ['packages']", | ||
" --packages (CLI flag. See --help)" | ||
); | ||
@@ -81,0 +104,0 @@ ui.logBottom(""); |
@@ -1,5 +0,7 @@ | ||
module.exports = (condition, ...lines) => { | ||
const lines = require("./lines"); | ||
module.exports = (condition, ...textLines) => { | ||
if (!condition) { | ||
throw new Error(lines.join("\n")); | ||
throw new Error(lines(...textLines)); | ||
} | ||
}; |
@@ -27,3 +27,3 @@ const { default: runProgram } = require("./utils/runProgram"); | ||
projectPath, | ||
"No packages found. Is this a Lerna project?" | ||
"Error: No packages found. Please specify via:" | ||
); | ||
@@ -33,2 +33,29 @@ }); | ||
describe("but given a package.json `packages` configuration", () => { | ||
it("uses the package.json `packages` configuration", async () => { | ||
// eslint-disable-next-line | ||
jest.setTimeout(100000); | ||
const projectPath = await generateProject({ | ||
...projectConfig, | ||
workspaces: { packages: ["fooPackages/*"] }, | ||
packages: [ | ||
{ | ||
name: "sub-package-myPackages", | ||
dependencies: { lodash: "0.1.0" }, | ||
moduleDirName: "fooPackages", | ||
}, | ||
], | ||
}); | ||
await runProgram( | ||
projectPath, | ||
`? Select a dependency to upgrade: (Use arrow keys or type to search) | ||
❯ lodash (1 version) | ||
>>> input CTRL+C` | ||
); | ||
}); | ||
}); | ||
describe("when given a single non-standard packages location", () => { | ||
@@ -35,0 +62,0 @@ it("reads and installs correctly from/to that directory", async () => { |
@@ -8,3 +8,10 @@ const fs = require("fs-extra"); | ||
const generateProject = async (options, log) => { | ||
const { name, packages, dependencies, prefixPath, lernaJson } = options; | ||
const { | ||
name, | ||
packages, | ||
dependencies, | ||
prefixPath, | ||
lernaJson, | ||
workspaces, | ||
} = options; | ||
@@ -28,3 +35,4 @@ const p = path.resolve(prefixPath, name); | ||
"author": "", | ||
"license": "ISC" | ||
"license": "ISC", | ||
"workspaces": ${workspaces ? JSON.stringify(workspaces) : "{}"} | ||
}`), | ||
@@ -31,0 +39,0 @@ null, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22913342
40
1902