get-workspaces
Advanced tools
Comparing version 0.3.1 to 0.4.0
# get-workspaces | ||
## 0.4.0 | ||
### Minor Changes | ||
- [cbb2c953](https://github.com/changesets/changesets/commit/cbb2c953) [#89](https://github.com/changesets/changesets/pull/89) Thanks [@highvoltag3](https://github.com/highvoltag3)! - Making sure the arrays are sorted before using them | ||
### Patch Changes | ||
- [d4bbab4e](https://github.com/changesets/changesets/commit/d4bbab4e) [#91](https://github.com/changesets/changesets/pull/91) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Add PackageJSON type | ||
- [94267ff3](https://github.com/changesets/changesets/commit/94267ff3) [#106](https://github.com/changesets/changesets/pull/106) Thanks [@mitchellhamilton](https://github.com/mitchellhamilton)! - Add private property to PackageJSON type | ||
## 0.3.1 | ||
@@ -4,0 +15,0 @@ |
@@ -5,8 +5,21 @@ declare type Options = { | ||
}; | ||
declare type pkgJSON = { | ||
export declare type PackageJSON = { | ||
name: string; | ||
version: string; | ||
dependencies?: { | ||
[key: string]: string; | ||
}; | ||
peerDependencies?: { | ||
[key: string]: string; | ||
}; | ||
devDependencies?: { | ||
[key: string]: string; | ||
}; | ||
optionalDependencies?: { | ||
[key: string]: string; | ||
}; | ||
private?: boolean; | ||
}; | ||
export declare type Workspace = { | ||
config: pkgJSON; | ||
config: PackageJSON; | ||
name: string; | ||
@@ -13,0 +26,0 @@ dir: string; |
@@ -54,3 +54,3 @@ 'use strict'; | ||
let pkgJsonsMissingNameField = []; | ||
const results = await Promise.all(folders.filter(dir => fs.existsSync(path.join(dir, "package.json"))).map(async dir => fs.readFile(path.join(dir, "package.json"), "utf8").then(contents => { | ||
const results = await Promise.all(folders.sort().filter(dir => fs.existsSync(path.join(dir, "package.json"))).map(async dir => fs.readFile(path.join(dir, "package.json"), "utf8").then(contents => { | ||
const config = JSON.parse(contents); | ||
@@ -70,2 +70,3 @@ | ||
if (pkgJsonsMissingNameField.length !== 0) { | ||
pkgJsonsMissingNameField.sort(); | ||
throw new Error(`The following package.jsons are missing the "name" field:\n${pkgJsonsMissingNameField.join("\n")}`); | ||
@@ -72,0 +73,0 @@ } |
@@ -29,3 +29,3 @@ "use strict"; | ||
let pkgJsonsMissingNameField = []; | ||
const results = await Promise.all(folders.filter(dir => fs.existsSync(path.join(dir, "package.json"))).map(async dir => fs.readFile(path.join(dir, "package.json"), "utf8").then(contents => { | ||
const results = await Promise.all(folders.sort().filter(dir => fs.existsSync(path.join(dir, "package.json"))).map(async dir => fs.readFile(path.join(dir, "package.json"), "utf8").then(contents => { | ||
const config = JSON.parse(contents); | ||
@@ -39,3 +39,4 @@ return config.name || pkgJsonsMissingNameField.push(path.relative(cwd, path.join(dir, "package.json"))), | ||
}))); | ||
if (0 !== pkgJsonsMissingNameField.length) throw new Error(`The following package.jsons are missing the "name" field:\n${pkgJsonsMissingNameField.join("\n")}`); | ||
if (0 !== pkgJsonsMissingNameField.length) throw pkgJsonsMissingNameField.sort(), | ||
new Error(`The following package.jsons are missing the "name" field:\n${pkgJsonsMissingNameField.join("\n")}`); | ||
return results; | ||
@@ -42,0 +43,0 @@ } |
@@ -42,3 +42,3 @@ import fs from 'fs-extra'; | ||
let pkgJsonsMissingNameField = []; | ||
const results = await Promise.all(folders.filter(dir => fs.existsSync(path.join(dir, "package.json"))).map(async dir => fs.readFile(path.join(dir, "package.json"), "utf8").then(contents => { | ||
const results = await Promise.all(folders.sort().filter(dir => fs.existsSync(path.join(dir, "package.json"))).map(async dir => fs.readFile(path.join(dir, "package.json"), "utf8").then(contents => { | ||
const config = JSON.parse(contents); | ||
@@ -58,2 +58,3 @@ | ||
if (pkgJsonsMissingNameField.length !== 0) { | ||
pkgJsonsMissingNameField.sort(); | ||
throw new Error(`The following package.jsons are missing the "name" field:\n${pkgJsonsMissingNameField.join("\n")}`); | ||
@@ -60,0 +61,0 @@ } |
{ | ||
"name": "get-workspaces", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "Get workspaces for yarn workspaces, bolt workspaces, or the root package for building repo-agnostic tools", | ||
@@ -5,0 +5,0 @@ "main": "dist/get-workspaces.cjs.js", |
@@ -14,8 +14,13 @@ // This is a modified version of the package-getting in bolt | ||
type pkgJSON = { | ||
export type PackageJSON = { | ||
name: string; | ||
version: string; | ||
dependencies?: { [key: string]: string }; | ||
peerDependencies?: { [key: string]: string }; | ||
devDependencies?: { [key: string]: string }; | ||
optionalDependencies?: { [key: string]: string }; | ||
private?: boolean; | ||
}; | ||
export type Workspace = { config: pkgJSON; name: string; dir: string }; | ||
export type Workspace = { config: PackageJSON; name: string; dir: string }; | ||
@@ -62,2 +67,3 @@ export default async function getWorkspaces( | ||
folders | ||
.sort() | ||
.filter(dir => fs.existsSync(path.join(dir, "package.json"))) | ||
@@ -77,2 +83,3 @@ .map(async dir => | ||
if (pkgJsonsMissingNameField.length !== 0) { | ||
pkgJsonsMissingNameField.sort(); | ||
throw new Error( | ||
@@ -79,0 +86,0 @@ `The following package.jsons are missing the "name" field:\n${pkgJsonsMissingNameField.join( |
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
16863
338