From 5ae4ec2136e89cc3f612a327cad1e2e853467a9c Mon Sep 17 00:00:00 2001 From: upupming Date: Sun, 2 Feb 2020 17:16:52 +0800 Subject: [PATCH] :package: Chore: azure -> github actions --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++++ README.md | 6 ++--- azure-pipelines.yml | 55 ---------------------------------------- package.json | 5 ++-- src/utils/index.ts | 10 ++++---- src/vs-picgo/index.ts | 20 +++++++-------- tsconfig.json | 46 +++++++++++++++------------------ yarn.lock | 43 ++++++++++++++++--------------- 8 files changed, 97 insertions(+), 121 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 azure-pipelines.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ef9f79a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: Build +on: + push: + branches: + - dev + - master +jobs: + build-and-prerelease: + runs-on: macos-latest + steps: + - uses: actions/checkout@v1 + + - name: npm install, make test-coverage + run: | + npm install + npm run test + + - name: Coveralls + uses: coverallsapp/github-action@master + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build artifact + run: | + mkdir artifact + npm install -g vsce + rm README.md && vsce package -o artifact + + - name: Upload artifact + uses: actions/upload-artifact@v1 + with: + name: vs-picgo dev release + path: artifact diff --git a/README.md b/README.md index 30a0c6f..d14bba6 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![version](https://img.shields.io/vscode-marketplace/v/Spades.vs-picgo.svg?style=flat-square&label=vscode%20marketplace)](https://marketplace.visualstudio.com/items?itemName=Spades.vs-picgo) [![installs](https://img.shields.io/vscode-marketplace/d/Spades.vs-picgo.svg?style=flat-square)](https://marketplace.visualstudio.com/items?itemName=Spades.vs-picgo) -[![Azure DevOps builds (branch)](https://img.shields.io/azure-devops/build/PicGo/9bbe4cd2-a9fe-4547-b13a-60ee81f12932/1/dev.svg?label=azure%20pipeline&style=flat-square)](https://dev.azure.com/PicGo/vs-picgo/_build?definitionId=1) +[![Build](https://github.com/PicGo/vs-picgo/workflows/Build/badge.svg?sanitize=true)](https://github.com/PicGo/vs-picgo/actions?query=workflow%3A%22Build%22) [![Coveralls github branch](https://img.shields.io/coveralls/github/PicGo/vs-picgo/refs/heads/dev.svg?style=flat-square)](https://coveralls.io/github/PicGo/vs-picgo?branch=refs/heads/dev) [![GitHub stars](https://img.shields.io/github/stars/PicGo/vs-picgo.svg?style=flat-square&label=github%20stars)](https://github.com/PicGo/vs-picgo) [![PicGo Convention](https://img.shields.io/badge/picgo-convention-blue.svg?style=flat-square)](https://github.com/PicGo/bump-version) @@ -87,7 +87,7 @@ output-format.png - +
@@ -135,7 +135,7 @@ ## Versioning -For the versions available, see the [tags on PicGo/vs-picgo](https://github.com/PicGo/vs-picgo/tags). ChangeLogs can be found at [CHANGELOG.md](CHANGELOG.md). All the dev builds can be found on [Azure](https://dev.azure.com/PicGo/vs-picgo/_build?definitionId=1), and you can just open the build of a specific commit, and go to the Summary tab to download the artifacts. +For the versions available, see the [tags on PicGo/vs-picgo](https://github.com/PicGo/vs-picgo/tags). ChangeLogs can be found at [CHANGELOG.md](CHANGELOG.md). All the dev builds can be found on [GitHub Actions](https://github.com/PicGo/vs-picgo/actions/), and you can just open the build of a specific commit, and go to the Summary tab to download the artifacts. ## Contributing diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index efdb9ea..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,55 +0,0 @@ -variables: - system.debug: true -jobs: - - job: Windows - pool: - name: Hosted VS2017 - demands: npm - steps: - - task: NodeTool@0 - displayName: 'Use Node 8.x' - inputs: - versionSpec: 8.x - - task: Npm@1 - displayName: 'Install dependencies' - inputs: - verbose: false - - - task: Npm@1 - displayName: 'Compile sources and run tests' - inputs: - command: custom - verbose: false - customCommand: 'run test' - - # https://stackoverflow.com/questions/45602358/lcov-info-has-absolute-path-for-sf - - script: | - sed -i -- s/..\\..\\//g coverage/lcov.info && npm run coveralls - displayName: 'Publish code coverage' - env: - COVERALLS_SERVICE_NAME: $(COVERALLS_SERVICE_NAME) - COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN) - # https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables - COVERALLS_GIT_COMMIT: $(Build.SourceVersion) - # https://github.com/MicrosoftDocs/vsts-docs/issues/4259 - # https://stackoverflow.com/questions/16623835/remove-a-fixed-prefix-suffix-from-a-string-in-bash - COVERALLS_GIT_BRANCH: $(Build.SourceBranch) - COVERALLS_SERVICE_JOB_ID: $(Build.BuildId) - CI_PULL_REQUEST: $(System.PullRequest.PullRequestNumber) - - - script: 'npm install -g vsce && vsce package' - displayName: 'Build artifact' - - task: CopyFiles@2 - inputs: - contents: '*.vsix' - TargetFolder: '$(Build.ArtifactStagingDirectory)' - - task: PublishBuildArtifacts@1 - inputs: - pathtoPublish: '$(Build.ArtifactStagingDirectory)' - artifactName: vs-picgo-dev-build -trigger: - branches: - include: - - '*' # must quote since "*" is a YAML reserved character; we want a string -pr: -- dev* \ No newline at end of file diff --git a/package.json b/package.json index 7918669..98a33c6 100644 --- a/package.json +++ b/package.json @@ -272,7 +272,8 @@ "watch": "tsc -watch -p ./", "postinstall": "node ./node_modules/vscode/bin/install", "test": "npm run compile && node ./node_modules/vscode/bin/test", - "coveralls": "powershell type ./coverage/lcov.info | coveralls", + "coveralls": "cat ./coverage/lcov.info | coveralls", + "coveralls:windows": "powershell type ./coverage/lcov.info | coveralls", "lint": "prettier --list-different ./src/*.ts package.json package.nls.json", "lint:fix": "prettier --write ./src/*.ts package.json package.nls.json", "cz": "git-cz", @@ -325,7 +326,7 @@ "dependencies": { "lodash": "^4.17.11", "lodash-id": "^0.14.0", - "picgo": "^1.3.6" + "picgo": "1.4.4" }, "license": "MIT" } diff --git a/src/utils/index.ts b/src/utils/index.ts index acb07c1..762f5a4 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,7 +1,7 @@ import * as path from 'path'; import { IUploadName, IOutputUrl } from '../vs-picgo'; import { window } from 'vscode'; -import { ImgInfo } from 'picgo/dist/utils/interfaces'; +import { ImgInfo } from 'picgo/dist/src/utils/interfaces'; export function formatParam(file: string, mdFileName: string): IUploadName { const dt = new Date(); @@ -12,9 +12,9 @@ export function formatParam(file: string, mdFileName: string): IUploadName { const mm = dt.getMinutes(); const s = dt.getSeconds(); - let pad = function (x: number) { + let pad = function(x: number) { return ('00' + x).slice(-2); - } + }; const date = `${y}-${pad(m)}-${pad(d)}`; var extName = path.extname(file); @@ -61,10 +61,10 @@ export function showInfo(messgae: string) { /** * Return uploaded name accrding to `imgInfo.fileName`, * extname will be removed for the sake of simplicity when used as alt. - * @param imgInfo + * @param imgInfo */ export function getUploadedName(imgInfo: ImgInfo): string { - let fullName + let fullName; if (!imgInfo.fileName) { fullName = ''; } else { diff --git a/src/vs-picgo/index.ts b/src/vs-picgo/index.ts index 4c71613..599e6f7 100644 --- a/src/vs-picgo/index.ts +++ b/src/vs-picgo/index.ts @@ -3,8 +3,8 @@ import * as path from 'path'; import * as os from 'os'; import * as vscode from 'vscode'; -import PicGo from 'picgo/dist/core/PicGo'; -import { ImgInfo, Plugin } from 'picgo/dist/utils/interfaces'; +import PicGo from 'picgo/dist/src/core/PicGo'; +import { ImgInfo, Plugin } from 'picgo/dist/src/utils/interfaces'; import { promisify } from 'util'; @@ -53,9 +53,13 @@ export default class VSPicgo { configPicgo() { const picgoConfigPath = vscode.workspace.getConfiguration('picgo').get('configPath'); if (picgoConfigPath) { - VSPicgo.picgo.setConfig(JSON.parse(fs.readFileSync(picgoConfigPath, { - encoding: 'utf-8' - }))); + VSPicgo.picgo.setConfig( + JSON.parse( + fs.readFileSync(picgoConfigPath, { + encoding: 'utf-8', + }), + ), + ); } else { const picBed = vscode.workspace.getConfiguration('picgo.picBed'); VSPicgo.picgo.setConfig({ picBed }); @@ -80,7 +84,7 @@ export default class VSPicgo { if (err instanceof SyntaxError) { showError( `the data file ${this.dataPath} has syntax error, ` + - `please fix the error by yourself or delete the data file and vs-picgo will recreate for you.`, + `please fix the error by yourself or delete the data file and vs-picgo will recreate for you.`, ); } else { showError(`failed to read from data file ${this.dataPath}: ${err || ''}`); @@ -173,10 +177,6 @@ export default class VSPicgo { showError(`${notice.title}! ${notice.body || ''}${notice.text || ''}`); reject(); }); - VSPicgo.picgo.on('failed', error => { - showError(error.message); - reject(); - }); }); }, ); diff --git a/tsconfig.json b/tsconfig.json index 9763bc5..d3c0455 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,26 +1,22 @@ { - "compilerOptions": { - "module": "commonjs", - "target": "es6", - "outDir": "out", - "lib": [ - "es6" - ], - "allowSyntheticDefaultImports": true, - "resolveJsonModule": true, - "sourceMap": true, - "rootDir": ".", - /* Strict Type-Checking Option */ - "strict": true, - /* enable all strict type-checking options */ - /* Additional Checks */ - "noUnusedLocals": true /* Report errors on unused locals. */ - // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - // "noUnusedParameters": true, /* Report errors on unused parameters. */ - }, - "exclude": [ - "node_modules", - ".vscode-test" - ] -} \ No newline at end of file + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "outDir": "out", + "lib": ["es6"], + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, + "sourceMap": true, + "rootDir": ".", + /* Strict Type-Checking Option */ + "strict": true, + /* enable all strict type-checking options */ + /* Additional Checks */ + "noUnusedLocals": true /* Report errors on unused locals. */ + // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ + // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ + // "noUnusedParameters": true, /* Report errors on unused parameters. */ + }, + "include": ["./src/**/*", "./test/**/*"], + "exclude": ["node_modules", ".vscode-test"] +} diff --git a/yarn.lock b/yarn.lock index e6b5e91..91b3c98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -941,12 +941,15 @@ commander@~2.8.1: dependencies: graceful-readlink ">= 1.0.0" -comment-json@^1.1.3: - version "1.1.3" - resolved "https://registry.npm.taobao.org/comment-json/download/comment-json-1.1.3.tgz#6986c3330fee0c4c9e00c2398cd61afa5d8f239e" - integrity sha1-aYbDMw/uDEyeAMI5jNYa+l2PI54= - dependencies: - json-parser "^1.0.0" +comment-json@^2.3.1: + version "2.4.1" + resolved "https://registry.npm.taobao.org/comment-json/download/comment-json-2.4.1.tgz#2b4223550dc2ec66d147fa43070a77228c86ff33" + integrity sha1-K0IjVQ3C7GbRR/pDBwp3IoyG/zM= + dependencies: + core-util-is "^1.0.2" + esprima "^4.0.1" + has-own-prop "^2.0.0" + repeat-string "^1.6.1" commitizen@^3.0.7: version "3.1.1" @@ -1225,7 +1228,7 @@ core-js@^2.4.0, core-js@^2.5.0: resolved "https://registry.npm.taobao.org/core-js/download/core-js-2.6.8.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcore-js%2Fdownload%2Fcore-js-2.6.8.tgz#dc3a1e633a04267944e0cb850d3880f340248139" integrity sha1-3DoeYzoEJnlE4MuFDTiA80AkgTk= -core-util-is@1.0.2, core-util-is@~1.0.0: +core-util-is@1.0.2, core-util-is@^1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.npm.taobao.org/core-util-is/download/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= @@ -1677,12 +1680,12 @@ escodegen@1.8.x: optionalDependencies: source-map "~0.2.0" -esprima@2.7.x, esprima@^2.7.0, esprima@^2.7.1: +esprima@2.7.x, esprima@^2.7.1: version "2.7.3" resolved "https://registry.npm.taobao.org/esprima/download/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581" integrity sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE= -esprima@^4.0.0: +esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" resolved "https://registry.npm.taobao.org/esprima/download/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha1-E7BM2z5sXRnfkatph6hpVhmwqnE= @@ -2328,6 +2331,11 @@ has-flag@^3.0.0: resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= +has-own-prop@^2.0.0: + version "2.0.0" + resolved "https://registry.npm.taobao.org/has-own-prop/download/has-own-prop-2.0.0.tgz#f0f95d58f65804f5d218db32563bb85b8e0417af" + integrity sha1-8PldWPZYBPXSGNsyVju4W44EF68= + has-symbol-support-x@^1.4.1: version "1.4.2" resolved "https://registry.npm.taobao.org/has-symbol-support-x/download/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" @@ -2829,13 +2837,6 @@ json-parse-better-errors@^1.0.1: resolved "https://registry.npm.taobao.org/json-parse-better-errors/download/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" integrity sha1-u4Z8+zRQ5pEHwTHRxRS6s9yLyqk= -json-parser@^1.0.0: - version "1.1.5" - resolved "https://registry.npm.taobao.org/json-parser/download/json-parser-1.1.5.tgz#e62ec5261d1a6a5fc20e812a320740c6d9005677" - integrity sha1-5i7FJh0aal/CDoEqMgdAxtkAVnc= - dependencies: - esprima "^2.7.0" - json-schema-traverse@^0.4.1: version "0.4.1" resolved "https://registry.npm.taobao.org/json-schema-traverse/download/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" @@ -3656,14 +3657,14 @@ performance-now@^2.1.0: resolved "https://registry.npm.taobao.org/performance-now/download/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -picgo@^1.3.6: - version "1.3.6" - resolved "https://registry.npm.taobao.org/picgo/download/picgo-1.3.6.tgz#61e7127fb3e161cc1b031df33294d313b79d88df" - integrity sha1-YecSf7PhYcwbAx3zMpTTE7ediN8= +picgo@1.4.4: + version "1.4.4" + resolved "https://registry.npm.taobao.org/picgo/download/picgo-1.4.4.tgz#4fd2d51793a7f90a144a816c60035ed1f2f76bf2" + integrity sha1-T9LVF5On+QoUSoFsYANe0fL3a/I= dependencies: chalk "^2.4.1" commander "^2.17.0" - comment-json "^1.1.3" + comment-json "^2.3.1" cross-spawn "^6.0.5" dayjs "^1.7.4" download-git-repo "^1.1.0"