mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-25 15:07:06 -04:00
* feat(config): global `rc.yaml`
* fix: undefined `rawConfig`
* test: add a test
* feat: re-export `isSupportedNpmConfig`
* feat: return `'compat'` to distinguish compatibility reason
* docs: `isSupportedNpmConfig`
* fix: eslint
* docs: clarify the case of the config key
* feat(cli/config/set): target yaml for pnpm-specific settings
* fix: read the correct file
* fix: write to the correct directory
* refactor: remove disabled code
* refactor: get `configDir` directly
* docs: remove outdated documentation
* test: fix a test
* test: rename
* fix: explicitly tell npm the config file path
* test: add a test
* test: add a test
* test: fix a test
* fix: local config dir
* fix: `managingAuthSettings`
* test: rename
* test: fix
* test: add a test
* test: demonstrate choosing config files
* test: fix
* docs: yet another consideration
* test: demonstrate choosing config files
* fix: correct local config file names in test helper
* test: demonstrate choosing config files
* test: use the helper
* test: add a test
* test: correct a test
* test: fix
* test: fix
* fix: eslint
* test: remove duplicate
* feat: validate `rc.yaml`
* docs: changeset
* test: fix `configDelete.test.ts`
* feat: other `npm` call-sites
* fix: make optional again
* feat: remove the change from `publish`
* fix: eslint
* refactor: just one is sufficient
* refactor: replace type union with 3 functions
* refactor(test): extract helper functions
* fix: add `rc.yaml` to `rawConfig`
* test: keep workspace settings out of `rc.yaml`
* test: fix `spawn ENOENT`
* chore(git): revert invalid change
This reverts commit 1ff6fe2323.
* feat: rename `rc.yaml` to `config.yaml`
* refactor: replace `acceptNonRc` with `!globalSettingsOnly`
* feat!: remove compat completely
* refactor: rename a function
* fix: no actual catalogs
* refactor: replace bool flag with preemptive filter
* feat!: filter global config keys
* test: fix
* fix: exclude `deploy-all-files`
* fix: reverse schema merge order
* feat(cli/config/set): validate global config yaml key
* test: remove duplicated assertion
* docs: correct
* docs: goal changed
122 lines
3.5 KiB
TypeScript
122 lines
3.5 KiB
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
import { tempDir } from '@pnpm/prepare'
|
|
import { config } from '@pnpm/plugin-commands-config'
|
|
import { readIniFileSync } from 'read-ini-file'
|
|
import { sync as readYamlFile } from 'read-yaml-file'
|
|
import { sync as writeYamlFile } from 'write-yaml-file'
|
|
|
|
test('config delete on registry key not set', async () => {
|
|
const tmp = tempDir()
|
|
const configDir = path.join(tmp, 'global-config')
|
|
fs.mkdirSync(configDir, { recursive: true })
|
|
fs.writeFileSync(path.join(configDir, 'rc'), '@my-company:registry=https://registry.my-company.example.com/')
|
|
|
|
await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir,
|
|
global: true,
|
|
rawConfig: {},
|
|
}, ['delete', 'registry'])
|
|
|
|
expect(readIniFileSync(path.join(configDir, 'rc'))).toEqual({
|
|
'@my-company:registry': 'https://registry.my-company.example.com/',
|
|
})
|
|
})
|
|
|
|
test('config delete on registry key set', async () => {
|
|
const tmp = tempDir()
|
|
const configDir = path.join(tmp, 'global-config')
|
|
fs.mkdirSync(configDir, { recursive: true })
|
|
fs.writeFileSync(path.join(configDir, 'rc'), 'registry=https://registry.my-company.example.com/')
|
|
|
|
await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir,
|
|
global: true,
|
|
rawConfig: {},
|
|
}, ['delete', 'registry'])
|
|
|
|
expect(fs.readdirSync(configDir)).not.toContain('rc')
|
|
})
|
|
|
|
test('config delete on npm-compatible key not set', async () => {
|
|
const tmp = tempDir()
|
|
const configDir = path.join(tmp, 'global-config')
|
|
fs.mkdirSync(configDir, { recursive: true })
|
|
fs.writeFileSync(path.join(configDir, 'rc'), '@my-company:registry=https://registry.my-company.example.com/')
|
|
|
|
await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir,
|
|
global: true,
|
|
rawConfig: {},
|
|
}, ['delete', 'cafile'])
|
|
|
|
expect(readIniFileSync(path.join(configDir, 'rc'))).toEqual({
|
|
'@my-company:registry': 'https://registry.my-company.example.com/',
|
|
})
|
|
})
|
|
|
|
test('config delete on npm-compatible key set', async () => {
|
|
const tmp = tempDir()
|
|
const configDir = path.join(tmp, 'global-config')
|
|
fs.mkdirSync(configDir, { recursive: true })
|
|
fs.writeFileSync(path.join(configDir, 'rc'), 'cafile=some-cafile')
|
|
|
|
await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir,
|
|
global: true,
|
|
rawConfig: {},
|
|
}, ['delete', 'cafile'])
|
|
|
|
// NOTE: pnpm currently does not delete empty rc files.
|
|
// TODO: maybe we should?
|
|
expect(readIniFileSync(path.join(configDir, 'rc'))).toEqual({})
|
|
})
|
|
|
|
test('config delete on pnpm-specific key not set', async () => {
|
|
const tmp = tempDir()
|
|
const configDir = path.join(tmp, 'global-config')
|
|
fs.mkdirSync(configDir, { recursive: true })
|
|
writeYamlFile(path.join(configDir, 'config.yaml'), {
|
|
cacheDir: '~/cache',
|
|
})
|
|
|
|
await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir,
|
|
global: true,
|
|
rawConfig: {},
|
|
}, ['delete', 'store-dir'])
|
|
|
|
expect(readYamlFile(path.join(configDir, 'config.yaml'))).toStrictEqual({
|
|
cacheDir: '~/cache',
|
|
})
|
|
})
|
|
|
|
test('config delete on pnpm-specific key set', async () => {
|
|
const tmp = tempDir()
|
|
const configDir = path.join(tmp, 'global-config')
|
|
fs.mkdirSync(configDir, { recursive: true })
|
|
writeYamlFile(path.join(configDir, 'config.yaml'), {
|
|
cacheDir: '~/cache',
|
|
})
|
|
|
|
await config.handler({
|
|
dir: process.cwd(),
|
|
cliOptions: {},
|
|
configDir,
|
|
global: true,
|
|
rawConfig: {},
|
|
}, ['delete', 'cache-dir'])
|
|
|
|
expect(fs.readdirSync(configDir)).not.toContain('config.yaml')
|
|
})
|