From b4b3d2dcb76f6dfbae8bb9f2d65782354252a4e4 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Wed, 14 Dec 2022 23:05:55 -0300 Subject: [PATCH 01/19] testing --- .github/workflows/ci.yml | 6 +++++- client/src/extension.ts | 18 ++++++++---------- server/package.json | 4 ++++ server/src/cli.ts | 30 ++++++++++++++++++++++++++++++ server/src/server.ts | 12 +++--------- 5 files changed, 50 insertions(+), 20 deletions(-) create mode 100644 server/src/cli.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 41ddf4290..0ee183bc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [ master ] + branches: [ master, publish-npm ] tags: "*.*.*" pull_request: branches: [ master ] @@ -207,3 +207,7 @@ jobs: - name: Publish extension as release if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version + + - name: Publish server to npm + run: npm pack + working-directory: ./server diff --git a/client/src/extension.ts b/client/src/extension.ts index f8acdb1ba..ab2154e5f 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -16,7 +16,7 @@ import { LanguageClientOptions, ServerOptions, State, - TransportKind, + Executable, } from "vscode-languageclient/node"; import * as customCommands from "./commands"; @@ -80,22 +80,20 @@ export function activate(context: ExtensionContext) { function createLanguageClient() { // The server is implemented in node - let serverModule = context.asAbsolutePath( - path.join("server", "out", "server.js") + let serverPath = context.asAbsolutePath( + path.join("server", "out", "cli.js") ); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging - let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; + // let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used + let run: Executable = { command: serverPath }; + let serverOptions: ServerOptions = { - run: { module: serverModule, transport: TransportKind.ipc }, - debug: { - module: serverModule, - transport: TransportKind.ipc, - options: debugOptions, - }, + run, + debug: run, }; // Options to control the language client diff --git a/server/package.json b/server/package.json index bfc41d3f1..0c8ff9fac 100644 --- a/server/package.json +++ b/server/package.json @@ -4,6 +4,10 @@ "version": "1.8.2", "author": "chenglou", "license": "MIT", + "main": "./out/cli.js", + "bin": { + "rescriptlsp": "./out/cli.js" + }, "engines": { "node": "*" }, diff --git a/server/src/cli.ts b/server/src/cli.ts new file mode 100644 index 000000000..44c2718d6 --- /dev/null +++ b/server/src/cli.ts @@ -0,0 +1,30 @@ +#!/usr/bin/env node +import fs from "fs"; +import server from "./server"; + +const args = process.argv.slice(2) + +const help = `ReScript Language Server + +Options: + +--version Print version +--help Print help`; + +(() => { + if (args.length === 0) { + return server(); + } + + switch (args[0]) { + case '--version': + console.log(JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version); + process.exit(0); + case '--help': + console.log(help); + process.exit(0); + default: + console.log(help); + process.exit(1) + } +})(); \ No newline at end of file diff --git a/server/src/server.ts b/server/src/server.ts index 5b3be2505..fe4632c12 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -400,19 +400,13 @@ let getOpenedFileContent = (fileUri: string) => { }; // Start listening now! -// We support two modes: the regular node RPC mode for VSCode, and the --stdio -// mode for other editors The latter is _technically unsupported_. It's an -// implementation detail that might change at any time -if (process.argv.includes("--stdio")) { +// We support only --stdio mode +export default function listen() { let writer = new rpc.StreamMessageWriter(process.stdout); let reader = new rpc.StreamMessageReader(process.stdin); // proper `this` scope for writer send = (msg: p.Message) => writer.write(msg); - reader.listen(onMessage); -} else { - // proper `this` scope for process - send = (msg: p.Message) => process.send!(msg); - process.on("message", onMessage); + return reader.listen(onMessage); } function hover(msg: p.RequestMessage) { From b0b1bb3105127889432d032026f01b05f2148b95 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Wed, 14 Dec 2022 23:17:27 -0300 Subject: [PATCH 02/19] simplify ci --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ee183bc4..4ec7f00be 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,18 +14,18 @@ jobs: matrix: # Stay on the oldest Ubuntu version that's still supported by Github Actions # to avoid glibc incompatibilities as far as possible. - os: [macos-latest, macos-arm, ubuntu-20.04, windows-latest] + os: [ubuntu-20.04] # syntax explanation: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations include: - - os: macos-latest - artifact-folder: darwin - - os: macos-arm - artifact-folder: darwinarm64 + # - os: macos-latest + # artifact-folder: darwin + # - os: macos-arm + # artifact-folder: darwinarm64 - os: ubuntu-20.04 artifact-folder: linux - - os: windows-latest - artifact-folder: win32 + # - os: windows-latest + # artifact-folder: win32 runs-on: ${{matrix.os}} @@ -209,5 +209,5 @@ jobs: run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version - name: Publish server to npm - run: npm pack + run: npm publish --dry-run working-directory: ./server From 813e425386b503065b016afd5f099d6a6f624f09 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Wed, 14 Dec 2022 23:25:06 -0300 Subject: [PATCH 03/19] fix test ci --- .github/workflows/ci.yml | 44 ++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4ec7f00be..6f6206175 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,21 +96,21 @@ jobs: - run: npm ci - run: npm run compile - - name: Download MacOS binary - uses: actions/download-artifact@v3 - with: - name: macos-latest - path: ./server/analysis_binaries - - run: tar -xvf binary.tar - working-directory: ./server/analysis_binaries - - - name: Download MacOS ARM binary - uses: actions/download-artifact@v3 - with: - name: macos-arm - path: ./server/analysis_binaries - - run: tar -xvf binary.tar - working-directory: ./server/analysis_binaries + # - name: Download MacOS binary + # uses: actions/download-artifact@v3 + # with: + # name: macos-latest + # path: ./server/analysis_binaries + # - run: tar -xvf binary.tar + # working-directory: ./server/analysis_binaries + + # - name: Download MacOS ARM binary + # uses: actions/download-artifact@v3 + # with: + # name: macos-arm + # path: ./server/analysis_binaries + # - run: tar -xvf binary.tar + # working-directory: ./server/analysis_binaries - name: Download Linux binary uses: actions/download-artifact@v3 @@ -120,13 +120,13 @@ jobs: - run: tar -xvf binary.tar working-directory: ./server/analysis_binaries - - name: Download Windows binary - uses: actions/download-artifact@v3 - with: - name: windows-latest - path: ./server/analysis_binaries - - run: tar -xvf binary.tar - working-directory: ./server/analysis_binaries + # - name: Download Windows binary + # uses: actions/download-artifact@v3 + # with: + # name: windows-latest + # path: ./server/analysis_binaries + # - run: tar -xvf binary.tar + # working-directory: ./server/analysis_binaries - name: Cleanup tar file run: rm binary.tar From b530dd8c77cb4b839072abc1063244805d7ada95 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 15 Dec 2022 00:20:15 -0300 Subject: [PATCH 04/19] npm publish test ci --- .github/workflows/ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f6206175..69c9bec3d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,6 +208,17 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version - - name: Publish server to npm - run: npm publish --dry-run + - name: Publish pre-release server to npm + # if: github.ref == 'refs/heads/master' + run: | + npm version minor + npm publish --dry-run + # npm publish --tag experimental + working-directory: ./server + + - name: Publish release server to npm + if: startsWith(github.ref, 'refs/tags/') + run: | + npm version ${{ steps.tag_name.outputs.tag }} + npm publish --tag latest working-directory: ./server From 5026760667be4381739d690f7ff438871f9b6ea6 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 15 Dec 2022 01:40:52 -0300 Subject: [PATCH 05/19] update server cli --- server/src/cli.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/cli.ts b/server/src/cli.ts index 44c2718d6..754eed684 100644 --- a/server/src/cli.ts +++ b/server/src/cli.ts @@ -6,10 +6,12 @@ const args = process.argv.slice(2) const help = `ReScript Language Server +Usage: rescriptlsp [options?] + Options: ---version Print version ---help Print help`; +-v, --version Print version +-h, --help Print help`; (() => { if (args.length === 0) { @@ -18,13 +20,15 @@ Options: switch (args[0]) { case '--version': + case '-v': console.log(JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version); process.exit(0); case '--help': + case '-h': console.log(help); process.exit(0); default: console.log(help); process.exit(1) } -})(); \ No newline at end of file +})(); From b08d00d1858260fd4e84ca76f32251b455b8fcb3 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Thu, 15 Dec 2022 15:37:02 -0300 Subject: [PATCH 06/19] update server --- .github/workflows/ci.yml | 9 +++++---- client/src/extension.ts | 12 ++++++++---- server/src/cli.ts | 7 +++++-- server/src/server.ts | 24 ++++++++++++++++-------- 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 69c9bec3d..a6f3594ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,12 +208,13 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version + # Get version from experimental tag and increment minor version - name: Publish pre-release server to npm - # if: github.ref == 'refs/heads/master' + if: github.ref == 'refs/heads/master' run: | - npm version minor - npm publish --dry-run - # npm publish --tag experimental + NEW_NPM_VERSION=$(npm show rescript-language-server dist-tags --json | jq -r '.experimental' | awk 'BEGIN{FS=OFS="."} {$2+=1} 1') + npm version $(NEW_NPM_VERSION) + npm publish --tag experimental working-directory: ./server - name: Publish release server to npm diff --git a/client/src/extension.ts b/client/src/extension.ts index ab2154e5f..b1aab3409 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -17,6 +17,7 @@ import { ServerOptions, State, Executable, + TransportKind } from "vscode-languageclient/node"; import * as customCommands from "./commands"; @@ -89,11 +90,14 @@ export function activate(context: ExtensionContext) { // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used - let run: Executable = { command: serverPath }; - let serverOptions: ServerOptions = { - run, - debug: run, + // run, + run: { command: serverPath }, + debug: { + command: serverPath, + transport: TransportKind.ipc, + // options: debugOptions, + }, }; // Options to control the language client diff --git a/server/src/cli.ts b/server/src/cli.ts index 754eed684..9019a2ef9 100644 --- a/server/src/cli.ts +++ b/server/src/cli.ts @@ -1,6 +1,6 @@ #!/usr/bin/env node import fs from "fs"; -import server from "./server"; +// import server from "./server"; const args = process.argv.slice(2) @@ -10,15 +10,18 @@ Usage: rescriptlsp [options?] Options: +--stdio Use stdio -v, --version Print version -h, --help Print help`; (() => { if (args.length === 0) { - return server(); + // return server(); } switch (args[0]) { + case '--stdio': + // return server(true); case '--version': case '-v': console.log(JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version); diff --git a/server/src/server.ts b/server/src/server.ts index fe4632c12..391a6ef9a 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -399,14 +399,22 @@ let getOpenedFileContent = (fileUri: string) => { return content; }; -// Start listening now! -// We support only --stdio mode -export default function listen() { - let writer = new rpc.StreamMessageWriter(process.stdout); - let reader = new rpc.StreamMessageReader(process.stdin); - // proper `this` scope for writer - send = (msg: p.Message) => writer.write(msg); - return reader.listen(onMessage); +export default function listen(useStdio = false) { + // Start listening now! + // We support two modes: the regular node RPC mode for VSCode, and the --stdio + // mode for other editors The latter is _technically unsupported_. It's an + // implementation detail that might change at any time + if (useStdio) { + let writer = new rpc.StreamMessageWriter(process.stdout); + let reader = new rpc.StreamMessageReader(process.stdin); + // proper `this` scope for writer + send = (msg: p.Message) => writer.write(msg); + reader.listen(onMessage); + } else { + // proper `this` scope for process + send = (msg: p.Message) => process.send!(msg); + process.on("message", onMessage); + } } function hover(msg: p.RequestMessage) { From a26fa2f83efc60be1f31e5e474006ccfc84601c6 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 17 Feb 2023 02:54:33 -0300 Subject: [PATCH 07/19] add node-ipc --- client/src/extension.ts | 11 ++++++----- server/README.md | 20 ++++++++++++++++++++ server/package-lock.json | 3 +++ server/package.json | 4 ++++ server/src/cli.ts | 13 ++++++------- 5 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 server/README.md diff --git a/client/src/extension.ts b/client/src/extension.ts index b1aab3409..8669c822a 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -81,22 +81,23 @@ export function activate(context: ExtensionContext) { function createLanguageClient() { // The server is implemented in node - let serverPath = context.asAbsolutePath( + let serverModule = context.asAbsolutePath( path.join("server", "out", "cli.js") ); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging - // let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; + let debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] }; // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used let serverOptions: ServerOptions = { // run, - run: { command: serverPath }, + run: { module: serverModule, args: ["--node-ipc"], transport: TransportKind.ipc }, debug: { - command: serverPath, + module: serverModule, + args: ["--node-ipc"], transport: TransportKind.ipc, - // options: debugOptions, + options: debugOptions }, }; diff --git a/server/README.md b/server/README.md new file mode 100644 index 000000000..a2418ae54 --- /dev/null +++ b/server/README.md @@ -0,0 +1,20 @@ +# ReScript Language Server + +## Run + +```sh +resciptlsp --stdio +``` + +```sh +ReScript Language Server + +Usage: rescriptlsp [options] + +Options: + +--stdio Use stdio +--node-ipc Use node-ipc +-v, --version Print version +-h, --help Print help +``` \ No newline at end of file diff --git a/server/package-lock.json b/server/package-lock.json index 214a64a46..10ca5eaef 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -14,6 +14,9 @@ "vscode-languageserver": "^8.0.1", "vscode-languageserver-protocol": "^3.17.1" }, + "bin": { + "rescriptlsp": "out/cli.js" + }, "engines": { "node": "*" } diff --git a/server/package.json b/server/package.json index a48dab6a9..d559d939e 100644 --- a/server/package.json +++ b/server/package.json @@ -8,6 +8,10 @@ "bin": { "rescriptlsp": "./out/cli.js" }, + "files": [ + "out/*", + "README.md" + ], "engines": { "node": "*" }, diff --git a/server/src/cli.ts b/server/src/cli.ts index 9019a2ef9..6018f4c2b 100644 --- a/server/src/cli.ts +++ b/server/src/cli.ts @@ -1,27 +1,26 @@ #!/usr/bin/env node import fs from "fs"; -// import server from "./server"; +import server from "./server"; const args = process.argv.slice(2) const help = `ReScript Language Server -Usage: rescriptlsp [options?] +Usage: rescriptlsp [options] Options: --stdio Use stdio +--node-ipc Use node-ipc -v, --version Print version -h, --help Print help`; (() => { - if (args.length === 0) { - // return server(); - } - switch (args[0]) { case '--stdio': - // return server(true); + return server(true); + case '--node-ipc': + return server(false); case '--version': case '-v': console.log(JSON.parse(fs.readFileSync('./package.json', { encoding: 'utf8' })).version); From b292d62790917403a86fbfdd87b41d622a4fbb3b Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 17 Feb 2023 02:57:50 -0300 Subject: [PATCH 08/19] restore ci --- .github/workflows/ci.yml | 69 +++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6f3594ce..5d406acf4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,7 +2,7 @@ name: CI on: push: - branches: [ master, publish-npm ] + branches: [ master ] tags: "*.*.*" pull_request: branches: [ master ] @@ -14,18 +14,18 @@ jobs: matrix: # Stay on the oldest Ubuntu version that's still supported by Github Actions # to avoid glibc incompatibilities as far as possible. - os: [ubuntu-20.04] + os: [macos-latest, macos-arm, ubuntu-20.04, windows-latest] # syntax explanation: # https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations include: - # - os: macos-latest - # artifact-folder: darwin - # - os: macos-arm - # artifact-folder: darwinarm64 + - os: macos-latest + artifact-folder: darwin + - os: macos-arm + artifact-folder: darwinarm64 - os: ubuntu-20.04 artifact-folder: linux - # - os: windows-latest - # artifact-folder: win32 + - os: windows-latest + artifact-folder: win32 runs-on: ${{matrix.os}} @@ -96,21 +96,21 @@ jobs: - run: npm ci - run: npm run compile - # - name: Download MacOS binary - # uses: actions/download-artifact@v3 - # with: - # name: macos-latest - # path: ./server/analysis_binaries - # - run: tar -xvf binary.tar - # working-directory: ./server/analysis_binaries - - # - name: Download MacOS ARM binary - # uses: actions/download-artifact@v3 - # with: - # name: macos-arm - # path: ./server/analysis_binaries - # - run: tar -xvf binary.tar - # working-directory: ./server/analysis_binaries + - name: Download MacOS binary + uses: actions/download-artifact@v3 + with: + name: macos-latest + path: ./server/analysis_binaries + - run: tar -xvf binary.tar + working-directory: ./server/analysis_binaries + + - name: Download MacOS ARM binary + uses: actions/download-artifact@v3 + with: + name: macos-arm + path: ./server/analysis_binaries + - run: tar -xvf binary.tar + working-directory: ./server/analysis_binaries - name: Download Linux binary uses: actions/download-artifact@v3 @@ -120,13 +120,13 @@ jobs: - run: tar -xvf binary.tar working-directory: ./server/analysis_binaries - # - name: Download Windows binary - # uses: actions/download-artifact@v3 - # with: - # name: windows-latest - # path: ./server/analysis_binaries - # - run: tar -xvf binary.tar - # working-directory: ./server/analysis_binaries + - name: Download Windows binary + uses: actions/download-artifact@v3 + with: + name: windows-latest + path: ./server/analysis_binaries + - run: tar -xvf binary.tar + working-directory: ./server/analysis_binaries - name: Cleanup tar file run: rm binary.tar @@ -208,15 +208,6 @@ jobs: if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version - # Get version from experimental tag and increment minor version - - name: Publish pre-release server to npm - if: github.ref == 'refs/heads/master' - run: | - NEW_NPM_VERSION=$(npm show rescript-language-server dist-tags --json | jq -r '.experimental' | awk 'BEGIN{FS=OFS="."} {$2+=1} 1') - npm version $(NEW_NPM_VERSION) - npm publish --tag experimental - working-directory: ./server - - name: Publish release server to npm if: startsWith(github.ref, 'refs/tags/') run: | From b860f9f59147b8dd855b5049b056b8279b8bb326 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Fri, 17 Feb 2023 02:58:29 -0300 Subject: [PATCH 09/19] restore ci --- .github/workflows/ci.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d406acf4..41ddf4290 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -207,10 +207,3 @@ jobs: - name: Publish extension as release if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version - - - name: Publish release server to npm - if: startsWith(github.ref, 'refs/tags/') - run: | - npm version ${{ steps.tag_name.outputs.tag }} - npm publish --tag latest - working-directory: ./server From c35ac1ddc2a20053db761de48bc9eec216dd17d0 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 00:22:58 -0300 Subject: [PATCH 10/19] update --- client/src/extension.ts | 2 +- server/README.md | 12 +++++++++--- server/package-lock.json | 10 +++++----- server/package.json | 23 +++++++++++++++++------ server/src/cli.ts | 11 +++++------ server/src/rescriptls | 2 ++ 6 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 server/src/rescriptls diff --git a/client/src/extension.ts b/client/src/extension.ts index 8669c822a..0aaf33b2e 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -82,7 +82,7 @@ export function activate(context: ExtensionContext) { function createLanguageClient() { // The server is implemented in node let serverModule = context.asAbsolutePath( - path.join("server", "out", "cli.js") + path.join("server", "out", "rescriptls") ); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging diff --git a/server/README.md b/server/README.md index a2418ae54..d144a58f9 100644 --- a/server/README.md +++ b/server/README.md @@ -1,15 +1,21 @@ # ReScript Language Server +## Install + +```sh +npm install -g @rescript/lsp +``` + ## Run ```sh -resciptlsp --stdio +resciptls --stdio ``` ```sh ReScript Language Server -Usage: rescriptlsp [options] +Usage: rescriptls [options] Options: @@ -17,4 +23,4 @@ Options: --node-ipc Use node-ipc -v, --version Print version -h, --help Print help -``` \ No newline at end of file +``` diff --git a/server/package-lock.json b/server/package-lock.json index ce13d9bd8..1e772a75f 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { - "name": "rescript-language-server", - "version": "1.20.0", + "name": "@rescript/lsp", + "version": "3.1.0-beta.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "rescript-language-server", - "version": "1.20.0", + "name": "@rescript/lsp", + "version": "3.1.0-beta.0", "license": "MIT", "dependencies": { "chokidar": "^3.5.1", @@ -15,7 +15,7 @@ "vscode-languageserver-protocol": "^3.17.1" }, "bin": { - "rescriptlsp": "out/cli.js" + "rescriptls": "out/rescriptls" }, "engines": { "node": "*" diff --git a/server/package.json b/server/package.json index 8618ab6ef..4f981643d 100644 --- a/server/package.json +++ b/server/package.json @@ -1,13 +1,17 @@ { - "name": "rescript-language-server", - "description": "ReScript's language-server", + "name": "@rescript/lsp", + "description": "LSP server for ReScript", "version": "1.20.0", "author": "chenglou", "license": "MIT", - "main": "./out/cli.js", "bin": { - "rescriptlsp": "./out/cli.js" + "rescriptls": "out/rescriptls" }, + "keywords": [ + "ReScript", + "LSP", + "Language Server" + ], "files": [ "out/*", "README.md" @@ -15,9 +19,14 @@ "engines": { "node": "*" }, + "homepage": "https://github.com/rescript-lang/rescript-vscode/server/README.md", "repository": { "type": "git", - "url": "https://github.com/rescript-lang/rescript-vscode" + "url": "https://github.com/rescript-lang/rescript-vscode", + "directory": "server" + }, + "bugs": { + "url": "https://github.com/rescript-lang/rescript-vscode/issues" }, "dependencies": { "chokidar": "^3.5.1", @@ -25,5 +34,7 @@ "vscode-languageserver": "^8.0.1", "vscode-languageserver-protocol": "^3.17.1" }, - "scripts": {} + "scripts": { + "build": "cp src/rescriptls out/rescriptls" + } } diff --git a/server/src/cli.ts b/server/src/cli.ts index 6018f4c2b..44bd52bc9 100644 --- a/server/src/cli.ts +++ b/server/src/cli.ts @@ -1,4 +1,3 @@ -#!/usr/bin/env node import fs from "fs"; import server from "./server"; @@ -6,14 +5,14 @@ const args = process.argv.slice(2) const help = `ReScript Language Server -Usage: rescriptlsp [options] +Usage: rescriptls [options] Options: ---stdio Use stdio ---node-ipc Use node-ipc --v, --version Print version --h, --help Print help`; +--stdio Use stdio +--node-ipc Use node-ipc +-v, --version Print version +-h, --help Print help`; (() => { switch (args[0]) { diff --git a/server/src/rescriptls b/server/src/rescriptls new file mode 100644 index 000000000..1f2ec24fa --- /dev/null +++ b/server/src/rescriptls @@ -0,0 +1,2 @@ +#!/usr/bin/env node +require("./cli.js") From f94f3ee6c7ef68c2870372ff60b0acb7d9549e09 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 00:26:01 -0300 Subject: [PATCH 11/19] test ci --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 330a23f33..654117ccd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -211,3 +211,7 @@ jobs: - name: Publish extension as release if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version + + - name: NPM dry-run + working-directory: server + run: npm publish --dry-run From fa854c4e2751e4c890d91d743a0501aef1eb1ee8 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 00:38:57 -0300 Subject: [PATCH 12/19] update ci --- .github/workflows/ci.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 654117ccd..89fc2c6d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -214,4 +214,12 @@ jobs: - name: NPM dry-run working-directory: server - run: npm publish --dry-run + run: | + npm build + npm publish --dry-run + + - name: Test LSP install + working-directory: server + run: | + npm install -g . + rescriptls --help From 3f5083c49549247be0464fbf72ca4b9fa32b9edf Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 00:51:38 -0300 Subject: [PATCH 13/19] fix cmd --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89fc2c6d9..5c97e4a8c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -215,7 +215,7 @@ jobs: - name: NPM dry-run working-directory: server run: | - npm build + npm run build npm publish --dry-run - name: Test LSP install From e3f8f6c49144ce2e4c26c1818b69417d4afa450b Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 01:05:50 -0300 Subject: [PATCH 14/19] test matrix os --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c97e4a8c..870866186 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: package: needs: test - runs-on: ubuntu-20.04 + runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v3 From 16e86df28e8e94578c83cc0793a53ff51619adce Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 01:16:09 -0300 Subject: [PATCH 15/19] test with windows --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 870866186..e2067c4a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: package: needs: test - runs-on: ${{matrix.os}} + runs-on: windows-latest steps: - uses: actions/checkout@v3 From 7b5b2ba4ac2eae7a361fbf401f10c6c21cf178ea Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 01:32:26 -0300 Subject: [PATCH 16/19] update --- CONTRIBUTING.md | 12 +++++++++++- server/package.json | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9bbc16c1e..b7c122bff 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,9 @@ Thanks for your interest. Below is an informal spec of how the plugin's server c ├── package.json // The extension manifest └── server // Language Server. Usable standalone ├── src - │ └── server.ts // Language Server entry point + │ ├── server.ts // Language Server Module + │ ├── cli.ts // LSP CLI + │ ├── rescripls // Binary └── analysis_binaries // Prod-time platform-specific analysis binaries ├── darwin ├── linux @@ -46,6 +48,14 @@ opam install ocaml-lsp-server - `npm run compile`. You don't need this if you're developing this repo in VSCode. The compilation happens automatically in the background. - `cd analysis && make`. +## Build LSP + +Enter `server` folder + +```sh +npm run build +``` + ## Test - Open VS Code to the project root. diff --git a/server/package.json b/server/package.json index 4f981643d..88d2efa26 100644 --- a/server/package.json +++ b/server/package.json @@ -14,6 +14,7 @@ ], "files": [ "out/*", + "analysis_binaries", "README.md" ], "engines": { From 3bad7043b0c66f9ae05bf1750d9899f13783e60e Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 02:14:40 -0300 Subject: [PATCH 17/19] update --- .github/workflows/ci.yml | 14 +------------- client/src/extension.ts | 2 +- server/package-lock.json | 6 +++--- server/package.json | 5 +---- server/src/cli.ts | 1 + server/src/rescriptls | 2 -- 6 files changed, 7 insertions(+), 23 deletions(-) delete mode 100644 server/src/rescriptls diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e2067c4a8..330a23f33 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,7 +87,7 @@ jobs: package: needs: test - runs-on: windows-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v3 @@ -211,15 +211,3 @@ jobs: - name: Publish extension as release if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version - - - name: NPM dry-run - working-directory: server - run: | - npm run build - npm publish --dry-run - - - name: Test LSP install - working-directory: server - run: | - npm install -g . - rescriptls --help diff --git a/client/src/extension.ts b/client/src/extension.ts index 0aaf33b2e..8669c822a 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -82,7 +82,7 @@ export function activate(context: ExtensionContext) { function createLanguageClient() { // The server is implemented in node let serverModule = context.asAbsolutePath( - path.join("server", "out", "rescriptls") + path.join("server", "out", "cli.js") ); // The debug options for the server // --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging diff --git a/server/package-lock.json b/server/package-lock.json index 1e772a75f..dc3d20848 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,12 +1,12 @@ { "name": "@rescript/lsp", - "version": "3.1.0-beta.0", + "version": "1.20.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@rescript/lsp", - "version": "3.1.0-beta.0", + "version": "1.20.0", "license": "MIT", "dependencies": { "chokidar": "^3.5.1", @@ -15,7 +15,7 @@ "vscode-languageserver-protocol": "^3.17.1" }, "bin": { - "rescriptls": "out/rescriptls" + "rescriptls": "rescriptls" }, "engines": { "node": "*" diff --git a/server/package.json b/server/package.json index 88d2efa26..fbfb20ccb 100644 --- a/server/package.json +++ b/server/package.json @@ -5,7 +5,7 @@ "author": "chenglou", "license": "MIT", "bin": { - "rescriptls": "out/rescriptls" + "rescriptls": "./out/cli.js" }, "keywords": [ "ReScript", @@ -34,8 +34,5 @@ "vscode-jsonrpc": "^8.0.1", "vscode-languageserver": "^8.0.1", "vscode-languageserver-protocol": "^3.17.1" - }, - "scripts": { - "build": "cp src/rescriptls out/rescriptls" } } diff --git a/server/src/cli.ts b/server/src/cli.ts index 44bd52bc9..d67f72a78 100644 --- a/server/src/cli.ts +++ b/server/src/cli.ts @@ -1,3 +1,4 @@ +#!/usr/bin/env node import fs from "fs"; import server from "./server"; diff --git a/server/src/rescriptls b/server/src/rescriptls deleted file mode 100644 index 1f2ec24fa..000000000 --- a/server/src/rescriptls +++ /dev/null @@ -1,2 +0,0 @@ -#!/usr/bin/env node -require("./cli.js") From 386add13d7823764ffaefbff32122169e6471757 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 02:16:19 -0300 Subject: [PATCH 18/19] update --- CONTRIBUTING.md | 9 --------- client/src/extension.ts | 3 +-- 2 files changed, 1 insertion(+), 11 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b7c122bff..b13cdac66 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -17,7 +17,6 @@ Thanks for your interest. Below is an informal spec of how the plugin's server c ├── src │ ├── server.ts // Language Server Module │ ├── cli.ts // LSP CLI - │ ├── rescripls // Binary └── analysis_binaries // Prod-time platform-specific analysis binaries ├── darwin ├── linux @@ -48,14 +47,6 @@ opam install ocaml-lsp-server - `npm run compile`. You don't need this if you're developing this repo in VSCode. The compilation happens automatically in the background. - `cd analysis && make`. -## Build LSP - -Enter `server` folder - -```sh -npm run build -``` - ## Test - Open VS Code to the project root. diff --git a/client/src/extension.ts b/client/src/extension.ts index 8669c822a..1ef2e2bca 100644 --- a/client/src/extension.ts +++ b/client/src/extension.ts @@ -91,13 +91,12 @@ export function activate(context: ExtensionContext) { // If the extension is launched in debug mode then the debug server options are used // Otherwise the run options are used let serverOptions: ServerOptions = { - // run, run: { module: serverModule, args: ["--node-ipc"], transport: TransportKind.ipc }, debug: { module: serverModule, args: ["--node-ipc"], transport: TransportKind.ipc, - options: debugOptions + options: debugOptions, }, }; From 78f47d3238b0316baf227f9d24d5b05121b5e123 Mon Sep 17 00:00:00 2001 From: Pedro Castro Date: Sun, 8 Oct 2023 02:38:25 -0300 Subject: [PATCH 19/19] add ci step to publish --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 330a23f33..d83653e2a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,6 +57,7 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 + registry-url: 'https://registry.npmjs.org' - run: npm ci - run: opam install dune cppo @@ -211,3 +212,10 @@ jobs: - name: Publish extension as release if: startsWith(github.ref, 'refs/tags/') run: npx vsce publish --pat ${{ secrets.MARKETPLACE_TOKEN }} ${{ steps.tag_name.outputs.tag }} --no-git-tag-version + + - name: Publish LSP to NPM + if: startsWith(github.ref, 'refs/tags/') + working-directory: server + run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}