@pnpm/config.commands 1100.0.28 → 1100.0.29
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/CHANGELOG.md +8 -0
- package/package.json +5 -5
- package/lib/ConfigCommandOptions.d.ts +0 -7
- package/lib/ConfigCommandOptions.js +0 -2
- package/lib/config.d.ts +0 -10
- package/lib/config.js +0 -119
- package/lib/configGet.d.ts +0 -5
- package/lib/configGet.js +0 -83
- package/lib/configList.d.ts +0 -2
- package/lib/configList.js +0 -5
- package/lib/configSet.d.ts +0 -21
- package/lib/configSet.js +0 -225
- package/lib/configToRecord.d.ts +0 -10
- package/lib/configToRecord.js +0 -49
- package/lib/get.d.ts +0 -7
- package/lib/get.js +0 -9
- package/lib/getConfigFileInfo.d.ts +0 -8
- package/lib/getConfigFileInfo.js +0 -20
- package/lib/index.d.ts +0 -4
- package/lib/parseConfigPropertyPath.d.ts +0 -5
- package/lib/parseConfigPropertyPath.js +0 -15
- package/lib/protectedSettings.d.ts +0 -4
- package/lib/protectedSettings.js +0 -21
- package/lib/set.d.ts +0 -7
- package/lib/set.js +0 -9
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/config.commands",
|
|
3
|
-
"version": "1100.0.
|
|
3
|
+
"version": "1100.0.29",
|
|
4
4
|
"description": "Commands for reading and writing settings to/from config files",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"!*.map"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@pnpm/cli.utils": "1101.0.
|
|
32
|
-
"@pnpm/config.reader": "1101.12.
|
|
31
|
+
"@pnpm/cli.utils": "1101.0.15",
|
|
32
|
+
"@pnpm/config.reader": "1101.12.1",
|
|
33
33
|
"@pnpm/constants": "1100.0.0",
|
|
34
34
|
"@pnpm/error": "1100.0.1",
|
|
35
35
|
"@pnpm/object.key-sorting": "1100.0.1",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@jest/globals": "30.4.1",
|
|
52
|
-
"@pnpm/config.commands": "1100.0.
|
|
52
|
+
"@pnpm/config.commands": "1100.0.29",
|
|
53
53
|
"@pnpm/logger": "1100.0.0",
|
|
54
|
-
"@pnpm/prepare": "1100.0.
|
|
54
|
+
"@pnpm/prepare": "1100.0.20",
|
|
55
55
|
"@types/ini": "4.1.1",
|
|
56
56
|
"@types/lodash.kebabcase": "4.1.9",
|
|
57
57
|
"read-yaml-file": "^3.0.0"
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Config, ConfigContext } from '@pnpm/config.reader';
|
|
2
|
-
export type ConfigCommandOptions = Pick<Config, 'configDir' | 'dir' | 'global' | 'authConfig' | 'workspaceDir'> & Pick<ConfigContext, 'cliOptions'> & {
|
|
3
|
-
_config: Config;
|
|
4
|
-
_context: ConfigContext;
|
|
5
|
-
json?: boolean;
|
|
6
|
-
location?: 'global' | 'project';
|
|
7
|
-
};
|
package/lib/config.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { ConfigCommandOptions } from './ConfigCommandOptions.js';
|
|
2
|
-
export declare function rcOptionsTypes(): Record<string, unknown>;
|
|
3
|
-
export declare function cliOptionsTypes(): Record<string, unknown>;
|
|
4
|
-
export declare const commandNames: string[];
|
|
5
|
-
export declare function help(): string;
|
|
6
|
-
export type ConfigHandlerResult = string | undefined | {
|
|
7
|
-
output: string;
|
|
8
|
-
exitCode: number;
|
|
9
|
-
};
|
|
10
|
-
export declare function handler(opts: ConfigCommandOptions, params: string[]): Promise<ConfigHandlerResult>;
|
package/lib/config.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { docsUrl } from '@pnpm/cli.utils';
|
|
2
|
-
import { PnpmError } from '@pnpm/error';
|
|
3
|
-
import { renderHelp } from 'render-help';
|
|
4
|
-
import { configGet } from './configGet.js';
|
|
5
|
-
import { configList } from './configList.js';
|
|
6
|
-
import { configSet } from './configSet.js';
|
|
7
|
-
export function rcOptionsTypes() {
|
|
8
|
-
return {};
|
|
9
|
-
}
|
|
10
|
-
export function cliOptionsTypes() {
|
|
11
|
-
return {
|
|
12
|
-
global: Boolean,
|
|
13
|
-
location: ['global', 'project'],
|
|
14
|
-
json: Boolean,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export const commandNames = ['config', 'c'];
|
|
18
|
-
export function help() {
|
|
19
|
-
return renderHelp({
|
|
20
|
-
description: 'Manage the pnpm configuration files.',
|
|
21
|
-
descriptionLists: [
|
|
22
|
-
{
|
|
23
|
-
title: 'Commands',
|
|
24
|
-
list: [
|
|
25
|
-
{
|
|
26
|
-
description: 'Set the config key to the value provided',
|
|
27
|
-
name: 'set',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
description: 'Print the config value for the provided key',
|
|
31
|
-
name: 'get',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
description: 'Remove the config key from the config file',
|
|
35
|
-
name: 'delete',
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
description: 'Show all the config settings',
|
|
39
|
-
name: 'list',
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
title: 'Options',
|
|
45
|
-
list: [
|
|
46
|
-
{
|
|
47
|
-
description: 'Sets the configuration in the global config file',
|
|
48
|
-
name: '--global',
|
|
49
|
-
shortAlias: '-g',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
description: 'When set to "project", the pnpm-workspace.yaml file will be used if it exists. If only .npmrc exists, it will be used. If neither exists, a pnpm-workspace.yaml file will be created.',
|
|
53
|
-
name: '--location <project|global>',
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
description: 'Show all types of values in JSON format (not just objects and arrays)',
|
|
57
|
-
name: '--json',
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
url: docsUrl('config'),
|
|
63
|
-
usages: [
|
|
64
|
-
'pnpm config set <key> <value>',
|
|
65
|
-
'pnpm config get <key>',
|
|
66
|
-
'pnpm config get --json <key>',
|
|
67
|
-
'pnpm config delete <key>',
|
|
68
|
-
'pnpm config list',
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
export async function handler(opts, params) {
|
|
73
|
-
if (params.length === 0) {
|
|
74
|
-
throw new PnpmError('CONFIG_NO_SUBCOMMAND', 'Please specify the subcommand', {
|
|
75
|
-
hint: help(),
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
if (opts.location) {
|
|
79
|
-
opts.global = opts.location === 'global';
|
|
80
|
-
}
|
|
81
|
-
else if (opts.cliOptions['global'] == null) {
|
|
82
|
-
opts.global = true;
|
|
83
|
-
}
|
|
84
|
-
switch (params[0]) {
|
|
85
|
-
case 'set':
|
|
86
|
-
case 'delete': {
|
|
87
|
-
if (!params[1]) {
|
|
88
|
-
throw new PnpmError('CONFIG_NO_PARAMS', `\`pnpm config ${params[0]}\` requires the config key`);
|
|
89
|
-
}
|
|
90
|
-
if (params[0] === 'set') {
|
|
91
|
-
let [key, value] = params.slice(1);
|
|
92
|
-
if (value == null) {
|
|
93
|
-
const parts = key.split('=');
|
|
94
|
-
key = parts.shift();
|
|
95
|
-
value = parts.join('=');
|
|
96
|
-
}
|
|
97
|
-
return configSet(opts, key, value ?? '');
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
return configSet(opts, params[1], null);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
case 'get': {
|
|
104
|
-
if (params[1]) {
|
|
105
|
-
return configGet(opts, params[1]);
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
return configList(opts);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
case 'list': {
|
|
112
|
-
return configList(opts);
|
|
113
|
-
}
|
|
114
|
-
default: {
|
|
115
|
-
throw new PnpmError('CONFIG_UNKNOWN_SUBCOMMAND', 'This subcommand is not known');
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
//# sourceMappingURL=config.js.map
|
package/lib/configGet.d.ts
DELETED
package/lib/configGet.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { getGlobalConfigPath, isIniConfigKey, types } from '@pnpm/config.reader';
|
|
2
|
-
import { getObjectValueByPropertyPath } from '@pnpm/object.property-path';
|
|
3
|
-
import { isCamelCase } from '@pnpm/text.naming-cases';
|
|
4
|
-
import camelcase from 'camelcase';
|
|
5
|
-
import kebabCase from 'lodash.kebabcase';
|
|
6
|
-
import { configToRecord } from './configToRecord.js';
|
|
7
|
-
import { parseConfigPropertyPath } from './parseConfigPropertyPath.js';
|
|
8
|
-
export function configGet(opts, key) {
|
|
9
|
-
const isScopedKey = key.startsWith('@');
|
|
10
|
-
const configResult = lookupConfig(opts, key, isScopedKey) ?? (isPropertyPath(key) ? lookupByPropertyPath(opts, key) : { value: undefined });
|
|
11
|
-
const output = displayConfig(configResult?.value, opts);
|
|
12
|
-
return { output, exitCode: 0 };
|
|
13
|
-
}
|
|
14
|
-
function lookupConfig(opts, key, isScopedKey) {
|
|
15
|
-
if (isScopedKey) {
|
|
16
|
-
// Scoped registry keys (e.g. `@scope:registry`) can be set in two places:
|
|
17
|
-
// `.npmrc` (which lands in authConfig) or pnpm-workspace.yaml's
|
|
18
|
-
// `registries` block (which lands in the merged Config.registries map).
|
|
19
|
-
// Prefer the merged map so this command reports the same value that
|
|
20
|
-
// `pnpm publish` and the resolvers actually use.
|
|
21
|
-
if (key.endsWith(':registry')) {
|
|
22
|
-
const scope = key.slice(0, key.length - ':registry'.length);
|
|
23
|
-
const merged = opts._config.registries?.[scope];
|
|
24
|
-
if (merged !== undefined) {
|
|
25
|
-
return { value: merged };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return { value: opts.authConfig[key] };
|
|
29
|
-
}
|
|
30
|
-
if (key === 'globalconfig') {
|
|
31
|
-
return { value: getGlobalConfigPath(opts.configDir) };
|
|
32
|
-
}
|
|
33
|
-
const kebabKey = isCamelCase(key) ? kebabCase(key) : key;
|
|
34
|
-
// Resolve typed keys from Config — check explicitly set values first,
|
|
35
|
-
// then fall back to authConfig (for keys like registry set in .npmrc)
|
|
36
|
-
if (Object.hasOwn(types, kebabKey)) {
|
|
37
|
-
const camelKey = camelcase(kebabKey, { locale: 'en-US' });
|
|
38
|
-
const explicit = opts._context.explicitlySetKeys;
|
|
39
|
-
if (!explicit || explicit.has(camelKey)) {
|
|
40
|
-
return { value: opts._config[camelKey] };
|
|
41
|
-
}
|
|
42
|
-
// Fall back to authConfig for INI keys (registry, ca, etc.)
|
|
43
|
-
if (kebabKey in opts.authConfig) {
|
|
44
|
-
return { value: opts.authConfig[kebabKey] };
|
|
45
|
-
}
|
|
46
|
-
return { value: undefined };
|
|
47
|
-
}
|
|
48
|
-
// Auth-specific INI keys (//host:_authToken, _auth, etc.) from authConfig
|
|
49
|
-
if (isIniConfigKey(key)) {
|
|
50
|
-
return { value: opts.authConfig[key] };
|
|
51
|
-
}
|
|
52
|
-
// For keys not in types (e.g., package-extensions), look up via configToRecord
|
|
53
|
-
// which excludes internal/sensitive fields.
|
|
54
|
-
const camelKey = camelcase(key, { locale: 'en-US' });
|
|
55
|
-
const record = configToRecord(opts._config, opts._context.explicitlySetKeys);
|
|
56
|
-
if (Object.hasOwn(record, camelKey)) {
|
|
57
|
-
return { value: record[camelKey] };
|
|
58
|
-
}
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
function lookupByPropertyPath(opts, propertyPath) {
|
|
62
|
-
const parsedPropertyPath = Array.from(parseConfigPropertyPath(propertyPath));
|
|
63
|
-
if (parsedPropertyPath.length === 0) {
|
|
64
|
-
return { value: configToRecord(opts._config, opts._context.explicitlySetKeys) };
|
|
65
|
-
}
|
|
66
|
-
const record = configToRecord(opts._config, opts._context.explicitlySetKeys);
|
|
67
|
-
return {
|
|
68
|
-
value: getObjectValueByPropertyPath(record, parsedPropertyPath),
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
function isPropertyPath(key) {
|
|
72
|
-
return key === '' || key.includes('.') || key.includes('[');
|
|
73
|
-
}
|
|
74
|
-
function displayConfig(config, opts) {
|
|
75
|
-
if (Boolean(opts.json) || Array.isArray(config)) {
|
|
76
|
-
return JSON.stringify(config, undefined, 2);
|
|
77
|
-
}
|
|
78
|
-
if (typeof config === 'object' && config != null) {
|
|
79
|
-
return JSON.stringify(config, undefined, 2);
|
|
80
|
-
}
|
|
81
|
-
return String(config);
|
|
82
|
-
}
|
|
83
|
-
//# sourceMappingURL=configGet.js.map
|
package/lib/configList.d.ts
DELETED
package/lib/configList.js
DELETED
package/lib/configSet.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { PnpmError } from '@pnpm/error';
|
|
2
|
-
import type { ConfigCommandOptions } from './ConfigCommandOptions.js';
|
|
3
|
-
export declare function configSet(opts: ConfigCommandOptions, key: string, valueParam: string | null): Promise<void>;
|
|
4
|
-
export declare class ConfigSetKeyEmptyKeyError extends PnpmError {
|
|
5
|
-
constructor();
|
|
6
|
-
}
|
|
7
|
-
export declare class ConfigSetDeepKeyError extends PnpmError {
|
|
8
|
-
constructor();
|
|
9
|
-
}
|
|
10
|
-
export declare class ConfigSetUnsupportedIniConfigKeyError extends PnpmError {
|
|
11
|
-
readonly key: string;
|
|
12
|
-
constructor(key: string);
|
|
13
|
-
}
|
|
14
|
-
export declare class ConfigSetUnsupportedWorkspaceKeyError extends PnpmError {
|
|
15
|
-
readonly key: string;
|
|
16
|
-
constructor(key: string);
|
|
17
|
-
}
|
|
18
|
-
export declare class ConfigSetUnsupportedYamlConfigKeyError extends PnpmError {
|
|
19
|
-
readonly key: string;
|
|
20
|
-
constructor(key: string);
|
|
21
|
-
}
|
package/lib/configSet.js
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import util from 'node:util';
|
|
3
|
-
import { isConfigFileKey, isIniConfigKey, types } from '@pnpm/config.reader';
|
|
4
|
-
import { GLOBAL_CONFIG_YAML_FILENAME, WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants';
|
|
5
|
-
import { PnpmError } from '@pnpm/error';
|
|
6
|
-
import { parsePropertyPath } from '@pnpm/object.property-path';
|
|
7
|
-
import { isCamelCase, isStrictlyKebabCase } from '@pnpm/text.naming-cases';
|
|
8
|
-
import { updateWorkspaceManifest } from '@pnpm/workspace.workspace-manifest-writer';
|
|
9
|
-
import camelCase from 'camelcase';
|
|
10
|
-
import kebabCase from 'lodash.kebabcase';
|
|
11
|
-
import { readIniFile } from 'read-ini-file';
|
|
12
|
-
import { writeIniFile } from 'write-ini-file';
|
|
13
|
-
import { getConfigFileInfo } from './getConfigFileInfo.js';
|
|
14
|
-
export async function configSet(opts, key, valueParam) {
|
|
15
|
-
let isAuthSetting = isIniConfigKey(key);
|
|
16
|
-
if (!isAuthSetting) {
|
|
17
|
-
key = validateSimpleKey(key);
|
|
18
|
-
isAuthSetting = isIniConfigKey(key);
|
|
19
|
-
}
|
|
20
|
-
let value = valueParam;
|
|
21
|
-
if (valueParam != null && opts.json) {
|
|
22
|
-
value = JSON.parse(valueParam);
|
|
23
|
-
}
|
|
24
|
-
if (isAuthSetting) {
|
|
25
|
-
const configPath = opts.global
|
|
26
|
-
? path.join(opts.configDir, 'auth.ini')
|
|
27
|
-
: path.join(opts.dir, '.npmrc');
|
|
28
|
-
if (value != null && typeof value !== 'string' && isStringOnlyIniKey(key)) {
|
|
29
|
-
throw new PnpmError('CONFIG_SET_AUTH_NON_STRING', `Cannot set ${key} to a non-string value (${JSON.stringify(value)})`);
|
|
30
|
-
}
|
|
31
|
-
const settings = await safeReadIniFile(configPath);
|
|
32
|
-
if (value == null) {
|
|
33
|
-
if (settings[key] == null)
|
|
34
|
-
return;
|
|
35
|
-
delete settings[key];
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
settings[key] = value;
|
|
39
|
-
}
|
|
40
|
-
await writeIniFile(configPath, settings);
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const { configDir, configFileName } = getConfigFileInfo(key, opts);
|
|
44
|
-
const configPath = path.join(configDir, configFileName);
|
|
45
|
-
switch (configFileName) {
|
|
46
|
-
case GLOBAL_CONFIG_YAML_FILENAME:
|
|
47
|
-
case WORKSPACE_MANIFEST_FILENAME: {
|
|
48
|
-
if (configFileName === GLOBAL_CONFIG_YAML_FILENAME) {
|
|
49
|
-
key = validateYamlConfigKey(key);
|
|
50
|
-
}
|
|
51
|
-
key = validateWorkspaceKey(key);
|
|
52
|
-
await updateWorkspaceManifest(configDir, {
|
|
53
|
-
fileName: configFileName,
|
|
54
|
-
updatedFields: ({
|
|
55
|
-
[key]: castField(value, kebabCase(key)),
|
|
56
|
-
}),
|
|
57
|
-
});
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
case 'auth.ini':
|
|
61
|
-
case '.npmrc': {
|
|
62
|
-
const settings = await safeReadIniFile(configPath);
|
|
63
|
-
key = validateIniConfigKey(key);
|
|
64
|
-
if (value == null) {
|
|
65
|
-
if (settings[key] == null)
|
|
66
|
-
return;
|
|
67
|
-
delete settings[key];
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
settings[key] = value;
|
|
71
|
-
}
|
|
72
|
-
await writeIniFile(configPath, settings);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
default: {
|
|
76
|
-
const _typeGuard = configFileName;
|
|
77
|
-
throw new Error(`Unhandled case: ${JSON.stringify(_typeGuard)}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function castField(value, key) {
|
|
82
|
-
if (typeof value !== 'string') {
|
|
83
|
-
return value;
|
|
84
|
-
}
|
|
85
|
-
const type = types[key];
|
|
86
|
-
const typeList = Array.isArray(type) ? type : [type];
|
|
87
|
-
const isNumber = typeList.includes(Number);
|
|
88
|
-
value = value.trim();
|
|
89
|
-
switch (value) {
|
|
90
|
-
case 'true': {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
case 'false': {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
case 'null': {
|
|
97
|
-
return null;
|
|
98
|
-
}
|
|
99
|
-
case 'undefined': {
|
|
100
|
-
return undefined;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
if (isNumber && !isNaN(value)) {
|
|
104
|
-
value = Number(value);
|
|
105
|
-
}
|
|
106
|
-
return value;
|
|
107
|
-
}
|
|
108
|
-
export class ConfigSetKeyEmptyKeyError extends PnpmError {
|
|
109
|
-
constructor() {
|
|
110
|
-
super('CONFIG_SET_EMPTY_KEY', 'Cannot set config with an empty key');
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
export class ConfigSetDeepKeyError extends PnpmError {
|
|
114
|
-
constructor() {
|
|
115
|
-
// it shouldn't be supported until there is a mechanism to validate the config value
|
|
116
|
-
super('CONFIG_SET_DEEP_KEY', 'Setting deep property path is not supported');
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Validate if {@link key} is a simple key or a property path.
|
|
121
|
-
*
|
|
122
|
-
* If it is an empty property path or a property path longer than 1, throw an error.
|
|
123
|
-
*
|
|
124
|
-
* If it is a simple key (or a property path with length of 1), return it.
|
|
125
|
-
*/
|
|
126
|
-
function validateSimpleKey(key) {
|
|
127
|
-
if (isStrictlyKebabCase(key))
|
|
128
|
-
return key;
|
|
129
|
-
const iter = parsePropertyPath(key);
|
|
130
|
-
const first = iter.next();
|
|
131
|
-
if (first.done)
|
|
132
|
-
throw new ConfigSetKeyEmptyKeyError();
|
|
133
|
-
const second = iter.next();
|
|
134
|
-
if (!second.done)
|
|
135
|
-
throw new ConfigSetDeepKeyError();
|
|
136
|
-
return first.value.toString();
|
|
137
|
-
}
|
|
138
|
-
export class ConfigSetUnsupportedIniConfigKeyError extends PnpmError {
|
|
139
|
-
key;
|
|
140
|
-
constructor(key) {
|
|
141
|
-
super('CONFIG_SET_UNSUPPORTED_INI_CONFIG_KEY', `Key ${JSON.stringify(key)} isn't supported by INI config files`, {
|
|
142
|
-
hint: `Add ${JSON.stringify(camelCase(key))} to the project workspace manifest instead`,
|
|
143
|
-
});
|
|
144
|
-
this.key = key;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Validate whether the kebab-case of {@link key} is supported by INI config files.
|
|
149
|
-
*
|
|
150
|
-
* Return the kebab-case if it is, throw an error otherwise.
|
|
151
|
-
*
|
|
152
|
-
* "INI config files" includes:
|
|
153
|
-
* * The global INI config file named `rc`.
|
|
154
|
-
* * The local INI config file named `.npmrc`.
|
|
155
|
-
*/
|
|
156
|
-
function validateIniConfigKey(key) {
|
|
157
|
-
const kebabKey = kebabCase(key);
|
|
158
|
-
if (Object.hasOwn(types, kebabKey)) {
|
|
159
|
-
return kebabKey;
|
|
160
|
-
}
|
|
161
|
-
throw new ConfigSetUnsupportedIniConfigKeyError(key);
|
|
162
|
-
}
|
|
163
|
-
export class ConfigSetUnsupportedWorkspaceKeyError extends PnpmError {
|
|
164
|
-
key;
|
|
165
|
-
constructor(key) {
|
|
166
|
-
super('CONFIG_SET_UNSUPPORTED_WORKSPACE_KEY', `The key ${JSON.stringify(key)} isn't supported by the workspace manifest`, {
|
|
167
|
-
hint: `Try ${JSON.stringify(camelCase(key))}`,
|
|
168
|
-
});
|
|
169
|
-
this.key = key;
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Only an rc option key would be allowed to be kebab-case, otherwise, it must be camelCase.
|
|
174
|
-
*
|
|
175
|
-
* Return the camelCase of {@link key} if it's valid.
|
|
176
|
-
*/
|
|
177
|
-
function validateWorkspaceKey(key) {
|
|
178
|
-
if (Object.hasOwn(types, key) || isConfigFileKey(key))
|
|
179
|
-
return camelCase(key);
|
|
180
|
-
if (!isCamelCase(key))
|
|
181
|
-
throw new ConfigSetUnsupportedWorkspaceKeyError(key);
|
|
182
|
-
return key;
|
|
183
|
-
}
|
|
184
|
-
const STRING_ONLY_INI_KEYS = ['_auth', '_authToken', '_password', 'username', 'registry'];
|
|
185
|
-
function isStringOnlyIniKey(key) {
|
|
186
|
-
if (STRING_ONLY_INI_KEYS.includes(key))
|
|
187
|
-
return true;
|
|
188
|
-
if (key.startsWith('@'))
|
|
189
|
-
return true;
|
|
190
|
-
if (key.startsWith('//'))
|
|
191
|
-
return true;
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
async function safeReadIniFile(configPath) {
|
|
195
|
-
try {
|
|
196
|
-
return await readIniFile(configPath);
|
|
197
|
-
}
|
|
198
|
-
catch (err) {
|
|
199
|
-
if (util.types.isNativeError(err) && 'code' in err && err.code === 'ENOENT')
|
|
200
|
-
return {};
|
|
201
|
-
throw err;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
export class ConfigSetUnsupportedYamlConfigKeyError extends PnpmError {
|
|
205
|
-
key;
|
|
206
|
-
constructor(key) {
|
|
207
|
-
super('CONFIG_SET_UNSUPPORTED_YAML_CONFIG_KEY', `The key ${JSON.stringify(key)} isn't supported by the global config.yaml file`, {
|
|
208
|
-
hint: 'Try setting them instead to the local pnpm-workspace.yaml file',
|
|
209
|
-
});
|
|
210
|
-
this.key = key;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
/**
|
|
214
|
-
* Validate whether the {@link key} is allowed in the global config.yaml file.
|
|
215
|
-
*
|
|
216
|
-
* Return the kebab-case if it is, throw an error otherwise.
|
|
217
|
-
*/
|
|
218
|
-
function validateYamlConfigKey(key) {
|
|
219
|
-
const kebabKey = kebabCase(key);
|
|
220
|
-
if (!isConfigFileKey(kebabKey)) {
|
|
221
|
-
throw new ConfigSetUnsupportedYamlConfigKeyError(key);
|
|
222
|
-
}
|
|
223
|
-
return kebabKey;
|
|
224
|
-
}
|
|
225
|
-
//# sourceMappingURL=configSet.js.map
|
package/lib/configToRecord.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { type Config } from '@pnpm/config.reader';
|
|
2
|
-
/**
|
|
3
|
-
* Convert a Config object to a camelCase record for display.
|
|
4
|
-
* Only includes explicitly set values (from CLI, env vars, or workspace yaml),
|
|
5
|
-
* not default values. Auth/registry keys from authConfig are always included.
|
|
6
|
-
*
|
|
7
|
-
* Accepts a clean Config object (without ConfigContext fields mixed in),
|
|
8
|
-
* so no INTERNAL_CONFIG_KEYS exclusion list is needed.
|
|
9
|
-
*/
|
|
10
|
-
export declare function configToRecord(config: Config, explicitlySetKeys: Set<string>): Record<string, unknown>;
|
package/lib/configToRecord.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { types } from '@pnpm/config.reader';
|
|
2
|
-
import { sortDirectKeys } from '@pnpm/object.key-sorting';
|
|
3
|
-
import camelcase from 'camelcase';
|
|
4
|
-
import { censorProtectedSettings } from './protectedSettings.js';
|
|
5
|
-
// Auth-related Config fields that are internal objects, not user settings.
|
|
6
|
-
const NON_SETTING_CONFIG_KEYS = new Set([
|
|
7
|
-
'authConfig', 'configByUri',
|
|
8
|
-
]);
|
|
9
|
-
/**
|
|
10
|
-
* Convert a Config object to a camelCase record for display.
|
|
11
|
-
* Only includes explicitly set values (from CLI, env vars, or workspace yaml),
|
|
12
|
-
* not default values. Auth/registry keys from authConfig are always included.
|
|
13
|
-
*
|
|
14
|
-
* Accepts a clean Config object (without ConfigContext fields mixed in),
|
|
15
|
-
* so no INTERNAL_CONFIG_KEYS exclusion list is needed.
|
|
16
|
-
*/
|
|
17
|
-
export function configToRecord(config, explicitlySetKeys) {
|
|
18
|
-
const result = {};
|
|
19
|
-
// Add typed settings (only explicitly set ones if tracking is available)
|
|
20
|
-
for (const kebabKey of Object.keys(types)) {
|
|
21
|
-
const camelKey = camelcase(kebabKey, { locale: 'en-US' });
|
|
22
|
-
if (!explicitlySetKeys.has(camelKey))
|
|
23
|
-
continue;
|
|
24
|
-
const value = config[camelKey];
|
|
25
|
-
if (value !== undefined) {
|
|
26
|
-
result[camelKey] = value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
// Add non-types config properties (e.g., packageExtensions, overrides)
|
|
30
|
-
for (const [key, value] of Object.entries(config)) {
|
|
31
|
-
if (value === undefined || NON_SETTING_CONFIG_KEYS.has(key))
|
|
32
|
-
continue;
|
|
33
|
-
if (!(key in result) && explicitlySetKeys.has(key)) {
|
|
34
|
-
result[key] = value;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
// Add auth/registry keys (scoped keys, auth tokens) — keep original casing
|
|
38
|
-
for (const [key, value] of Object.entries(config.authConfig)) {
|
|
39
|
-
if (!(key in result)) {
|
|
40
|
-
result[key] = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
// Always include user-agent for debugging connectivity issues
|
|
44
|
-
if (config.userAgent) {
|
|
45
|
-
result.userAgent = config.userAgent;
|
|
46
|
-
}
|
|
47
|
-
return censorProtectedSettings(sortDirectKeys(result));
|
|
48
|
-
}
|
|
49
|
-
//# sourceMappingURL=configToRecord.js.map
|
package/lib/get.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as configCmd from './config.js';
|
|
2
|
-
import type { ConfigCommandOptions } from './ConfigCommandOptions.js';
|
|
3
|
-
export declare const rcOptionsTypes: typeof configCmd.rcOptionsTypes;
|
|
4
|
-
export declare const cliOptionsTypes: typeof configCmd.cliOptionsTypes;
|
|
5
|
-
export declare const help: typeof configCmd.help;
|
|
6
|
-
export declare const commandNames: string[];
|
|
7
|
-
export declare function handler(opts: ConfigCommandOptions, params: string[]): Promise<configCmd.ConfigHandlerResult>;
|
package/lib/get.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as configCmd from './config.js';
|
|
2
|
-
export const rcOptionsTypes = configCmd.rcOptionsTypes;
|
|
3
|
-
export const cliOptionsTypes = configCmd.cliOptionsTypes;
|
|
4
|
-
export const help = configCmd.help;
|
|
5
|
-
export const commandNames = ['get'];
|
|
6
|
-
export async function handler(opts, params) {
|
|
7
|
-
return configCmd.handler(opts, ['get', ...params]);
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=get.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GLOBAL_CONFIG_YAML_FILENAME, WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants';
|
|
2
|
-
import type { ConfigCommandOptions } from './ConfigCommandOptions.js';
|
|
3
|
-
export type ConfigFileName = 'auth.ini' | '.npmrc' | typeof GLOBAL_CONFIG_YAML_FILENAME | typeof WORKSPACE_MANIFEST_FILENAME;
|
|
4
|
-
export interface ConfigFilePathInfo {
|
|
5
|
-
configDir: string;
|
|
6
|
-
configFileName: ConfigFileName;
|
|
7
|
-
}
|
|
8
|
-
export declare function getConfigFileInfo(key: string, opts: Pick<ConfigCommandOptions, 'global' | 'configDir' | 'dir'>): ConfigFilePathInfo;
|
package/lib/getConfigFileInfo.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { isIniConfigKey } from '@pnpm/config.reader';
|
|
2
|
-
import { GLOBAL_CONFIG_YAML_FILENAME, WORKSPACE_MANIFEST_FILENAME } from '@pnpm/constants';
|
|
3
|
-
import kebabCase from 'lodash.kebabcase';
|
|
4
|
-
export function getConfigFileInfo(key, opts) {
|
|
5
|
-
key = kebabCase(key);
|
|
6
|
-
const configDir = opts.global ? opts.configDir : opts.dir;
|
|
7
|
-
if (isIniConfigKey(key)) {
|
|
8
|
-
// NOTE: The following code no longer does what the merged PR at <https://github.com/pnpm/pnpm/pull/10073> wants to do,
|
|
9
|
-
// but considering the settings are now clearly divided into 2 separate categories, it should no longer be relevant.
|
|
10
|
-
// TODO: Auth, network, and proxy settings should belong only to INI files.
|
|
11
|
-
// Add more settings to `isIniConfigKey` to make it complete.
|
|
12
|
-
const configFileName = opts.global ? 'auth.ini' : '.npmrc';
|
|
13
|
-
return { configDir, configFileName };
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
const configFileName = opts.global ? GLOBAL_CONFIG_YAML_FILENAME : WORKSPACE_MANIFEST_FILENAME;
|
|
17
|
-
return { configDir, configFileName };
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=getConfigFileInfo.js.map
|
package/lib/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Just like {@link parsePropertyPath} but the first element is converted to camelCase
|
|
3
|
-
* to match the camelCase keys produced by {@link configToRecord}.
|
|
4
|
-
*/
|
|
5
|
-
export declare function parseConfigPropertyPath(propertyPath: string): Generator<string | number, void, void>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { parsePropertyPath } from '@pnpm/object.property-path';
|
|
2
|
-
import camelcase from 'camelcase';
|
|
3
|
-
/**
|
|
4
|
-
* Just like {@link parsePropertyPath} but the first element is converted to camelCase
|
|
5
|
-
* to match the camelCase keys produced by {@link configToRecord}.
|
|
6
|
-
*/
|
|
7
|
-
export function* parseConfigPropertyPath(propertyPath) {
|
|
8
|
-
const iter = parsePropertyPath(propertyPath);
|
|
9
|
-
const first = iter.next();
|
|
10
|
-
if (first.done)
|
|
11
|
-
return;
|
|
12
|
-
yield typeof first.value === 'number' ? first.value : camelcase(first.value, { locale: 'en-US' });
|
|
13
|
-
yield* iter;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=parseConfigPropertyPath.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/** Protected settings are settings which `npm config get` refuses to print. */
|
|
2
|
-
export declare const isSettingProtected: (key: string) => boolean;
|
|
3
|
-
/** Hide all protected settings by setting them to `(protected)`. */
|
|
4
|
-
export declare function censorProtectedSettings(config: Record<string, unknown>): Record<string, unknown>;
|
package/lib/protectedSettings.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
const PROTECTED_SUFFICES = [
|
|
2
|
-
'_auth',
|
|
3
|
-
'_authToken',
|
|
4
|
-
'username',
|
|
5
|
-
'_password',
|
|
6
|
-
];
|
|
7
|
-
/** Protected settings are settings which `npm config get` refuses to print. */
|
|
8
|
-
export const isSettingProtected = (key) => key.startsWith('//')
|
|
9
|
-
? PROTECTED_SUFFICES.some(suffix => key.endsWith(`:${suffix}`))
|
|
10
|
-
: PROTECTED_SUFFICES.includes(key);
|
|
11
|
-
/** Hide all protected settings by setting them to `(protected)`. */
|
|
12
|
-
export function censorProtectedSettings(config) {
|
|
13
|
-
config = { ...config };
|
|
14
|
-
for (const key in config) {
|
|
15
|
-
if (isSettingProtected(key)) {
|
|
16
|
-
config[key] = '(protected)';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return config;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=protectedSettings.js.map
|
package/lib/set.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import * as configCmd from './config.js';
|
|
2
|
-
import type { ConfigCommandOptions } from './ConfigCommandOptions.js';
|
|
3
|
-
export declare const rcOptionsTypes: typeof configCmd.rcOptionsTypes;
|
|
4
|
-
export declare const cliOptionsTypes: typeof configCmd.cliOptionsTypes;
|
|
5
|
-
export declare const help: typeof configCmd.help;
|
|
6
|
-
export declare const commandNames: string[];
|
|
7
|
-
export declare function handler(opts: ConfigCommandOptions, params: string[]): Promise<configCmd.ConfigHandlerResult>;
|
package/lib/set.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as configCmd from './config.js';
|
|
2
|
-
export const rcOptionsTypes = configCmd.rcOptionsTypes;
|
|
3
|
-
export const cliOptionsTypes = configCmd.cliOptionsTypes;
|
|
4
|
-
export const help = configCmd.help;
|
|
5
|
-
export const commandNames = ['set'];
|
|
6
|
-
export async function handler(opts, params) {
|
|
7
|
-
return configCmd.handler(opts, ['set', ...params]);
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=set.js.map
|