瀏覽代碼

Add a test page, simplify development setup

Alex Dima 8 年之前
父節點
當前提交
517d32307e
共有 3 個文件被更改,包括 119 次插入28 次删除
  1. 6 23
      README.md
  2. 4 5
      package.json
  3. 109 0
      test/index.html

+ 6 - 23
README.md

@@ -17,36 +17,19 @@ in [Visual Studio Code](https://github.com/Microsoft/vscode) to power the JSON e
 
 ## Issues
 
-Please file issues concering `monaco-json` in the [`monaco-editor`-repository](https://github.com/Microsoft/monaco-editor/issues).
+Please file issues concering `monaco-json` in the [`monaco-editor` repository](https://github.com/Microsoft/monaco-editor/issues).
 
 ## Installing
 
 This npm module is bundled and distributed in the [monaco-editor](https://www.npmjs.com/package/monaco-editor) npm module.
 
-* change to your favorite source folder (`/src/`)
-* `git clone https://github.com/Microsoft/monaco-editor` (this will create `$/src/monaco-editor`)
-* in folder `monaco-editor` run `npm install` and run `npm run simpleserver`
-* open http://localhost:8080/monaco-editor/test/index.html#sample - json
-
 ## Development
 
-### Dev: Running monaco-json from source
-* change to your favorite source folder (`/src/`).
-* if you haven't done so: `git clone https://github.com/Microsoft/monaco-editor` (this will create `$/src/monaco-editor`)
-* `git clone https://github.com/Microsoft/monaco-json` (this will create `$/src/monaco-json`)
-* Important: both monaco repositories must have the same parent folder.
-* in folder `monaco-json` run `npm install` and run `npm run watch`
-* in folder `monaco-editor` run `npm install` and run `npm run simpleserver`
-* open http://localhost:8080/monaco-editor/test/?monaco-json=dev
-
-### [Optional] Running monaco-editor-core from source
-
-* this is only needed when you want to make changes also in `monaco-editor-core`.
-* change to the same favorite source folder (`/src/`) that already contains `monaco-json` and `monaco-editor`
-* `git clone https://github.com/Microsoft/vscode` (this will create `$/src/vscode/`)
-* read [here](https://github.com/Microsoft/vscode/wiki/How-to-Contribute#installing-prerequisites) on how to initialize the VS code source repository.
-* in folder `vscode` run `gulp watch`
-* open http://localhost:8080/monaco-editor/test/?monaco-json=dev&editor=dev
+* `git clone https://github.com/Microsoft/monaco-json`
+* `cd monaco-json`
+* `npm install .`
+* `npm run watch`
+* open `$/monaco-json/test/index.html` in your favorite browser.
 
 ## License
 [MIT](https://github.com/Microsoft/monaco-json/blob/master/LICENSE.md)

+ 4 - 5
package.json

@@ -18,10 +18,6 @@
   "bugs": {
     "url": "https://github.com/Microsoft/monaco-json/issues"
   },
-  "dependencies": {
-    "vscode-json-languageservice": "^1.1.5-next.1",
-    "vscode-languageserver-types": "^1.0.1"
-  },
   "devDependencies": {
     "event-stream": "^3.3.2",
     "gulp": "^3.9.1",
@@ -30,8 +26,11 @@
     "gulp-uglify": "^1.5.3",
     "merge-stream": "^1.0.0",
     "monaco-editor-core": "^0.7.0",
+    "monaco-languages": "^0.6.1",
     "object-assign": "^4.1.0",
     "rimraf": "^2.5.2",
-    "typescript": "2.0.3"
+    "typescript": "2.0.3",
+    "vscode-json-languageservice": "^1.1.5-next.1",
+    "vscode-languageserver-types": "^1.0.1"
   }
 }

+ 109 - 0
test/index.html

@@ -0,0 +1,109 @@
+<!DOCTYPE html>
+<html>
+<head>
+	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
+	<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+	<link rel="stylesheet" data-name="vs/editor/editor.main" href="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.css">
+</head>
+<body>
+
+<h2>Monaco Editor JSON test page</h2>
+<div id="container" style="width:800px;height:600px;border:1px solid grey"></div>
+
+<script>
+	// Loading basic-languages to get the json language definition
+	var require = {
+		paths: {
+			'vs/basic-languages': '../node_modules/monaco-languages/release',
+			'vs/language/json': '../release/dev',
+			'vs': '../node_modules/monaco-editor-core/dev/vs'
+		}
+	};
+</script>
+<script src="../node_modules/monaco-editor-core/dev/vs/loader.js"></script>
+<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.nls.js"></script>
+<script src="../node_modules/monaco-editor-core/dev/vs/editor/editor.main.js"></script>
+
+<script>
+	require([
+		'vs/basic-languages/src/monaco.contribution',
+		'vs/language/json/monaco.contribution'
+	], function() {
+		var editor = monaco.editor.create(document.getElementById('container'), {
+			value: [
+				'{',
+				'	"type": "team",',
+				'	"test": {',
+				'		"testPage": "tools/testing/run-tests.htm",',
+				'		"enabled": true',
+				'	},',
+				'	"search": {',
+				'		"excludeFolders": [',
+				'			".git",',
+				'			"node_modules",',
+				'			"tools/bin",',
+				'			"tools/counts",',
+				'			"tools/policheck",',
+				'			"tools/tfs_build_extensions",',
+				'			"tools/testing/jscoverage",',
+				'			"tools/testing/qunit",',
+				'			"tools/testing/chutzpah",',
+				'			"server.net"',
+				'		]',
+				'	},',
+				'	"languages": {',
+				'		"vs.languages.typescript": {',
+				'			"validationSettings": [{',
+				'				"scope":"/",',
+				'				"noImplicitAny":true,',
+				'				"noLib":false,',
+				'				"extraLibs":[],',
+				'				"semanticValidation":true,',
+				'				"syntaxValidation":true,',
+				'				"codeGenTarget":"ES5",',
+				'				"moduleGenTarget":"",',
+				'				"lint": {',
+				'					"emptyBlocksWithoutComment": "warning",',
+				'					"curlyBracketsMustNotBeOmitted": "warning",',
+				'					"comparisonOperatorsNotStrict": "warning",',
+				'					"missingSemicolon": "warning",',
+				'					"unknownTypeOfResults": "warning",',
+				'					"semicolonsInsteadOfBlocks": "warning",',
+				'					"functionsInsideLoops": "warning",',
+				'					"functionsWithoutReturnType": "warning",',
+				'					"tripleSlashReferenceAlike": "warning",',
+				'					"unusedImports": "warning",',
+				'					"unusedVariables": "warning",',
+				'					"unusedFunctions": "warning",',
+				'					"unusedMembers": "warning"',
+				'				}',
+				'			},',
+				'			{',
+				'				"scope":"/client",',
+				'				"baseUrl":"/client",',
+				'				"moduleGenTarget":"amd"',
+				'			},',
+				'			{',
+				'				"scope":"/server",',
+				'				"moduleGenTarget":"commonjs"',
+				'			},',
+				'			{',
+				'				"scope":"/build",',
+				'				"moduleGenTarget":"commonjs"',
+				'			},',
+				'			{',
+				'				"scope":"/node_modules/nake",',
+				'				"moduleGenTarget":"commonjs"',
+				'			}],',
+				'			"allowMultipleWorkers": true',
+				'		}',
+				'	}',
+				'}',
+			].join('\n'),
+			language: 'json'
+		});
+	});
+</script>
+
+</body>
+</html>