From cc0ad64395928dbd4c52665e958cfa1c07dc7b25 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Sat, 3 Feb 2018 17:36:57 +0000 Subject: [PATCH 1/8] chore(package): update semantic-release-vsce to version 2.0.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index fd611e4..0f36d69 100644 --- a/package.json +++ b/package.json @@ -89,7 +89,7 @@ "chai": "^4.1.2", "del-cli": "^1.1.0", "semantic-release": "^12.2.2", - "semantic-release-vsce": "^1.0.2", + "semantic-release-vsce": "^2.0.0", "sinon": "^4.2.0", "sinon-chai": "^2.14.0", "tslint": "^5.9.1", From d1a90c4da7ab3373d02d071d807c537f0e610f18 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Sat, 3 Feb 2018 17:42:19 +0000 Subject: [PATCH 2/8] chore(package): update lockfile https://npm.im/greenkeeper-lockfile --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index c9b4376..ef0f351 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3453,9 +3453,9 @@ samsam@1.x: version "1.3.0" resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" -semantic-release-vsce@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/semantic-release-vsce/-/semantic-release-vsce-1.0.2.tgz#333fe5121f004dddd1d3eccc79ff0d84cc231175" +semantic-release-vsce@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/semantic-release-vsce/-/semantic-release-vsce-2.0.0.tgz#7e5b6ce08430038b825a9f44b667357cd25c0a10" dependencies: "@semantic-release/error" "^2.1.0" commander "^2.11.0" From abc45f1f70b73ad59760346dfd4f2c2bba5a328c Mon Sep 17 00:00:00 2001 From: Shobhit Gupta Date: Mon, 5 Feb 2018 23:17:09 -0800 Subject: [PATCH 3/8] feat(import management): Merge imports from the same package (#392) Does automatically merge imports from the same package into one. --- .vscode/settings.json | 2 +- src/import-organizer/import-manager.ts | 13 ++++++++++++- test/etc/workspace_1/main.ts | 6 ++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 78218b7..78664b2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "editor.tabSize": 4 + "editor.tabSize": 2 } diff --git a/src/import-organizer/import-manager.ts b/src/import-organizer/import-manager.ts index c82a529..0de1ed5 100644 --- a/src/import-organizer/import-manager.ts +++ b/src/import-organizer/import-manager.ts @@ -153,9 +153,20 @@ export default class ImportManager { .filter(o => this._parsedDocument.nonLocalUsages.indexOf(o.alias || o.specifier) > -1) .sort(specifierSort); const defaultSpec = actImport.defaultAlias; + const libraryAlreadyImported = keep.find(d => d.libraryName === actImport.libraryName); if (actImport.specifiers.length || (!!defaultSpec && this._parsedDocument.nonLocalUsages.indexOf(defaultSpec) >= 0)) { - keep.push(actImport); + if (libraryAlreadyImported) { + if (actImport.defaultAlias) { + (libraryAlreadyImported).defaultAlias = actImport.defaultAlias; + } + (libraryAlreadyImported).specifiers = [ + ...(libraryAlreadyImported).specifiers, + ...actImport.specifiers, + ]; + } else { + keep.push(actImport); + } } } else if (actImport instanceof StringImport) { keep.push(actImport); diff --git a/test/etc/workspace_1/main.ts b/test/etc/workspace_1/main.ts index b836f09..b6800e5 100644 --- a/test/etc/workspace_1/main.ts +++ b/test/etc/workspace_1/main.ts @@ -1,9 +1,11 @@ -import iocSymbols from './ioc-symbols'; import { Foo } from './server/indices/foobar'; +import { Loggee } from './utilities/Logger'; import winstonLogger, { Logger } from './utilities/Logger'; +import iocSymbols from './ioc-symbols'; + function foo() { - console.log(winstonLogger, Logger, iocSymbols); + console.log(winstonLogger, Logger, Loggee, iocSymbols); } Foo From 9df79a8cb418d8afc560fff05c0dda5b65c3398e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Tue, 6 Feb 2018 08:28:12 +0100 Subject: [PATCH 4/8] docs: add gitter badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b1c650f..6c0ce7a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ When you are coding a lot of `TypeScript` you may want vscode to organize your i [![Semantic release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release) [![Greenkeeper](https://badges.greenkeeper.io/buehler/typescript-hero.svg)](https://greenkeeper.io/) [![License](https://img.shields.io/github/license/buehler/typescript-hero.svg)](https://github.com/buehler/typescript-hero/blob/master/LICENSE) +[![Gitter](https://img.shields.io/gitter/room/vscode-typescript-hero/Lobby.svg)](https://gitter.im/vscode-typescript-hero/Lobby) If you'd like to buy me a beer :-) From 1e6b60e522622af180d70a65687ce25ccccbb8d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Tue, 6 Feb 2018 08:51:16 +0100 Subject: [PATCH 5/8] fix(settings): use the correct name for imports.grouping --- src/configuration/imports-config.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/configuration/imports-config.ts b/src/configuration/imports-config.ts index 4a7a92f..dc371d3 100644 --- a/src/configuration/imports-config.ts +++ b/src/configuration/imports-config.ts @@ -1,10 +1,10 @@ import { Uri, workspace } from 'vscode'; import { - ImportGroup, - ImportGroupSetting, - ImportGroupSettingParser, - RemainImportGroup, + ImportGroup, + ImportGroupSetting, + ImportGroupSettingParser, + RemainImportGroup, } from '../import-organizer/import-grouping'; const sectionKey = 'typescriptHero.imports'; @@ -55,7 +55,7 @@ export default class ImportsConfig { } public grouping(resource: Uri): ImportGroup[] { - const groups = workspace.getConfiguration(sectionKey, resource).get('importGroups'); + const groups = workspace.getConfiguration(sectionKey, resource).get('grouping'); let importGroups: ImportGroup[] = []; try { From 16ca4915591070a1ee270a137f1c5ade15065d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Wed, 7 Feb 2018 17:12:19 +0100 Subject: [PATCH 6/8] test: add tests back to typescript hero (#399) --- .appveyor.yml | 18 +- .gitignore | 3 +- .travis.yml | 63 ++- .vscode/launch.json | 26 +- .vscodeignore | 3 + README.md | 1 + config/tsconfig.test-multi-workspace.json | 16 + ...on => tsconfig.test-single-workspace.json} | 6 +- package.json | 31 +- src/declarations/workspace-declarations.ts | 5 +- src/utilities/logger.ts | 4 +- test/_old/multi-root.code-workspace | 20 - .../DocumentSymbolStructureExtension.test.ts | 2 +- test/etc/multi-root.code-workspace | 16 + test/etc/workspace_1/.vscode/settings.json | 3 + test/etc/workspace_1/code-outline/code.js | 13 + test/etc/workspace_1/code-outline/code.ts | 14 + test/etc/workspace_1/code-outline/empty.ts | 0 .../code-outline/not-parseable.txt | 0 test/etc/workspace_1/server/indices/foobar.ts | 1 - test/etc/workspace_2/code-outline/code.ts | 14 + test/etc/workspace_2/main.ts | 11 + test/etc/workspace_3/main.ts | 11 + test/single-workspace/demo.spec.ts | 9 - test/single-workspace/index.ts | 40 -- .../code-outline.multi.test.ts.snap | 35 ++ .../__snapshots__/code-outline.test.ts.snap | 51 +++ ...claration-structure-tree-item.test.ts.snap | 50 +++ .../imports-structure-tree-item.test.ts.snap | 45 +++ .../resource-structure-tree-item.test.ts.snap | 18 + .../code-outline/code-outline.multi.test.ts | 57 +++ test/tests/code-outline/code-outline.test.ts | 87 ++++ .../declaration-structure-tree-item.test.ts | 127 ++++++ .../disabled-structure-tree-item.test.ts | 19 + .../imports-structure-tree-item.test.ts | 76 ++++ .../not-parseable-structure-tree-item.test.ts | 19 + .../resource-structure-tree-item.test.ts | 43 ++ test/tests/index.ts | 146 +++++++ test/tests/setup.ts | 28 ++ yarn.lock | 372 +++++++++++++----- 40 files changed, 1295 insertions(+), 208 deletions(-) create mode 100644 config/tsconfig.test-multi-workspace.json rename config/{tsconfig.test.json => tsconfig.test-single-workspace.json} (60%) delete mode 100644 test/_old/multi-root.code-workspace create mode 100644 test/etc/multi-root.code-workspace create mode 100644 test/etc/workspace_1/.vscode/settings.json create mode 100644 test/etc/workspace_1/code-outline/code.js create mode 100644 test/etc/workspace_1/code-outline/code.ts create mode 100644 test/etc/workspace_1/code-outline/empty.ts create mode 100644 test/etc/workspace_1/code-outline/not-parseable.txt delete mode 100644 test/etc/workspace_1/server/indices/foobar.ts create mode 100644 test/etc/workspace_2/code-outline/code.ts create mode 100644 test/etc/workspace_2/main.ts create mode 100644 test/etc/workspace_3/main.ts delete mode 100644 test/single-workspace/demo.spec.ts delete mode 100644 test/single-workspace/index.ts create mode 100644 test/tests/code-outline/__snapshots__/code-outline.multi.test.ts.snap create mode 100644 test/tests/code-outline/__snapshots__/code-outline.test.ts.snap create mode 100644 test/tests/code-outline/__snapshots__/declaration-structure-tree-item.test.ts.snap create mode 100644 test/tests/code-outline/__snapshots__/imports-structure-tree-item.test.ts.snap create mode 100644 test/tests/code-outline/__snapshots__/resource-structure-tree-item.test.ts.snap create mode 100644 test/tests/code-outline/code-outline.multi.test.ts create mode 100644 test/tests/code-outline/code-outline.test.ts create mode 100644 test/tests/code-outline/declaration-structure-tree-item.test.ts create mode 100644 test/tests/code-outline/disabled-structure-tree-item.test.ts create mode 100644 test/tests/code-outline/imports-structure-tree-item.test.ts create mode 100644 test/tests/code-outline/not-parseable-structure-tree-item.test.ts create mode 100644 test/tests/code-outline/resource-structure-tree-item.test.ts create mode 100644 test/tests/index.ts create mode 100644 test/tests/setup.ts diff --git a/.appveyor.yml b/.appveyor.yml index 66439f9..c8af398 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,11 +1,19 @@ -version: "{build} - {branch}" +version: "{branch} - {build}" skip_tags: true skip_branch_with_pr: true +matrix: + fast_finish: true + environment: nodejs_version: "9" - CODE_TESTS_WORKSPACE: "$(APPVEYOR_BUILD_FOLDER)/test/etc/workspace_1" - CODE_TESTS_PATH: "$(APPVEYOR_BUILD_FOLDER)/out/test/single-workspace" + CODE_TESTS_PATH: "$(APPVEYOR_BUILD_FOLDER)/out/test/tests" + + matrix: + - CODE_TESTS_WORKSPACE: "$(APPVEYOR_BUILD_FOLDER)/test/etc/workspace_1" + YARN_CMD: "test:single-workspace" + - CODE_TESTS_WORKSPACE: "$(APPVEYOR_BUILD_FOLDER)/test/etc/multi-root.code-workspace" + YARN_CMD: "test:multi-workspace" install: - ps: Install-Product node $env:nodejs_version @@ -13,6 +21,8 @@ install: - yarn install test_script: - - yarn test + - yarn %YARN_CMD% + - npm install -g codecov + - codecov build: off diff --git a/.gitignore b/.gitignore index de27cdd..014d19b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ node_modules # Logs logs *.log -npm-debug.log* \ No newline at end of file +npm-debug.log* +coverage/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 10aca35..d12b5f7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,9 @@ stages: - name: deploy if: branch = master AND type != pull_request +matrix: + fast_finish: true + notifications: email: false @@ -19,7 +22,43 @@ jobs: sudo: required env: - CODE_TESTS_WORKSPACE=$TRAVIS_BUILD_DIR/test/etc/workspace_1 - - CODE_TESTS_PATH=$TRAVIS_BUILD_DIR/out/test/single-workspace + - CODE_TESTS_PATH=$TRAVIS_BUILD_DIR/out/test/tests + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - gcc-4.9 + - g++-4.9 + - gcc-4.9-multilib + - g++-4.9-multilib + - zip + - libgtk2.0-0 + - libx11-dev + - libxkbfile-dev + - libsecret-1-dev + before_install: + - export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0 + - sh -e /etc/init.d/xvfb start + - sleep 3 + - yarn global add greenkeeper-lockfile@1 + install: + - yarn install + before_script: + - greenkeeper-lockfile-update + script: + - yarn test:single-workspace + after_script: + - greenkeeper-lockfile-upload + after_success: + - npm i -g codecov + - codecov + - stage: test + os: linux + sudo: required + env: + - CODE_TESTS_WORKSPACE=$TRAVIS_BUILD_DIR/test/etc/multi-root.code-workspace + - CODE_TESTS_PATH=$TRAVIS_BUILD_DIR/out/test/tests addons: apt: sources: @@ -44,9 +83,12 @@ jobs: before_script: - greenkeeper-lockfile-update script: - - yarn test --silent + - yarn test:multi-workspace after_script: - greenkeeper-lockfile-upload + after_success: + - npm i -g codecov + - codecov - stage: deploy install: - yarn install @@ -54,20 +96,3 @@ jobs: - yarn build script: - semantic-release - -#- github_changelog_generator --no-verbose -u buehler -p typescript-hero --enhancement-labels "enhancement,feature" --include-labels "bug,enhancement,feature" --future-release $(node -p "require('./package.json').version") - -# add as soon as multi root workspaces are available: -#- CODE_TESTS_WORKSPACE=$TRAVIS_BUILD_DIR/test/multi-root.code-workspace CODE_TESTS_PATH=$TRAVIS_BUILD_DIR/out/test/multi-root-workspace-tests - -# OSX Build. which takes a billon years to complete. -# - stage: test -# os: osx -# sudo: false -# env: -# - CODE_TESTS_WORKSPACE=$TRAVIS_BUILD_DIR/test/_workspace -# - CODE_TESTS_PATH=$TRAVIS_BUILD_DIR/out/test/single-workspace-tests -# install: -# - yarn install -# script: -# - yarn test --silent diff --git a/.vscode/launch.json b/.vscode/launch.json index 49eb6a0..4ff367d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -43,17 +43,22 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ - "${workspaceRoot}/test/_workspace", + "${workspaceRoot}/test/etc/workspace_1", "--extensionDevelopmentPath=${workspaceRoot}", - "--extensionTestsPath=${workspaceRoot}/out/test/single-workspace-tests/" + "--extensionTestsPath=${workspaceRoot}/out/test/tests/" ], "env": { - "CI": "true" + "EXT_DEBUG": "true", + "LOCAL_TEST": "true", + "COVERAGE": "true", + "CHAI_JEST_SNAPSHOT_UPDATE_ALL": "true" }, "stopOnEntry": false, "sourceMaps": true, + "smartStep": true, "outFiles": [ - "${workspaceRoot}/out/test/single-workspace-tests/**/*.js" + "${workspaceRoot}/out/src/**/*.js", + "${workspaceRoot}/out/test/tests/**/*.js" ] }, { @@ -62,17 +67,22 @@ "request": "launch", "runtimeExecutable": "${execPath}", "args": [ - "${workspaceRoot}/test/multi-root.code-workspace", + "${workspaceRoot}/test/etc/multi-root.code-workspace", "--extensionDevelopmentPath=${workspaceRoot}", - "--extensionTestsPath=${workspaceRoot}/out/test/multi-root-workspace-tests/" + "--extensionTestsPath=${workspaceRoot}/out/test/tests/" ], "env": { - "CI": "true" + "EXT_DEBUG": "true", + "LOCAL_TEST": "true", + "COVERAGE": "true", + "CHAI_JEST_SNAPSHOT_UPDATE_ALL": "true" }, "stopOnEntry": false, "sourceMaps": true, + "smartStep": true, "outFiles": [ - "${workspaceRoot}/out/test/**/*.js" + "${workspaceRoot}/out/src/**/*.js", + "${workspaceRoot}/out/test/tests/**/*.js" ] } ], diff --git a/.vscodeignore b/.vscodeignore index b1075a5..8615a93 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -12,6 +12,9 @@ src/** !src/extension/assets/** tsconfig.json tslint.json +coverage/** + +__snapshots__/** *.vsix out/test/** diff --git a/README.md b/README.md index 6c0ce7a..c250868 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ When you are coding a lot of `TypeScript` you may want vscode to organize your i [![Travis build](https://img.shields.io/travis/buehler/typescript-hero.svg)](https://travis-ci.org/buehler/typescript-hero) [![AppVeyor status](https://ci.appveyor.com/api/projects/status/p1vbbyh69j4s0rbh?svg=true)](https://ci.appveyor.com/project/buehler/typescript-hero) +[![codecov](https://codecov.io/gh/buehler/typescript-hero/branch/master/graph/badge.svg)](https://codecov.io/gh/buehler/typescript-hero) [![Marketplace](https://vsmarketplacebadge.apphb.com/version-short/rbbit.typescript-hero.svg)](https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero) [![Installs](https://vsmarketplacebadge.apphb.com/installs/rbbit.typescript-hero.svg)](https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero) [![GitHub issues](https://img.shields.io/github/issues/buehler/typescript-hero.svg)](https://github.com/buehler/typescript-hero/issues) diff --git a/config/tsconfig.test-multi-workspace.json b/config/tsconfig.test-multi-workspace.json new file mode 100644 index 0000000..5b8571d --- /dev/null +++ b/config/tsconfig.test-multi-workspace.json @@ -0,0 +1,16 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "sourceMap": true + }, + "include": [ + "../src/**/*", + "../test/**/*" + ], + "exclude": [ + "../src/_old", + "../test/_old", + "../test/etc", + "../test/**/*.single.test.ts" + ] +} diff --git a/config/tsconfig.test.json b/config/tsconfig.test-single-workspace.json similarity index 60% rename from config/tsconfig.test.json rename to config/tsconfig.test-single-workspace.json index d5ec25e..1bf40ca 100644 --- a/config/tsconfig.test.json +++ b/config/tsconfig.test-single-workspace.json @@ -1,5 +1,8 @@ { "extends": "./tsconfig.base.json", + "compilerOptions": { + "sourceMap": true + }, "include": [ "../src/**/*", "../test/**/*" @@ -7,6 +10,7 @@ "exclude": [ "../src/_old", "../test/_old", - "../test/etc" + "../test/etc", + "../test/**/*.multi.test.ts" ] } diff --git a/package.json b/package.json index 0f36d69..c3da71e 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,11 @@ "href": "https://ci.appveyor.com/project/buehler/typescript-hero", "description": "AppVeyor build" }, + { + "url": "https://codecov.io/gh/buehler/typescript-hero/branch/master/graph/badge.svg", + "href": "https://codecov.io/gh/buehler/typescript-hero", + "description": "Code coverage" + }, { "url": "https://img.shields.io/github/issues/buehler/typescript-hero.svg", "href": "https://github.com/buehler/typescript-hero/issues", @@ -58,7 +63,8 @@ "build": "npm run clean && tsc -p ./config/tsconfig.build.json", "develop": "npm run clean && tsc -p .", "lint": "tslint -c ./tslint.json -p ./config/tsconfig.build.json", - "test": "npm run lint && npm run clean && tsc -p ./config/tsconfig.test.json && node ./node_modules/vscode/bin/test", + "test:single-workspace": "npm run lint && npm run clean && tsc -p ./config/tsconfig.test-single-workspace.json && node ./node_modules/vscode/bin/test", + "test:multi-workspace": "npm run lint && npm run clean && tsc -p ./config/tsconfig.test-multi-workspace.json && node ./node_modules/vscode/bin/test", "semantic-release": "semantic-release" }, "release": { @@ -80,28 +86,33 @@ }, "devDependencies": { "@smartive/tslint-config": "^2.0.0", - "@types/chai": "^4.1.1", - "@types/mocha": "^2.2.46", - "@types/node": "^9.3.0", + "@types/chai": "^4.1.2", + "@types/istanbul": "^0.4.29", + "@types/mocha": "^2.2.48", + "@types/node": "^9.4.0", "@types/reflect-metadata": "0.1.0", "@types/sinon": "^4.1.3", "@types/sinon-chai": "^2.7.29", "chai": "^4.1.2", + "chai-jest-snapshot": "^2.0.0", + "decache": "^4.4.0", "del-cli": "^1.1.0", - "semantic-release": "^12.2.2", + "istanbul": "^0.4.5", + "remap-istanbul": "^0.10.1", + "semantic-release": "^12.4.1", "semantic-release-vsce": "^2.0.0", - "sinon": "^4.2.0", + "sinon": "^4.2.2", "sinon-chai": "^2.14.0", "tslint": "^5.9.1", - "tsutils": "^2.19.1", + "tsutils": "^2.21.0", "vscode": "^1.1.10" }, "dependencies": { "fs-extra": "^5.0.0", - "inversify": "^4.9.0", + "inversify": "^4.10.0", "reflect-metadata": "^0.1.12", - "tslib": "^1.8.1", - "typescript": "~2.6.2", + "tslib": "^1.9.0", + "typescript": "~2.7.1", "typescript-parser": "^2.2.2", "winston": "^3.0.0-rc1" }, diff --git a/src/declarations/workspace-declarations.ts b/src/declarations/workspace-declarations.ts index a5635f1..56aa82f 100644 --- a/src/declarations/workspace-declarations.ts +++ b/src/declarations/workspace-declarations.ts @@ -63,6 +63,7 @@ export default class WorkspaceDeclarations implements Disposable { this._index = new DeclarationIndex(this.parser, this.folder.uri.fsPath); const files = await this.findFiles(); + this.logger.info(`Found ${files.length} files in workspace.`, { workspace: this.folder.uri.fsPath }); const watcher = workspace.createFileSystemWatcher( new RelativePattern( this.folder, @@ -81,13 +82,13 @@ export default class WorkspaceDeclarations implements Disposable { this._workspaceStateChanged.fire(WorkspaceDeclarationsState.Idle); profiler.done({ - message: 'Built index for workspace', + message: 'Built index for workspace.', workspace: this.folder.uri.fsPath, }); } catch (error) { this._workspaceStateChanged.fire(WorkspaceDeclarationsState.Error); this.logger.error( - 'Error during indexing of workspacefiles', + 'Error during indexing of workspacefiles.', { error: error.toString(), workspace: this.folder.uri.fsPath }, ); } diff --git a/src/utilities/logger.ts b/src/utilities/logger.ts index ca3d0e9..3cce418 100644 --- a/src/utilities/logger.ts +++ b/src/utilities/logger.ts @@ -65,14 +65,14 @@ export interface Logger { const loggerTransports = [ new ConsoleLogTransport({ - level: !!process.env.CI ? 'error' : 'debug', + level: !!process.env.CI || !!process.env.LOCAL_TEST ? 'error' : 'debug', }), ]; export default function winstonLogger(verbosity: keyof typeof levels, context: ExtensionContext): Logger { const level = !!process.env.CI ? 'error' : verbosity; - if (!process.env.CI && !process.env.EXT_DEBUG) { + if (!process.env.CI && !process.env.EXT_DEBUG && !process.env.LOCAL_TEST) { const channel = window.createOutputChannel('TypeScript Hero'); context.subscriptions.push(channel); channel.show(); diff --git a/test/_old/multi-root.code-workspace b/test/_old/multi-root.code-workspace deleted file mode 100644 index 7cc4784..0000000 --- a/test/_old/multi-root.code-workspace +++ /dev/null @@ -1,20 +0,0 @@ -{ - "folders": [ - { - "path": "_workspace" - }, - { - "path": "_workspace_2" - }, - { - "path": "_workspace/server" - } - ], - "settings": { - "typescriptHero.verbosity": "Warnings", - "typescriptHero.codeOutline.enabled": true, - "typescriptHero.resolver.organizeOnSave": false, - "typescriptHero.resolver.promptForSpecifiers": true, - "editor.formatOnSave": true - } -} diff --git a/test/_old/single-workspace-tests/extension/extensions/DocumentSymbolStructureExtension.test.ts b/test/_old/single-workspace-tests/extension/extensions/DocumentSymbolStructureExtension.test.ts index 11d5588..827a5f1 100644 --- a/test/_old/single-workspace-tests/extension/extensions/DocumentSymbolStructureExtension.test.ts +++ b/test/_old/single-workspace-tests/extension/extensions/DocumentSymbolStructureExtension.test.ts @@ -49,7 +49,7 @@ describe('DocumentSymbolStructureExtension', () => { await vscode.commands.executeCommand('workbench.action.closeAllEditors'); }); - it.skip('should return an empty array if no active window is set', async () => { + it('should return an empty array if no active window is set', async () => { await vscode.commands.executeCommand('workbench.action.closeAllEditors'); const elements = await extension.getChildren() as BaseStructureTreeItem[]; diff --git a/test/etc/multi-root.code-workspace b/test/etc/multi-root.code-workspace new file mode 100644 index 0000000..dbec728 --- /dev/null +++ b/test/etc/multi-root.code-workspace @@ -0,0 +1,16 @@ +{ + "folders": [ + { + "path": "workspace_1" + }, + { + "path": "workspace_2" + }, + { + "path": "workspace_3" + } + ], + "settings": { + "typescriptHero.codeOutline.enabled": true + } +} diff --git a/test/etc/workspace_1/.vscode/settings.json b/test/etc/workspace_1/.vscode/settings.json new file mode 100644 index 0000000..1556936 --- /dev/null +++ b/test/etc/workspace_1/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "typescriptHero.codeOutline.enabled": true +} diff --git a/test/etc/workspace_1/code-outline/code.js b/test/etc/workspace_1/code-outline/code.js new file mode 100644 index 0000000..86c5483 --- /dev/null +++ b/test/etc/workspace_1/code-outline/code.js @@ -0,0 +1,13 @@ +import 'string-only'; + +import { Foobar } from 'my-lib'; + +class Yay extends Foobar { + constructor() { + this.name = 'foobar'; + } + + method() { + console.log(this.name); + } +} diff --git a/test/etc/workspace_1/code-outline/code.ts b/test/etc/workspace_1/code-outline/code.ts new file mode 100644 index 0000000..17c3b7a --- /dev/null +++ b/test/etc/workspace_1/code-outline/code.ts @@ -0,0 +1,14 @@ +import 'string-only'; + +import { Foobar } from 'my-lib'; + +class Yay extends Foobar { + public name: string; + + public method(): void { + } +} + +class ArrList { + public method(param: T): T { } +} diff --git a/test/etc/workspace_1/code-outline/empty.ts b/test/etc/workspace_1/code-outline/empty.ts new file mode 100644 index 0000000..e69de29 diff --git a/test/etc/workspace_1/code-outline/not-parseable.txt b/test/etc/workspace_1/code-outline/not-parseable.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/etc/workspace_1/server/indices/foobar.ts b/test/etc/workspace_1/server/indices/foobar.ts deleted file mode 100644 index eaaf9cd..0000000 --- a/test/etc/workspace_1/server/indices/foobar.ts +++ /dev/null @@ -1 +0,0 @@ -export class Foo { } diff --git a/test/etc/workspace_2/code-outline/code.ts b/test/etc/workspace_2/code-outline/code.ts new file mode 100644 index 0000000..17c3b7a --- /dev/null +++ b/test/etc/workspace_2/code-outline/code.ts @@ -0,0 +1,14 @@ +import 'string-only'; + +import { Foobar } from 'my-lib'; + +class Yay extends Foobar { + public name: string; + + public method(): void { + } +} + +class ArrList { + public method(param: T): T { } +} diff --git a/test/etc/workspace_2/main.ts b/test/etc/workspace_2/main.ts new file mode 100644 index 0000000..b6800e5 --- /dev/null +++ b/test/etc/workspace_2/main.ts @@ -0,0 +1,11 @@ +import { Foo } from './server/indices/foobar'; +import { Loggee } from './utilities/Logger'; +import winstonLogger, { Logger } from './utilities/Logger'; + +import iocSymbols from './ioc-symbols'; + +function foo() { + console.log(winstonLogger, Logger, Loggee, iocSymbols); +} + +Foo diff --git a/test/etc/workspace_3/main.ts b/test/etc/workspace_3/main.ts new file mode 100644 index 0000000..b6800e5 --- /dev/null +++ b/test/etc/workspace_3/main.ts @@ -0,0 +1,11 @@ +import { Foo } from './server/indices/foobar'; +import { Loggee } from './utilities/Logger'; +import winstonLogger, { Logger } from './utilities/Logger'; + +import iocSymbols from './ioc-symbols'; + +function foo() { + console.log(winstonLogger, Logger, Loggee, iocSymbols); +} + +Foo diff --git a/test/single-workspace/demo.spec.ts b/test/single-workspace/demo.spec.ts deleted file mode 100644 index 2d2c427..0000000 --- a/test/single-workspace/demo.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -import * as chai from 'chai'; - -const expect = chai.expect; - -describe('Demo test', () => { - it('should be tested', () => { - expect(true).to.equal(true); - }); -}); diff --git a/test/single-workspace/index.ts b/test/single-workspace/index.ts deleted file mode 100644 index 1b31247..0000000 --- a/test/single-workspace/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -// tslint:disable -// -// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING -// -// This file is providing the test runner to use when running extension tests. -// By default the test runner in use is Mocha based. -// -// You can provide your own test runner if you want to override it by exporting -// a function run(testRoot: string, clb: (error:Error) => void) that the extension -// host can call to run the tests. The test runner is expected to use console.log -// to report the results back to the caller. When the tests are finished, return -// a possible error to the callback or null if none. -import { ExtensionContext, Memento } from 'vscode'; - -import ioc from '../../src/ioc'; -import iocSymbols from '../../src/ioc-symbols'; - -class ContextMock implements ExtensionContext { - subscriptions: { dispose(): any }[] = []; - workspaceState: Memento; - globalState: Memento; - extensionPath: string = ''; - storagePath: string = ''; - asAbsolutePath(): string { - return ''; - } -} - -ioc.bind(iocSymbols.extensionContext).toConstantValue(new ContextMock()); - -const testRunner = require('vscode/lib/testrunner'); - -// You can directly control Mocha options by uncommenting the following lines -// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info -testRunner.configure({ - ui: 'bdd', - useColors: true -}); - -module.exports = testRunner; diff --git a/test/tests/code-outline/__snapshots__/code-outline.multi.test.ts.snap b/test/tests/code-outline/__snapshots__/code-outline.multi.test.ts.snap new file mode 100644 index 0000000..a694ee5 --- /dev/null +++ b/test/tests/code-outline/__snapshots__/code-outline.multi.test.ts.snap @@ -0,0 +1,35 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CodeOutline (multi root) should return a code structure for a valid js file (workspace 2) 1`] = ` +Array [ + Object { + "ctor": "ImportsStructureTreeItem", + "label": "Imports", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "Yay", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "ArrList", + }, +] +`; + +exports[`CodeOutline (multi root) should return a code structure for a valid ts file (workspace 1) 1`] = ` +Array [ + Object { + "ctor": "ImportsStructureTreeItem", + "label": "Imports", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "Yay", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "ArrList", + }, +] +`; diff --git a/test/tests/code-outline/__snapshots__/code-outline.test.ts.snap b/test/tests/code-outline/__snapshots__/code-outline.test.ts.snap new file mode 100644 index 0000000..bddba4e --- /dev/null +++ b/test/tests/code-outline/__snapshots__/code-outline.test.ts.snap @@ -0,0 +1,51 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`CodeOutline should return a code structure for a valid js file 1`] = ` +Array [ + Object { + "ctor": "ImportsStructureTreeItem", + "label": "Imports", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "Yay", + }, +] +`; + +exports[`CodeOutline should return a code structure for a valid ts file 1`] = ` +Array [ + Object { + "ctor": "ImportsStructureTreeItem", + "label": "Imports", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "Yay", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "ArrList", + }, +] +`; + +exports[`CodeOutline should return an empty array if no document is open 1`] = `Array []`; + +exports[`CodeOutline should return disabled structure item when it is disabled 1`] = ` +Array [ + Object { + "ctor": "DisabledStructureTreeItem", + "label": "Feature is disabled.", + }, +] +`; + +exports[`CodeOutline should return not parseable on non ts / js file 1`] = ` +Array [ + Object { + "ctor": "NotParseableStructureTreeItem", + "label": "File not parseable.", + }, +] +`; diff --git a/test/tests/code-outline/__snapshots__/declaration-structure-tree-item.test.ts.snap b/test/tests/code-outline/__snapshots__/declaration-structure-tree-item.test.ts.snap new file mode 100644 index 0000000..3c41446 --- /dev/null +++ b/test/tests/code-outline/__snapshots__/declaration-structure-tree-item.test.ts.snap @@ -0,0 +1,50 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`DeclarationStructureTreeItem should not return children on simple declarations 1`] = `Array []`; + +exports[`DeclarationStructureTreeItem should return the correct accessor children 1`] = ` +Array [ + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "get() getter", + }, +] +`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "class" 1`] = `"src/assets/icons/declarations/class.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "const" 1`] = `"src/assets/icons/declarations/default.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "default" 1`] = `"src/assets/icons/declarations/default.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "enum" 1`] = `"src/assets/icons/declarations/enum.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "function" 1`] = `"src/assets/icons/declarations/callable.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "interface" 1`] = `"src/assets/icons/declarations/interface.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "method" 1`] = `"src/assets/icons/declarations/callable.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "module" 1`] = `"src/assets/icons/declarations/module.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "property" 1`] = `"src/assets/icons/declarations/property.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct icon path for itemKind "variable" 1`] = `"src/assets/icons/declarations/variable.svg"`; + +exports[`DeclarationStructureTreeItem should return the correct method children 1`] = ` +Array [ + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "method()", + }, +] +`; + +exports[`DeclarationStructureTreeItem should return the correct property children 1`] = ` +Array [ + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "property", + }, +] +`; diff --git a/test/tests/code-outline/__snapshots__/imports-structure-tree-item.test.ts.snap b/test/tests/code-outline/__snapshots__/imports-structure-tree-item.test.ts.snap new file mode 100644 index 0000000..e3ddfcd --- /dev/null +++ b/test/tests/code-outline/__snapshots__/imports-structure-tree-item.test.ts.snap @@ -0,0 +1,45 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ImportStructureTreeItem should return the correct children for the "ExternalModuleImport" import 1`] = ` +Array [ + Object { + "ctor": "ImportSpecifierStructureTreeItem", + "label": "extImp", + }, +] +`; + +exports[`ImportStructureTreeItem should return the correct children for the "NamedImport" import 1`] = `Array []`; + +exports[`ImportStructureTreeItem should return the correct children for the "NamedImport" import 2`] = ` +Array [ + Object { + "ctor": "ImportSpecifierStructureTreeItem", + "label": "(default) default", + }, + Object { + "ctor": "ImportSpecifierStructureTreeItem", + "label": "spec", + }, +] +`; + +exports[`ImportStructureTreeItem should return the correct children for the "NamespaceImport" import 1`] = ` +Array [ + Object { + "ctor": "ImportSpecifierStructureTreeItem", + "label": "namespace", + }, +] +`; + +exports[`ImportStructureTreeItem should return the correct children for the "StringImport" import 1`] = `Array []`; + +exports[`ImportsStructureTreeItem should return the children for the imports 1`] = ` +Array [ + Object { + "ctor": "ImportStructureTreeItem", + "label": "lib", + }, +] +`; diff --git a/test/tests/code-outline/__snapshots__/resource-structure-tree-item.test.ts.snap b/test/tests/code-outline/__snapshots__/resource-structure-tree-item.test.ts.snap new file mode 100644 index 0000000..eafd039 --- /dev/null +++ b/test/tests/code-outline/__snapshots__/resource-structure-tree-item.test.ts.snap @@ -0,0 +1,18 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ResourceStructureTreeItem should return correct children 1`] = ` +Array [ + Object { + "ctor": "ImportsStructureTreeItem", + "label": "Imports", + }, + Object { + "ctor": "ResourceStructureTreeItem", + "label": "namespace", + }, + Object { + "ctor": "DeclarationStructureTreeItem", + "label": "var", + }, +] +`; diff --git a/test/tests/code-outline/code-outline.multi.test.ts b/test/tests/code-outline/code-outline.multi.test.ts new file mode 100644 index 0000000..137663f --- /dev/null +++ b/test/tests/code-outline/code-outline.multi.test.ts @@ -0,0 +1,57 @@ +import { join } from 'path'; +import { TypescriptParser } from 'typescript-parser'; +import { commands, ExtensionContext, window, workspace } from 'vscode'; + +import CodeOutline from '../../../src/code-outline'; +import Configuration from '../../../src/configuration'; +import ioc from '../../../src/ioc'; +import iocSymbols from '../../../src/ioc-symbols'; +import { Logger } from '../../../src/utilities/logger'; +import { expect } from '../setup'; + +describe('CodeOutline (multi root)', () => { + const r1 = workspace.workspaceFolders![0].uri.fsPath; + const r2 = workspace.workspaceFolders![1].uri.fsPath; + + const files = { + W1_codeTs: join(r1, 'code-outline', 'code.ts'), + W2_codeTs: join(r2, 'code-outline', 'code.ts'), + }; + + let extension: CodeOutline; + + before(async () => { + const document = await workspace.openTextDocument(files.W1_codeTs); + await window.showTextDocument(document); + + const context = ioc.get(iocSymbols.extensionContext); + const logger = ioc.get(iocSymbols.logger); + const config = ioc.get(iocSymbols.configuration); + const parser = ioc.get(iocSymbols.parser); + + extension = new CodeOutline(context, logger, config, parser); + }); + + after(async () => { + await commands.executeCommand('workbench.action.closeAllEditors'); + }); + + it('should return a code structure for a valid ts file (workspace 1)', async () => { + const document = await workspace.openTextDocument(files.W1_codeTs); + await window.showTextDocument(document); + (extension as any).documentCache = undefined; + expect( + (await extension.getChildren() || []).map(c => ({ label: c.label, ctor: c.constructor.name })), + ).to.matchSnapshot(); + }); + + it('should return a code structure for a valid js file (workspace 2)', async () => { + const document = await workspace.openTextDocument(files.W2_codeTs); + await window.showTextDocument(document); + (extension as any).documentCache = undefined; + expect( + (await extension.getChildren() || []).map(c => ({ label: c.label, ctor: c.constructor.name })), + ).to.matchSnapshot(); + }); + +}); diff --git a/test/tests/code-outline/code-outline.test.ts b/test/tests/code-outline/code-outline.test.ts new file mode 100644 index 0000000..d235c4f --- /dev/null +++ b/test/tests/code-outline/code-outline.test.ts @@ -0,0 +1,87 @@ +import { join } from 'path'; +import { TypescriptParser } from 'typescript-parser'; +import { commands, ExtensionContext, window, workspace } from 'vscode'; + +import CodeOutline from '../../../src/code-outline'; +import Configuration from '../../../src/configuration'; +import ioc from '../../../src/ioc'; +import iocSymbols from '../../../src/ioc-symbols'; +import { Logger } from '../../../src/utilities/logger'; +import { expect } from '../setup'; + +describe('CodeOutline', () => { + const rootPath = workspace.workspaceFolders![0].uri.fsPath; + const files = { + empty: join(rootPath, 'code-outline', 'empty.ts'), + nonParseable: join(rootPath, 'code-outline', 'not-parseable.txt'), + codeTs: join(rootPath, 'code-outline', 'code.ts'), + codeJs: join(rootPath, 'code-outline', 'code.js'), + }; + + let extension: CodeOutline; + + before(async () => { + const document = await workspace.openTextDocument(files.empty); + await window.showTextDocument(document); + + const context = ioc.get(iocSymbols.extensionContext); + const logger = ioc.get(iocSymbols.logger); + const config = ioc.get(iocSymbols.configuration); + const parser = ioc.get(iocSymbols.parser); + + extension = new CodeOutline(context, logger, config, parser); + }); + + after(async () => { + await commands.executeCommand('workbench.action.closeAllEditors'); + }); + + it('should return an empty array if no document is open', async () => { + await commands.executeCommand('workbench.action.closeAllEditors'); + expect(await extension.getChildren()).to.matchSnapshot(); + }); + + it('should return disabled structure item when it is disabled', async () => { + const document = await workspace.openTextDocument(files.codeTs); + await window.showTextDocument(document); + const config = workspace.getConfiguration('typescriptHero'); + const value = config.get('codeOutline.enabled', true); + + try { + await config.update('codeOutline.enabled', false); + expect( + (await extension.getChildren() || []).map(c => ({ label: c.label, ctor: c.constructor.name })), + ).to.matchSnapshot(); + } finally { + await config.update('codeOutline.enabled', value); + } + }); + + it('should return not parseable on non ts / js file', async () => { + const document = await workspace.openTextDocument(files.nonParseable); + await window.showTextDocument(document); + + expect( + (await extension.getChildren() || []).map(c => ({ label: c.label, ctor: c.constructor.name })), + ).to.matchSnapshot(); + }); + + it('should return a code structure for a valid ts file', async () => { + const document = await workspace.openTextDocument(files.codeTs); + await window.showTextDocument(document); + (extension as any).documentCache = undefined; + expect( + (await extension.getChildren() || []).map(c => ({ label: c.label, ctor: c.constructor.name })), + ).to.matchSnapshot(); + }); + + it('should return a code structure for a valid js file', async () => { + const document = await workspace.openTextDocument(files.codeJs); + await window.showTextDocument(document); + (extension as any).documentCache = undefined; + expect( + (await extension.getChildren() || []).map(c => ({ label: c.label, ctor: c.constructor.name })), + ).to.matchSnapshot(); + }); + +}); diff --git a/test/tests/code-outline/declaration-structure-tree-item.test.ts b/test/tests/code-outline/declaration-structure-tree-item.test.ts new file mode 100644 index 0000000..0ae3339 --- /dev/null +++ b/test/tests/code-outline/declaration-structure-tree-item.test.ts @@ -0,0 +1,127 @@ +import { relative } from 'path'; +import { + ClassDeclaration, + EnumDeclaration, + FunctionDeclaration, + GetterDeclaration, + InterfaceDeclaration, + MethodDeclaration, + ModuleDeclaration, + PropertyDeclaration, + TypeAliasDeclaration, + VariableDeclaration, +} from 'typescript-parser'; +import { ExtensionContext } from 'vscode'; + +import DeclarationStructureTreeItem from '../../../src/code-outline/declaration-structure-tree-item'; +import ioc from '../../../src/ioc'; +import iocSymbols from '../../../src/ioc-symbols'; +import { expect } from '../setup'; + +declare global { + namespace Chai { + interface Assertion { + matchSnapshot(): Assertion; + } + } +} + +describe('DeclarationStructureTreeItem', () => { + + let context: ExtensionContext; + + before(() => { + context = ioc.get(iocSymbols.extensionContext); + }); + + it('should create a tree item', () => { + const declaration = new ClassDeclaration('class', true, 0, 100); + const item = new DeclarationStructureTreeItem(declaration, context); + + expect(item).to.exist; + }); + + const iconPossibilities = [ + { + name: 'class', + declaration: new ClassDeclaration('class', true, 0, 100), + }, + { + name: 'interface', + declaration: new InterfaceDeclaration('interface', true, 0, 100), + }, + { + name: 'enum', + declaration: new EnumDeclaration('enum', true, 0, 100), + }, + { + name: 'function', + declaration: new FunctionDeclaration('function', true, 'void', 0, 100), + }, + { + name: 'method', + declaration: new MethodDeclaration('method', false, undefined, 'void', 0, 100), + }, + { + name: 'module', + declaration: new ModuleDeclaration('module', 0, 100), + }, + { + name: 'property', + declaration: new PropertyDeclaration('property', undefined, 'void', 0, 100), + }, + { + name: 'variable', + declaration: new VariableDeclaration('variable', false, true, 'string', 0, 100), + }, + { + name: 'const', + declaration: new VariableDeclaration('const', true, true, 'string', 0, 100), + }, + { + name: 'default', + declaration: new TypeAliasDeclaration('typealias', true, 0, 100), + }, + ]; + + for (const test of iconPossibilities) { + it(`should return the correct icon path for itemKind "${test.name}"`, () => { + const item = new DeclarationStructureTreeItem(test.declaration, context); + + const path = relative(global['rootPath'], item.iconPath || '').replace(/[\\/]/g, '/'); + expect(path).to.matchSnapshot(); + }); + } + + it('should return the correct accessor children', () => { + const declaration = new ClassDeclaration('class', true, 0, 100); + declaration.accessors.push(new GetterDeclaration('getter', undefined, undefined, false)); + const item = new DeclarationStructureTreeItem(declaration, context); + + expect(item.getChildren().map(c => ({ label: c.label, ctor: c.constructor.name }))).to.matchSnapshot(); + }); + + it('should return the correct property children', () => { + const declaration = new ClassDeclaration('class', true, 0, 100); + declaration.properties.push(new PropertyDeclaration('property', undefined, undefined)); + const item = new DeclarationStructureTreeItem(declaration, context); + + expect(item.getChildren().map(c => ({ label: c.label, ctor: c.constructor.name }))).to.matchSnapshot(); + }); + + it('should return the correct method children', () => { + const declaration = new ClassDeclaration('class', true, 0, 100); + declaration.methods.push(new MethodDeclaration('method', false, undefined, undefined)); + const item = new DeclarationStructureTreeItem(declaration, context); + + expect(item.getChildren().map(c => ({ label: c.label, ctor: c.constructor.name }))).to.matchSnapshot(); + }); + + it('should not return children on simple declarations', () => { + const declaration = new VariableDeclaration('variable', false, true, undefined); + const item = new DeclarationStructureTreeItem(declaration, context); + + expect(item.getChildren()).to.matchSnapshot(); + }); + +}); diff --git a/test/tests/code-outline/disabled-structure-tree-item.test.ts b/test/tests/code-outline/disabled-structure-tree-item.test.ts new file mode 100644 index 0000000..96157dd --- /dev/null +++ b/test/tests/code-outline/disabled-structure-tree-item.test.ts @@ -0,0 +1,19 @@ +import { expect } from 'chai'; + +import DisabledStructureTreeItem from '../../../src/code-outline/disabled-structure-tree-item'; + +describe('DisabledStructureTreeItem', () => { + + it('should create a tree item', () => { + const item = new DisabledStructureTreeItem(); + + expect(item).to.exist; + }); + + it('should return disabled text', () => { + const item = new DisabledStructureTreeItem(); + + expect(item.label).to.equal('Feature is disabled.'); + }); + +}); diff --git a/test/tests/code-outline/imports-structure-tree-item.test.ts b/test/tests/code-outline/imports-structure-tree-item.test.ts new file mode 100644 index 0000000..3c5a911 --- /dev/null +++ b/test/tests/code-outline/imports-structure-tree-item.test.ts @@ -0,0 +1,76 @@ +import { ExternalModuleImport, File, NamedImport, NamespaceImport, StringImport, SymbolSpecifier } from 'typescript-parser'; +import { ExtensionContext } from 'vscode'; + +import { ImportsStructureTreeItem, ImportStructureTreeItem } from '../../../src/code-outline/imports-structure-tree-item'; +import ioc from '../../../src/ioc'; +import iocSymbols from '../../../src/ioc-symbols'; +import { expect } from '../setup'; + +declare global { + namespace Chai { + interface Assertion { + matchSnapshot(): Assertion; + } + } +} + +describe('ImportsStructureTreeItem', () => { + + let context: ExtensionContext; + + before(() => { + context = ioc.get(iocSymbols.extensionContext); + }); + + it('should create a tree item', () => { + const resource = new File('./path', '/root', 0, 100); + resource.imports.push(new NamedImport('lib', 0, 1)); + const item = new ImportsStructureTreeItem(resource, context); + + expect(item).to.exist; + }); + + it('should return the children for the imports', () => { + const resource = new File('./path', '/root', 0, 100); + resource.imports.push(new NamedImport('lib', 0, 1)); + const item = new ImportsStructureTreeItem(resource, context); + + expect(item.getChildren().map(c => ({ label: c.label, ctor: c.constructor.name }))).to.matchSnapshot(); + }); + +}); + +describe('ImportStructureTreeItem', () => { + + let context: ExtensionContext; + + before(() => { + context = ioc.get(iocSymbols.extensionContext); + }); + + it('should create a tree item', () => { + const item = new ImportStructureTreeItem(new NamedImport('lib', 0, 1), context); + + expect(item).to.exist; + }); + + const specImport = new NamedImport('named-spec-imp', 0, 1); + specImport.defaultAlias = 'default'; + specImport.specifiers.push(new SymbolSpecifier('spec')); + const imports = [ + new NamedImport('named-imp', 0, 1), + new StringImport('str-imp'), + new ExternalModuleImport('ext-imp', 'extImp', 0, 1), + new NamespaceImport('namespace-imp', 'namespace', 0, 1), + specImport, + ]; + + for (const test of imports) { + it(`should return the correct children for the "${test.constructor.name}" import`, () => { + const item = new ImportStructureTreeItem(test, context); + + expect(item.getChildren().map(c => ({ label: c.label, ctor: c.constructor.name }))).to.matchSnapshot(); + }); + } + +}); diff --git a/test/tests/code-outline/not-parseable-structure-tree-item.test.ts b/test/tests/code-outline/not-parseable-structure-tree-item.test.ts new file mode 100644 index 0000000..0e0bdc9 --- /dev/null +++ b/test/tests/code-outline/not-parseable-structure-tree-item.test.ts @@ -0,0 +1,19 @@ +import { expect } from 'chai'; + +import NotParseableStructureTreeItem from '../../../src/code-outline/not-parseable-structure-tree-item'; + +describe('NotParseableStructureTreeItem', () => { + + it('should create a tree item', () => { + const item = new NotParseableStructureTreeItem(); + + expect(item).to.exist; + }); + + it('should return disabled text', () => { + const item = new NotParseableStructureTreeItem(); + + expect(item.label).to.equal('File not parseable.'); + }); + +}); diff --git a/test/tests/code-outline/resource-structure-tree-item.test.ts b/test/tests/code-outline/resource-structure-tree-item.test.ts new file mode 100644 index 0000000..6b2d30a --- /dev/null +++ b/test/tests/code-outline/resource-structure-tree-item.test.ts @@ -0,0 +1,43 @@ +import { File, Namespace, StringImport, VariableDeclaration } from 'typescript-parser'; +import { ExtensionContext } from 'vscode'; + +import ResourceStructureTreeItem from '../../../src/code-outline/resource-structure-tree-item'; +import ioc from '../../../src/ioc'; +import iocSymbols from '../../../src/ioc-symbols'; +import { expect } from '../setup'; + +declare global { + namespace Chai { + interface Assertion { + matchSnapshot(): Assertion; + } + } +} + +describe('ResourceStructureTreeItem', () => { + + let context: ExtensionContext; + + before(() => { + context = ioc.get(iocSymbols.extensionContext); + }); + + it('should create a tree item', () => { + const resource = new File('./path', '/root', 0, 100); + const item = new ResourceStructureTreeItem(resource, context); + + expect(item).to.exist; + }); + + it('should return correct children', () => { + const resource = new File('./path', '/root', 0, 100); + resource.imports.push(new StringImport('str-imp')); + resource.declarations.push(new VariableDeclaration('var', false, false, undefined)); + resource.resources.push(new Namespace('namespace', 10, 20)); + + const item = new ResourceStructureTreeItem(resource, context); + + expect(item.getChildren().map(c => ({ label: c.label, ctor: c.constructor.name }))).to.matchSnapshot(); + }); + +}); diff --git a/test/tests/index.ts b/test/tests/index.ts new file mode 100644 index 0000000..e3a2723 --- /dev/null +++ b/test/tests/index.ts @@ -0,0 +1,146 @@ +// PLEASE DO NOT MODIFY / DELETE UNLESS YOU KNOW WHAT YOU ARE DOING +// +// This file is providing the test runner to use when running extension tests. +// By default the test runner in use is Mocha based. +// +// You can provide your own test runner if you want to override it by exporting +// a function run(testRoot: string, clb: (error:Error) => void) that the extension +// host can call to run the tests. The test runner is expected to use console.log +// to report the results back to the caller. When the tests are finished, return +// a possible error to the callback or null if none. +import { ensureFileSync, readFileSync, writeFileSync } from 'fs-extra'; +import * as glob from 'glob'; +import { hook, Instrumenter, Reporter } from 'istanbul'; +import { platform } from 'os'; +import { join, relative } from 'path'; +import { ExtensionContext, Memento } from 'vscode'; + +const remapIstanbul = require('remap-istanbul'); + +type MatcherFunction = ((file: string) => boolean) & { files?: string[] }; +type Transformer = (code: string, filename: string) => string; + +class ContextMock implements ExtensionContext { + subscriptions: { dispose(): any }[] = []; + workspaceState: Memento; + globalState: Memento; + extensionPath: string = ''; + storagePath: string = ''; + asAbsolutePath(path: string): string { + return relative(global['rootPath'], path); + } +} + +// Prepare for snapshot (sigh) tests. +// HACK +if (platform() === 'win32') { + global['rootPath'] = join(process.cwd(), '..'); +} else { + global['rootPath'] = process.cwd(); +} +// END HACK + +const testRunner = require('vscode/lib/testrunner'); + +// You can directly control Mocha options by uncommenting the following lines +// See https://github.com/mochajs/mocha/wiki/Using-mocha-programmatically#set-options for more info +const options: any = { + ui: 'bdd', + useColors: true, + timeout: 5000, +}; + +if (process.env.EXT_DEBUG) { + options.timeout = 2 * 60 * 60 * 1000; +} + +testRunner.configure(options); + +const originalRun = testRunner.run; + +function reportCoverage( + coverageVariable: string, + matchFunction: MatcherFunction, + instrumenter: Instrumenter, + transformer: Transformer, +): void { + (hook as any).unhookRequire(); + + if (typeof global[coverageVariable] === 'undefined' || Object.keys(global[coverageVariable]).length === 0) { + console.error('No coverage information was collected, exit without writing coverage information'); + return; + } + const coverage = global[coverageVariable]; + + for (const file of (matchFunction.files || [])) { + if (coverage[file]) { + continue; + } + transformer(readFileSync(file, 'utf-8'), file); + + for (const key of Object.keys((instrumenter as any).coverState.s)) { + (instrumenter as any).coverState.s[key] = 0; + } + + coverage[file] = (instrumenter as any).coverState; + } + + const coverageDir = join(process.cwd(), 'coverage'); + const coverageFile = join(coverageDir, 'coverage.json'); + + ensureFileSync(coverageFile); + writeFileSync(coverageFile, JSON.stringify(coverage), 'utf8'); + + const remappedCollector = remapIstanbul.remap(coverage, { + warn: () => { }, + }); + + const reporter = new Reporter(undefined, coverageDir); + reporter.add('lcov'); + reporter.write(remappedCollector, true, () => { + console.log(`reports written to ${coverageDir}`); + }); +} + +testRunner.run = (testRoot: string, callback: (error: Error | null) => void) => { + if (process.env.CI || process.env.COVERAGE) { + const coverageVariable = `$$cov_${new Date().getTime()}$$`; + const sourceRoot = join(testRoot, '../../src'); + const sourceFiles = glob.sync('**/**.js', { cwd: sourceRoot, ignore: ['ioc*.js'] }); + const fileMap = {}; + const instrumenter = new Instrumenter({ coverageVariable }); + + for (const file of sourceFiles) { + const fullPath = join(sourceRoot, file); + fileMap[fullPath] = true; + const decache = require('decache'); + decache(fullPath); + } + + const matchFunction: MatcherFunction = file => fileMap[file]; + matchFunction.files = Object.keys(fileMap); + + const hookOpts = { verbose: false, extensions: ['.js'] }; + const transformer = instrumenter.instrumentSync.bind(instrumenter); + (hook as any).hookRequire(matchFunction, transformer, hookOpts); + + global[coverageVariable] = {}; + + process.on('exit', () => { + reportCoverage( + coverageVariable, + matchFunction, + instrumenter, + transformer, + ); + }); + } + + const { default: ioc } = require('../../src/ioc'); + const { default: iocSymbols } = require('../../src/ioc-symbols'); + ioc.bind(iocSymbols.extensionContext).toConstantValue(new ContextMock()); + + originalRun(testRoot, callback); +}; + +module.exports = testRunner; diff --git a/test/tests/setup.ts b/test/tests/setup.ts new file mode 100644 index 0000000..f6a78be --- /dev/null +++ b/test/tests/setup.ts @@ -0,0 +1,28 @@ +import { expect as chaiExpect, use } from 'chai'; +import { join, parse } from 'path'; + +const chaiJestSnapshot = require('chai-jest-snapshot'); + +declare global { + namespace Chai { + interface Assertion { + matchSnapshot(): Assertion; + } + } +} + +use(chaiJestSnapshot); + +before(() => { + chaiJestSnapshot.resetSnapshotRegistry(); +}); + +beforeEach(function (): void { + const fileFromTestRoot = ((this.currentTest as any).file.replace(/.*out[\\/]/, '')).replace(/\.js$/, '.ts'); + const tsFile = parse(join(global['rootPath'], fileFromTestRoot)); + const snapPath = join(tsFile.dir, '__snapshots__', tsFile.base); + chaiJestSnapshot.configureUsingMochaContext(this); + chaiJestSnapshot.setFilename(`${snapPath}.snap`); +}); + +export const expect = chaiExpect; diff --git a/yarn.lock b/yarn.lock index ef0f351..ed8c6ea 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3,13 +3,14 @@ "@octokit/rest@^14.0.3": - version "14.0.5" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-14.0.5.tgz#6d130aa0c0024e2e2c8a4e3a48373f70b6ba983e" + version "14.0.8" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-14.0.8.tgz#594292f9c30eb86a832f99f7d464ee7c9c8114c5" dependencies: before-after-hook "^1.1.0" debug "^3.1.0" dotenv "^4.0.0" https-proxy-agent "^2.1.0" + is-array-buffer "^1.0.0" is-stream "^1.1.0" lodash "^4.17.4" proxy-from-env "^1.0.0" @@ -45,8 +46,8 @@ url-join "^3.0.0" "@semantic-release/npm@^2.0.0": - version "2.6.4" - resolved "https://registry.yarnpkg.com/@semantic-release/npm/-/npm-2.6.4.tgz#0343816d94f3d1d6539c216c2886391647e3f9b7" + version "2.7.0" + resolved "https://registry.yarnpkg.com/@semantic-release/npm/-/npm-2.7.0.tgz#69d6b28c969c658458135eb8d725356c73a7320a" dependencies: "@semantic-release/error" "^2.1.0" debug "^3.1.0" @@ -61,11 +62,11 @@ registry-auth-token "^3.3.1" "@semantic-release/release-notes-generator@^6.0.0": - version "6.0.4" - resolved "https://registry.yarnpkg.com/@semantic-release/release-notes-generator/-/release-notes-generator-6.0.4.tgz#babf4bfb8374b73b8f2a27b04cc14f564f53aed7" + version "6.0.5" + resolved "https://registry.yarnpkg.com/@semantic-release/release-notes-generator/-/release-notes-generator-6.0.5.tgz#cd98a374a525d524a82ee767287b65d533f467d3" dependencies: conventional-changelog-angular "^1.4.0" - conventional-changelog-writer "^2.0.1" + conventional-changelog-writer "^3.0.0" conventional-commits-parser "^2.0.0" debug "^3.1.0" get-stream "^3.0.0" @@ -81,17 +82,21 @@ tslint-config-airbnb "~5.4.2" tslint-react "^3.2.0" -"@types/chai@*", "@types/chai@^4.1.1": +"@types/chai@*", "@types/chai@^4.1.2": version "4.1.2" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.2.tgz#f1af664769cfb50af805431c407425ed619daa21" -"@types/mocha@^2.2.46": - version "2.2.47" - resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.47.tgz#30bbd880834d4af0f609025f282a69b8d4458f06" +"@types/istanbul@^0.4.29": + version "0.4.29" + resolved "https://registry.yarnpkg.com/@types/istanbul/-/istanbul-0.4.29.tgz#29c8cbb747ac57280965545dc58514ba0dbb99af" -"@types/node@*", "@types/node@^9.3.0": - version "9.3.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-9.3.0.tgz#3a129cda7c4e5df2409702626892cb4b96546dd5" +"@types/mocha@^2.2.48": + version "2.2.48" + resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-2.2.48.tgz#3523b126a0b049482e1c3c11877460f76622ffab" + +"@types/node@*", "@types/node@^9.4.0": + version "9.4.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-9.4.0.tgz#b85a0bcf1e1cc84eb4901b7e96966aedc6f078d1" "@types/reflect-metadata@0.1.0": version "0.1.0" @@ -117,6 +122,14 @@ JSONStream@^1.0.4: jsonparse "^1.2.0" through ">=2.2.7 <3" +abbrev@1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" + +abbrev@1.0.x: + version "1.0.9" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" + acorn-jsx@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b" @@ -127,9 +140,9 @@ acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" -acorn@^5.2.1: - version "5.3.0" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" +acorn@^5.4.0: + version "5.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.4.1.tgz#fdc58d9d17f4a4e98d102ded826a9b9759125102" agent-base@^4.1.0: version "4.2.0" @@ -137,6 +150,13 @@ agent-base@^4.1.0: dependencies: es6-promisify "^5.0.0" +aggregate-error@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-1.0.0.tgz#888344dad0220a72e3af50906117f48771925fac" + dependencies: + clean-stack "^1.0.0" + indent-string "^3.0.0" + ajv-keywords@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" @@ -158,7 +178,7 @@ align-text@^0.1.1, align-text@^0.1.3: longest "^1.0.1" repeat-string "^1.5.2" -amdefine@>=0.0.4: +amdefine@>=0.0.4, amdefine@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/amdefine/-/amdefine-1.0.1.tgz#4a5282ac164729e93619bcfd3ad151f817ce91f5" @@ -202,7 +222,7 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.1.0: +ansi-styles@^3.1.0, ansi-styles@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.0.tgz#c159b8d5be0f9e5a6f346dab94f16ce022161b88" dependencies: @@ -308,7 +328,7 @@ assertion-error@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" -async@^1.0.0, async@^1.4.0: +async@1.x, async@^1.0.0, async@^1.4.0: version "1.5.2" resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a" @@ -431,6 +451,10 @@ caller-path@^0.1.0: dependencies: callsites "^0.2.0" +callsite@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/callsite/-/callsite-1.0.0.tgz#280398e5d664bd74038b6f0905153e6e8af1bc20" + callsites@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca" @@ -480,6 +504,13 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" +chai-jest-snapshot@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/chai-jest-snapshot/-/chai-jest-snapshot-2.0.0.tgz#a1fd340db4a9c7cd93e00466d8bab97d5e71a433" + dependencies: + jest-snapshot "21.2.1" + lodash.values "^4.3.0" + chai@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c" @@ -532,6 +563,10 @@ circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" +clean-stack@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-1.3.0.tgz#9e821501ae979986c46b1d66d2d432db2fd4ae31" + cli-boxes@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143" @@ -661,8 +696,8 @@ commander@2.11.0: resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563" commander@^2.11.0, commander@^2.12.1, commander@^2.8.1, commander@^2.9.0: - version "2.13.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-2.13.0.tgz#6964bca67685df7c1f1430c584f07d7597885b9c" + version "2.14.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.14.0.tgz#7b25325963e6aace20d3a9285b09379b0c2208b5" compare-func@^1.3.1: version "1.3.2" @@ -710,15 +745,15 @@ contains-path@^0.1.0: resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" conventional-changelog-angular@^1.4.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.0.tgz#0a26a071f2c9fcfcf2b86ba0cfbf6e6301b75bfa" + version "1.6.2" + resolved "https://registry.yarnpkg.com/conventional-changelog-angular/-/conventional-changelog-angular-1.6.2.tgz#0a811313de46326e5e4e11dac281d61cfe1f00c4" dependencies: compare-func "^1.3.1" q "^1.4.1" -conventional-changelog-writer@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-2.0.3.tgz#073b0c39f1cc8fc0fd9b1566e93833f51489c81c" +conventional-changelog-writer@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/conventional-changelog-writer/-/conventional-changelog-writer-3.0.0.tgz#e106154ed94341e387d717b61be2181ff53254cc" dependencies: compare-func "^1.3.1" conventional-commits-filter "^1.1.1" @@ -739,8 +774,8 @@ conventional-commits-filter@^1.1.1: modify-values "^1.0.0" conventional-commits-parser@^2.0.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.1.0.tgz#9b4b7c91124bf2a1a9a2cc1c72760d382cbbb229" + version "2.1.1" + resolved "https://registry.yarnpkg.com/conventional-commits-parser/-/conventional-commits-parser-2.1.1.tgz#1525a01bdad3349297b4210396e283d8a8ffd044" dependencies: JSONStream "^1.0.4" is-text-path "^1.0.0" @@ -855,6 +890,12 @@ debug@^2.6.8, debug@^2.6.9: dependencies: ms "2.0.0" +decache@^4.4.0: + version "4.4.0" + resolved "https://registry.yarnpkg.com/decache/-/decache-4.4.0.tgz#6f6df6b85d7e7c4410a932ffc26489b78e9acd13" + dependencies: + callsite "^1.0.0" + decamelize@^1.0.0, decamelize@^1.1.2: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -1078,8 +1119,8 @@ entities@^1.1.1, entities@~1.1.1: resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0" env-ci@^1.0.0: - version "1.2.1" - resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-1.2.1.tgz#3973dd365289df494fe6fbacbf208486d79c4207" + version "1.4.0" + resolved "https://registry.yarnpkg.com/env-ci/-/env-ci-1.4.0.tgz#d5a81534fb25c9dd8627c61e8db0d45bcbb7ef2c" dependencies: execa "^0.9.0" java-properties "^0.2.9" @@ -1108,6 +1149,17 @@ escape-string-regexp@1.0.5, escape-string-regexp@^1.0.2, escape-string-regexp@^1 version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" +escodegen@1.8.x: + version "1.8.1" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.8.1.tgz#5a5b53af4693110bebb0867aa3430dd3b70a1018" + dependencies: + esprima "^2.7.1" + estraverse "^1.9.1" + esutils "^2.0.2" + optionator "^0.8.1" + optionalDependencies: + source-map "~0.2.0" + eslint-config-standard@^10.2.1: version "10.2.1" resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-10.2.1.tgz#c061e4d066f379dc17cd562c64e819b4dd454591" @@ -1170,8 +1222,8 @@ eslint-visitor-keys@^1.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d" eslint@^4.11.0: - version "4.16.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.16.0.tgz#934ada9e98715e1d7bbfd6f6f0519ed2fab35cc1" + version "4.17.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.17.0.tgz#dc24bb51ede48df629be7031c71d9dc0ee4f3ddf" dependencies: ajv "^5.3.0" babel-code-frame "^6.22.0" @@ -1212,13 +1264,13 @@ eslint@^4.11.0: text-table "~0.2.0" espree@^3.5.2: - version "3.5.2" - resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca" + version "3.5.3" + resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.3.tgz#931e0af64e7fbbed26b050a29daad1fc64799fa6" dependencies: - acorn "^5.2.1" + acorn "^5.4.0" acorn-jsx "^3.0.0" -esprima@^2.6.0: +esprima@2.7.x, esprima@^2.6.0, esprima@^2.7.1: version "2.7.3" resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" @@ -1243,6 +1295,10 @@ esrecurse@^4.1.0: estraverse "^4.1.0" object-assign "^4.0.1" +estraverse@^1.9.1: + version "1.9.3" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-1.9.3.tgz#af67f2dc922582415950926091a4005d29c9bb44" + estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" @@ -1560,8 +1616,8 @@ git-up@^2.0.0: parse-url "^1.3.0" git-url-parse@^8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/git-url-parse/-/git-url-parse-8.0.0.tgz#249430c84e6b11ebae630136f50d7993eb03e211" + version "8.0.1" + resolved "https://registry.yarnpkg.com/git-url-parse/-/git-url-parse-8.0.1.tgz#eb3fa427e294d214d9abbeb59637cc8646279c00" dependencies: git-up "^2.0.0" @@ -1609,7 +1665,7 @@ glob@7.1.2, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^5.0.3: +glob@^5.0.15, glob@^5.0.3: version "5.0.15" resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1" dependencies: @@ -1626,8 +1682,8 @@ global-dirs@^0.1.0: ini "^1.3.4" globals@^11.0.1: - version "11.2.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-11.2.0.tgz#aa2ece052a787563ba70a3dcd9dc2eb8a9a0488c" + version "11.3.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.3.0.tgz#e04fdb7b9796d8adac9c8f64c14837b2313378b0" globby@^5.0.0: version "5.0.0" @@ -1794,7 +1850,7 @@ gulplog@^1.0.0: dependencies: glogg "^1.0.0" -handlebars@^4.0.2: +handlebars@^4.0.1, handlebars@^4.0.2: version "4.0.11" resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.11.tgz#630a35dfe0294bc281edae6ffc5d329fc7982dcc" dependencies: @@ -1830,6 +1886,10 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" +has-flag@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" + has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" @@ -1880,6 +1940,10 @@ hoek@4.x.x: version "4.2.0" resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d" +hook-std@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/hook-std/-/hook-std-0.4.0.tgz#fa8b2f84d358763137cb7d17e3308b28714bd174" + hosted-git-info@^2.1.4, hosted-git-info@^2.4.2: version "2.5.0" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.5.0.tgz#6d60e34b3abbc8313062c3b798ef8d901a07af3c" @@ -1946,6 +2010,10 @@ indent-string@^2.1.0: dependencies: repeating "^2.0.0" +indent-string@^3.0.0: + version "3.2.0" + resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.2.0.tgz#4a5fd6d27cc332f37e5419a504dbb837105c9289" + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -1987,9 +2055,13 @@ into-stream@^3.1.0: from2 "^2.1.1" p-is-promise "^1.1.0" -inversify@^4.9.0: - version "4.9.0" - resolved "https://registry.yarnpkg.com/inversify/-/inversify-4.9.0.tgz#caa01f5856cfa0499aaaed9b1a635ef0c4a9f4d3" +inversify@^4.10.0: + version "4.10.0" + resolved "https://registry.yarnpkg.com/inversify/-/inversify-4.10.0.tgz#06b97792e69220dd150b986cde9a445b3bcb9482" + +is-array-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-array-buffer/-/is-array-buffer-1.0.0.tgz#f32497a0509d109423f472003f98bab6a8ea34cb" is-arrayish@^0.2.1: version "0.2.1" @@ -2201,10 +2273,61 @@ isstream@0.1.x, isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" +istanbul@0.4.5, istanbul@^0.4.5: + version "0.4.5" + resolved "https://registry.yarnpkg.com/istanbul/-/istanbul-0.4.5.tgz#65c7d73d4c4da84d4f3ac310b918fb0b8033733b" + dependencies: + abbrev "1.0.x" + async "1.x" + escodegen "1.8.x" + esprima "2.7.x" + glob "^5.0.15" + handlebars "^4.0.1" + js-yaml "3.x" + mkdirp "0.5.x" + nopt "3.x" + once "1.x" + resolve "1.1.x" + supports-color "^3.1.0" + which "^1.1.1" + wordwrap "^1.0.0" + java-properties@^0.2.9: version "0.2.10" resolved "https://registry.yarnpkg.com/java-properties/-/java-properties-0.2.10.tgz#2551560c25fa1ad94d998218178f233ad9b18f60" +jest-diff@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-21.2.1.tgz#46cccb6cab2d02ce98bc314011764bb95b065b4f" + dependencies: + chalk "^2.0.1" + diff "^3.2.0" + jest-get-type "^21.2.0" + pretty-format "^21.2.1" + +jest-get-type@^21.2.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-21.2.0.tgz#f6376ab9db4b60d81e39f30749c6c466f40d4a23" + +jest-matcher-utils@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-21.2.1.tgz#72c826eaba41a093ac2b4565f865eb8475de0f64" + dependencies: + chalk "^2.0.1" + jest-get-type "^21.2.0" + pretty-format "^21.2.1" + +jest-snapshot@21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-21.2.1.tgz#29e49f16202416e47343e757e5eff948c07fd7b0" + dependencies: + chalk "^2.0.1" + jest-diff "^21.2.1" + jest-matcher-utils "^21.2.1" + mkdirp "^0.5.1" + natural-compare "^1.4.0" + pretty-format "^21.2.1" + js-tokens@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" @@ -2216,7 +2339,7 @@ js-yaml@3.6.1: argparse "^1.0.7" esprima "^2.6.0" -js-yaml@^3.7.0, js-yaml@^3.9.0, js-yaml@^3.9.1: +js-yaml@3.x, js-yaml@^3.7.0, js-yaml@^3.9.0, js-yaml@^3.9.1: version "3.10.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc" dependencies: @@ -2477,9 +2600,13 @@ lodash.toarray@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.toarray/-/lodash.toarray-4.4.0.tgz#24c4bfcd6b2fba38bfd0594db1179d8e9b656561" +lodash.values@^4.3.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/lodash.values/-/lodash.values-4.3.0.tgz#a3a6c2b0ebecc5c2cba1c17e6e620fe81b53d347" + lodash@^4.0.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.1, lodash@^4.3.0: - version "4.17.4" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" + version "4.17.5" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.5.tgz#99a92d65c0272debe8c96b6057bc8fbfa3bed511" log-driver@1.2.5: version "1.2.5" @@ -2497,8 +2624,8 @@ lolex@^1.6.0: resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.6.0.tgz#3a9a0283452a47d7439e72731b9e07d7386e49f6" lolex@^2.2.0: - version "2.3.1" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.3.1.tgz#3d2319894471ea0950ef64692ead2a5318cff362" + version "2.3.2" + resolved "https://registry.yarnpkg.com/lolex/-/lolex-2.3.2.tgz#85f9450425103bf9e7a60668ea25dc43274ca807" longest@^1.0.1: version "1.0.1" @@ -2622,8 +2749,8 @@ mime@^2.0.3: resolved "https://registry.yarnpkg.com/mime/-/mime-2.2.0.tgz#161e541965551d3b549fa1114391e3a3d55b923b" mimic-fn@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" + version "1.2.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022" "minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4: version "3.0.4" @@ -2643,7 +2770,7 @@ minimist@~0.0.1: version "0.0.10" resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.10.tgz#de3f98543dbf96082be48ad1a0c7cda836301dcf" -mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1: +mkdirp@0.5.1, mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: @@ -2700,8 +2827,8 @@ nerf-dart@^1.0.0: resolved "https://registry.yarnpkg.com/nerf-dart/-/nerf-dart-1.0.0.tgz#e6dab7febf5ad816ea81cf5c629c5a0ebde72c1a" nise@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/nise/-/nise-1.2.0.tgz#079d6cadbbcb12ba30e38f1c999f36ad4d6baa53" + version "1.2.2" + resolved "https://registry.yarnpkg.com/nise/-/nise-1.2.2.tgz#9aa5edb500da38035884106e3c571341bc68b2c1" dependencies: formatio "^1.2.0" just-extend "^1.1.26" @@ -2728,6 +2855,12 @@ node.extend@~1.1.2: dependencies: is "^3.1.0" +nopt@3.x: + version "3.0.6" + resolved "https://registry.yarnpkg.com/nopt/-/nopt-3.0.6.tgz#c6465dbf08abcd4db359317f79ac68a646b28ff9" + dependencies: + abbrev "1" + normalize-package-data@^2.3.2, normalize-package-data@^2.3.4, "normalize-package-data@~1.0.1 || ^2.0.0": version "2.4.0" resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" @@ -2828,7 +2961,7 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" -once@^1.3.0, once@^1.3.3, once@^1.4.0: +once@1.x, once@^1.3.0, once@^1.3.3, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" dependencies: @@ -2851,7 +2984,7 @@ optimist@^0.6.1: minimist "~0.0.1" wordwrap "~0.0.2" -optionator@^0.8.2: +optionator@^0.8.1, optionator@^0.8.2: version "0.8.2" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64" dependencies: @@ -2912,6 +3045,10 @@ p-reduce@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" +p-reflect@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-reflect/-/p-reflect-1.0.0.tgz#f4fa1ee1bb546d8eb3ec0321148dfe0a79137bb8" + p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" @@ -3098,6 +3235,13 @@ preserve@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" +pretty-format@^21.2.1: + version "21.2.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-21.2.1.tgz#ae5407f3cf21066cd011aa1ba5fce7b6a2eddb36" + dependencies: + ansi-regex "^3.0.0" + ansi-styles "^3.2.0" + process-nextick-args@^1.0.6, process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" @@ -3139,8 +3283,8 @@ qs@~6.5.1: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" query-string@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.0.1.tgz#6e2b86fe0e08aef682ecbe86e85834765402bd88" + version "5.1.0" + resolved "https://registry.yarnpkg.com/query-string/-/query-string-5.1.0.tgz#9583b15fd1307f899e973ed418886426a9976469" dependencies: decode-uri-component "^0.2.0" object-assign "^4.1.0" @@ -3170,8 +3314,8 @@ randomatic@^1.1.3: kind-of "^4.0.0" rc@^1.0.1, rc@^1.1.6: - version "1.2.4" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.4.tgz#a0f606caae2a3b862bbd0ef85482c0125b315fa3" + version "1.2.5" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.5.tgz#275cd687f6e3b36cc756baa26dfee80a790301fd" dependencies: deep-extend "~0.4.0" ini "~1.3.0" @@ -3259,6 +3403,17 @@ readable-stream@~1.1.9: isarray "0.0.1" string_decoder "~0.10.x" +readable-stream@~2.0.0: + version "2.0.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.1" + isarray "~1.0.0" + process-nextick-args "~1.0.6" + string_decoder "~0.10.x" + util-deprecate "~1.0.1" + redent@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/redent/-/redent-1.0.0.tgz#cf916ab1fd5f1f16dfb20822dd6ec7f730c2afde" @@ -3295,6 +3450,17 @@ registry-url@^3.0.3: dependencies: rc "^1.0.1" +remap-istanbul@^0.10.1: + version "0.10.1" + resolved "https://registry.yarnpkg.com/remap-istanbul/-/remap-istanbul-0.10.1.tgz#3aa58dd5021d499f336d3ba5bf3bbb91c1b88e37" + dependencies: + amdefine "^1.0.0" + istanbul "0.4.5" + minimatch "^3.0.3" + plugin-error "^0.1.2" + source-map "^0.6.1" + through2 "2.0.1" + remove-trailing-separator@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" @@ -3400,6 +3566,10 @@ resolve-from@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" +resolve@1.1.x: + version "1.1.7" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" + resolve@^1.3.2, resolve@^1.3.3, resolve@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36" @@ -3472,15 +3642,16 @@ semantic-release-vsce@^2.0.0: semver "^5.4.1" vsce "^1.33.2" -semantic-release@^12.2.2: - version "12.2.5" - resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-12.2.5.tgz#595cdffc4226a1974c3257052b6ee259c2353568" +semantic-release@^12.4.1: + version "12.4.1" + resolved "https://registry.yarnpkg.com/semantic-release/-/semantic-release-12.4.1.tgz#4faeee44fe7fbebbc7af8cc9e3522eb7877a0260" dependencies: "@semantic-release/commit-analyzer" "^5.0.0" "@semantic-release/error" "^2.1.0" "@semantic-release/github" "^3.0.1" "@semantic-release/npm" "^2.0.0" "@semantic-release/release-notes-generator" "^6.0.0" + aggregate-error "^1.0.0" chalk "^2.3.0" commander "^2.11.0" cosmiconfig "^4.0.0" @@ -3489,10 +3660,12 @@ semantic-release@^12.2.2: execa "^0.9.0" get-stream "^3.0.0" git-log-parser "^1.2.0" + hook-std "^0.4.0" lodash "^4.17.4" marked "^0.3.9" marked-terminal "^2.0.0" p-reduce "^1.0.0" + p-reflect "^1.0.0" read-pkg-up "^3.0.0" resolve-from "^4.0.0" semver "^5.4.1" @@ -3533,9 +3706,9 @@ sinon-chai@^2.14.0: version "2.14.0" resolved "https://registry.yarnpkg.com/sinon-chai/-/sinon-chai-2.14.0.tgz#da7dd4cc83cd6a260b67cca0f7a9fdae26a1205d" -sinon@^4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-4.2.1.tgz#3664e90ea4bccec6ebde3c06e3da8179983371d9" +sinon@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/sinon/-/sinon-4.2.2.tgz#e039ab27bdb426fc61363c380726e996a2e2c620" dependencies: diff "^3.1.0" formatio "1.2.0" @@ -3589,10 +3762,16 @@ source-map@^0.4.4: dependencies: amdefine ">=0.0.4" -source-map@^0.6.0: +source-map@^0.6.0, source-map@^0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" +source-map@~0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.2.0.tgz#dab73fbcfc2ba819b4de03bd6f6eaa48164b3f9d" + dependencies: + amdefine ">=0.0.4" + source-map@~0.5.1: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" @@ -3788,6 +3967,12 @@ supports-color@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" +supports-color@^3.1.0: + version "3.2.3" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" + dependencies: + has-flag "^1.0.0" + supports-color@^4.0.0: version "4.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" @@ -3848,6 +4033,13 @@ through2-filter@^2.0.0: through2 "~2.0.0" xtend "~4.0.0" +through2@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.1.tgz#384e75314d49f32de12eebb8136b8eb6b5d59da9" + dependencies: + readable-stream "~2.0.0" + xtend "~4.0.0" + through2@^0.6.0, through2@~0.6.5: version "0.6.5" resolved "https://registry.yarnpkg.com/through2/-/through2-0.6.5.tgz#41ab9c67b29d57209071410e1d7a7a968cd3ad48" @@ -3914,7 +4106,7 @@ triple-beam@^1.0.1: version "1.1.0" resolved "https://registry.yarnpkg.com/triple-beam/-/triple-beam-1.1.0.tgz#2ac387c8c4bd04bd26c61df891a6079f8592fe10" -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" @@ -3927,11 +4119,11 @@ tslint-config-airbnb@~5.4.2: tslint-microsoft-contrib "~5.0.1" tslint-consistent-codestyle@^1.10.0: - version "1.11.0" - resolved "https://registry.yarnpkg.com/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.11.0.tgz#051493eeb3536a74e98d14b66f38028a785f8c2b" + version "1.11.1" + resolved "https://registry.yarnpkg.com/tslint-consistent-codestyle/-/tslint-consistent-codestyle-1.11.1.tgz#fa39ff5f5f8a25c537bd1e1f50de6190a2f4d70d" dependencies: tslib "^1.7.1" - tsutils "^2.12.2" + tsutils "^2.21.0" tslint-eslint-rules@^4.1.1: version "4.1.1" @@ -3974,9 +4166,9 @@ tsutils@^1.4.0: version "1.9.1" resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0" -tsutils@^2.12.1, tsutils@^2.12.2, tsutils@^2.13.1, tsutils@^2.19.1: - version "2.19.1" - resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.19.1.tgz#76d7ebdea9d7a7bf4a05f50ead3701b0168708d7" +tsutils@^2.12.1, tsutils@^2.13.1, tsutils@^2.21.0: + version "2.21.0" + resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.21.0.tgz#43466a2283a0abce64e2209bc732ad72f8a04fab" dependencies: tslib "^1.8.1" @@ -4005,8 +4197,8 @@ type-check@~0.3.2: prelude-ls "~1.1.2" type-detect@^4.0.0, type-detect@^4.0.5: - version "4.0.7" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.7.tgz#862bd2cf6058ad92799ff5a5b8cf7b6cec726198" + version "4.0.8" + resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" typed-rest-client@^0.9.0: version "0.9.0" @@ -4028,13 +4220,13 @@ typescript-parser@^2.2.2: tslib "^1.7.1" typescript "^2.5.3" -typescript@^2.5.3, typescript@~2.6.2: - version "2.6.2" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.6.2.tgz#3c5b6fd7f6de0914269027f03c0946758f7673a4" +typescript@^2.5.3, typescript@~2.7.1: + version "2.7.1" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.1.tgz#bb3682c2c791ac90e7c6210b26478a8da085c359" uc.micro@^1.0.1, uc.micro@^1.0.3: - version "1.0.3" - resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.3.tgz#7ed50d5e0f9a9fb0a573379259f2a77458d50192" + version "1.0.5" + resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376" uglify-js@^2.6: version "2.8.29" @@ -4222,8 +4414,8 @@ vinyl@~2.0.1: replace-ext "^1.0.0" vsce@^1.33.2: - version "1.36.1" - resolved "https://registry.yarnpkg.com/vsce/-/vsce-1.36.1.tgz#f74a0db46abc4fb17cd9940457211d8f09ee58ed" + version "1.36.2" + resolved "https://registry.yarnpkg.com/vsce/-/vsce-1.36.2.tgz#dfcfca722bc6aa6bfcbffb1efd23176ba99b2944" dependencies: cheerio "^1.0.0-rc.1" commander "^2.8.1" @@ -4271,7 +4463,7 @@ vso-node-api@^6.1.2-preview: typed-rest-client "^0.9.0" underscore "^1.8.3" -which@^1.2.9: +which@^1.1.1, which@^1.2.9: version "1.3.0" resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a" dependencies: @@ -4314,14 +4506,14 @@ wordwrap@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" +wordwrap@^1.0.0, wordwrap@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" + wordwrap@~0.0.2: version "0.0.3" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" -wordwrap@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb" - wrappy@1: version "1.0.2" resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" From bc1221678e398c949f7b42851709ffaf118cfda7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Thu, 8 Feb 2018 12:56:09 +0100 Subject: [PATCH 7/8] fix(logging): output panel does not pop up when tsh starts (#401) Fixes #390. Remove the call to `.show()` on the output channel and does refactor some logging messages. --- src/code-outline/index.ts | 14 ++++----- src/declarations/declaration-manager.ts | 18 +++++------ src/declarations/workspace-declarations.ts | 25 ++++++++++----- src/import-organizer/import-manager.ts | 8 ++--- src/import-organizer/index.ts | 36 +++++++++++----------- src/typescript-hero.ts | 8 ++--- src/utilities/logger.ts | 3 -- 7 files changed, 59 insertions(+), 53 deletions(-) diff --git a/src/code-outline/index.ts b/src/code-outline/index.ts index 6b9ea51..b1f8b28 100644 --- a/src/code-outline/index.ts +++ b/src/code-outline/index.ts @@ -45,7 +45,7 @@ export default class CodeOutline implements Activatable, TreeDataProvider { if (this.config.codeOutline.isEnabled() && !this.disposables) { this.start(); @@ -61,10 +61,10 @@ export default class CodeOutline implements Activatable, TreeDataProvider(); this.disposables.push(window.registerTreeDataProvider('codeOutline', this)); this.disposables.push(this._onDidChangeTreeData); @@ -74,10 +74,10 @@ export default class CodeOutline implements Activatable, TreeDataProvider e.uri.scheme === 'file'); this.logger.info( - 'Workspaces changed, adjusting indices', + '[DeclarationManager] Workspaces changed, adjusting indices', { added: added.map(e => e.uri.fsPath), removed: removed.map(e => e.uri.fsPath) }, ); for (const add of event.added) { if (this.workspaces[add.uri.fsPath]) { this.logger.warn( - 'Workspace index already exists, skipping', + '[DeclarationManager] Workspace index already exists, skipping', { workspace: add.uri.fsPath }, ); continue; @@ -111,22 +111,22 @@ export default class DeclarationManager implements Disposable { return; } if (state === WorkspaceDeclarationsState.Error) { - this.logger.error('A workspace did encounter an error.'); + this.logger.error('[DeclarationManager] A workspace did encounter an error.'); this.statusBarItem.text = ResolverState.error; return; } if (state === WorkspaceDeclarationsState.Syncing) { - this.logger.debug('A workspace is syncing it\'s files.'); + this.logger.debug('[DeclarationManager] A workspace is syncing it\'s files.'); this.activeWorkspaces++; this.statusBarItem.text = ResolverState.syncing; return; } if (state === WorkspaceDeclarationsState.Idle) { - this.logger.debug('A workspace is done syncing it\'s files.'); + this.logger.debug('[DeclarationManager] A workspace is done syncing it\'s files.'); this.activeWorkspaces--; } if (this.activeWorkspaces <= 0) { - this.logger.debug('All workspaces are done syncing.'); + this.logger.debug('[DeclarationManager] All workspaces are done syncing.'); this.statusBarItem.text = ResolverState.ok; } } diff --git a/src/declarations/workspace-declarations.ts b/src/declarations/workspace-declarations.ts index 56aa82f..2f8c736 100644 --- a/src/declarations/workspace-declarations.ts +++ b/src/declarations/workspace-declarations.ts @@ -44,13 +44,19 @@ export default class WorkspaceDeclarations implements Disposable { constructor( private readonly folder: WorkspaceFolder, ) { - this.logger.debug('Creating workspace declarations index.', { workspace: this.folder.uri.fsPath }); + this.logger.debug( + '[WorkspaceDeclarations] Creating workspace declarations index.', + { workspace: this.folder.uri.fsPath }, + ); this.disposables.push(this._workspaceStateChanged); this.initialize(); } public dispose(): void { - this.logger.debug('Disposing workspace declarations index.', { workspace: this.folder.uri.fsPath }); + this.logger.debug( + '[WorkspaceDeclarations] Disposing workspace declarations index.', + { workspace: this.folder.uri.fsPath }, + ); for (const disposable of this.disposables) { disposable.dispose(); } @@ -63,7 +69,10 @@ export default class WorkspaceDeclarations implements Disposable { this._index = new DeclarationIndex(this.parser, this.folder.uri.fsPath); const files = await this.findFiles(); - this.logger.info(`Found ${files.length} files in workspace.`, { workspace: this.folder.uri.fsPath }); + this.logger.info( + `[WorkspaceDeclarations] Found ${files.length} files in workspace.`, + { workspace: this.folder.uri.fsPath }, + ); const watcher = workspace.createFileSystemWatcher( new RelativePattern( this.folder, @@ -82,13 +91,13 @@ export default class WorkspaceDeclarations implements Disposable { this._workspaceStateChanged.fire(WorkspaceDeclarationsState.Idle); profiler.done({ - message: 'Built index for workspace.', + message: '[WorkspaceDeclarations] Built index for workspace.', workspace: this.folder.uri.fsPath, }); } catch (error) { this._workspaceStateChanged.fire(WorkspaceDeclarationsState.Error); this.logger.error( - 'Error during indexing of workspacefiles.', + '[WorkspaceDeclarations] Error during indexing of workspacefiles.', { error: error.toString(), workspace: this.folder.uri.fsPath }, ); } @@ -151,7 +160,7 @@ export default class WorkspaceDeclarations implements Disposable { 'typings/**/*', ]; const moduleExcludes = this.config.index.moduleIgnorePatterns(this.folder.uri); - this.logger.debug('Calculated excludes for workspace.', { + this.logger.debug('[WorkspaceDeclarations] Calculated excludes for workspace.', { workspaceExcludes, moduleExcludes, workspace: this.folder.uri.fsPath, @@ -168,7 +177,7 @@ export default class WorkspaceDeclarations implements Disposable { const hasPackageJson = await exists(join(rootPath, 'package.json')); if (rootPath && hasPackageJson) { - this.logger.debug('Found package.json, calculate searchable node modules.', { + this.logger.debug('[WorkspaceDeclarations] Found package.json, calculate searchable node modules.', { workspace: this.folder.uri.fsPath, packageJson: join(rootPath, 'package.json'), }); @@ -194,7 +203,7 @@ export default class WorkspaceDeclarations implements Disposable { } } - this.logger.debug('Calculated node module search.', { + this.logger.debug('[WorkspaceDeclarations] Calculated node module search.', { globs, ignores, workspace: this.folder.uri.fsPath, diff --git a/src/import-organizer/import-manager.ts b/src/import-organizer/import-manager.ts index 0de1ed5..50c7a1c 100644 --- a/src/import-organizer/import-manager.ts +++ b/src/import-organizer/import-manager.ts @@ -100,7 +100,7 @@ export default class ImportManager { private readonly generatorFactory: TypescriptCodeGeneratorFactory, ) { this.logger.debug( - `Create import manager`, + `[ImportManager] Create import manager`, { file: document.fileName }, ); this.reset(); @@ -129,7 +129,7 @@ export default class ImportManager { */ public organizeImports(): this { this.logger.debug( - 'Organize the imports', + '[ImportManager] Organize the imports', { file: this.document.fileName }, ); this.organize = true; @@ -212,7 +212,7 @@ export default class ImportManager { */ public addDeclarationImport(declarationInfo: DeclarationInfo): this { this.logger.debug( - 'Add declaration as import', + '[ImportManager] Add declaration as import', { file: this.document.fileName, specifier: declarationInfo.declaration.name, library: declarationInfo.from }, ); // If there is something already imported, it must be a NamedImport @@ -272,7 +272,7 @@ export default class ImportManager { workspaceEdit.set(this.document.uri, edits); this.logger.debug( - 'Commit the file', + '[ImportManager] Commit the file', { file: this.document.fileName }, ); diff --git a/src/import-organizer/index.ts b/src/import-organizer/index.ts index 6930804..d34116a 100644 --- a/src/import-organizer/index.ts +++ b/src/import-organizer/index.ts @@ -24,7 +24,7 @@ export default class ImportOrganizer implements Activatable { ) { } public setup(): void { - this.logger.debug('Setting up ImportOrganizer.'); + this.logger.debug('[ImportOrganizer] Setting up ImportOrganizer.'); this.context.subscriptions.push( commands.registerTextEditorCommand('typescriptHero.imports.organize', () => this.organizeImports()), ); @@ -41,20 +41,20 @@ export default class ImportOrganizer implements Activatable { workspace.onWillSaveTextDocument((event) => { if (!this.config.imports.organizeOnSave(event.document.uri)) { this.logger.debug( - 'OrganizeOnSave is deactivated through config', + '[ImportOrganizer] OrganizeOnSave is deactivated through config', ); return; } if (this.config.parseableLanguages().indexOf(event.document.languageId) < 0) { this.logger.debug( - 'OrganizeOnSave not possible for given language', + '[ImportOrganizer] OrganizeOnSave not possible for given language', { language: event.document.languageId }, ); return; } this.logger.info( - 'OrganizeOnSave for file', + '[ImportOrganizer] OrganizeOnSave for file', { file: event.document.fileName }, ); event.waitUntil( @@ -65,15 +65,15 @@ export default class ImportOrganizer implements Activatable { } public start(): void { - this.logger.info('Starting up ImportOrganizer.'); + this.logger.info('[ImportOrganizer] Starting up ImportOrganizer.'); } public stop(): void { - this.logger.info('Stopping ImportOrganizer.'); + this.logger.info('[ImportOrganizer] Stopping ImportOrganizer.'); } public dispose(): void { - this.logger.debug('Disposing ImportOrganizer.'); + this.logger.debug('[ImportOrganizer] Disposing ImportOrganizer.'); } /** @@ -90,14 +90,14 @@ export default class ImportOrganizer implements Activatable { } try { this.logger.debug( - 'Organize the imports in the document', + '[ImportOrganizer] Organize the imports in the document', { file: window.activeTextEditor.document.fileName }, ); const ctrl = await this.importManagerProvider(window.activeTextEditor.document); await ctrl.organizeImports().commit(); } catch (e) { this.logger.error( - 'Imports could not be organized, error: %s', + '[ImportOrganizer] Imports could not be organized, error: %s', e, { file: window.activeTextEditor.document.fileName }, ); @@ -129,14 +129,14 @@ export default class ImportOrganizer implements Activatable { ); if (selectedItem) { this.logger.info( - 'Add import to document', + '[ImportOrganizer] Add import to document', { specifier: selectedItem.declarationInfo.declaration.name, library: selectedItem.declarationInfo.from }, ); this.addImportToDocument(selectedItem.declarationInfo); } } catch (e) { this.logger.error( - 'Import could not be added to document', + '[ImportOrganizer] Import could not be added to document', { file: window.activeTextEditor.document.fileName, error: e.toString() }, ); window.showErrorMessage('The import cannot be completed, there was an error during the process.'); @@ -163,7 +163,7 @@ export default class ImportOrganizer implements Activatable { } try { const selectedSymbol = this.getSymbolUnderCursor(); - this.logger.debug('Add import for symbol under cursor', { selectedSymbol }); + this.logger.debug('[ImportOrganizer] Add import for symbol under cursor', { selectedSymbol }); if (!!!selectedSymbol) { return; } @@ -175,7 +175,7 @@ export default class ImportOrganizer implements Activatable { if (resolveItems.length < 1) { this.logger.info( - 'The symbol was not found or is already imported', + '[ImportOrganizer] The symbol was not found or is already imported', { selectedSymbol }, ); window.showInformationMessage( @@ -183,7 +183,7 @@ export default class ImportOrganizer implements Activatable { ); } else if (resolveItems.length === 1 && resolveItems[0].declaration.name === selectedSymbol) { this.logger.info( - 'Add import to document', + '[ImportOrganizer] Add import to document', { specifier: resolveItems[0].declaration.name, library: resolveItems[0].from, @@ -196,7 +196,7 @@ export default class ImportOrganizer implements Activatable { ); if (selectedItem) { this.logger.info( - 'Add import to document', + '[ImportOrganizer] Add import to document', { specifier: selectedItem.declarationInfo.declaration.name, library: selectedItem.declarationInfo.from, @@ -207,7 +207,7 @@ export default class ImportOrganizer implements Activatable { } } catch (e) { this.logger.error( - 'Import could not be added to document.', + '[ImportOrganizer] Import could not be added to document.', { file: window.activeTextEditor.document.fileName, error: e.toString() }, ); window.showErrorMessage('The import cannot be completed, there was an error during the process.'); @@ -239,7 +239,7 @@ export default class ImportOrganizer implements Activatable { } this.logger.debug( - 'Calculate possible imports for document', + '[ImportOrganizer] Calculate possible imports for document', { cursorSymbol, file: documentPath }, ); @@ -303,7 +303,7 @@ export default class ImportOrganizer implements Activatable { */ private showCacheWarning(): void { this.logger.warn( - 'index was not ready or not index for this file found', + '[ImportOrganizer] Index was not ready or not index for this file found', ); window.showWarningMessage('Please wait a few seconds longer until the symbol cache has been build.'); } diff --git a/src/typescript-hero.ts b/src/typescript-hero.ts index b284621..17c7f92 100644 --- a/src/typescript-hero.ts +++ b/src/typescript-hero.ts @@ -14,7 +14,7 @@ export default class TypescriptHero implements Activatable { ) { } public setup(): void { - this.logger.debug('Setting up extension and activatables.'); + this.logger.debug('[TypescriptHero] Setting up extension and activatables.'); this.extendCodeGenerator(); for (const activatable of this.activatables) { activatable.setup(); @@ -22,21 +22,21 @@ export default class TypescriptHero implements Activatable { } public start(): void { - this.logger.debug('Starting up extension and activatables.'); + this.logger.debug('[TypescriptHero] Starting up extension and activatables.'); for (const activatable of this.activatables) { activatable.start(); } } public stop(): void { - this.logger.debug('Stopping extension and activatables.'); + this.logger.debug('[TypescriptHero] Stopping extension and activatables.'); for (const activatable of this.activatables) { activatable.stop(); } } public dispose(): void { - this.logger.debug('Disposing extension and activatables.'); + this.logger.debug('[TypescriptHero] Disposing extension and activatables.'); for (const activatable of this.activatables) { activatable.dispose(); } diff --git a/src/utilities/logger.ts b/src/utilities/logger.ts index 3cce418..6a49476 100644 --- a/src/utilities/logger.ts +++ b/src/utilities/logger.ts @@ -75,7 +75,6 @@ export default function winstonLogger(verbosity: keyof typeof levels, context: E if (!process.env.CI && !process.env.EXT_DEBUG && !process.env.LOCAL_TEST) { const channel = window.createOutputChannel('TypeScript Hero'); context.subscriptions.push(channel); - channel.show(); const fileHandler = new transports.File({ level: ['info', 'debug'].indexOf(level) >= 0 ? level : 'info', @@ -92,8 +91,6 @@ export default function winstonLogger(verbosity: keyof typeof levels, context: E loggerTransports.push(outputHandler); exceptions.handle(fileHandler); - // exceptions.handle(outputHandler); - // exceptions.handle(new HandleUncatchedException(context.extensionPath)); } const logger = createLogger({ From 06a7f0806b9a8e177ae8b599632af6e6c0a2855d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BChler?= Date: Thu, 8 Feb 2018 13:27:40 +0100 Subject: [PATCH 8/8] docs: move documentation to wiki --- LICENSE | 4 +- README.md | 165 ------------------------------------------------------ 2 files changed, 2 insertions(+), 167 deletions(-) diff --git a/LICENSE b/LICENSE index 5a402f3..64bf4b4 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016 smartive +Copyright (c) 2018 Christoph Bühler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/README.md b/README.md index c250868..a7a6ce4 100644 --- a/README.md +++ b/README.md @@ -26,171 +26,6 @@ Here is a brief list, of what TypeScript Hero is capable of (more at the end): - Sort and organize your imports (sort and remove unused) - Code outline view of your open TS / TSX document -## Commands - -All commands are preceeded by `typescriptHero`. - -| Command | Extension part | Description | -| ---------------------------- | ---------------- | --------------------------------------------------------- | -| imports.organize | import organizer | Removes unused imports and orders all imports | - -## Keybindings - -The following commands are bound by default when the extension is installed. - -| Command | Keybinding | -| ---------------------------- | ------------------ | -| imports.organize | `ctrl+alt+o` | - -## Settings - -In the following tables, all possible settings are explained. If you find any -settings that are not listed here, that means they are "beta" or "not implemented yet". - -All settings are preceeded by `typescriptHero`. - -### General - -These settings do not have a prefix. - -| Setting | Description | -| ---------- | --------------------------------------------------------------------------------------- | -| verbosity | The log level that the extension writes its messages to the output channel and the file | - -### Import Organizer - -The following settings do have the prefix `imports`. So an example setting could be -`typescriptHero.imports.stringQuoteStyle`. - -| Setting | Description | -| ------------------------------------- | --------------------------------------------------------------------------------------------- | -| disableImportSorting | Disable sorting during organize imports action | -| disableImportRemovalOnOrganize | Disable removal unsed imports during organize imports action | -| insertSpaceBeforeAndAfterImportBraces | If the extension should place spaces into import braces (`{Symbol}` vs `{ Symbol }`) | -| insertSemicolons | If the extension should add a semicolon to the end of a statement | -| importGroups | The groups that are used for sorting the imports (description below) | -| ignoredFromRemoval | Imports that are never removed during organize import (e.g. react) | -| multiLineWrapThreshold | The threshold, when imports are converted into multiline imports | -| multiLineTrailingComma | When multiline imports are created, `true` inserts a trailing comma to the last line | -| organizeOnSave | Enable or disable the `organizeImports` action on a save of a document | -| organizeSortsByFirstSpecifier | When organizing runs, sort by first specifier/alias (if any) instead of module path | -| removeTrailingIndex | Remove trailing `/index` from imports, since that is javascript default to look there | -| stringQuoteStyle | The string delimiter to use for the imports (`'` or `"`) | - -### Code outline view - -The following settings do have the prefix `codeOutline`. So an example setting could be -`typescriptHero.codeOutline.enabled`. - -| Setting | Description | -| --------- | -------------------------------------------------------------------------- | -| enabled | Defines if the view should actually parse the opened documents | - -## Features (extended) - -### Import management - -TypeScript Hero can manage your imports. It is capable of: - -- Remove unused imports and sort the remaining ones by alphabet -- Do organize the imports when a document is saved - - Organizing used module paths by default, sorted lexicographically. An option lets you use first - import specifier/alias instead, in natural-language order. - -#### Import groups - -The import groups setting allows you to order all your imports as you may want. The settings is an array of elements. -An element can either be a string (with a certain keyword or a regex like string) or an object that contains an -identifier (with a certain keyword or a regex like string) and a sort order. The order you enter those objects / string -does matter since it is used to define the import groups. - -An example (complex) could be: - -```json -[ - "Plains", - "/@angular/", - { - "identifier": "/Foo[1-9]Bar/", - "order": "desc" - }, - "Workspace", - { - "identifier": "Remaining", - "order": "desc" - } -] -``` - -##### Keyword imports - -- `Modules` : contains all imports from modules (npm etc) `import ... from 'vscode';` -- `Plains` : contains all string only imports `import 'reflect-metadata;` -- `Workspace` : contains all local project files `import ... from '../server';` -- `Remaining` : contains all imports that are not matched by other import groups - -(_hint_: The `Remaining` group is added implicitly as the last import group if not added specifically) - -The default is as follows: - -```json -[ - "Plains", - "Modules", - "Workspace" -] -``` - -For everybody that just wants all imports ordered in asc or desc, just overwrite the default with: - -For all imports sorted asc: -```json -[] -``` - -For all imports sorted desc: -```json -[ - { - "identifier": "Remaining", - "order": "desc" - } -] -``` - -##### Regex imports - -The regex import group contains a regex string. Let's say you want to group all your `@angular` namespaced imports together -in one group you'd use `/@angular/` as "identifier" (either in the object when you want to change the order or just -the plain regex since default order is `asc`). - -(_hint_: only the name of the library is matched against the regex) - -```json -[ - "/@angular/" -] -``` - -The setting above would create two groups: one with all @angular imports another with all other imports. - -```typescript -import {http} from '@angular/http'; -import {component} from '@angular/core'; - -import 'reflect-metadata'; -import {Server} from './server'; -``` - -### Code outline view - -This view is below your file explorer. It displays a code outline of your actually opened typescript or typescript-react -file. If you switch your actual editor, the new file is parsed and shown. When you expand classes and imports, you'll -see what's in them. If you click on an element, the editor will jump to the location of the element. - -By now, only typescript / typescript-react is supported. Maybe this will wander in it's own extension to support -more languages than those two. - ## Known Issues Please visit [the issue list](https://github.com/buehler/typescript-hero/issues) :-)