From 01f51e6a5a7ef5e4107a7f73916b6d7c7ffcd3ea Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdxcode@users.noreply.github.com> Date: Thu, 13 Sep 2018 09:05:38 -0700 Subject: [PATCH] fix: updated deps --- package.json | 6 +-- src/config.ts | 32 +++++------ src/plugin.ts | 10 ++-- src/util.ts | 8 +-- test/config.test.ts | 114 ++++++++++++++++++++-------------------- test/typescript.test.ts | 28 +++++----- yarn.lock | 43 ++++++++++----- 7 files changed, 129 insertions(+), 112 deletions(-) diff --git a/package.json b/package.json index 2c2b208d..501b6351 100644 --- a/package.json +++ b/package.json @@ -5,13 +5,13 @@ "author": "Jeff Dickey @jdxcode", "bugs": "https://github.com/oclif/config/issues", "dependencies": { - "debug": "^3.1.0", + "debug": "^4.0.1", "tslib": "^1.9.3" }, "devDependencies": { "@oclif/errors": "^1.2.0", "@oclif/parser": "^3.6.1", - "@oclif/tslint": "^2.0.0", + "@oclif/tslint": "^3.1.0", "@types/chai": "^4.1.4", "@types/globby": "^8.0.0", "@types/indent-string": "^3.0.0", @@ -22,7 +22,7 @@ "chai": "^4.1.2", "fancy-test": "^1.4.0", "globby": "^8.0.1", - "lodash": "^4.17.10", + "lodash": "^4.17.11", "mocha": "^5.2.0", "ts-node": "^7.0.1", "tslint": "^5.11.0", diff --git a/src/config.ts b/src/config.ts index 02c810ce..2e27a2a4 100644 --- a/src/config.ts +++ b/src/config.ts @@ -276,23 +276,23 @@ export class Config implements IConfig { warn(message: string) { warn(message) }, } return Promise.all((p.hooks[event] || []) - .map(async hook => { - try { - const f = tsPath(p.root, hook) - debug('start', f) - const search = (m: any): Hook => { - if (typeof m === 'function') return m - if (m.default && typeof m.default === 'function') return m.default - return Object.values(m).find((m: any) => typeof m === 'function') as Hook + .map(async hook => { + try { + const f = tsPath(p.root, hook) + debug('start', f) + const search = (m: any): Hook => { + if (typeof m === 'function') return m + if (m.default && typeof m.default === 'function') return m.default + return Object.values(m).find((m: any) => typeof m === 'function') as Hook + } + + await search(require(f)).call(context, {...opts as any, config: this}) + debug('done') + } catch (err) { + if (err && err.oclif && err.oclif.exit !== undefined) throw err + this.warn(err, `runHook ${event}`) } - - await search(require(f)).call(context, {...opts as any, config: this}) - debug('done') - } catch (err) { - if (err && err.oclif && err.oclif.exit !== undefined) throw err - this.warn(err, `runHook ${event}`) - } - })) + })) }) await Promise.all(promises) debug('%s hook done', event) diff --git a/src/plugin.ts b/src/plugin.ts index f1796e0e..30c3f949 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -218,11 +218,11 @@ export class Plugin implements IPlugin { else throw this.addErrorScope(err, scope) } }) - .filter((f): f is [string, Command] => !!f) - .reduce((commands, [id, c]) => { - commands[id] = c - return commands - }, {} as {[k: string]: Command}) + .filter((f): f is [string, Command] => !!f) + .reduce((commands, [id, c]) => { + commands[id] = c + return commands + }, {} as {[k: string]: Command}) } } diff --git a/src/util.ts b/src/util.ts index 50ee3bc1..f3e1cf4c 100644 --- a/src/util.ts +++ b/src/util.ts @@ -9,10 +9,10 @@ export function flatMap(arr: T[], fn: (i: T) => U[]): U[] { export function mapValues(obj: {[P in keyof T]: T[P]}, fn: (i: T[keyof T], k: keyof T) => TResult): {[P in keyof T]: TResult} { return Object.entries(obj) - .reduce((o, [k, v]) => { - o[k] = fn(v as any, k as any) - return o - }, {} as any) + .reduce((o, [k, v]) => { + o[k] = fn(v as any, k as any) + return o + }, {} as any) } export function loadJSONSync(path: string): any { diff --git a/test/config.test.ts b/test/config.test.ts index 7fc9a7ca..4d9e233d 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -9,8 +9,8 @@ import {expect, fancy} from './test' interface Options { pjson?: any, homedir?: string, - platform?: string, - env?: {[k: string]: string}, + platform?: string, + env?: {[k: string]: string}, } describe('Config', () => { @@ -28,26 +28,26 @@ describe('Config', () => { return { hasS3Key(k: keyof PJSON.S3.Templates, expected: string, extra: any = {}) { return this - .it(`renders ${k} template as ${expected}`, config => { - let {ext, ...options} = extra - options = { - bin: 'oclif-cli', - version: '1.0.0', - ext: '.tar.gz', - ...options, - } - const o = ext ? config.s3Key(k as any, ext, options) : config.s3Key(k, options) - expect(o).to.equal(expected) - }) + .it(`renders ${k} template as ${expected}`, config => { + let {ext, ...options} = extra + options = { + bin: 'oclif-cli', + version: '1.0.0', + ext: '.tar.gz', + ...options, + } + const o = ext ? config.s3Key(k as any, ext, options) : config.s3Key(k, options) + expect(o).to.equal(expected) + }) }, hasProperty(k: K | undefined, v: IConfig[K] | undefined) { return this - .it(`has ${k}=${v}`, config => expect(config).to.have.property(k!, v)) + .it(`has ${k}=${v}`, config => expect(config).to.have.property(k!, v)) }, it(expectation: string, fn: (config: IConfig) => any) { test - .do(({config}) => fn(config)) - .it(expectation) + .do(({config}) => fn(config)) + .it(expectation) return this } } @@ -55,20 +55,20 @@ describe('Config', () => { describe('darwin', () => { testConfig() - .hasProperty('cacheDir', path.join('/my/home/Library/Caches/@oclif/config')) - .hasProperty('configDir', path.join('/my/home/.config/@oclif/config')) - .hasProperty('errlog', path.join('/my/home/Library/Caches/@oclif/config/error.log')) - .hasProperty('dataDir', path.join('/my/home/.local/share/@oclif/config')) - .hasProperty('home', path.join('/my/home')) + .hasProperty('cacheDir', path.join('/my/home/Library/Caches/@oclif/config')) + .hasProperty('configDir', path.join('/my/home/.config/@oclif/config')) + .hasProperty('errlog', path.join('/my/home/Library/Caches/@oclif/config/error.log')) + .hasProperty('dataDir', path.join('/my/home/.local/share/@oclif/config')) + .hasProperty('home', path.join('/my/home')) }) describe('linux', () => { testConfig({platform: 'linux'}) - .hasProperty('cacheDir', path.join('/my/home/.cache/@oclif/config')) - .hasProperty('configDir', path.join('/my/home/.config/@oclif/config')) - .hasProperty('errlog', path.join('/my/home/.cache/@oclif/config/error.log')) - .hasProperty('dataDir', path.join('/my/home/.local/share/@oclif/config')) - .hasProperty('home', path.join('/my/home')) + .hasProperty('cacheDir', path.join('/my/home/.cache/@oclif/config')) + .hasProperty('configDir', path.join('/my/home/.config/@oclif/config')) + .hasProperty('errlog', path.join('/my/home/.cache/@oclif/config/error.log')) + .hasProperty('dataDir', path.join('/my/home/.local/share/@oclif/config')) + .hasProperty('home', path.join('/my/home')) }) describe('win32', () => { @@ -76,43 +76,43 @@ describe('Config', () => { platform: 'win32', env: {LOCALAPPDATA: '/my/home/localappdata'}, }) - .hasProperty('cacheDir', path.join('/my/home/localappdata/@oclif\\config')) - .hasProperty('configDir', path.join('/my/home/localappdata/@oclif\\config')) - .hasProperty('errlog', path.join('/my/home/localappdata/@oclif\\config/error.log')) - .hasProperty('dataDir', path.join('/my/home/localappdata/@oclif\\config')) - .hasProperty('home', path.join('/my/home')) + .hasProperty('cacheDir', path.join('/my/home/localappdata/@oclif\\config')) + .hasProperty('configDir', path.join('/my/home/localappdata/@oclif\\config')) + .hasProperty('errlog', path.join('/my/home/localappdata/@oclif\\config/error.log')) + .hasProperty('dataDir', path.join('/my/home/localappdata/@oclif\\config')) + .hasProperty('home', path.join('/my/home')) }) describe('s3Key', () => { const target = {platform: 'darwin', arch: 'x64'} const beta = {version: '2.0.0-beta', channel: 'beta'} testConfig() - .hasS3Key('baseDir', 'oclif-cli') - .hasS3Key('manifest', 'version') - .hasS3Key('manifest', 'channels/beta/version', beta) - .hasS3Key('manifest', 'darwin-x64', target) - .hasS3Key('manifest', 'channels/beta/darwin-x64', {...beta, ...target}) - .hasS3Key('unversioned', 'oclif-cli.tar.gz') - .hasS3Key('unversioned', 'oclif-cli.tar.gz') - .hasS3Key('unversioned', 'channels/beta/oclif-cli.tar.gz', beta) - .hasS3Key('unversioned', 'channels/beta/oclif-cli.tar.gz', beta) - .hasS3Key('unversioned', 'oclif-cli-darwin-x64.tar.gz', target) - .hasS3Key('unversioned', 'oclif-cli-darwin-x64.tar.gz', target) - .hasS3Key('unversioned', 'channels/beta/oclif-cli-darwin-x64.tar.gz', {...beta, ...target}) - .hasS3Key('unversioned', 'channels/beta/oclif-cli-darwin-x64.tar.gz', {...beta, ...target}) - .hasS3Key('versioned', 'oclif-cli-v1.0.0/oclif-cli-v1.0.0.tar.gz') - .hasS3Key('versioned', 'oclif-cli-v1.0.0/oclif-cli-v1.0.0-darwin-x64.tar.gz', target) - .hasS3Key('versioned', 'channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta.tar.gz', beta) - .hasS3Key('versioned', 'channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta-darwin-x64.tar.gz', {...beta, ...target}) + .hasS3Key('baseDir', 'oclif-cli') + .hasS3Key('manifest', 'version') + .hasS3Key('manifest', 'channels/beta/version', beta) + .hasS3Key('manifest', 'darwin-x64', target) + .hasS3Key('manifest', 'channels/beta/darwin-x64', {...beta, ...target}) + .hasS3Key('unversioned', 'oclif-cli.tar.gz') + .hasS3Key('unversioned', 'oclif-cli.tar.gz') + .hasS3Key('unversioned', 'channels/beta/oclif-cli.tar.gz', beta) + .hasS3Key('unversioned', 'channels/beta/oclif-cli.tar.gz', beta) + .hasS3Key('unversioned', 'oclif-cli-darwin-x64.tar.gz', target) + .hasS3Key('unversioned', 'oclif-cli-darwin-x64.tar.gz', target) + .hasS3Key('unversioned', 'channels/beta/oclif-cli-darwin-x64.tar.gz', {...beta, ...target}) + .hasS3Key('unversioned', 'channels/beta/oclif-cli-darwin-x64.tar.gz', {...beta, ...target}) + .hasS3Key('versioned', 'oclif-cli-v1.0.0/oclif-cli-v1.0.0.tar.gz') + .hasS3Key('versioned', 'oclif-cli-v1.0.0/oclif-cli-v1.0.0-darwin-x64.tar.gz', target) + .hasS3Key('versioned', 'channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta.tar.gz', beta) + .hasS3Key('versioned', 'channels/beta/oclif-cli-v2.0.0-beta/oclif-cli-v2.0.0-beta-darwin-x64.tar.gz', {...beta, ...target}) }) testConfig() - .it('has s3Url', config => { - const orig = config.pjson.oclif.update.s3.host - config.pjson.oclif.update.s3.host = 'https://bar.com/a/' - expect(config.s3Url('/b/c')).to.equal('https://bar.com/a/b/c') - config.pjson.oclif.update.s3.host = orig - }) + .it('has s3Url', config => { + const orig = config.pjson.oclif.update.s3.host + config.pjson.oclif.update.s3.host = 'https://bar.com/a/' + expect(config.s3Url('/b/c')).to.equal('https://bar.com/a/b/c') + config.pjson.oclif.update.s3.host = orig + }) testConfig({ pjson: { @@ -139,7 +139,7 @@ describe('Config', () => { } } }) - .it('has subtopics', config => { - expect(config.topics.map(t => t.name)).to.have.members(['t1', 't1:t1-1', 't1:t1-1:t1-1-1', 't1:t1-1:t1-1-2']) - }) + .it('has subtopics', config => { + expect(config.topics.map(t => t.name)).to.have.members(['t1', 't1:t1-1', 't1:t1-1:t1-1-1', 't1:t1-1:t1-1-2']) + }) }) diff --git a/test/typescript.test.ts b/test/typescript.test.ts index 0c83048c..743e35d5 100644 --- a/test/typescript.test.ts +++ b/test/typescript.test.ts @@ -12,23 +12,23 @@ const withConfig = fancy describe('typescript', () => { withConfig - .it('has commandsDir', ({config}) => { - expect(config.plugins[0]).to.deep.include({ - commandsDir: p('src/commands'), + .it('has commandsDir', ({config}) => { + expect(config.plugins[0]).to.deep.include({ + commandsDir: p('src/commands'), + }) }) - }) withConfig - .stdout() - .it('runs ts command and prerun hooks', async ctx => { - await ctx.config.runCommand('foo:bar:baz') - expect(ctx.stdout).to.equal('running ts prerun hook\nit works!\n') - }) + .stdout() + .it('runs ts command and prerun hooks', async ctx => { + await ctx.config.runCommand('foo:bar:baz') + expect(ctx.stdout).to.equal('running ts prerun hook\nit works!\n') + }) withConfig - .stdout() - .it('runs init hook', async ctx => { - await ctx.config.runHook('init', {id: 'myid', argv: ['foo']}) - expect(ctx.stdout).to.equal('running ts init hook\n') - }) + .stdout() + .it('runs init hook', async ctx => { + await ctx.config.runHook('init', {id: 'myid', argv: ['foo']}) + expect(ctx.stdout).to.equal('running ts init hook\n') + }) }) diff --git a/yarn.lock b/yarn.lock index cd2b7c26..fcf69049 100644 --- a/yarn.lock +++ b/yarn.lock @@ -27,8 +27,8 @@ glob-to-regexp "^0.3.0" "@nodelib/fs.stat@^1.0.1": - version "1.1.1" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.1.tgz#53f349bb986ab273d601175aa1b25a655ab90ee3" + version "1.1.2" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26" "@oclif/errors@^1.2.0": version "1.2.0" @@ -52,10 +52,11 @@ chalk "^2.4.1" tslib "^1.9.3" -"@oclif/tslint@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@oclif/tslint/-/tslint-2.0.0.tgz#6eb3a43cc288e0e8d84bc0808c3fbcba00d00ea6" +"@oclif/tslint@^3.1.0": + version "3.1.0" + resolved "https://registry.yarnpkg.com/@oclif/tslint/-/tslint-3.1.0.tgz#4beea4ddeeb9e8964f4c9d15d25349db799311a6" dependencies: + tslint-eslint-rules "^5.4.0" tslint-xo "^0.9.0" "@types/chai@^4.1.4": @@ -322,11 +323,11 @@ color-name@1.1.3: commander@2.15.1: version "2.15.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" + resolved "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" commander@^2.12.1: - version "2.17.1" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" + version "2.18.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.18.0.tgz#2bf063ddee7c7891176981a2cc798e5754bc6970" component-emitter@^1.2.1: version "1.2.1" @@ -340,7 +341,7 @@ copy-descriptor@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" -debug@3.1.0, debug@^3.1.0: +debug@3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -352,6 +353,18 @@ debug@^2.2.0, debug@^2.3.3: dependencies: ms "2.0.0" +debug@^3.1.0: + version "3.2.5" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.5.tgz#c2418fbfd7a29f4d4f70ff4cea604d4b64c46407" + dependencies: + ms "^2.1.1" + +debug@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.0.1.tgz#f9bb36d439b8d1f0dd52d8fb6b46e4ebb8c1cd5b" + dependencies: + ms "^2.1.1" + decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" @@ -783,9 +796,9 @@ kind-of@^6.0.0, kind-of@^6.0.2: version "6.0.2" resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" -lodash@^4.17.10: - version "4.17.10" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" +lodash@^4.17.10, lodash@^4.17.11: + version "4.17.11" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" make-error@^1.1.1: version "1.3.5" @@ -874,6 +887,10 @@ ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" +ms@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" @@ -1181,7 +1198,7 @@ tslint-consistent-codestyle@^1.11.0: tslib "^1.7.1" tsutils "^2.27.0" -tslint-eslint-rules@^5.3.1: +tslint-eslint-rules@^5.3.1, tslint-eslint-rules@^5.4.0: version "5.4.0" resolved "https://registry.yarnpkg.com/tslint-eslint-rules/-/tslint-eslint-rules-5.4.0.tgz#e488cc9181bf193fe5cd7bfca213a7695f1737b5" dependencies: