@pnpm/cli.utils 1001.2.8
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 +6 -0
- package/lib/index.js +11 -0
- package/lib/packageIsInstallable.d.ts +15 -0
- package/lib/packageIsInstallable.js +27 -0
- package/lib/readDepNameCompletions.d.ts +3 -0
- package/lib/readDepNameCompletions.js +7 -0
- package/lib/readProjectManifest.d.ts +22 -0
- package/lib/readProjectManifest.js +20 -0
- package/lib/recursiveSummary.d.ts +13 -0
- package/lib/recursiveSummary.js +17 -0
- package/lib/style.d.ts +20 -0
- package/lib/style.js +25 -0
- package/package.json +54 -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-2026 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/cli-utils
|
|
2
|
+
|
|
3
|
+
> Utils for pnpm commands
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@pnpm/cli-utils)
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm add @pnpm/cli-utils
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { packageManager } from '@pnpm/cli.meta';
|
|
2
|
+
export * from './packageIsInstallable.js';
|
|
3
|
+
export * from './readDepNameCompletions.js';
|
|
4
|
+
export * from './readProjectManifest.js';
|
|
5
|
+
export * from './recursiveSummary.js';
|
|
6
|
+
export * from './style.js';
|
|
7
|
+
export function docsUrl(cmd) {
|
|
8
|
+
const [pnpmMajorVersion] = packageManager.version.split('.');
|
|
9
|
+
return `https://pnpm.io/${pnpmMajorVersion}.x/cli/${cmd}`;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type WantedEngine } from '@pnpm/config.package-is-installable';
|
|
2
|
+
import type { SupportedArchitectures } from '@pnpm/types';
|
|
3
|
+
export declare function packageIsInstallable(pkgPath: string, pkg: {
|
|
4
|
+
packageManager?: string;
|
|
5
|
+
engines?: WantedEngine;
|
|
6
|
+
cpu?: string[];
|
|
7
|
+
os?: string[];
|
|
8
|
+
libc?: string[];
|
|
9
|
+
}, opts: {
|
|
10
|
+
packageManagerStrict?: boolean;
|
|
11
|
+
packageManagerStrictVersion?: boolean;
|
|
12
|
+
engineStrict?: boolean;
|
|
13
|
+
nodeVersion?: string;
|
|
14
|
+
supportedArchitectures?: SupportedArchitectures;
|
|
15
|
+
}): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { packageManager } from '@pnpm/cli.meta';
|
|
2
|
+
import { checkPackage, UnsupportedEngineError } from '@pnpm/config.package-is-installable';
|
|
3
|
+
import { logger } from '@pnpm/logger';
|
|
4
|
+
export function packageIsInstallable(pkgPath, pkg, opts) {
|
|
5
|
+
const currentPnpmVersion = packageManager.name === 'pnpm'
|
|
6
|
+
? packageManager.version
|
|
7
|
+
: undefined;
|
|
8
|
+
const err = checkPackage(pkgPath, pkg, {
|
|
9
|
+
nodeVersion: opts.nodeVersion,
|
|
10
|
+
pnpmVersion: currentPnpmVersion,
|
|
11
|
+
supportedArchitectures: opts.supportedArchitectures ?? {
|
|
12
|
+
os: ['current'],
|
|
13
|
+
cpu: ['current'],
|
|
14
|
+
libc: ['current'],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (err === null)
|
|
18
|
+
return;
|
|
19
|
+
if ((err instanceof UnsupportedEngineError && err.wanted.pnpm) ??
|
|
20
|
+
opts.engineStrict)
|
|
21
|
+
throw err;
|
|
22
|
+
logger.warn({
|
|
23
|
+
message: `Unsupported ${err instanceof UnsupportedEngineError ? 'engine' : 'platform'}: wanted: ${JSON.stringify(err.wanted)} (current: ${JSON.stringify(err.current)})`,
|
|
24
|
+
prefix: pkgPath,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=packageIsInstallable.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getAllDependenciesFromManifest } from '@pnpm/pkg-manifest.utils';
|
|
2
|
+
import { readProjectManifest } from '@pnpm/workspace.project-manifest-reader';
|
|
3
|
+
export async function readDepNameCompletions(dir) {
|
|
4
|
+
const { manifest } = await readProjectManifest(dir ?? process.cwd());
|
|
5
|
+
return Object.keys(getAllDependenciesFromManifest(manifest)).map((name) => ({ name }));
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=readDepNameCompletions.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ProjectManifest, SupportedArchitectures } from '@pnpm/types';
|
|
2
|
+
export interface ReadProjectManifestOpts {
|
|
3
|
+
engineStrict?: boolean;
|
|
4
|
+
packageManagerStrict?: boolean;
|
|
5
|
+
packageManagerStrictVersion?: boolean;
|
|
6
|
+
nodeVersion?: string;
|
|
7
|
+
supportedArchitectures?: SupportedArchitectures;
|
|
8
|
+
}
|
|
9
|
+
interface BaseReadProjectManifestResult {
|
|
10
|
+
fileName: string;
|
|
11
|
+
writeProjectManifest: (manifest: ProjectManifest, force?: boolean) => Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface ReadProjectManifestResult extends BaseReadProjectManifestResult {
|
|
14
|
+
manifest: ProjectManifest;
|
|
15
|
+
}
|
|
16
|
+
export declare function readProjectManifest(projectDir: string, opts?: ReadProjectManifestOpts): Promise<ReadProjectManifestResult>;
|
|
17
|
+
export declare function readProjectManifestOnly(projectDir: string, opts?: ReadProjectManifestOpts): Promise<ProjectManifest>;
|
|
18
|
+
export interface TryReadProjectManifestResult extends BaseReadProjectManifestResult {
|
|
19
|
+
manifest: ProjectManifest | null;
|
|
20
|
+
}
|
|
21
|
+
export declare function tryReadProjectManifest(projectDir: string, opts: ReadProjectManifestOpts): Promise<TryReadProjectManifestResult>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as utils from '@pnpm/workspace.project-manifest-reader';
|
|
2
|
+
import { packageIsInstallable } from './packageIsInstallable.js';
|
|
3
|
+
export async function readProjectManifest(projectDir, opts = {}) {
|
|
4
|
+
const { fileName, manifest, writeProjectManifest } = await utils.readProjectManifest(projectDir);
|
|
5
|
+
packageIsInstallable(projectDir, manifest, opts); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
6
|
+
return { fileName, manifest, writeProjectManifest };
|
|
7
|
+
}
|
|
8
|
+
export async function readProjectManifestOnly(projectDir, opts = {}) {
|
|
9
|
+
const manifest = await utils.readProjectManifestOnly(projectDir);
|
|
10
|
+
packageIsInstallable(projectDir, manifest, opts); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
11
|
+
return manifest;
|
|
12
|
+
}
|
|
13
|
+
export async function tryReadProjectManifest(projectDir, opts) {
|
|
14
|
+
const { fileName, manifest, writeProjectManifest } = await utils.tryReadProjectManifest(projectDir);
|
|
15
|
+
if (manifest == null)
|
|
16
|
+
return { fileName, manifest, writeProjectManifest };
|
|
17
|
+
packageIsInstallable(projectDir, manifest, opts); // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
18
|
+
return { fileName, manifest, writeProjectManifest };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=readProjectManifest.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface ActionFailure {
|
|
2
|
+
status: 'failure';
|
|
3
|
+
duration?: number;
|
|
4
|
+
prefix: string;
|
|
5
|
+
message: string;
|
|
6
|
+
error: Error;
|
|
7
|
+
}
|
|
8
|
+
export type RecursiveSummary = Record<string, {
|
|
9
|
+
status: 'passed' | 'queued' | 'running' | 'skipped';
|
|
10
|
+
duration?: number;
|
|
11
|
+
} | ActionFailure>;
|
|
12
|
+
export declare function throwOnCommandFail(command: string, recursiveSummary: RecursiveSummary): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PnpmError } from '@pnpm/error';
|
|
2
|
+
class RecursiveFailError extends PnpmError {
|
|
3
|
+
failures;
|
|
4
|
+
passes;
|
|
5
|
+
constructor(command, recursiveSummary, failures) {
|
|
6
|
+
super('RECURSIVE_FAIL', `"${command}" failed in ${failures.length} packages`);
|
|
7
|
+
this.failures = failures;
|
|
8
|
+
this.passes = Object.values(recursiveSummary).filter(({ status }) => status === 'passed').length;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function throwOnCommandFail(command, recursiveSummary) {
|
|
12
|
+
const failures = Object.values(recursiveSummary).filter(({ status }) => status === 'failure');
|
|
13
|
+
if (failures.length > 0) {
|
|
14
|
+
throw new RecursiveFailError(command, recursiveSummary, failures);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=recursiveSummary.js.map
|
package/lib/style.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export declare const TABLE_OPTIONS: {
|
|
2
|
+
border: {
|
|
3
|
+
topBody: string;
|
|
4
|
+
topJoin: string;
|
|
5
|
+
topLeft: string;
|
|
6
|
+
topRight: string;
|
|
7
|
+
bottomBody: string;
|
|
8
|
+
bottomJoin: string;
|
|
9
|
+
bottomLeft: string;
|
|
10
|
+
bottomRight: string;
|
|
11
|
+
bodyJoin: string;
|
|
12
|
+
bodyLeft: string;
|
|
13
|
+
bodyRight: string;
|
|
14
|
+
joinBody: string;
|
|
15
|
+
joinJoin: string;
|
|
16
|
+
joinLeft: string;
|
|
17
|
+
joinRight: string;
|
|
18
|
+
};
|
|
19
|
+
columns: {};
|
|
20
|
+
};
|
package/lib/style.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
export const TABLE_OPTIONS = {
|
|
3
|
+
border: {
|
|
4
|
+
topBody: '─',
|
|
5
|
+
topJoin: '┬',
|
|
6
|
+
topLeft: '┌',
|
|
7
|
+
topRight: '┐',
|
|
8
|
+
bottomBody: '─',
|
|
9
|
+
bottomJoin: '┴',
|
|
10
|
+
bottomLeft: '└',
|
|
11
|
+
bottomRight: '┘',
|
|
12
|
+
bodyJoin: '│',
|
|
13
|
+
bodyLeft: '│',
|
|
14
|
+
bodyRight: '│',
|
|
15
|
+
joinBody: '─',
|
|
16
|
+
joinJoin: '┼',
|
|
17
|
+
joinLeft: '├',
|
|
18
|
+
joinRight: '┤',
|
|
19
|
+
},
|
|
20
|
+
columns: {},
|
|
21
|
+
};
|
|
22
|
+
for (const [key, value] of Object.entries(TABLE_OPTIONS.border)) {
|
|
23
|
+
TABLE_OPTIONS.border[key] = chalk.grey(value);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=style.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pnpm/cli.utils",
|
|
3
|
+
"version": "1001.2.8",
|
|
4
|
+
"description": "Utils for pnpm commands",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pnpm",
|
|
7
|
+
"pnpm11"
|
|
8
|
+
],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"funding": "https://opencollective.com/pnpm",
|
|
11
|
+
"repository": "https://github.com/pnpm/pnpm/tree/main/cli/utils",
|
|
12
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/cli/utils#readme",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/pnpm/pnpm/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": "./lib/index.js"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"lib",
|
|
24
|
+
"!*.map"
|
|
25
|
+
],
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"chalk": "^5.6.0",
|
|
28
|
+
"load-json-file": "^7.0.1",
|
|
29
|
+
"@pnpm/cli.meta": "1000.0.11",
|
|
30
|
+
"@pnpm/config.package-is-installable": "1000.0.15",
|
|
31
|
+
"@pnpm/error": "1000.0.5",
|
|
32
|
+
"@pnpm/pkg-manifest.utils": "1001.0.6",
|
|
33
|
+
"@pnpm/workspace.project-manifest-reader": "1001.1.4",
|
|
34
|
+
"@pnpm/types": "1000.9.0"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"@pnpm/logger": ">=1001.0.0 <1002.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@pnpm/cli.utils": "1001.2.8",
|
|
41
|
+
"@pnpm/logger": "1001.0.1"
|
|
42
|
+
},
|
|
43
|
+
"engines": {
|
|
44
|
+
"node": ">=22.13"
|
|
45
|
+
},
|
|
46
|
+
"jest": {
|
|
47
|
+
"preset": "@pnpm/jest-config"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"lint": "eslint \"src/**/*.ts\"",
|
|
51
|
+
"compile": "tsgo --build && pnpm run lint --fix",
|
|
52
|
+
"test": "pnpm run compile"
|
|
53
|
+
}
|
|
54
|
+
}
|