Skip to content

Commit

Permalink
chore: align with pengx17/master branch
Browse files Browse the repository at this point in the history
  • Loading branch information
pengx17 committed Oct 25, 2018
1 parent 63bca49 commit a0db642
Show file tree
Hide file tree
Showing 40 changed files with 1,510 additions and 2,937 deletions.
5 changes: 2 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/.vscode/
/lib/
/out/
/scripts/
/src/
/test/
/release/dev/
/gulpfile.js
/.gitignore
/.npmignore
22 changes: 19 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,37 @@ YAML language plugin for the Monaco Editor. It provides the following features w
* Formatting
* Document Symbols
* Syntax highlighting
* Automatically load remote schema files

Schemas can be provided by configuration. See [here](https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts)
Schemas can also be provided by configuration. See [here](https://github.com/Microsoft/monaco-json/blob/master/src/monaco.d.ts)
for the API that the JSON plugin offers to configure the JSON language support.

## Installing

TODO: Document exact distribution method
`yarn add monaco-yaml`
See `test/index.html` as an example. Currently only load with vs loader is supported. (AMD)
Load with ESM is added, but not yet tested.

## Development

* `git clone https://github.com/kpdecker/monaco-yaml`
* `cd monaco-yaml`
* `yarn`
* `npm run watch`
* `yarn watch`
* open `$/monaco-yaml/test/index.html` in your favorite browser.

A running example:
![demo-image](test-demo.png)

## Credits
- https://github.com/redhat-developer/yaml-language-server

### Maintain
Manually clone dependencies list below and update the project files accordingly:
- `src/languageservice`: https://github.com/redhat-developer/yaml-language-server
- `cp yaml-language-server/src/languageservice monaco-yaml/src/languageservice`
- Modify the import paths, go to the test page and see if it still works
- `src/yaml-ast-parser`: https://github.com/mulesoft-labs/yaml-ast-parser/tree/master/src

## License
[MIT](https://github.com/kpdecker/monaco-yaml/blob/master/LICENSE.md)
190 changes: 0 additions & 190 deletions gulpfile.js

This file was deleted.

44 changes: 25 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
{
"name": "monaco-yaml",
"version": "1.0.0",
"version": "1.1.0",
"description": "YAML plugin for the Monaco Editor",
"scripts": {
"compile": "gulp compile",
"watch": "gulp watch",
"prepublish": "gulp release"
"compile": "rimraf ./out && tsc -p ./src/tsconfig.json && tsc -p ./src/tsconfig.esm.json",
"watch": "tsc -p ./src --watch",
"prepublish": "rimraf ./release && yarn run compile && node ./scripts/release.js && node ./scripts/bundle && mcopy ./src/monaco.d.ts ./release/monaco.d.ts"
},
"author": "Kevin Decker <[email protected]> (http://incaseofstairs.com)",
"maintainers": [
"kpdecker",
"pengx17"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/kpdecker/monaco-yaml"
},
"bugs": {
"url": "https://github.com/kpdecker/monaco-yaml/issues"
},
"devDependencies": {
"event-stream": "^3.3.2",
"gulp": "^3.9.1",
"gulp-requirejs": "^0.1.3",
"gulp-tsb": "^2.0.0",
"gulp-uglify": "^1.5.3",
"js-yaml": "^3.10.0",
"jsonc-parser": "1.0.0",
"merge-stream": "^1.0.0",
"monaco-editor-core": "^0.10.1",
"monaco-languages": "^0.9.0",
"object-assign": "^4.1.0",
"rimraf": "^2.5.2",
"typescript": "^2.7.1",
"vscode-json-languageservice": "^3.0.5",
"vscode-languageserver-types": "^3.5.0"
"@types/chai": "^4.1.4",
"@types/mocha": "^5.2.5",
"@types/node": "^10.9.3",
"js-yaml": "^3.12.0",
"jsonc-parser": "^2.0.2",
"monaco-editor-core": "0.14.6",
"monaco-languages": "1.5.1",
"monaco-plugin-helpers": "^1.0.2",
"requirejs": "^2.3.5",
"rimraf": "^2.6.2",
"typescript": "^3.0.3",
"uglify-es": "^3.3.9",
"vscode-json-languageservice": "^3.1.6",
"vscode-languageserver-types": "3.12.0"
}
}
82 changes: 82 additions & 0 deletions scripts/bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
const requirejs = require('requirejs');
const path = require('path');
const fs = require('fs');
const UglifyES = require("uglify-es");
const helpers = require('monaco-plugin-helpers');

const REPO_ROOT = path.resolve(__dirname, '..');

const sha1 = helpers.getGitVersion(REPO_ROOT);
const semver = require('../package.json').version;
const headerVersion = semver + '(' + sha1 + ')';

const BUNDLED_FILE_HEADER = [
'/*!-----------------------------------------------------------------------------',
' * Copyright (c) Microsoft Corporation. All rights reserved.',
' * monaco-yaml version: ' + headerVersion,
' * Released under the MIT license',
' * https://github.com/kpdecker/monaco-yaml/blob/master/LICENSE.md',
' *-----------------------------------------------------------------------------*/',
''
].join('\n');

bundleOne('monaco.contribution');
bundleOne('yamlMode');
bundleOne('yamlWorker');

function bundleOne(moduleId, exclude) {
requirejs.optimize({
baseUrl: 'out/amd/',
name: 'vs/language/yaml/' + moduleId,
out: 'release/dev/' + moduleId + '.js',
exclude: exclude,
paths: {
'vs/language/yaml': REPO_ROOT + '/out/amd'
},
optimize: 'none',
packages: [
{
name: 'js-yaml',
location: path.join(REPO_ROOT, 'node_modules/js-yaml/dist'),
main: 'js-yaml'
},

// The following is required by YAML language service
{
name: 'jsonc-parser',
location: path.join(REPO_ROOT, 'node_modules/jsonc-parser/lib/umd'),
main: 'main'
}, {
name: 'vscode-json-languageservice/lib',
location: path.join(REPO_ROOT, 'node_modules/vscode-json-languageservice/lib/umd')
},

{
name: 'vscode-languageserver-types',
location: path.join(REPO_ROOT, 'node_modules/vscode-languageserver-types/lib/umd'),
main: 'main'
}, {
name: 'vscode-uri',
location: path.join(REPO_ROOT, 'node_modules/vscode-uri/lib/umd'),
main: 'index'
}, {
name: 'vscode-nls',
location: path.join(REPO_ROOT, '/out/amd/fillers'),
main: 'vscode-nls'
}]
}, function () {
const devFilePath = path.join(REPO_ROOT, 'release/dev/' + moduleId + '.js');
const minFilePath = path.join(REPO_ROOT, 'release/min/' + moduleId + '.js');
const fileContents = fs.readFileSync(devFilePath).toString();
console.log();
console.log(`Minifying ${devFilePath}...`);
const result = UglifyES.minify(fileContents, {
output: {
comments: 'some'
}
});
console.log(`Done.`);
try { fs.mkdirSync(path.join(REPO_ROOT, 'release/min')) } catch (err) { }
fs.writeFileSync(minFilePath, BUNDLED_FILE_HEADER + result.code);
})
}
Loading

0 comments on commit a0db642

Please sign in to comment.