diff --git a/package.json b/package.json index b2c00d1a..0c101b0a 100644 --- a/package.json +++ b/package.json @@ -14,8 +14,8 @@ "devDependencies": { "@dxcli/dev-nyc-config": "^0.0.3", "@dxcli/dev-semantic-release": "^0.1.0", - "@dxcli/dev-tslint": "^0.0.15", - "@dxcli/engine": "^0.1.5", + "@dxcli/dev-tslint": "^0.0.16", + "@dxcli/engine": "^0.1.9", "@heroku-cli/config-edit": "^1.0.4", "@types/ansi-styles": "^2.0.30", "@types/chai": "^4.1.2", @@ -29,10 +29,10 @@ "chai": "^4.1.2", "eslint": "^4.16.0", "eslint-config-dxcli": "^1.1.4", - "fancy-mocha": "^0.3.2", + "fancy-test": "^0.3.7", "husky": "^0.14.3", "mocha": "^5.0.0", - "mocha-junit-reporter": "^1.16.0", + "mocha-junit-reporter": "^1.17.0", "nps": "^5.7.1", "nps-utils": "^1.5.0", "nyc": "^11.4.1", diff --git a/src/config.ts b/src/config.ts index 2610c410..7a3f3435 100644 --- a/src/config.ts +++ b/src/config.ts @@ -22,6 +22,7 @@ export interface IConfig { bin: string cacheDir: string commandsDir: string | undefined + pluginsModule: string | undefined configDir: string dataDir: string dirname: string @@ -83,6 +84,7 @@ export class Config { windows: boolean userAgent: string commandsDir: string | undefined + pluginsModule: string | undefined tsconfig: TSConfig | undefined debug: number = 0 hooks: {[k: string]: string[]} @@ -118,6 +120,9 @@ export class Config { this.tsconfig = await this._tsConfig() this.commandsDir = await this._libToSrcPath(this.pjson.dxcli.commands) this.hooks = await this._hooks() + if (typeof this.pjson.dxcli.plugins === 'string') { + this.pluginsModule = await this._libToSrcPath(this.pjson.dxcli.plugins) + } this.npmRegistry = this.scopedEnvVar('NPM_REGISTRY') || this.pjson.dxcli.npmRegistry || 'https://registry.yarnpkg.com' return this diff --git a/src/plugin.ts b/src/plugin.ts index d658b689..b1336d08 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -13,6 +13,7 @@ export interface IPlugin { version: string type: string root: string + tag: string config: IConfig module?: IPluginModule commands: ICachedCommand[] diff --git a/test/config.test.ts b/test/config.test.ts index 19be310e..417db00a 100644 --- a/test/config.test.ts +++ b/test/config.test.ts @@ -1,4 +1,4 @@ -import {expect, fancy} from 'fancy-mocha' +import {expect, fancy} from 'fancy-test' import * as os from 'os' import * as path from 'path' @@ -12,13 +12,13 @@ const testPlugin = (plugin: string) => async () => { } describe('PluginConfig', () => { - fancy() + fancy .env({}, {clear: true}) - .mock(os, 'homedir', () => path.join('/my/home')) - .mock(os, 'platform', () => 'darwin') - .add(testPlugin('heroku-cli-status')) + .stub(os, 'homedir', () => path.join('/my/home')) + .stub(os, 'platform', () => 'darwin') + .add('config', testPlugin('heroku-cli-status')) .end('darwin', ({config}) => { - expect(config).to.include({ + expect(config.config).to.include({ cacheDir: path.join('/my/home/Library/Caches/heroku-cli-status'), configDir: path.join('/my/home/.config/heroku-cli-status'), errlog: path.join('/my/home/Library/Caches/heroku-cli-status/error.log'), @@ -28,13 +28,13 @@ describe('PluginConfig', () => { }) }) - fancy() + fancy .env({}, {clear: true}) - .mock(os, 'homedir', () => path.join('/my/home')) - .mock(os, 'platform', () => 'linux') - .add(testPlugin('heroku-cli-status')) + .stub(os, 'homedir', () => path.join('/my/home')) + .stub(os, 'platform', () => 'linux') + .add('config', testPlugin('heroku-cli-status')) .end('linux', ({config}) => { - expect(config).to.include({ + expect(config.config).to.include({ cacheDir: path.join('/my/home/.cache/heroku-cli-status'), configDir: path.join('/my/home/.config/heroku-cli-status'), errlog: path.join('/my/home/.cache/heroku-cli-status/error.log'), @@ -44,13 +44,13 @@ describe('PluginConfig', () => { }) }) - fancy() + fancy .env({LOCALAPPDATA: '/my/home/localappdata'}, {clear: true}) - .mock(os, 'homedir', () => path.join('/my/home')) - .mock(os, 'platform', () => 'win32') - .add(testPlugin('heroku-cli-status')) + .stub(os, 'homedir', () => path.join('/my/home')) + .stub(os, 'platform', () => 'win32') + .add('config', testPlugin('heroku-cli-status')) .end('win32', ({config}) => { - expect(config).to.include({ + expect(config.config).to.include({ cacheDir: path.join('/my/home/localappdata/heroku-cli-status'), configDir: path.join('/my/home/localappdata/heroku-cli-status'), errlog: path.join('/my/home/localappdata/heroku-cli-status/error.log'), @@ -60,18 +60,18 @@ describe('PluginConfig', () => { }) }) - fancy() - .add(testPlugin('heroku-run')) + fancy + .add('config', testPlugin('heroku-run')) .end('heroku-run has properties', ({config}) => { - expect(config).to.include({ + expect(config.config).to.include({ commandsDir: undefined }) }) - fancy() - .add(testPlugin('@heroku-cli/config-edit')) - .end('@heroku-cli/config-edit has properties', ({config}) => { - expect(config).to.include({ + fancy + .add('plugin', testPlugin('@heroku-cli/config-edit')) + .end('@heroku-cli/config-edit has properties', ({plugin}) => { + expect(plugin.config).to.include({ name: '@heroku-cli/config-edit', commandsDir: path.join(__dirname, '../node_modules/@heroku-cli/config-edit/lib/commands'), }) diff --git a/yarn.lock b/yarn.lock index 4a870b59..7fc0fd59 100644 --- a/yarn.lock +++ b/yarn.lock @@ -118,19 +118,19 @@ dependencies: find-up "^2.1.0" -"@dxcli/command@^0.1.13": - version "0.1.13" - resolved "https://registry.yarnpkg.com/@dxcli/command/-/command-0.1.13.tgz#b4dec2e629076c2b50f4cf43c9324dd6ccb98382" +"@dxcli/command@^0.1.16": + version "0.1.17" + resolved "https://registry.yarnpkg.com/@dxcli/command/-/command-0.1.17.tgz#5437fe8ca459a2c7598fe207c3e287a473355a4f" dependencies: - "@dxcli/config" "^0.1.20" - "@dxcli/parser" "^0.0.3" - "@dxcli/screen" "^0.0.1" - cli-ux "^3.1.3" + "@dxcli/config" "^0.1.24" + "@dxcli/parser" "^0.0.5" + cli-ux "^3.1.5" debug "^3.1.0" + tslib "^1.9.0" -"@dxcli/config@^0.1.20": - version "0.1.22" - resolved "https://registry.yarnpkg.com/@dxcli/config/-/config-0.1.22.tgz#a486f2f9afc3cf05a9ea50d82b96bea505cb6a67" +"@dxcli/config@^0.1.24": + version "0.1.24" + resolved "https://registry.yarnpkg.com/@dxcli/config/-/config-0.1.24.tgz#fc6d14f7c91b742bf3d0ca7c2974565a959471ae" dependencies: debug "^3.1.0" fs-extra "^5.0.0" @@ -162,37 +162,37 @@ "@semantic-release/npm" "^2.6.4" semantic-release "^12.2.2" -"@dxcli/dev-tslint@^0.0.15": - version "0.0.15" - resolved "https://registry.yarnpkg.com/@dxcli/dev-tslint/-/dev-tslint-0.0.15.tgz#54dbd49deccaaaf9dc590d83894415e3fab0b0ac" +"@dxcli/dev-tslint@^0.0.16": + version "0.0.16" + resolved "https://registry.yarnpkg.com/@dxcli/dev-tslint/-/dev-tslint-0.0.16.tgz#84aa077d5f0c92f770b2b7eb091588c8553b4c9f" dependencies: tslint "^5.9.1" tslint-xo "^0.5.0" -"@dxcli/engine@^0.1.5": - version "0.1.5" - resolved "https://registry.yarnpkg.com/@dxcli/engine/-/engine-0.1.5.tgz#7d576b0d15cd65a4f57035af2bead7c0c069f0c2" +"@dxcli/engine@^0.1.9": + version "0.1.9" + resolved "https://registry.yarnpkg.com/@dxcli/engine/-/engine-0.1.9.tgz#6179b1ac925d0f04cd143a9696cccdc52e38ed01" dependencies: - "@dxcli/command" "^0.1.13" - "@dxcli/config" "^0.1.20" - "@dxcli/loader" "^0.1.4" - cli-ux "^3.1.3" + "@dxcli/command" "^0.1.16" + "@dxcli/config" "^0.1.24" + "@dxcli/loader" "^0.2.0" + cli-ux "^3.1.5" debug "^3.1.0" -"@dxcli/loader@^0.1.4": - version "0.1.4" - resolved "https://registry.yarnpkg.com/@dxcli/loader/-/loader-0.1.4.tgz#ac8e3e02574f191158beb9c7f1661229ebe52910" +"@dxcli/loader@^0.2.0": + version "0.2.2" + resolved "https://registry.yarnpkg.com/@dxcli/loader/-/loader-0.2.2.tgz#e124e97ca73252f11ebf673a2b6a75bd63d842bd" dependencies: - "@dxcli/config" "^0.1.20" - "@dxcli/manifest-file" "^0.0.3" - cli-ux "^3.1.3" + "@dxcli/config" "^0.1.24" + "@dxcli/manifest-file" "^0.0.4" + cli-ux "^3.1.5" debug "^3.1.0" globby "^7.1.1" lodash "^4.17.4" -"@dxcli/manifest-file@^0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@dxcli/manifest-file/-/manifest-file-0.0.3.tgz#0bb44827b354e844f3276d4e38571104c2b8ecb2" +"@dxcli/manifest-file@^0.0.4": + version "0.0.4" + resolved "https://registry.yarnpkg.com/@dxcli/manifest-file/-/manifest-file-0.0.4.tgz#cc5f250f9baf59083ad9cc4693af61f08cc0daf2" dependencies: debug "^3.1.0" fs-extra "^5.0.0" @@ -200,18 +200,14 @@ lodash "^4.17.4" rwlockfile "^2.0.21" -"@dxcli/parser@^0.0.3": - version "0.0.3" - resolved "https://registry.yarnpkg.com/@dxcli/parser/-/parser-0.0.3.tgz#be08ac4b3809685b3351978ae702b1e14cae47fd" +"@dxcli/parser@^0.0.5": + version "0.0.5" + resolved "https://registry.yarnpkg.com/@dxcli/parser/-/parser-0.0.5.tgz#51daf8133e8cec6ff21bfa464c4d58cd46b5ed99" dependencies: - "@dxcli/screen" "^0.0.0" + "@dxcli/screen" "^0.0.1" chalk "^2.3.0" lodash "^4.17.4" -"@dxcli/screen@^0.0.0": - version "0.0.0" - resolved "https://registry.yarnpkg.com/@dxcli/screen/-/screen-0.0.0.tgz#a85f69bfb00d3961656bad5d7b12f8e603c7ce09" - "@dxcli/screen@^0.0.1": version "0.0.1" resolved "https://registry.yarnpkg.com/@dxcli/screen/-/screen-0.0.1.tgz#9af4e8d0e5a9475e9e4b5f2da775b0447ff72fc2" @@ -1016,9 +1012,9 @@ cli-ux@^2.0.21: supports-color "^5.1.0" ts-lodash "^4.0.8" -cli-ux@^3.1.3: - version "3.1.5" - resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-3.1.5.tgz#c6d3ed628a54067ad2084dd465ea015ca26488c9" +cli-ux@^3.1.5: + version "3.1.6" + resolved "https://registry.yarnpkg.com/cli-ux/-/cli-ux-3.1.6.tgz#e1190fcc429ae6a101dbaf24640027485b9b3506" dependencies: "@dxcli/screen" "^0.0.1" "@heroku/linewrap" "^1.0.0" @@ -1843,9 +1839,9 @@ extsprintf@^1.2.0: version "1.4.0" resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" -fancy-mocha@^0.3.2: - version "0.3.2" - resolved "https://registry.yarnpkg.com/fancy-mocha/-/fancy-mocha-0.3.2.tgz#4bcc8dc4f323224ce0733bd1a093d8c485852406" +fancy-test@^0.3.7: + version "0.3.7" + resolved "https://registry.yarnpkg.com/fancy-test/-/fancy-test-0.3.7.tgz#e124ac886328329dfc4cdba893456b9e5cecfbab" dependencies: lodash "^4.17.4" stdout-stderr "^0.1.4" @@ -3220,13 +3216,14 @@ mkdirp@0.5.1, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.1: dependencies: minimist "0.0.8" -mocha-junit-reporter@^1.16.0: - version "1.16.0" - resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.16.0.tgz#3d76af53e2f5e81f9b93406acee1e48b5dd6e6cc" +mocha-junit-reporter@^1.17.0: + version "1.17.0" + resolved "https://registry.yarnpkg.com/mocha-junit-reporter/-/mocha-junit-reporter-1.17.0.tgz#2e5149ed40fc5d2e3ca71e42db5ab1fec9c6d85c" dependencies: debug "^2.2.0" md5 "^2.1.0" mkdirp "~0.5.1" + strip-ansi "^4.0.0" xml "^1.0.0" mocha@^5.0.0: @@ -4704,7 +4701,7 @@ tsconfig@^7.0.0: strip-bom "^3.0.0" strip-json-comments "^2.0.0" -tslib@^1.0.0, tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1: +tslib@^1.0.0, tslib@^1.7.1, tslib@^1.8.0, tslib@^1.8.1, tslib@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.0.tgz#e37a86fda8cbbaf23a057f473c9f4dc64e5fc2e8"