@pnpm/workspace.find-packages 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +15 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.js +76 -0
- package/lib/index.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-2016 Rico Sta. Cruz and other contributors
|
|
4
|
+
Copyright (c) 2016-2023 Zoltan Kochan and other contributors
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @pnpm/workspace.find-packages
|
|
2
|
+
|
|
3
|
+
> Finds packages inside a workspace
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/workspace.find-packages)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @pnpm/workspace.find-packages
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Project } from '@pnpm/types';
|
|
2
|
+
export type { Project };
|
|
3
|
+
export declare function findWorkspacePackages(workspaceRoot: string, opts?: {
|
|
4
|
+
engineStrict?: boolean;
|
|
5
|
+
nodeVersion?: string;
|
|
6
|
+
patterns?: string[];
|
|
7
|
+
}): Promise<Project[]>;
|
|
8
|
+
export declare function findWorkspacePackagesNoCheck(workspaceRoot: string, opts?: {
|
|
9
|
+
patterns?: string[];
|
|
10
|
+
}): Promise<Project[]>;
|
|
11
|
+
type ArrayOfWorkspacePackagesToMapResult = Record<string, Record<string, Pick<Project, 'manifest'>>>;
|
|
12
|
+
export declare function arrayOfWorkspacePackagesToMap(pkgs: Array<Pick<Project, 'manifest'>>): ArrayOfWorkspacePackagesToMapResult;
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.arrayOfWorkspacePackagesToMap = exports.findWorkspacePackagesNoCheck = exports.findWorkspacePackages = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const cli_utils_1 = require("@pnpm/cli-utils");
|
|
9
|
+
const constants_1 = require("@pnpm/constants");
|
|
10
|
+
const util_lex_comparator_1 = require("@pnpm/util.lex-comparator");
|
|
11
|
+
const fs_find_packages_1 = require("@pnpm/fs.find-packages");
|
|
12
|
+
const logger_1 = require("@pnpm/logger");
|
|
13
|
+
const read_yaml_file_1 = __importDefault(require("read-yaml-file"));
|
|
14
|
+
async function findWorkspacePackages(workspaceRoot, opts) {
|
|
15
|
+
const pkgs = await findWorkspacePackagesNoCheck(workspaceRoot, opts);
|
|
16
|
+
for (const pkg of pkgs) {
|
|
17
|
+
(0, cli_utils_1.packageIsInstallable)(pkg.dir, pkg.manifest, opts ?? {});
|
|
18
|
+
if (pkg.dir !== workspaceRoot) {
|
|
19
|
+
checkNonRootProjectManifest(pkg);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return pkgs;
|
|
23
|
+
}
|
|
24
|
+
exports.findWorkspacePackages = findWorkspacePackages;
|
|
25
|
+
async function findWorkspacePackagesNoCheck(workspaceRoot, opts) {
|
|
26
|
+
let patterns = opts?.patterns;
|
|
27
|
+
if (patterns == null) {
|
|
28
|
+
const packagesManifest = await requirePackagesManifest(workspaceRoot);
|
|
29
|
+
patterns = packagesManifest?.packages ?? undefined;
|
|
30
|
+
}
|
|
31
|
+
const pkgs = await (0, fs_find_packages_1.findPackages)(workspaceRoot, {
|
|
32
|
+
ignore: [
|
|
33
|
+
'**/node_modules/**',
|
|
34
|
+
'**/bower_components/**',
|
|
35
|
+
],
|
|
36
|
+
includeRoot: true,
|
|
37
|
+
patterns,
|
|
38
|
+
});
|
|
39
|
+
pkgs.sort((pkg1, pkg2) => (0, util_lex_comparator_1.lexCompare)(pkg1.dir, pkg2.dir));
|
|
40
|
+
return pkgs;
|
|
41
|
+
}
|
|
42
|
+
exports.findWorkspacePackagesNoCheck = findWorkspacePackagesNoCheck;
|
|
43
|
+
async function requirePackagesManifest(dir) {
|
|
44
|
+
try {
|
|
45
|
+
return await (0, read_yaml_file_1.default)(path_1.default.join(dir, constants_1.WORKSPACE_MANIFEST_FILENAME));
|
|
46
|
+
}
|
|
47
|
+
catch (err) { // eslint-disable-line
|
|
48
|
+
if (err['code'] === 'ENOENT') {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function arrayOfWorkspacePackagesToMap(pkgs) {
|
|
55
|
+
return pkgs.reduce((acc, pkg) => {
|
|
56
|
+
if (!pkg.manifest.name)
|
|
57
|
+
return acc;
|
|
58
|
+
if (!acc[pkg.manifest.name]) {
|
|
59
|
+
acc[pkg.manifest.name] = {};
|
|
60
|
+
}
|
|
61
|
+
acc[pkg.manifest.name][pkg.manifest.version ?? '0.0.0'] = pkg;
|
|
62
|
+
return acc;
|
|
63
|
+
}, {});
|
|
64
|
+
}
|
|
65
|
+
exports.arrayOfWorkspacePackagesToMap = arrayOfWorkspacePackagesToMap;
|
|
66
|
+
function checkNonRootProjectManifest({ manifest, dir }) {
|
|
67
|
+
for (const rootOnlyField of ['pnpm', 'resolutions']) {
|
|
68
|
+
if (manifest?.[rootOnlyField]) {
|
|
69
|
+
logger_1.logger.warn({
|
|
70
|
+
message: `The field "${rootOnlyField}" was found in ${dir}/package.json. This will not take effect. You should configure "${rootOnlyField}" at the root of the workspace instead.`,
|
|
71
|
+
prefix: dir,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AACvB,+CAAsD;AACtD,+CAA6D;AAE7D,mEAAsD;AACtD,6DAAqD;AACrD,yCAAqC;AACrC,oEAAyC;AAIlC,KAAK,UAAU,qBAAqB,CACzC,aAAqB,EACrB,IAIC;IAED,MAAM,IAAI,GAAG,MAAM,4BAA4B,CAAC,aAAa,EAAE,IAAI,CAAC,CAAA;IACpE,KAAK,M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V;AACH,CAAC;AAID,SAAgB,6BAA6B,CAC3C,IAAsC;IAEtC,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;QAC9B,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI;YAAE,OAAO,GAAG,CAAA;QAClC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAC3B,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAA;SAC5B;QACD,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,IAAI,OAAO,CAAC,GAAG,GAAG,CAAA;QAC7D,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAyC,CAAC,CAAA;AAC/C,CAAC;AAXD,sEAWC;AAED,SAAS,2BAA2B,CAAE,EAAE,QAAQ,EAAE,GAAG,EAAW;IAC9D,KAAK,MAAM,aAAa,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,EAAE;QACnD,IAAI,QAAQ,EAAE,CAAC,aAAsC,CAAC,EAAE;YACtD,eAAM,CAAC,IAAI,CAAC;gBACV,OAAO,EAAE,cAAc,aAAa,kBAAkB,GAAG,mEAAmE,aAAa,yCAAyC;gBAClL,MAAM,EAAE,GAAG;aACZ,CAAC,CAAA;SACH;KACF;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/workspace.find-packages",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Finds packages inside a workspace",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib",
|
|
9
|
+
"!*.map"
|
|
10
|
+
],
|
|
11
|
+
"engines": {
|
|
12
|
+
"node": ">=16.14"
|
|
13
|
+
},
|
|
14
|
+
"repository": "https://github.com/pnpm/pnpm/blob/main/workspace/find-packages",
|
|
15
|
+
"keywords": [
|
|
16
|
+
"pnpm8",
|
|
17
|
+
"pnpm"
|
|
18
|
+
],
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"bugs": {
|
|
21
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/pnpm/pnpm/blob/main/workspace/find-packages#readme",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@pnpm/util.lex-comparator": "1.0.0",
|
|
26
|
+
"read-yaml-file": "^2.1.0",
|
|
27
|
+
"@pnpm/cli-utils": "2.0.10",
|
|
28
|
+
"@pnpm/constants": "7.1.1",
|
|
29
|
+
"@pnpm/fs.find-packages": "2.0.2",
|
|
30
|
+
"@pnpm/types": "9.1.0"
|
|
31
|
+
},
|
|
32
|
+
"funding": "https://opencollective.com/pnpm",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@pnpm/workspace.find-packages": "1.0.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@pnpm/logger": "^5.0.0"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
".": "./lib/index.js"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
44
|
+
"_test": "jest",
|
|
45
|
+
"test": "pnpm run compile && pnpm run _test",
|
|
46
|
+
"compile": "tsc --build && pnpm run lint --fix"
|
|
47
|
+
}
|
|
48
|
+
}
|