Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
Niclas Thobaben | 4a37b44beb | |
Niclas Thobaben | 08e01a9149 | |
Niclas Thobaben | 432a9e8103 | |
Niclas Thobaben | 299c40e359 |
|
@ -5,14 +5,8 @@ describe('process-yarn', () => {
|
|||
describe('parseOutdatedLibraries()', () => {
|
||||
it('contains correct library for input', () => {
|
||||
const input = `
|
||||
yarn outdated v1.22.19
|
||||
info Color legend :
|
||||
"<red>" : Major Update backward-incompatible updates
|
||||
"<yellow>" : Minor Update backward-compatible features
|
||||
"<green>" : Patch Update backward-compatible bug fixes
|
||||
Package Current Wanted Latest Package Type URL
|
||||
@types/jest 23.3.14 23.3.14 29.2.3 devDependencies https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest
|
||||
Done in 12.56s.
|
||||
{"type":"info","data":"Color legend : \\n \\"<red>\\" : Major Update backward-incompatible updates \\n \\"<yellow>\\" : Minor Update backward-compatible features \\n \\"<green>\\" : Patch Update backward-compatible bug fixes"}
|
||||
{"type":"table","data":{"head":["Package","Current","Wanted","Latest","Package Type","URL"],"body":[["@types/jest","23.3.14","23.3.14","29.2.3","devDependencies","https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest"],["jest","28.1.3","28.1.3","29.3.1","devDependencies","https://jestjs.io/"],["jest-junit","14.0.1","14.0.1","15.0.0","devDependencies","https://github.com/jest-community/jest-junit#readme"],["tslint","5.20.1","5.20.1","6.1.3","devDependencies","https://palantir.github.io/tslint"]]}}
|
||||
`
|
||||
expect(parseOutdatedLibraries(input, 'package.json')).toEqual(
|
||||
expect.arrayContaining([
|
||||
|
@ -55,17 +49,8 @@ describe('process-yarn', () => {
|
|||
})
|
||||
it('returns correct number of results', () => {
|
||||
const input = `
|
||||
yarn outdated v1.22.19
|
||||
info Color legend :
|
||||
"<red>" : Major Update backward-incompatible updates
|
||||
"<yellow>" : Minor Update backward-compatible features
|
||||
"<green>" : Patch Update backward-compatible bug fixes
|
||||
Package Current Wanted Latest Package Type URL
|
||||
@types/jest 23.3.14 23.3.14 29.2.3 devDependencies https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest
|
||||
jest 28.1.3 28.1.3 29.3.1 devDependencies https://jestjs.io/
|
||||
jest-junit 14.0.1 14.0.1 15.0.0 devDependencies https://github.com/jest-community/jest-junit#readme
|
||||
tslint 5.20.1 5.20.1 6.1.3 devDependencies https://palantir.github.io/tslint
|
||||
Done in 12.56s.`
|
||||
{"type":"info","data":"Color legend : \\n \\"<red>\\" : Major Update backward-incompatible updates \\n \\"<yellow>\\" : Minor Update backward-compatible features \\n \\"<green>\\" : Patch Update backward-compatible bug fixes"}
|
||||
{"type":"table","data":{"head":["Package","Current","Wanted","Latest","Package Type","URL"],"body":[["@types/jest","23.3.14","23.3.14","29.2.3","devDependencies","https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest"],["jest","28.1.3","28.1.3","29.3.1","devDependencies","https://jestjs.io/"],["jest-junit","14.0.1","14.0.1","15.0.0","devDependencies","https://github.com/jest-community/jest-junit#readme"],["tslint","5.20.1","5.20.1","6.1.3","devDependencies","https://palantir.github.io/tslint"]]}}`
|
||||
expect(parseOutdatedLibraries(input, 'package.json')).toHaveLength(4)
|
||||
})
|
||||
})
|
||||
|
|
|
@ -19,11 +19,13 @@ export class NpmResolver implements Resolver<NpmResolverOptions> {
|
|||
}
|
||||
|
||||
private async resolveWithYarn(): Promise<ResolveResult[]> {
|
||||
console.log('Run npm resolver using yarn')
|
||||
try {
|
||||
child_process.execSync('yarn outdated', { })
|
||||
child_process.execSync('yarn outdated --json', { })
|
||||
}catch (e: any) {
|
||||
// Unfortunately the command throws an error, that we have to catch
|
||||
const stdout = String(e.stdout)
|
||||
console.debug(stdout)
|
||||
return parseOutdatedLibraries(stdout, 'package.json')
|
||||
}
|
||||
return []
|
||||
|
|
|
@ -1,35 +1,18 @@
|
|||
import { ResolveResult } from '../resolver'
|
||||
import { compareVersions, parseSemver } from '../helpers'
|
||||
|
||||
/**
|
||||
* yarn outdated v1.22.19
|
||||
* info Color legend :
|
||||
* "<red>" : Major Update backward-incompatible updates
|
||||
* "<yellow>" : Minor Update backward-compatible features
|
||||
* "<green>" : Patch Update backward-compatible bug fixes
|
||||
* Package Current Wanted Latest Package Type URL
|
||||
* @types/jest 23.3.14 23.3.14 29.2.3 devDependencies https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest
|
||||
* jest 28.1.3 28.1.3 29.3.1 devDependencies https://jestjs.io/
|
||||
* jest-junit 14.0.1 14.0.1 15.0.0 devDependencies https://github.com/jest-community/jest-junit#readme
|
||||
* tslint 5.20.1 5.20.1 6.1.3 devDependencies https://palantir.github.io/tslint
|
||||
* Done in 12.56s.
|
||||
*/
|
||||
|
||||
|
||||
export const parseOutdatedLibraries = (stdout: string, location: string): ResolveResult[] => {
|
||||
const startHeaders = stdout.indexOf('Package')
|
||||
const endDone = stdout.indexOf('Done in')
|
||||
const data = stdout.substring(startHeaders, endDone)
|
||||
|
||||
const linesRaw = data.split('\n')
|
||||
|
||||
const lines = data.split('\n')
|
||||
.slice(1, linesRaw.length-1) //Ignore headers and 'Done'
|
||||
const lines = stdout.split('\n')
|
||||
.map((line) => line.trim())
|
||||
.map((line) => line.split(/\s+/).map((item) => item.trim()))
|
||||
.filter((line) => !!line)
|
||||
.map((line) => JSON.parse(line))
|
||||
.filter((item) => item.type !== 'info')
|
||||
.map((item) => item.data.body as string[])[0]
|
||||
|
||||
const results = lines
|
||||
.map(([name, current, , latest, packageType, url]) => {
|
||||
console.debug('Parse yarn outdated output', name, current, latest, packageType, url)
|
||||
|
||||
const currentVersion = parseSemver(current)
|
||||
const recommendedVersion = parseSemver(latest)
|
||||
const changeType = compareVersions(currentVersion, recommendedVersion)
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
||||
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
||||
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
||||
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
||||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
||||
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
||||
// "removeComments": true, /* Disable emitting comments. */
|
||||
|
|
Loading…
Reference in New Issue