chore: bundle extension
MODIFY
editors/vscode/.vscodeignore
editors/vscode/.vscodeignore
!icon.png
!LICENSE
!node_modules/
-!out/extension.js
+!out/main.js
!package-lock.json
!package.json
!server/rome_lsp

MODIFY
editors/vscode/package-lock.json
editors/vscode/package-lock.json
{
"name": "rome",
- "version": "0.6.0",
+ "version": "0.0.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==",
"dev": true
},
+ "esbuild": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.14.27.tgz",
+ "integrity": "sha512-MZQt5SywZS3hA9fXnMhR22dv0oPGh6QtjJRIYbgL1AeqAoQZE+Qn5ppGYQAoHv/vq827flj4tIJ79Mrdiwk46Q==",
+ "dev": true,
+ "requires": {
+ "esbuild-android-64": "0.14.27",
+ "esbuild-android-arm64": "0.14.27",
+ "esbuild-darwin-64": "0.14.27",
+ "esbuild-darwin-arm64": "0.14.27",
+ "esbuild-freebsd-64": "0.14.27",
+ "esbuild-freebsd-arm64": "0.14.27",
+ "esbuild-linux-32": "0.14.27",
+ "esbuild-linux-64": "0.14.27",
+ "esbuild-linux-arm": "0.14.27",
+ "esbuild-linux-arm64": "0.14.27",
+ "esbuild-linux-mips64le": "0.14.27",
+ "esbuild-linux-ppc64le": "0.14.27",
+ "esbuild-linux-riscv64": "0.14.27",
+ "esbuild-linux-s390x": "0.14.27",
+ "esbuild-netbsd-64": "0.14.27",
+ "esbuild-openbsd-64": "0.14.27",
+ "esbuild-sunos-64": "0.14.27",
+ "esbuild-windows-32": "0.14.27",
+ "esbuild-windows-64": "0.14.27",
+ "esbuild-windows-arm64": "0.14.27"
+ }
+ },
+ "esbuild-android-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.14.27.tgz",
+ "integrity": "sha512-LuEd4uPuj/16Y8j6kqy3Z2E9vNY9logfq8Tq+oTE2PZVuNs3M1kj5Qd4O95ee66yDGb3isaOCV7sOLDwtMfGaQ==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-android-arm64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.14.27.tgz",
+ "integrity": "sha512-E8Ktwwa6vX8q7QeJmg8yepBYXaee50OdQS3BFtEHKrzbV45H4foMOeEE7uqdjGQZFBap5VAqo7pvjlyA92wznQ==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-darwin-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.14.27.tgz",
+ "integrity": "sha512-czw/kXl/1ZdenPWfw9jDc5iuIYxqUxgQ/Q+hRd4/3udyGGVI31r29LCViN2bAJgGvQkqyLGVcG03PJPEXQ5i2g==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-darwin-arm64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.14.27.tgz",
+ "integrity": "sha512-BEsv2U2U4o672oV8+xpXNxN9bgqRCtddQC6WBh4YhXKDcSZcdNh7+6nS+DM2vu7qWIWNA4JbRG24LUUYXysimQ==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-freebsd-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.14.27.tgz",
+ "integrity": "sha512-7FeiFPGBo+ga+kOkDxtPmdPZdayrSzsV9pmfHxcyLKxu+3oTcajeZlOO1y9HW+t5aFZPiv7czOHM4KNd0tNwCA==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-freebsd-arm64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.14.27.tgz",
+ "integrity": "sha512-8CK3++foRZJluOWXpllG5zwAVlxtv36NpHfsbWS7TYlD8S+QruXltKlXToc/5ZNzBK++l6rvRKELu/puCLc7jA==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-32": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.14.27.tgz",
+ "integrity": "sha512-qhNYIcT+EsYSBClZ5QhLzFzV5iVsP1YsITqblSaztr3+ZJUI+GoK8aXHyzKd7/CKKuK93cxEMJPpfi1dfsOfdw==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.14.27.tgz",
+ "integrity": "sha512-ESjck9+EsHoTaKWlFKJpPZRN26uiav5gkI16RuI8WBxUdLrrAlYuYSndxxKgEn1csd968BX/8yQZATYf/9+/qg==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-arm": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.14.27.tgz",
+ "integrity": "sha512-JnnmgUBdqLQO9hoNZQqNHFWlNpSX82vzB3rYuCJMhtkuaWQEmQz6Lec1UIxJdC38ifEghNTBsF9bbe8dFilnCw==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-arm64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.14.27.tgz",
+ "integrity": "sha512-no6Mi17eV2tHlJnqBHRLekpZ2/VYx+NfGxKcBE/2xOMYwctsanCaXxw4zapvNrGE9X38vefVXLz6YCF8b1EHiQ==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-mips64le": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.14.27.tgz",
+ "integrity": "sha512-NolWP2uOvIJpbwpsDbwfeExZOY1bZNlWE/kVfkzLMsSgqeVcl5YMen/cedRe9mKnpfLli+i0uSp7N+fkKNU27A==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-ppc64le": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.14.27.tgz",
+ "integrity": "sha512-/7dTjDvXMdRKmsSxKXeWyonuGgblnYDn0MI1xDC7J1VQXny8k1qgNp6VmrlsawwnsymSUUiThhkJsI+rx0taNA==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-riscv64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.14.27.tgz",
+ "integrity": "sha512-D+aFiUzOJG13RhrSmZgrcFaF4UUHpqj7XSKrIiCXIj1dkIkFqdrmqMSOtSs78dOtObWiOrFCDDzB24UyeEiNGg==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-linux-s390x": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.14.27.tgz",
+ "integrity": "sha512-CD/D4tj0U4UQjELkdNlZhQ8nDHU5rBn6NGp47Hiz0Y7/akAY5i0oGadhEIg0WCY/HYVXFb3CsSPPwaKcTOW3bg==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-netbsd-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.14.27.tgz",
+ "integrity": "sha512-h3mAld69SrO1VoaMpYl3a5FNdGRE/Nqc+E8VtHOag4tyBwhCQXxtvDDOAKOUQexBGca0IuR6UayQ4ntSX5ij1Q==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-openbsd-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.14.27.tgz",
+ "integrity": "sha512-xwSje6qIZaDHXWoPpIgvL+7fC6WeubHHv18tusLYMwL+Z6bEa4Pbfs5IWDtQdHkArtfxEkIZz77944z8MgDxGw==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-sunos-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.14.27.tgz",
+ "integrity": "sha512-/nBVpWIDjYiyMhuqIqbXXsxBc58cBVH9uztAOIfWShStxq9BNBik92oPQPJ57nzWXRNKQUEFWr4Q98utDWz7jg==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-windows-32": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.14.27.tgz",
+ "integrity": "sha512-Q9/zEjhZJ4trtWhFWIZvS/7RUzzi8rvkoaS9oiizkHTTKd8UxFwn/Mm2OywsAfYymgUYm8+y2b+BKTNEFxUekw==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-windows-64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.14.27.tgz",
+ "integrity": "sha512-b3y3vTSl5aEhWHK66ngtiS/c6byLf6y/ZBvODH1YkBM+MGtVL6jN38FdHUsZasCz9gFwYs/lJMVY9u7GL6wfYg==",
+ "dev": true,
+ "optional": true
+ },
+ "esbuild-windows-arm64": {
+ "version": "0.14.27",
+ "resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.14.27.tgz",
+ "integrity": "sha512-I/reTxr6TFMcR5qbIkwRGvldMIaiBu2+MP0LlD7sOlNXrfqIl9uNjsuxFPGEG4IRomjfQ5q8WT+xlF/ySVkqKg==",
+ "dev": true,
+ "optional": true
+ },
"escape-string-regexp": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
}
},
"minimist": {
- "version": "1.2.5",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
- "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
+ "version": "1.2.6",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.6.tgz",
+ "integrity": "sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==",
"dev": true
},
"mkdirp-classic": {

MODIFY
editors/vscode/package.json
editors/vscode/package.json
"onLanguage:javascript",
"onLanguage:typescript"
],
- "main": "./out/extension.js",
+ "main": "./out/main.js",
"repository": {
"type": "git",
"url": "https://github.com/rome/tools.git"
},
"rome.formatter.indentStyle": {
"type": "string",
- "enum": ["Tabs", "Spaces"],
+ "enum": [
+ "Tabs",
+ "Spaces"
+ ],
"default": "Tabs",
"markdownEnumDescriptions": [
"**BETA**: applies **tabs** while formatting",
"license": "MIT",
"preview": true,
"scripts": {
- "compile": "tsc -b",
+ "compile": "esbuild src/main.ts --bundle --outfile=out/main.js --external:vscode --format=cjs --platform=node --target=node14",
+ "watch": "npm run compile -- --sourcemap --watch",
"package": "vsce package -o rome_lsp.vsix",
- "build": "npm run compile && npm run package",
- "install-extension": "code --install-extension rome_lsp.vsix"
+ "build": "npm run compile -- --minify && npm run package",
+ "install-extension": "code --install-extension rome_lsp.vsix",
+ "format": "cargo run --bin cli format ./src/ ./scripts"
},
"dependencies": {
"vscode-languageclient": "^8.0.0-next.13"
"@types/node": "^16.11.9",
"@types/vscode": "^1.52.0",
"typescript": "^4.5.2",
- "vsce": "^2.7.0"
+ "vsce": "^2.7.0",
+ "esbuild": "^0.14.27"
}
}

MODIFY
editors/vscode/scripts/updateVersionForPrerelease.mjs
editors/vscode/scripts/updateVersionForPrerelease.mjs
@@ -7,11 +7,12 @@ function pad(date) {
if (date < 10) {
return "0" + date;
}
- return "" + date
+ return "" + date;
}
// read the package.json file
-readFile(manifestPath, "utf8").then(async (value) => {
+readFile(manifestPath, "utf8")
+ .then(async (value) => {
const manifest = JSON.parse(value);
const currentVersion = manifest.version;
const versionAsSemver = currentVersion.split(".");
@@ -22,20 +23,22 @@ readFile(manifestPath, "utf8").then(async (value) => {
const date = new Date();
const newMinor = currentMinor + 1;
- const newPatch = [pad(date.getFullYear()), pad(date.getMonth() + 1), pad(date.getDate())].join("");
+ const newPatch = [
+ pad(date.getFullYear()),
+ pad(date.getMonth() + 1),
+ pad(date.getDate()),
+ ].join("");
// update the version field
manifest.version = `${currentMajor}.${newMinor}.${newPatch}`;
try {
await writeFile(manifestPath, JSON.stringify(manifest, null, "\t"));
- console.log('version=' + manifest.version);
+ console.log("version=" + manifest.version);
} catch (_e) {
- console.log("Could not write the package.json file at " + manifestPath)
+ console.log("Could not write the package.json file at " + manifestPath);
process.exit(1);
-
}
-}).catch(() => {
- console.log("Could not read the package.json file at " + manifestPath)
- process.exit(1);
})
-
-
+ .catch(() => {
+ console.log("Could not read the package.json file at " + manifestPath);
+ process.exit(1);
+ });

RENAME
editors/vscode/src/extension.ts
editors/vscode/src/main.ts
import { ExtensionContext, workspace, Uri, window } from 'vscode';
-import {
- LanguageClient,
- LanguageClientOptions,
- ServerOptions,
- TransportKind
-} from 'vscode-languageclient/node';
+import { LanguageClient, LanguageClientOptions, ServerOptions, TransportKind } from 'vscode-languageclient/node';
let client: LanguageClient;
@@ -15,24 +10,24 @@ export async function activate(context: ExtensionContext) {
await window.showErrorMessage(
"The Rome extensions doesn't ship with prebuilt binaries for your platform yet. " +
"You can still use it by cloning the rome/tools repo from GitHub to build the LSP " +
- "yourself and use it with this extension with the rome.lspBin setting"
+ "yourself and use it with this extension with the rome.lspBin setting",
);
return;
}
- const serverOptions: ServerOptions =
- { command, transport: TransportKind.stdio };
+ const serverOptions: ServerOptions = {
+ command,
+ transport: TransportKind.stdio,
+ };
const clientOptions: LanguageClientOptions = {
- documentSelector: [{ scheme: 'file', language: 'javascript' }, { scheme: 'file', language: 'typescript' }],
+ documentSelector: [
+ { scheme: "file", language: "javascript" },
+ { scheme: "file", language: "typescript" },
+ ],
};
- client = new LanguageClient(
- 'rome_lsp',
- 'Rome',
- serverOptions,
- clientOptions
- );
+ client = new LanguageClient("rome_lsp", "Rome", serverOptions, clientOptions);
client.start();
}
@@ -46,24 +41,17 @@ type PlatformTriplets = {
};
const PLATFORM_TRIPLETS: PlatformTriplets = {
- win32: {
- x64: "x86_64-pc-windows-msvc",
- arm64: "aarch64-pc-windows-msvc",
- },
- darwin: {
- x64: "x86_64-apple-darwin",
- arm64: "aarch64-apple-darwin",
- },
- linux: {
- x64: "x86_64-unknown-linux-gnu",
- arm64: "aarch64-unknown-linux-gnu",
- }
+ win32: { x64: "x86_64-pc-windows-msvc", arm64: "aarch64-pc-windows-msvc" },
+ darwin: { x64: "x86_64-apple-darwin", arm64: "aarch64-apple-darwin" },
+ linux: { x64: "x86_64-unknown-linux-gnu", arm64: "aarch64-unknown-linux-gnu" },
};
-async function getServerPath(context: ExtensionContext): Promise<string | undefined> {
+async function getServerPath(context: ExtensionContext): Promise<
+ string | undefined
+> {
const config = workspace.getConfiguration();
const explicitPath = config.get("rome.lspBin");
- if (typeof explicitPath === 'string' && explicitPath !== '') {
+ if (typeof explicitPath === "string" && explicitPath !== "") {
return explicitPath;
}
@@ -72,10 +60,10 @@ async function getServerPath(context: ExtensionContext): Promise<string | undefi
return undefined;
}
- const binaryExt = triplet.includes('windows') ? '.exe' : '';
+ const binaryExt = triplet.includes("windows") ? ".exe" : "";
const binaryName = `rome_lsp${binaryExt}`;
- const bundlePath = Uri.joinPath(context.extensionUri, 'server', binaryName);
+ const bundlePath = Uri.joinPath(context.extensionUri, "server", binaryName);
const bundleExists = await fileExists(bundlePath);
return bundleExists ? bundlePath.fsPath : undefined;
@@ -86,7 +74,7 @@ async function fileExists(path: Uri) {
await workspace.fs.stat(path);
return true;
} catch (err) {
- if(err.code === 'ENOENT') {
+ if (err.code === "ENOENT") {
return false;
} else {
throw err;

chore: bundle extension (#2306)