summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbscan <10503608+bscan@users.noreply.github.com>2024-04-06 00:17:57 -0400
committerbscan <10503608+bscan@users.noreply.github.com>2024-04-06 00:17:57 -0400
commitcffe367d194270e39c612e15fa7812832ee59f68 (patch)
tree8612cca2db6f7d1556f2ffa43c7e14a6252802c9
parent21e88866341037587820c473f857dd028bcfac18 (diff)
downloadPerlNavigator-cffe367d194270e39c612e15fa7812832ee59f68.zip
Moving asset extraction into the initialize step, plus clearing a node deprecation warning
-rw-r--r--package-lock.json18
-rw-r--r--package.json2
-rw-r--r--server/package-lock.json4
-rw-r--r--server/src/assets.ts20
-rw-r--r--server/src/diagnostics.ts18
-rw-r--r--server/src/formatting.ts4
-rw-r--r--server/src/navigation.ts2
-rw-r--r--server/src/server.ts4
8 files changed, 38 insertions, 34 deletions
diff --git a/package-lock.json b/package-lock.json
index b896b04..b80ea80 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "perlnavigator",
- "version": "0.8.3",
+ "version": "0.8.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "perlnavigator",
- "version": "0.8.3",
+ "version": "0.8.9",
"hasInstallScript": true,
"license": "MIT",
"bin": {
@@ -14,7 +14,7 @@
},
"devDependencies": {
"@types/mocha": "^10.0.1",
- "@types/node": "^12.12.0",
+ "@types/node": "^15.0.0",
"@types/webpack-env": "^1.16.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
@@ -362,9 +362,9 @@
"dev": true
},
"node_modules/@types/node": {
- "version": "12.20.42",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.42.tgz",
- "integrity": "sha512-aI3/oo5DzyiI5R/xAhxxRzfZlWlsbbqdgxfTPkqu/Zt+23GXiJvMCyPJT4+xKSXOnLqoL8jJYMLTwvK2M3a5hw==",
+ "version": "15.14.9",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.9.tgz",
+ "integrity": "sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==",
"dev": true
},
"node_modules/@types/webpack-env": {
@@ -5637,9 +5637,9 @@
"dev": true
},
"@types/node": {
- "version": "12.20.42",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.42.tgz",
- "integrity": "sha512-aI3/oo5DzyiI5R/xAhxxRzfZlWlsbbqdgxfTPkqu/Zt+23GXiJvMCyPJT4+xKSXOnLqoL8jJYMLTwvK2M3a5hw==",
+ "version": "15.14.9",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-15.14.9.tgz",
+ "integrity": "sha512-qjd88DrCxupx/kJD5yQgZdcYKZKSIGBVDIBE1/LTGcNm3d2Np/jxojkdePDdfnBHJc5W7vSMpbJ1aB7p/Py69A==",
"dev": true
},
"@types/webpack-env": {
diff --git a/package.json b/package.json
index 1a44823..78a209d 100644
--- a/package.json
+++ b/package.json
@@ -388,7 +388,7 @@
},
"devDependencies": {
"@types/mocha": "^10.0.1",
- "@types/node": "^12.12.0",
+ "@types/node": "^15.0.0",
"@typescript-eslint/eslint-plugin": "^4.23.0",
"@typescript-eslint/parser": "^4.23.0",
"@types/webpack-env": "^1.16.0",
diff --git a/server/package-lock.json b/server/package-lock.json
index 21220e3..edd88d9 100644
--- a/server/package-lock.json
+++ b/server/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "perlnavigator-server",
- "version": "0.8.3",
+ "version": "0.8.9",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "perlnavigator-server",
- "version": "0.8.3",
+ "version": "0.8.9",
"license": "MIT",
"dependencies": {
"lru-cache": "^6.0.0",
diff --git a/server/src/assets.ts b/server/src/assets.ts
index 0acc208..73a2173 100644
--- a/server/src/assets.ts
+++ b/server/src/assets.ts
@@ -1,25 +1,25 @@
import "process";
import { tmpdir } from "os";
-import { rmdirSync, mkdirSync, mkdtempSync, createReadStream, createWriteStream } from "fs";
+import { rmSync, mkdirSync, mkdtempSync, createReadStream, createWriteStream } from "fs";
import { dirname, join } from "path";
let haveExtractedAssets = false;
let pkgAssetPath: string;
-function extractAssetsIfNecessary(): string {
+async function extractAssetsIfNecessary(): Promise<string> {
if (!haveExtractedAssets) {
pkgAssetPath = mkdtempSync(join(tmpdir(), "perl-navigator"));
let assets: string[] = [
+ "src/perl/lib_bs22/ModHunter.pl",
+ "src/perl/Inquisitor.pm",
+ "src/perl/criticWrapper.pl",
"src/perl/lib_bs22/Class/Inspector.pm",
"src/perl/lib_bs22/Devel/Symdump.pm",
"src/perl/lib_bs22/Devel/Symdump/Export.pm",
"src/perl/lib_bs22/Inspectorito.pm",
- "src/perl/lib_bs22/ModHunter.pl",
"src/perl/lib_bs22/SubUtilPP.pm",
"src/perl/lib_bs22/SourceStash.pm",
"src/perl/lib_bs22/pltags.pm",
- "src/perl/Inquisitor.pm",
- "src/perl/criticWrapper.pl",
"src/perl/defaultCriticProfile",
"src/perl/tidyWrapper.pl",
"src/perl/perlimportsWrapper.pl",
@@ -33,11 +33,13 @@ function extractAssetsIfNecessary(): string {
});
haveExtractedAssets = true;
+ // Allow time to copy. TODO: Change writeStreams to be async and just wait on them
+ return new Promise(resolve => setTimeout(() => resolve(pkgAssetPath), 50));
}
return pkgAssetPath;
}
-export function getAssetsPath(): string {
+async function getAssetsPath(): Promise<string> {
let anyProcess = <any>process;
if (anyProcess.pkg) {
// When running inside of a pkg built executable, the assets
@@ -51,13 +53,13 @@ export function getAssetsPath(): string {
return dirname(__dirname);
}
-export function getPerlAssetsPath(): string {
- return join(getAssetsPath(), "src", "perl");
+export async function getPerlAssetsPath(): Promise<string> {
+ return join(await getAssetsPath(), "src", "perl");
}
export function cleanupTemporaryAssetPath() {
if (haveExtractedAssets) {
- rmdirSync(pkgAssetPath, { recursive: true }); // Create all parent folders
+ rmSync(pkgAssetPath, { recursive: true }); // Create all parent folders
haveExtractedAssets = false;
}
}
diff --git a/server/src/diagnostics.ts b/server/src/diagnostics.ts
index 94618b9..acd3203 100644
--- a/server/src/diagnostics.ts
+++ b/server/src/diagnostics.ts
@@ -25,7 +25,7 @@ export async function perlcompile(textDocument: TextDocument, workspaceFolders:
if (settings.enableWarnings) perlParams = perlParams.concat(["-Mwarnings", "-M-warnings=redefine"]); // Force enable some warnings.
perlParams = perlParams.concat(getIncPaths(workspaceFolders, settings));
- perlParams = perlParams.concat(getInquisitor());
+ perlParams = perlParams.concat(await getInquisitor());
nLog("Starting perl compilation check with the equivalent of: " + settings.perlPath + " " + perlParams.join(" ") + " " + filePath, settings);
@@ -56,14 +56,14 @@ export async function perlcompile(textDocument: TextDocument, workspaceFolders:
perlProcess?.child?.stdin?.end();
const out = await perlProcess;
- output = out.stderr;
- stdout = out.stdout;
+ output = out.stderr.toString();
+ stdout = out.stdout.toString();
severity = DiagnosticSeverity.Warning;
} catch (error: any) {
// TODO: Check if we overflowed the buffer.
if ("stderr" in error && "stdout" in error) {
- output = error.stderr;
- stdout = error.stdout;
+ output = error.stderr.toString();
+ stdout = error.stdout.toString();
severity = DiagnosticSeverity.Error;
} else {
nLog("Perlcompile failed with unknown error", settings);
@@ -85,8 +85,8 @@ export async function perlcompile(textDocument: TextDocument, workspaceFolders:
return { diags: uniq_diagnostics, perlDoc: mergedDoc };
}
-function getInquisitor(): string[] {
- const inq_path = getPerlAssetsPath();
+async function getInquisitor(): Promise<string[]> {
+ const inq_path = await getPerlAssetsPath();
let inq: string[] = ["-I", inq_path, "-MInquisitor"];
return inq;
}
@@ -175,7 +175,7 @@ function localizeErrors(violation: string, filePath: string, perlDoc: PerlDocume
export async function perlcritic(textDocument: TextDocument, workspaceFolders: WorkspaceFolder[] | null, settings: NavigatorSettings): Promise<Diagnostic[]> {
if (!settings.perlcriticEnabled) return [];
- const critic_path = join(getPerlAssetsPath(), "criticWrapper.pl");
+ const critic_path = join(await getPerlAssetsPath(), "criticWrapper.pl");
let criticParams: string[] = [...settings.perlParams, critic_path].concat(getCriticProfile(workspaceFolders, settings));
criticParams = criticParams.concat(["--file", Uri.parse(textDocument.uri).fsPath]);
@@ -215,7 +215,7 @@ export async function perlcritic(textDocument: TextDocument, workspaceFolders: W
export async function perlimports(textDocument: TextDocument, workspaceFolders: WorkspaceFolder[] | null, settings: NavigatorSettings): Promise<Diagnostic[]> {
if (!settings.perlimportsLintEnabled) return [];
- const importsPath = join(getPerlAssetsPath(), "perlimportsWrapper.pl");
+ const importsPath = join(await getPerlAssetsPath(), "perlimportsWrapper.pl");
const cliParams = [...settings.perlParams, importsPath, ...getPerlimportsProfile(settings), "--lint", "--json", "--filename", Uri.parse(textDocument.uri).fsPath];
nLog("Now starting perlimports with: " + cliParams.join(" "), settings);
diff --git a/server/src/formatting.ts b/server/src/formatting.ts
index 02141a3..dfbd401 100644
--- a/server/src/formatting.ts
+++ b/server/src/formatting.ts
@@ -75,7 +75,7 @@ async function maybeReturnEdits(
async function perlimports(doc: TextDocument, code: string, settings: NavigatorSettings): Promise<string | undefined> {
if (!settings.perlimportsTidyEnabled) return;
- const importsPath = join(getPerlAssetsPath(), "perlimportsWrapper.pl");
+ const importsPath = join(await getPerlAssetsPath(), "perlimportsWrapper.pl");
let cliParams: string[] = [importsPath].concat(getPerlimportsProfile(settings));
cliParams = cliParams.concat(["--filename", Uri.parse(doc.uri).fsPath]);
nLog("Now starting perlimports with: " + cliParams.join(" "), settings);
@@ -98,7 +98,7 @@ async function perlimports(doc: TextDocument, code: string, settings: NavigatorS
async function perltidy(code: string, settings: NavigatorSettings, workspaceFolders: WorkspaceFolder[] | null): Promise<string | undefined> {
if (!settings.perltidyEnabled) return;
- const tidy_path = join(getPerlAssetsPath(), "tidyWrapper.pl");
+ const tidy_path = join(await getPerlAssetsPath(), "tidyWrapper.pl");
let tidyParams: string[] = [tidy_path].concat(getTidyProfile(workspaceFolders, settings));
nLog("Now starting perltidy with: " + tidyParams.join(" "), settings);
diff --git a/server/src/navigation.ts b/server/src/navigation.ts
index 688d615..5d1432b 100644
--- a/server/src/navigation.ts
+++ b/server/src/navigation.ts
@@ -129,7 +129,7 @@ function badFile(uri: string): boolean {
export async function getAvailableMods(workspaceFolders: WorkspaceFolder[] | null, settings: NavigatorSettings): Promise<Map<string, string>> {
let perlParams = settings.perlParams;
perlParams = perlParams.concat(getIncPaths(workspaceFolders, settings));
- const modHunterPath = join(getPerlAssetsPath(), "lib_bs22", "ModHunter.pl");
+ const modHunterPath = join(await getPerlAssetsPath(), "lib_bs22", "ModHunter.pl");
perlParams.push(modHunterPath);
nLog("Starting to look for perl modules with " + perlParams.join(" "), settings);
diff --git a/server/src/server.ts b/server/src/server.ts
index ec4a038..de62214 100644
--- a/server/src/server.ts
+++ b/server/src/server.ts
@@ -33,6 +33,7 @@ import { formatDoc, formatRange } from "./formatting";
import { nLog } from "./utils";
import { startProgress, endProgress } from "./progress";
import { getSignature } from "./signatures";
+import { getPerlAssetsPath } from "./assets";
var LRU = require("lru-cache");
@@ -51,7 +52,7 @@ const documents: TextDocuments<TextDocument> = new TextDocuments(TextDocument);
let hasConfigurationCapability = false;
let hasWorkspaceFolderCapability = false;
-connection.onInitialize((params: InitializeParams) => {
+connection.onInitialize(async (params: InitializeParams) => {
const capabilities = params.capabilities;
// Does the client support the `workspace/configuration` request?
@@ -87,6 +88,7 @@ connection.onInitialize((params: InitializeParams) => {
},
};
}
+ await getPerlAssetsPath(); // Ensures assets are unpacked. Should this be in onInitialized?
return result;
});