@vltpkg/config 1.0.0-rc.27 → 1.0.0-rc.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.
Files changed (2) hide show
  1. package/dist/index.js +19 -3
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -8,8 +8,24 @@ import { isRecordField, pairsToRecords, recordsToPairs, } from '@vltpkg/cli-sdk/
8
8
  export const list = (conf) => {
9
9
  return recordsToPairs(conf.options);
10
10
  };
11
+ /**
12
+ * Match npm-style scoped registry keys like `@scope:registry`.
13
+ * The scope is captured (including the leading `@`) so it can be
14
+ * mapped onto the `scoped-registries` record field.
15
+ */
16
+ const npmScopeRegistryRe = /^(@[^:/\s]+):registry$/;
17
+ /**
18
+ * Translate an npm-style `@scope:registry` config key into the
19
+ * vlt equivalent dot-prop path `scoped-registries.@scope`.
20
+ *
21
+ * Any other key is returned unchanged.
22
+ */
23
+ const normalizeConfigKey = (key) => {
24
+ const m = npmScopeRegistryRe.exec(key);
25
+ return m?.[1] ? `scoped-registries.${m[1]}` : key;
26
+ };
11
27
  export const del = async (conf) => {
12
- const fields = conf.positionals.slice(1);
28
+ const fields = conf.positionals.slice(1).map(normalizeConfigKey);
13
29
  if (!fields.length) {
14
30
  throw error('At least one key is required', {
15
31
  code: 'EUSAGE',
@@ -21,7 +37,7 @@ export const del = async (conf) => {
21
37
  };
22
38
  export const get = async (conf) => {
23
39
  const keys = conf.positionals.slice(1);
24
- const k = keys[0];
40
+ const k = keys[0] && normalizeConfigKey(keys[0]);
25
41
  if (!k || keys.length > 1) {
26
42
  throw error('Exactly one key is required', {
27
43
  code: 'EUSAGE',
@@ -92,7 +108,7 @@ export const set = async (conf) => {
92
108
  code: 'EUSAGE',
93
109
  });
94
110
  }
95
- const key = pair.substring(0, eq);
111
+ const key = normalizeConfigKey(pair.substring(0, eq));
96
112
  const value = pair.substring(eq + 1);
97
113
  if (key.includes('.')) {
98
114
  const [field, ...rest] = key.split('.');
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vltpkg/config",
3
3
  "description": "Project config logic for vltpkg",
4
- "version": "1.0.0-rc.27",
4
+ "version": "1.0.0-rc.29",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/vltpkg/vltpkg.git",
@@ -13,12 +13,12 @@
13
13
  "url": "http://vlt.sh"
14
14
  },
15
15
  "dependencies": {
16
- "@vltpkg/cli-sdk": "1.0.0-rc.27",
17
- "@vltpkg/dot-prop": "1.0.0-rc.27",
18
- "@vltpkg/error-cause": "1.0.0-rc.27",
19
- "@vltpkg/output": "1.0.0-rc.27",
20
- "@vltpkg/package-json": "1.0.0-rc.27",
21
- "@vltpkg/types": "1.0.0-rc.27",
16
+ "@vltpkg/cli-sdk": "1.0.0-rc.29",
17
+ "@vltpkg/dot-prop": "1.0.0-rc.29",
18
+ "@vltpkg/error-cause": "1.0.0-rc.29",
19
+ "@vltpkg/output": "1.0.0-rc.29",
20
+ "@vltpkg/package-json": "1.0.0-rc.29",
21
+ "@vltpkg/types": "1.0.0-rc.29",
22
22
  "path-scurry": "^2.0.1"
23
23
  },
24
24
  "devDependencies": {