From f04b63bda3d7a73aa645b865801efa8810c261af Mon Sep 17 00:00:00 2001 From: Doron Behar Date: Thu, 13 Jun 2024 13:19:14 +0300 Subject: [PATCH] spectral-language-server: use yarnConfigHook instead of mkYarnPackage --- .../sp/spectral-language-server/package.json | 159 ------------------ .../sp/spectral-language-server/package.nix | 21 +-- 2 files changed, 9 insertions(+), 171 deletions(-) delete mode 100644 pkgs/by-name/sp/spectral-language-server/package.json diff --git a/pkgs/by-name/sp/spectral-language-server/package.json b/pkgs/by-name/sp/spectral-language-server/package.json deleted file mode 100644 index 1f3651349c62..000000000000 --- a/pkgs/by-name/sp/spectral-language-server/package.json +++ /dev/null @@ -1,159 +0,0 @@ -{ - "activationEvents": [ - "onStartupFinished" - ], - "author": "Stoplight ", - "bugs": { - "url": "https://github.com/stoplightio/vscode-spectral/issues" - }, - "categories": [ - "Linters" - ], - "contributes": { - "configuration": { - "properties": { - "spectral.enable": { - "default": true, - "description": "Controls whether or not Spectral is enabled.", - "scope": "resource", - "type": "boolean" - }, - "spectral.rulesetFile": { - "description": "Location of the ruleset file to use when validating. If omitted, the default is a .spectral.yml/.spectral.json in the same folder as the document being validated. Paths are relative to the workspace. This can also be a remote HTTP url.", - "scope": "resource", - "type": "string" - }, - "spectral.run": { - "default": "onType", - "description": "Run the linter on save (onSave) or as you type (onType).", - "enum": [ - "onSave", - "onType" - ], - "scope": "resource", - "type": "string" - }, - "spectral.trace.server": { - "default": "off", - "description": "Traces the communication between VS Code and the language server.", - "enum": [ - "off", - "messages", - "verbose" - ], - "scope": "window", - "type": "string" - }, - "spectral.validateFiles": { - "description": "An array of file globs (e.g., `**/*.yaml`) in minimatch glob format which should be validated by Spectral. If language identifiers are also specified, the file must match both in order to be validated. You can also use negative file globs (e.g., `!**/package.json`) here to exclude files.", - "items": { - "type": "string" - }, - "scope": "resource", - "type": "array" - }, - "spectral.validateLanguages": { - "default": [ - "json", - "yaml" - ], - "description": "An array of language IDs which should be validated by Spectral. If file globs are also specified, the file must match both in order to be validated.", - "items": { - "type": "string" - }, - "scope": "resource", - "type": "array" - } - }, - "title": "Spectral", - "type": "object" - }, - "commands": [ - { - "title": "Show Output Channel", - "category": "Spectral", - "command": "spectral.showOutputChannel" - } - ] - }, - "description": "JSON/YAML linter with OpenAPI and custom ruleset support.", - "devDependencies": { - "@types/chai": "^4.3.1", - "@types/chai-jest-snapshot": "^1.3.6", - "@types/glob": "^7.2.0", - "@types/mocha": "^9.1.0", - "@types/node": "^18.11.18", - "@types/vscode": "^1.48.0", - "@typescript-eslint/eslint-plugin": "^4.33.0", - "@typescript-eslint/parser": "^4.1.0", - "chai": "^4.2.0", - "chai-jest-snapshot": "^2.0.0", - "copyfiles": "^2.4.1", - "cross-env": "^7.0.3", - "eslint": "^7.8.1", - "eslint-config-google": "^0.14.0", - "glob": "^8.0.3", - "http-test-servers": "^2.0.0", - "merge-options": "^3.0.0", - "mocha": "^8.1.3", - "rimraf": "^3.0.2", - "semver": "^7.3.2", - "shelljs": "^0.8.5", - "ts-loader": "^9.2.8", - "ts-node": "^8.10.2", - "typescript": "beta", - "vsce": "^1.103.1", - "vscode-test": "^1.5.0", - "webpack": "^5.72.0", - "webpack-cli": "^4.9.2" - }, - "displayName": "Spectral", - "engines": { - "vscode": "^1.48.0", - "node": "^12.20 || >= 14.13" - }, - "homepage": "https://github.com/stoplightio/vscode-spectral", - "icon": "icon.png", - "keywords": [ - "linter", - "validator", - "OpenAPI", - "Swagger", - "API", - "style guide", - "API description", - "API specification", - "OAS", - "OAS2", - "OAS3", - "AsyncAPI", - "json", - "yaml" - ], - "license": "Apache-2.0", - "main": "./client/index.js", - "name": "spectral", - "private": true, - "publisher": "stoplight", - "repository": { - "type": "git", - "url": "https://github.com/stoplightio/vscode-spectral" - }, - "scripts": { - "clean": "rimraf dist && rimraf \"{server,client}/dist\"", - "lint": "eslint --ext .ts,.js .", - "test": "mocha -r ts-node/register \"./+(client|server)/__tests__/unit/**/*.test.ts\"", - "test:e2e": "cross-env CI=true CHAI_JEST_SNAPSHOT_UPDATE_ALL=false ts-node ./client/src/__tests__/e2e/index.ts" - }, - "version": "1.1.2", - "workspaces": { - "packages": [ - "client", - "server" - ], - "nohoist": [ - "client/**", - "server/**" - ] - } -} diff --git a/pkgs/by-name/sp/spectral-language-server/package.nix b/pkgs/by-name/sp/spectral-language-server/package.nix index 8193ff3acebd..9c895e171f7a 100644 --- a/pkgs/by-name/sp/spectral-language-server/package.nix +++ b/pkgs/by-name/sp/spectral-language-server/package.nix @@ -1,7 +1,10 @@ { lib , buildNpmPackage -, mkYarnPackage +, stdenv , fetchYarnDeps +, yarnConfigHook +, yarnBuildHook +, nodejs , fetchFromGitHub , typescript , jq @@ -10,33 +13,29 @@ let # Instead of the build script that spectral-language-server provides (ref: https://github.com/luizcorreia/spectral-language-server/blob/master/script/vscode-spectral-build.sh), we build vscode-spectral manually. # This is because the script must go through the network and will not work under the Nix sandbox environment. - vscodeSpectral = mkYarnPackage rec { + vscodeSpectral = stdenv.mkDerivation (finalAttrs: { pname = "vscode-spectral"; version = "1.1.2"; src = fetchFromGitHub { owner = "stoplightio"; repo = "vscode-spectral"; - rev = "v${version}"; + rev = "v${finalAttrs.version}"; hash = "sha256-TWy+bC6qhTKDY874ORTBbvCIH8ycpmBiU8GLYxBIiAs="; }; - packageJSON = ./package.json; - offlineCache = fetchYarnDeps { - yarnLock = src + "/yarn.lock"; + yarnLock = finalAttrs.src + "/yarn.lock"; hash = "sha256-am27A9VyFoXuOlgG9mnvNqV3Q7Bi7GJzDqqVFGDVWIA="; }; - nativeBuildInputs = [ typescript jq ]; + nativeBuildInputs = [ typescript jq yarnConfigHook ]; postPatch = '' cp server/tsconfig.json server/tsconfig.json.bak jq '.compilerOptions += {"module": "NodeNext", "moduleResolution": "NodeNext"}' server/tsconfig.json.bak > server/tsconfig.json ''; - dontConfigure = true; - buildPhase = '' runHook preBuild # FIXME: vscode-spactral depends on @rollup/pluginutils, but it may have a bug that doesn't provide the type definitions for NodeNext module resolution. (ref: https://github.com/rollup/plugins/issues/1192) @@ -53,14 +52,12 @@ let runHook postInstall ''; - doDist = false; - meta = with lib; { homepage = "https://github.com/stoplightio/vscode-spectral"; description = "VS Code extension bringing the awesome Spectral JSON/YAML linter with OpenAPI/AsyncAPI support"; license = licenses.asl20; }; - }; + }); in buildNpmPackage rec { pname = "spectral-language-server";