From 45bdfe41a734b9dfa5e38a48d77a61d35eb5be84 Mon Sep 17 00:00:00 2001 From: Yevhen Vydolob Date: Tue, 27 Oct 2020 09:10:08 +0200 Subject: [PATCH] Use next yaml parser (#341) * Use 'yaml-language-server-parser' insead of 'yaml-ast-parser-custom-tags' Signed-off-by: Yevhen Vydolob * Release with GH Action Signed-off-by: Yevhen Vydolob * Replace 'npm' with 'yarn' Signed-off-by: Yevhen Vydolob --- .github/workflows/release.yaml | 50 +++++++++++++++++++ .travis.yml | 24 --------- package.json | 5 +- scripts/check-dependencies.js | 21 ++++++++ .../parser/recursivelyBuildAst.ts | 2 +- src/languageservice/parser/yamlParser07.ts | 2 +- src/languageservice/utils/parseUtils.ts | 2 +- yarn.lock | 8 +-- 8 files changed, 81 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/release.yaml delete mode 100644 .travis.yml create mode 100644 scripts/check-dependencies.js diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..fd951627 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,50 @@ +# This is a basic workflow to help you get started with Actions + +name: Release to NPM + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + tags: + - '*' + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + + # Set up Node + - name: Use Node 12 + uses: actions/setup-node@v1 + with: + node-version: 12 + registry-url: 'https://registry.npmjs.org' + + # Run install dependencies + - name: Install dependencies + run: yarn + + # Build extension + - name: Run build + run: yarn build + + # Run tests + - name: Run Test + run: yarn test + + # Publish to npm + - run: | + yarn check-dependencies + yarn publish --access public + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 10b7850e..00000000 --- a/.travis.yml +++ /dev/null @@ -1,24 +0,0 @@ -version: ~> 1.0 -language: node_js -node_js: - - '12' -os: - - osx - - linux -before_install: - - if [ $TRAVIS_OS_NAME == "linux" ]; then export CXX="g++-4.9" CC="gcc-4.9" DISPLAY=:99.0; - sh -e /etc/init.d/xvfb start; sleep 3; fi - - yarn global add typescript -install: - - yarn install - - yarn run build -deploy: - provider: npm - email: gorkem.ercan@gmail.com - cleanup: false - edge: true - on: - tags: true - repo: redhat-developer/yaml-language-server - api_token: - secure: q5zN3WjUGWWTlxC0yViMK9RcXeEEwYRsXuqEwYBEyz+er4XUJzisHdXELu0tf56caCZ1Kp0NCUHsGqyV+fBS5zhaR0SSil59tSPp3fo+av/eLymI+4RXLAo3vCuRITSKPG+AwJnwAZF5cwGRdUCKPjV0yi7lX/WcZzZCPKb4IlKpMET/x9n0vhtSRK0Spxb0xB+pdjzujOHg2hkU9J81i1c62pZ6KlGhipdRrsONB6ujpSgpBakatp6FFPwmg8YwjbrNAWcqBZA1KwgiymaJSUa0asrGqeTRph/+xtVIr1WYRL7ed4yg1EYhLptNThhlO+To4FSZbOQfE5Rqcgo1BcLFLgQuPdp5HQwnQcVrkKWvRDyxvNI61cSW9Pb3hwytcVik0yz5neRGWVmJpVRulK5LVH37+XqVmic5Amc46ovst7HHw52dKayR97FoBq1+CXpxCONdjtvWnHZgahXxjOb4pJkNaGnmOR157MZ7Oo6GrilOSo8WBtdsOv2/CCrL119Eqbr8rJuQR9H2q5Y7at0QNsuO24jrKvFmqf8igE0t6Z70Dk1cxApME5nMAaww/tL7Mgv4zSvSGQRykwxvAZfoIu4v0fRHR+3I5wRy4P0HHvwxGlBPhq8+m4aCzHCbL+AejEOxSWknhnE/AEd9p719mVMx6FbqBrilnuSlOsg= diff --git a/package.json b/package.json index ce181c9f..f090db64 100755 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "vscode-languageserver-types": "^3.15.1", "vscode-nls": "^4.1.2", "vscode-uri": "^2.1.1", - "yaml-ast-parser-custom-tags": "0.0.43" + "yaml-language-server-parser": "next" }, "devDependencies": { "@types/chai": "^4.2.12", @@ -77,7 +77,8 @@ "build": "yarn clean && yarn lint && yarn compile && yarn build:libs", "build:libs": "yarn compile:umd && yarn compile:esm", "compile:umd": "tsc -p ./tsconfig.umd.json", - "compile:esm": "tsc -p ./tsconfig.esm.json" + "compile:esm": "tsc -p ./tsconfig.esm.json", + "check-dependencies": "node ./scripts/check-dependencies.js" }, "nyc": { "extension": [ diff --git a/scripts/check-dependencies.js b/scripts/check-dependencies.js new file mode 100644 index 00000000..f3e90756 --- /dev/null +++ b/scripts/check-dependencies.js @@ -0,0 +1,21 @@ +/* -------------------------------------------------------------------------------------------- + * Copyright (c) Red Hat, Inc. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * ------------------------------------------------------------------------------------------ */ + +//check package.json do not have dependency with 'next' version + +/* eslint-disable @typescript-eslint/no-var-requires */ + +const exit = require('process').exit; +const dependencies = require('../package.json').dependencies; + +for (const dep in dependencies) { + if (Object.prototype.hasOwnProperty.call(dependencies, dep)) { + const version = dependencies[dep]; + if (version === 'next') { + console.error(`Dependency ${dep} has "${version}" version, please change it to fixed version`); + exit(1); + } + } +} diff --git a/src/languageservice/parser/recursivelyBuildAst.ts b/src/languageservice/parser/recursivelyBuildAst.ts index 508e6858..60ce625c 100644 --- a/src/languageservice/parser/recursivelyBuildAst.ts +++ b/src/languageservice/parser/recursivelyBuildAst.ts @@ -7,7 +7,7 @@ import { ArrayASTNodeImpl, BooleanASTNodeImpl, } from './jsonParser07'; -import * as Yaml from 'yaml-ast-parser-custom-tags'; +import * as Yaml from 'yaml-language-server-parser'; import { ASTNode } from '../jsonASTTypes'; import { parseYamlBoolean } from './scalar-type'; diff --git a/src/languageservice/parser/yamlParser07.ts b/src/languageservice/parser/yamlParser07.ts index 7a338876..4de1889d 100644 --- a/src/languageservice/parser/yamlParser07.ts +++ b/src/languageservice/parser/yamlParser07.ts @@ -8,7 +8,7 @@ import * as nls from 'vscode-nls'; const localize = nls.loadMessageBundle(); -import * as Yaml from 'yaml-ast-parser-custom-tags'; +import * as Yaml from 'yaml-language-server-parser'; import { JSONDocument } from './jsonParser07'; import { YAMLDocDiagnostic, formatErrors, formatWarnings, customTagsToAdditionalOptions } from '../utils/parseUtils'; diff --git a/src/languageservice/utils/parseUtils.ts b/src/languageservice/utils/parseUtils.ts index 4cbc378f..c38a7f49 100644 --- a/src/languageservice/utils/parseUtils.ts +++ b/src/languageservice/utils/parseUtils.ts @@ -1,4 +1,4 @@ -import * as Yaml from 'yaml-ast-parser-custom-tags'; +import * as Yaml from 'yaml-language-server-parser'; import { Schema, Type } from 'js-yaml'; import { filterInvalidCustomTags } from './arrUtils'; diff --git a/yarn.lock b/yarn.lock index e75e41e6..b1272724 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2345,10 +2345,10 @@ yallist@^2.1.2: resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" integrity sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI= -yaml-ast-parser-custom-tags@0.0.43: - version "0.0.43" - resolved "https://registry.yarnpkg.com/yaml-ast-parser-custom-tags/-/yaml-ast-parser-custom-tags-0.0.43.tgz#46968145ce4e24cb03c3312057f0f141b93a7d02" - integrity sha512-R5063FF/JSAN6qXCmylwjt9PcDH6M0ExEme/nJBzLspc6FJDmHHIqM7xh2WfEmsTJqClF79A9VkXjkAqmZw9SQ== +yaml-language-server-parser@next: + version "0.1.1-2b9337f.0" + resolved "https://registry.yarnpkg.com/yaml-language-server-parser/-/yaml-language-server-parser-0.1.1-2b9337f.0.tgz#7d67395157117c1fdbfa1053506eca48f92f5d67" + integrity sha512-EHWndWCG23PlWqQSIElTQoHP2uklvGcZLiq+mqj4CUmrNiLVRRtX5CqhXU0ebOV3h0PeMYrntkiWZ6BcyhgdOg== yargs-parser@^13.0.0, yargs-parser@^13.1.2: version "13.1.2"