These are simple test but they show how you can run them.
This commit is contained in:
Nick Chen 2017-06-20 21:41:45 -07:00
Родитель e32c8e6559
Коммит 37f0addae6
24 изменённых файлов: 243 добавлений и 97 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -7,6 +7,7 @@ logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Runtime data
pids

36
.vscode/launch.json поставляемый
Просмотреть файл

@ -13,9 +13,41 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/packages/*/dist/src/**/*.js"
"${workspaceRoot}/packages/*/out/src/**/*.js"
],
"preLaunchTask": "npm"
"preLaunchTask": "Watch"
},
{
"name": "Launch SalesforceDX VS Code Core Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}/packages",
"--extensionTestsPath=${workspaceRoot}/packages/salesforcedx-vscode-core/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/packages/*/out/test/**/*.js"
],
"preLaunchTask": "Watch"
},
{
"name": "Launch SalesforceDX VS Code Apex Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}/packages",
"--extensionTestsPath=${workspaceRoot}/packages/salesforcedx-vscode-apex/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/packages/*/out/test/**/*.js"
],
"preLaunchTask": "Watch"
}
]
}

4
.vscode/settings.json поставляемый
Просмотреть файл

@ -1,10 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"dist": true // set this to false to include "dist" folder in search results
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib",
"editor.formatOnSave": true // we want to use the TS server from our node_modules folder to control its version

46
.vscode/tasks.json поставляемый
Просмотреть файл

@ -5,26 +5,32 @@
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",
// we want to run npm
"command": "npm",
// the command is a shell script
"isShellCommand": true,
// show the output window only if unrecognized errors occur.
"showOutput": "silent",
// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],
// The tsc compiler is started in watching mode
"isWatching": true,
// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
"problemMatcher": "$tsc-watch",
"tasks": [
{
"taskName": "Bootstrap",
"command": "lerna",
"isShellCommand": true,
"showOutput": "silent",
"args": [
"bootstrap"
],
"isBackground": false
},
{
"taskName": "Watch",
"command": "lerna",
"isShellCommand": true,
"showOutput": "silent",
"args": [
"run",
"--parallel",
"watch"
],
"isBackground": true,
"problemMatcher": "$tsc-watch"
}
]
}

Просмотреть файл

@ -5,12 +5,14 @@
1. This repository uses [Lerna](https://lernajs.io/) to manage it as a
_monorepo_. Please install Lerna globally using `npm install
--global lerna`.
1. We use `tslint` so please install it using `npm install --global
tslint`.
1. It is preferred, though not required, that you use the Insiders
version of VS Code from
[here](https://code.visualstudio.com/insiders).
1. There is a list of recommended extensions for this workspace in
.vscode/extensions.json. The first time you open VS Code on this
workspace, it will ask you to install them. **Please do so since it
workspace, it will ask you to install them. **Please do so since this
includes the linters and formatters**.
## Structure
@ -27,8 +29,13 @@ installed normally through npm.
1. Clone this repository from git.
1. `cd` into `salesforcedx-vscode`.
1. Open the project in VS Code.
1. `lerna bootstrap`.
1. `lerna run --parallel watch`.
You would usually do the following each time you close/reopen VS Code:
1. Open the Command Palette > Tasks: Run Task > Bootstrap (this
essentially runs `lerna bootstrap`).
1. Open the Command Palette > Tasks: Run Task > Watch (this essentially
runs `lerna run --parallel watch`).
1. In VS Code, open the debug view (Ctrl+Shift+D or Cmd+Shift+D on Mac)
and from the launch configuration dropdown, pick "Launch Extensions".

1
packages/.gitignore поставляемый
Просмотреть файл

@ -1 +0,0 @@
lerna-debug.json

23
packages/salesforcedx-vscode-apex/.gitignore поставляемый
Просмотреть файл

@ -1,15 +1,3 @@
#
# TypeScript generated files
#
dist/
#
# Istanbul code coverage files
#
coverage/
#
# https://github.com/github/gitignore/blob/master/Node.gitignore
#
@ -53,4 +41,13 @@ jspm_packages
.node_repl_history
# Generated vscode package
*.vsix
*.vsix
# VS Code tests
.vscode-test/**
# TypeScript generated files
out/
# Istanbul code coverage files
coverage/

Просмотреть файл

@ -13,7 +13,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/src/**/*.js"
"${workspaceRoot}/out/src/**/*.js"
],
"preLaunchTask": "npm"
},
@ -24,12 +24,12 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/dist/test"
"--extensionTestsPath=${workspaceRoot}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/test/**/*.js"
"${workspaceRoot}/out/test/**/*.js"
],
"preLaunchTask": "npm"
}

Просмотреть файл

@ -1,10 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"dist": true // set this to false to include "dist" folder in search results
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
}

Просмотреть файл

@ -1,6 +1,6 @@
.vscode/**
.vscode-test/**
dist/test/**
out/test/**
test/**
src/**
**/*.map

Двоичные данные
packages/salesforcedx-vscode-apex/dist/apex-jorje-lsp.jar поставляемый

Двоичный файл не отображается.

Просмотреть файл

@ -13,9 +13,11 @@
"Languages"
],
"devDependencies": {
"@types/chai": "^4.0.0",
"@types/mocha": "2.2.38",
"@types/node": "^6.0.40",
"@types/path-exists": "^1.0.29",
"chai": "^4.0.2",
"mocha": "3.2.0",
"typescript": "2.3.4",
"vscode": "1.1.0"
@ -24,13 +26,14 @@
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -p ./",
"watch": "tsc -watch -p .",
"clean": "rm -rf node_modules && rm -rf dist",
"postinstall": "node ./node_modules/vscode/bin/install"
"clean": "rm -rf node_modules && rm -rf out",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test"
},
"activationEvents": [
"workspaceContains:sfdx-project.json"
],
"main": "./dist/src",
"main": "./out/src",
"contributes": {
"languages": [
{

Просмотреть файл

@ -4,4 +4,4 @@ JORJE_LOCATION=/Users/nchen/Development/IdeaProjects/apex-jorje
(cd $JORJE_LOCATION; mvn clean install -Plsp -DskipTests)
cp `find $JORJE_LOCATION -type f -name 'apex-jorje-lsp-*-SNAPSHOT.jar' -not -name 'apex-jorje-lsp-test-*-SNAPSHOT.jar'` dist/apex-jorje-lsp.jar
cp `find $JORJE_LOCATION -type f -name 'apex-jorje-lsp-*-SNAPSHOT.jar' -not -name 'apex-jorje-lsp-test-*-SNAPSHOT.jar'` out/apex-jorje-lsp.jar

Просмотреть файл

@ -1,22 +1,22 @@
import * as vscode from 'vscode';
import * as child_process from 'child_process';
import * as path from 'path';
import * as net from 'net';
import * as portFinder from 'portfinder';
import * as requirements from './requirements';
import * as vscode from "vscode";
import * as child_process from "child_process";
import * as path from "path";
import * as net from "net";
import * as portFinder from "portfinder";
import * as requirements from "./requirements";
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
StreamInfo
} from 'vscode-languageclient';
} from "vscode-languageclient";
const UBER_JAR_NAME = 'apex-jorje-lsp.jar';
const UBER_JAR_NAME = "apex-jorje-lsp.jar";
const JDWP_DEBUG_PORT = 2739;
const APEX_LANGUAGE_SERVER_MAIN = 'apex.jorje.lsp.ApexLanguageServerLauncher';
const APEX_LANGUAGE_SERVER_MAIN = "apex.jorje.lsp.ApexLanguageServerLauncher";
declare var v8debug: any;
const DEBUG = typeof v8debug === 'object' || startedInDebugMode();
const DEBUG = typeof v8debug === "object" || startedInDebugMode();
async function createServer(
context: vscode.ExtensionContext
@ -25,33 +25,29 @@ async function createServer(
let requirementsData = await requirements.resolveRequirements();
return new Promise<any>((resolve, reject) => {
portFinder.getPort((err, port) => {
let uberJar = path.resolve(
context.extensionPath,
'dist',
UBER_JAR_NAME
);
let uberJar = path.resolve(context.extensionPath, "out", UBER_JAR_NAME);
let javaExecutable = path.resolve(
`${requirementsData.java_home}/bin/java`
);
let args: string[];
if (DEBUG) {
args = [
'-cp',
"-cp",
uberJar,
`-Dapex-lsp.port=${port}`,
'-Ddebug.internal.errors=true',
'-Ddebug.semantic.errors=false',
'-Dtrace.protocol=false',
"-Ddebug.internal.errors=true",
"-Ddebug.semantic.errors=false",
"-Dtrace.protocol=false",
`-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=${JDWP_DEBUG_PORT}`,
APEX_LANGUAGE_SERVER_MAIN
];
} else {
args = [
'-cp',
"-cp",
uberJar,
`-Dapex-lsp.port=${port}`,
'-Ddebug.internal.errors=true',
'-Ddebug.semantic.errors=false',
"-Ddebug.internal.errors=true",
"-Ddebug.semantic.errors=false",
APEX_LANGUAGE_SERVER_MAIN
];
}
@ -69,16 +65,16 @@ async function createServer(
};
let lspProcess = child_process.spawn(javaExecutable, args, options);
console.log('PROCESS INFO');
console.log("PROCESS INFO");
console.log(lspProcess);
lspProcess.stdout.on('data', data => {
lspProcess.stdout.on("data", data => {
console.log(`${data}`);
});
lspProcess.stderr.on('data', data => {
lspProcess.stderr.on("data", data => {
console.log(`${data}`);
});
lspProcess.on('close', code => {
lspProcess.on("close", code => {
console.log(`language server exited with code: ${code}`);
});
});
@ -105,20 +101,20 @@ export function createLanguageServer(
): LanguageClient {
let clientOptions: LanguageClientOptions = {
// Register the server for Apex documents
documentSelector: ['apex'],
documentSelector: ["apex"],
synchronize: {
configurationSection: 'apex',
configurationSection: "apex",
fileEvents: [
vscode.workspace.createFileSystemWatcher('**/*.cls'), // Apex classes
vscode.workspace.createFileSystemWatcher('**/*.trigger'), // Apex triggers
vscode.workspace.createFileSystemWatcher('**/sfdx-project.json') // SFDX workspace configuration file
vscode.workspace.createFileSystemWatcher("**/*.cls"), // Apex classes
vscode.workspace.createFileSystemWatcher("**/*.trigger"), // Apex triggers
vscode.workspace.createFileSystemWatcher("**/sfdx-project.json") // SFDX workspace configuration file
]
}
};
let client = new LanguageClient(
'apex',
'Apex Language Server',
"apex",
"Apex Language Server",
() => createServer(context),
clientOptions
);

Просмотреть файл

@ -0,0 +1,23 @@
//
// 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.
// tslint:disable-next-line:no-var-requires
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: 'tdd', // the TDD UI is being used in extension.test.ts (suite, test, etc.)
useColors: true // colored output from test results
});
module.exports = testRunner;

Просмотреть файл

@ -0,0 +1,11 @@
import { expect } from "chai";
import * as vscode from "vscode";
// Defines a Mocha test suite to group tests of similar kind together
suite("Extension Tests", () => {
// Defines a Mocha unit test
test("Something 1", () => {
expect([1, 2, 3].indexOf(5)).to.equal(-1);
expect([1, 2, 3].indexOf(1)).to.equal(0);
});
});

Просмотреть файл

@ -10,13 +10,13 @@
"moduleResolution": "node",
"noImplicitAny": true,
"rootDir": ".",
"outDir": "dist",
"outDir": "out",
"preserveConstEnums": true,
"strict": true
},
"exclude": [
"node_modules",
".vscode-test",
"dist"
"out"
]
}

53
packages/salesforcedx-vscode-core/.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,53 @@
#
# https://github.com/github/gitignore/blob/master/Node.gitignore
#
# Logs
logs
*.log
npm-debug.log*
# Runtime data
pids
*.pid
*.seed
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules
jspm_packages
# Optional npm cache directory
.npm
# Optional REPL history
.node_repl_history
# Generated vscode package
*.vsix
# VS Code tests
.vscode-test/**
# TypeScript generated files
out/
# Istanbul code coverage files
coverage/

Просмотреть файл

@ -13,7 +13,7 @@
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/src/**/*.js"
"${workspaceRoot}/out/src/**/*.js"
],
"preLaunchTask": "npm"
},
@ -24,12 +24,12 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/dist/test"
"--extensionTestsPath=${workspaceRoot}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/dist/test/**/*.js"
"${workspaceRoot}/out/test/**/*.js"
],
"preLaunchTask": "npm"
}

Просмотреть файл

@ -1,10 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"dist": false // set this to true to hide the "dist" folder with the compiled JS files
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"dist": true // set this to false to include "dist" folder in search results
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
}

Просмотреть файл

@ -1,6 +1,6 @@
.vscode/**
.vscode-test/**
dist/test/**
out/test/**
test/**
src/**
**/*.map

Просмотреть файл

@ -13,9 +13,11 @@
"Other"
],
"devDependencies": {
"@types/chai": "^4.0.0",
"@types/mocha": "2.2.38",
"@types/node": "^6.0.40",
"@types/path-exists": "^1.0.29",
"chai": "^4.0.2",
"mocha": "3.2.0",
"typescript": "2.3.4",
"vscode": "1.1.0"
@ -24,13 +26,14 @@
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -p ./",
"watch": "tsc -watch -p .",
"clean": "rm -rf node_modules && rm -rf dist",
"postinstall": "node ./node_modules/vscode/bin/install"
"clean": "rm -rf node_modules && rm -rf out",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "node ./node_modules/vscode/bin/test"
},
"activationEvents": [
"workspaceContains:sfdx-project.json"
],
"main": "./dist/src",
"main": "./out/src",
"contributes": {
"commands": [
{

Просмотреть файл

@ -0,0 +1,15 @@
import { expect } from "chai";
import * as vscode from "vscode";
// Defines a Mocha test suite to group tests of similar kind together
suite("Extension Tests", () => {
// Defines a Mocha unit test
test("Something 1", () => {
expect([1, 2, 3].indexOf(5)).to.equal(-1);
expect([1, 2, 3].indexOf(1)).to.equal(0);
});
test("Something 1", () => {
expect([1, 2, 3].indexOf(5)).to.equal(-1);
expect([1, 2, 3].indexOf(1)).to.equal(0);
});
});

Просмотреть файл

@ -10,13 +10,13 @@
"moduleResolution": "node",
"noImplicitAny": true,
"rootDir": ".",
"outDir": "dist",
"outDir": "out",
"preserveConstEnums": true,
"strict": true
},
"exclude": [
"node_modules",
".vscode-test",
"dist"
"out"
]
}