-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97f24f8
commit 3cab70a
Showing
17 changed files
with
148 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { cliOptionsMap } from '../cli-options' | ||
import { Index } from '../types/IndexType' | ||
import { PackageFile } from '../types/PackageFile' | ||
|
||
// dependency section aliases that will be resolved to the full name | ||
const depAliases: Index<keyof PackageFile> = { | ||
dev: 'devDependencies', | ||
peer: 'peerDependencies', | ||
prod: 'dependencies', | ||
optional: 'optionalDependencies', | ||
} | ||
|
||
/** Gets a list of dependency sections based on options.dep. */ | ||
const resolveDepSections = (dep?: string | string[]): (keyof PackageFile)[] => { | ||
// parse dep string and set default | ||
const depOptions: string[] = dep ? (typeof dep === 'string' ? dep.split(',') : dep) : cliOptionsMap.dep.default | ||
|
||
// map the dependency section option to a full dependency section name | ||
const depSections = depOptions.map(name => depAliases[name] || name) | ||
|
||
return depSections | ||
} | ||
|
||
export default resolveDepSections |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/** A valid package manager. */ | ||
export type PackageManagerName = 'npm' | 'yarn' | 'pnpm' | 'staticRegistry' | ||
export type PackageManagerName = 'npm' | 'yarn' | 'pnpm' | 'deno' | 'staticRegistry' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import chai from 'chai' | ||
import chaiAsPromised from 'chai-as-promised' | ||
import chaiString from 'chai-string' | ||
import fs from 'fs/promises' | ||
import jph from 'json-parse-helpfulerror' | ||
import os from 'os' | ||
import path from 'path' | ||
import spawn from 'spawn-please' | ||
|
||
chai.should() | ||
chai.use(chaiAsPromised) | ||
chai.use(chaiString) | ||
|
||
process.env.NCU_TESTS = 'true' | ||
|
||
const bin = path.join(__dirname, '../../../build/src/bin/cli.js') | ||
|
||
describe('deno', async function () { | ||
it('handle import map', async () => { | ||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-')) | ||
const pkgFile = path.join(tempDir, 'deno.json') | ||
const pkg = { | ||
imports: { | ||
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
} | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg), 'utf-8') | ||
try { | ||
const pkgData = await spawn( | ||
'node', | ||
[bin, '--jsonUpgraded', '--verbose', '--packageManager', 'deno', '--packageFile', pkgFile], | ||
undefined, | ||
) | ||
const pkg = jph.parse(pkgData) | ||
pkg.should.have.property('ncu-test-v2') | ||
} finally { | ||
await fs.rm(tempDir, { recursive: true, force: true }) | ||
} | ||
}) | ||
|
||
it('auto detect deno.json', async () => { | ||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-')) | ||
const pkgFile = path.join(tempDir, 'deno.json') | ||
const pkg = { | ||
imports: { | ||
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
} | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg), 'utf-8') | ||
try { | ||
const pkgData = await spawn('node', [bin, '--jsonUpgraded', '--verbose'], undefined, { | ||
cwd: tempDir, | ||
}) | ||
const pkg = jph.parse(pkgData) | ||
pkg.should.have.property('ncu-test-v2') | ||
} finally { | ||
await fs.rm(tempDir, { recursive: true, force: true }) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters