mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-07-05 11:00:53 +00:00
Merge pull request #45 from remcohaszing/fixes-and-cleanups
Fixes and cleanups
This commit is contained in:
commit
3da78b4f01
18 changed files with 189 additions and 3982 deletions
26
.github/workflows/ci.yaml
vendored
Normal file
26
.github/workflows/ci.yaml
vendored
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
name: ci
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
tags: ['*']
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pack:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with: { node-version: 14 }
|
||||||
|
- run: yarn --frozen-lockfile
|
||||||
|
- run: yarn pack
|
||||||
|
|
||||||
|
lint:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v2
|
||||||
|
with: { node-version: 14 }
|
||||||
|
- run: yarn --frozen-lockfile
|
||||||
|
- run: yarn lint
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -2,3 +2,4 @@
|
||||||
/out/
|
/out/
|
||||||
/lib/
|
/lib/
|
||||||
*.log
|
*.log
|
||||||
|
*.tgz
|
||||||
|
|
|
||||||
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
_
|
||||||
3
.husky/pre-commit
Executable file
3
.husky/pre-commit
Executable file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
yarn lint-staged
|
||||||
12
.npmignore
12
.npmignore
|
|
@ -1,12 +0,0 @@
|
||||||
/.vscode/
|
|
||||||
/out/
|
|
||||||
/scripts/
|
|
||||||
/examples/
|
|
||||||
/patches/
|
|
||||||
/src/
|
|
||||||
/test/
|
|
||||||
/.gitignore
|
|
||||||
/.npmignore
|
|
||||||
/examples
|
|
||||||
/test-demo.png
|
|
||||||
/.editorconfig
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
/lib/esm/_deps/
|
/dist/
|
||||||
|
/lib/
|
||||||
|
/out/
|
||||||
|
|
|
||||||
18
.vscode/launch.json
vendored
18
.vscode/launch.json
vendored
|
|
@ -1,18 +0,0 @@
|
||||||
{
|
|
||||||
// Use IntelliSense to learn about possible attributes.
|
|
||||||
// Hover to view descriptions of existing attributes.
|
|
||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
||||||
"version": "0.2.0",
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"type": "node",
|
|
||||||
"name": "vscode-jest-tests",
|
|
||||||
"request": "launch",
|
|
||||||
"args": ["--runInBand"],
|
|
||||||
"cwd": "${workspaceFolder}",
|
|
||||||
"console": "integratedTerminal",
|
|
||||||
"internalConsoleOptions": "neverOpen",
|
|
||||||
"program": "${workspaceFolder}/node_modules/jest/bin/jest"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
42
LICENSE.md
42
LICENSE.md
|
|
@ -1,21 +1,21 @@
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Copyright (c) Microsoft Corporation
|
Copyright (c) Microsoft Corporation
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
furnished to do so, subject to the following conditions:
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
The above copyright notice and this permission notice shall be included in all
|
||||||
copies or substantial portions of the Software.
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|
|
||||||
23
README.md
23
README.md
|
|
@ -1,13 +1,14 @@
|
||||||
# Monaco YAML
|
# Monaco YAML
|
||||||
|
|
||||||
YAML language plugin for the Monaco Editor. It provides the following features when editing YAML files:
|
YAML language plugin for the Monaco Editor. It provides the following features when editing YAML files:
|
||||||
* Code completion, based on JSON schemas or by looking at similar objects in the same file
|
|
||||||
* Hovers, based on JSON schemas
|
- Code completion, based on JSON schemas or by looking at similar objects in the same file
|
||||||
* Validation: Syntax errors and schema validation
|
- Hovers, based on JSON schemas
|
||||||
* Formatting
|
- Validation: Syntax errors and schema validation
|
||||||
* Document Symbols
|
- Formatting
|
||||||
* Syntax highlighting
|
- Document Symbols
|
||||||
* Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest)
|
- Syntax highlighting
|
||||||
|
- Automatically load remote schema files (by enabling DiagnosticsOptions.enableSchemaRequest)
|
||||||
|
|
||||||
Schemas can also 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.
|
for the API that the JSON plugin offers to configure the JSON language support.
|
||||||
|
|
@ -20,15 +21,17 @@ See `examples` directory for esm and umd examples.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
* `git clone https://github.com/pengx17/monaco-yaml`
|
- `git clone https://github.com/pengx17/monaco-yaml`
|
||||||
* `cd monaco-yaml`
|
- `cd monaco-yaml`
|
||||||
* `yarn`
|
- `yarn`
|
||||||
|
|
||||||
A running example:
|
A running example:
|
||||||

|

|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
- https://github.com/redhat-developer/yaml-language-server
|
- https://github.com/redhat-developer/yaml-language-server
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
[MIT](https://github.com/pengx17/monaco-yaml/blob/master/LICENSE.md)
|
[MIT](https://github.com/pengx17/monaco-yaml/blob/master/LICENSE.md)
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
# Demo: React + Weback + Worker Loader + Babel
|
# Demo: React + Weback + Worker Loader + Babel
|
||||||
|
|
||||||
To run:
|
To run:
|
||||||
|
|
||||||
```
|
```
|
||||||
yarn && yarn start
|
yarn && yarn start
|
||||||
```
|
```
|
||||||
|
|
||||||
The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded.
|
The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
# Demo: React + Weback + Babel
|
# Demo: React + Weback + Babel
|
||||||
|
|
||||||
To run:
|
To run:
|
||||||
|
|
||||||
```
|
```
|
||||||
yarn && yarn start
|
yarn && yarn start
|
||||||
```
|
```
|
||||||
|
|
||||||
The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded.
|
The demo will open in your browser. See (index.jsx)[index.jsx#L34-L36] for the schema loaded.
|
||||||
|
|
||||||
|
|
|
||||||
45
package.json
45
package.json
|
|
@ -11,16 +11,15 @@
|
||||||
"bundle:umd": "node ./scripts/bundle-umd",
|
"bundle:umd": "node ./scripts/bundle-umd",
|
||||||
"bundle:esm": "node ./scripts/bundle-esm",
|
"bundle:esm": "node ./scripts/bundle-esm",
|
||||||
"build": "yarn compile && yarn bundle",
|
"build": "yarn compile && yarn bundle",
|
||||||
"prepare": "yarn build",
|
"prepare": "husky install && yarn build",
|
||||||
"lint": "prettier \"{src,test}/**/*.{json,scss,html,ts}\" --write",
|
"lint": "prettier \"**/*.{css,js,json,jsx,html,md,ts}\" --check"
|
||||||
"test": "jest --verbose"
|
|
||||||
},
|
},
|
||||||
"main": "./lib/esm/monaco.contribution.js",
|
"main": "./lib/esm/monaco.contribution.js",
|
||||||
"module": "./lib/esm/monaco.contribution.js",
|
"module": "./lib/esm/monaco.contribution.js",
|
||||||
"typings": "./lib/monaco.d.ts",
|
"typings": "./lib/monaco.d.ts",
|
||||||
"directories": {
|
"files": [
|
||||||
"lib": "./lib"
|
"lib"
|
||||||
},
|
],
|
||||||
"author": "Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com)",
|
"author": "Kevin Decker <kpdecker@gmail.com> (http://incaseofstairs.com)",
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
"kpdecker",
|
"kpdecker",
|
||||||
|
|
@ -38,11 +37,8 @@
|
||||||
"yaml-language-server": "^0.11.1"
|
"yaml-language-server": "^0.11.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^23.3.10",
|
"husky": "^5.2.0",
|
||||||
"@types/node": "^12.12.6",
|
"lint-staged": "^10.5.4",
|
||||||
"husky": "^1.2.1",
|
|
||||||
"jest": "^23.6.0",
|
|
||||||
"lint-staged": "^10.1.2",
|
|
||||||
"monaco-editor": "^0.21.2",
|
"monaco-editor": "^0.21.2",
|
||||||
"monaco-editor-core": "^0.21.2",
|
"monaco-editor-core": "^0.21.2",
|
||||||
"monaco-languages": "^2.1.1",
|
"monaco-languages": "^2.1.1",
|
||||||
|
|
@ -50,10 +46,7 @@
|
||||||
"prettier": "^1.19.1",
|
"prettier": "^1.19.1",
|
||||||
"requirejs": "^2.3.6",
|
"requirejs": "^2.3.6",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
"ts-jest": "^23.10.5",
|
"typescript": "^4.2.3",
|
||||||
"typescript": "^3.8.3",
|
|
||||||
"typescript-tslint-plugin": "^0.5.5",
|
|
||||||
"eslint": "^6.8.0",
|
|
||||||
"uglify-es": "^3.3.9"
|
"uglify-es": "^3.3.9"
|
||||||
},
|
},
|
||||||
"prettier": {
|
"prettier": {
|
||||||
|
|
@ -65,27 +58,5 @@
|
||||||
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
|
"src/*.{json,scss,html,ts,js,jsx}|scripts/*.js": [
|
||||||
"prettier --write"
|
"prettier --write"
|
||||||
]
|
]
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "lint-staged"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"jest": {
|
|
||||||
"globals": {
|
|
||||||
"ts-jest": {
|
|
||||||
"tsConfig": "./test/tsconfig.json"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"moduleFileExtensions": [
|
|
||||||
"js",
|
|
||||||
"ts"
|
|
||||||
],
|
|
||||||
"transform": {
|
|
||||||
"^.+\\.(ts|tsx)$": "ts-jest"
|
|
||||||
},
|
|
||||||
"testMatch": [
|
|
||||||
"**/test/*.test.+(ts|js)"
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export class DiagnosticsAdapter {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let handle: NodeJS.Timer;
|
let handle: number;
|
||||||
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
|
this._listener[model.uri.toString()] = model.onDidChangeContent(() => {
|
||||||
clearTimeout(handle);
|
clearTimeout(handle);
|
||||||
handle = setTimeout(() => this._doValidate(model.uri, modeId), 500);
|
handle = setTimeout(() => this._doValidate(model.uri, modeId), 500);
|
||||||
|
|
|
||||||
81
src/monaco.d.ts
vendored
81
src/monaco.d.ts
vendored
|
|
@ -2,56 +2,53 @@
|
||||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
import { IEvent } from 'monaco-editor';
|
|
||||||
|
|
||||||
declare module 'monaco-editor' {
|
declare namespace monaco.languages.yaml {
|
||||||
namespace languages.yaml {
|
export interface DiagnosticsOptions {
|
||||||
export interface DiagnosticsOptions {
|
/**
|
||||||
|
* If set, the validator will be enabled and perform syntax validation as well as schema based validation.
|
||||||
|
*/
|
||||||
|
readonly validate?: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list of known schemas and/or associations of schemas to file names.
|
||||||
|
*/
|
||||||
|
readonly schemas?: Array<{
|
||||||
/**
|
/**
|
||||||
* If set, the validator will be enabled and perform syntax validation as well as schema based validation.
|
* The URI of the schema, which is also the identifier of the schema.
|
||||||
*/
|
*/
|
||||||
readonly validate?: boolean;
|
readonly uri: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of known schemas and/or associations of schemas to file names.
|
* A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
|
||||||
*/
|
*/
|
||||||
readonly schemas?: Array<{
|
readonly fileMatch?: string[];
|
||||||
/**
|
|
||||||
* The URI of the schema, which is also the identifier of the schema.
|
|
||||||
*/
|
|
||||||
readonly uri: string;
|
|
||||||
/**
|
|
||||||
* A list of file names that are associated to the schema. The '*' wildcard can be used. For example '*.schema.json', 'package.json'
|
|
||||||
*/
|
|
||||||
readonly fileMatch?: string[];
|
|
||||||
/**
|
|
||||||
* The schema for the given URI.
|
|
||||||
*/
|
|
||||||
readonly schema?: any;
|
|
||||||
}>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
* The schema for the given URI.
|
||||||
*/
|
*/
|
||||||
readonly enableSchemaRequest?: boolean;
|
readonly schema?: any;
|
||||||
/**
|
}>;
|
||||||
* If specified, this prefix will be added to all on demand schema requests
|
|
||||||
*/
|
|
||||||
readonly prefix?: string;
|
|
||||||
/**
|
|
||||||
* Whether or not kubernetes yaml is supported
|
|
||||||
*/
|
|
||||||
readonly isKubernetes?: boolean;
|
|
||||||
|
|
||||||
readonly format?: boolean;
|
/**
|
||||||
}
|
* If set, the schema service would load schema content on-demand with 'fetch' if available
|
||||||
|
*/
|
||||||
|
readonly enableSchemaRequest?: boolean;
|
||||||
|
/**
|
||||||
|
* If specified, this prefix will be added to all on demand schema requests
|
||||||
|
*/
|
||||||
|
readonly prefix?: string;
|
||||||
|
/**
|
||||||
|
* Whether or not kubernetes yaml is supported
|
||||||
|
*/
|
||||||
|
readonly isKubernetes?: boolean;
|
||||||
|
|
||||||
export interface LanguageServiceDefaults {
|
readonly format?: boolean;
|
||||||
readonly onDidChange: IEvent<LanguageServiceDefaults>;
|
|
||||||
readonly diagnosticsOptions: DiagnosticsOptions;
|
|
||||||
setDiagnosticsOptions(options: DiagnosticsOptions): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const yamlDefaults: LanguageServiceDefaults;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface LanguageServiceDefaults {
|
||||||
|
readonly onDidChange: IEvent<LanguageServiceDefaults>;
|
||||||
|
readonly diagnosticsOptions: DiagnosticsOptions;
|
||||||
|
setDiagnosticsOptions(options: DiagnosticsOptions): void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const yamlDefaults: LanguageServiceDefaults;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const STOP_WHEN_IDLE_FOR = 2 * 60 * 1000; // 2min
|
||||||
|
|
||||||
export class WorkerManager {
|
export class WorkerManager {
|
||||||
private _defaults: LanguageServiceDefaultsImpl;
|
private _defaults: LanguageServiceDefaultsImpl;
|
||||||
private _idleCheckInterval: NodeJS.Timer;
|
private _idleCheckInterval: number;
|
||||||
private _lastUsedTime: number;
|
private _lastUsedTime: number;
|
||||||
private _configChangeListener: IDisposable;
|
private _configChangeListener: IDisposable;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,7 @@
|
||||||
"lib": ["dom", "es2016"],
|
"lib": ["dom", "es2016"],
|
||||||
"outDir": "./out/esm",
|
"outDir": "./out/esm",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"target": "es6",
|
"target": "es6"
|
||||||
"plugins": [
|
|
||||||
{
|
|
||||||
"name": "typescript-tslint-plugin"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "out", "lib", "test"]
|
"exclude": ["node_modules", "out", "lib", "test"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,7 @@
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"lib": ["dom", "es2016"],
|
"lib": ["dom", "es2016"],
|
||||||
"outDir": "./out/amd",
|
"outDir": "./out/amd",
|
||||||
"target": "es6",
|
"target": "es6"
|
||||||
"plugins": [
|
|
||||||
{
|
|
||||||
"name": "typescript-tslint-plugin"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", "out", "lib", "test"]
|
"exclude": ["node_modules", "out", "lib", "test"]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue