which-webstorm 4.1.7-dev.8 → 4.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +35 -0
- package/bin/webstorm.js +1 -1
- package/output/main.d.ts +53 -0
- package/output/main.d.ts.map +1 -0
- package/output/main.js +118 -0
- package/output/main.js.map +1 -0
- package/package.json +18 -37
- package/.scripts/manifest-version.cjs +0 -84
package/Makefile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.PHONY: default build clean docs git-hook pretty lint test run
|
|
2
|
+
|
|
3
|
+
default: build
|
|
4
|
+
|
|
5
|
+
build: output
|
|
6
|
+
|
|
7
|
+
clean:
|
|
8
|
+
rm --force --recursive node_modules output tsconfig.tsbuildinfo
|
|
9
|
+
|
|
10
|
+
docs:
|
|
11
|
+
@echo "This project has no documentation."
|
|
12
|
+
|
|
13
|
+
git-hook:
|
|
14
|
+
echo "make pretty" > .git/hooks/pre-commit
|
|
15
|
+
|
|
16
|
+
pretty: node_modules
|
|
17
|
+
yarn biome check --write --no-errors-on-unmatched
|
|
18
|
+
npm pkg fix
|
|
19
|
+
|
|
20
|
+
lint: node_modules
|
|
21
|
+
yarn biome check .
|
|
22
|
+
yarn tsc --noEmit
|
|
23
|
+
|
|
24
|
+
test: build
|
|
25
|
+
yarn c8 --reporter=html-spa mocha output/*.test.js
|
|
26
|
+
|
|
27
|
+
run: build
|
|
28
|
+
node ./output/main.js
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
node_modules:
|
|
32
|
+
yarn install
|
|
33
|
+
|
|
34
|
+
output: node_modules
|
|
35
|
+
yarn tsc
|
package/bin/webstorm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { execa } from "execa";
|
|
4
3
|
import { statSync } from "node:fs";
|
|
5
4
|
import { resolve } from "node:path";
|
|
5
|
+
import { execa } from "execa";
|
|
6
6
|
import { WebStormLocator } from "../output/main.js";
|
|
7
7
|
|
|
8
8
|
new WebStormLocator().findWebstormAsync().then(webstorm => {
|
package/output/main.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Locates WebStorm.
|
|
3
|
+
*/
|
|
4
|
+
export declare class WebStormLocator {
|
|
5
|
+
#private;
|
|
6
|
+
/**
|
|
7
|
+
* Determines the name of the `webstorm` binary, based on the system bitness.
|
|
8
|
+
* @returns The correct name of the `webstorm` binary.
|
|
9
|
+
*/
|
|
10
|
+
webstormBinary(): string;
|
|
11
|
+
/**
|
|
12
|
+
* Find the webstorm binary.
|
|
13
|
+
* @returns The path of the webstorm binary.
|
|
14
|
+
*/
|
|
15
|
+
findWebstorm(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Find the webstorm binary asynchronously.
|
|
18
|
+
* @returns The path of the webstorm binary.
|
|
19
|
+
*/
|
|
20
|
+
findWebstormAsync(): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Finds all product path names of JetBrains products.
|
|
23
|
+
* @returns A list of all JetBrains product paths on the system.
|
|
24
|
+
*/
|
|
25
|
+
findJetbrainsProducts(): Array<string>;
|
|
26
|
+
/**
|
|
27
|
+
* Finds all product path names of JetBrains products asynchronously.
|
|
28
|
+
* @returns A list of all JetBrains product paths on the system.
|
|
29
|
+
*/
|
|
30
|
+
findJetbrainsProductsAsync(): Promise<Array<string>>;
|
|
31
|
+
/**
|
|
32
|
+
* Searches WebStorm in the filesystem.
|
|
33
|
+
* @returns The path of the webstorm binary.
|
|
34
|
+
*/
|
|
35
|
+
findManual(): string;
|
|
36
|
+
/**
|
|
37
|
+
* Searches WebStorm in the filesystem asynchronously.
|
|
38
|
+
* @returns The path of the webstorm binary.
|
|
39
|
+
*/
|
|
40
|
+
findManualAsync(): Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Find a webstorm binary in a list of JetBrains products.
|
|
43
|
+
* @param jetbrainsProducts - A list of JetBrains product names found on the system.
|
|
44
|
+
* @returns The path of the webstorm binary.
|
|
45
|
+
*/
|
|
46
|
+
findManualWindows(jetbrainsProducts: Array<string>): string;
|
|
47
|
+
}
|
|
48
|
+
declare const _export: (() => Promise<string>) & {
|
|
49
|
+
sync: () => string;
|
|
50
|
+
webstormBinary: () => string;
|
|
51
|
+
};
|
|
52
|
+
export default _export;
|
|
53
|
+
//# sourceMappingURL=main.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../source/main.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,qBAAa,eAAe;;IAC1B;;;OAGG;IACH,cAAc,IAAI,MAAM;IAIxB;;;OAGG;IACH,YAAY;IAQZ;;;OAGG;IACG,iBAAiB;IASvB;;;OAGG;IACH,qBAAqB,IAAI,KAAK,CAAC,MAAM,CAAC;IAGtC;;;OAGG;IACH,0BAA0B,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAIpD;;;OAGG;IACH,UAAU,IAAI,MAAM;IASpB;;;OAGG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC;IAUxC;;;;OAIG;IACH,iBAAiB,CAAC,iBAAiB,EAAE,KAAK,CAAC,MAAM,CAAC;CAmCnD;AAGD,QAAA,MAAM,OAAO,EAAE,CAAC,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,MAAM,CAAA;CAIvF,CAAC;AACL,eAAe,OAAO,CAAC"}
|
package/output/main.js
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { existsSync, promises, readdirSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { mustExist } from "@oliversalzburg/js-utils/data/nil.js";
|
|
4
|
+
import { coerce, gt, valid } from "semver";
|
|
5
|
+
import which from "which";
|
|
6
|
+
/**
|
|
7
|
+
* Locates WebStorm.
|
|
8
|
+
*/
|
|
9
|
+
export class WebStormLocator {
|
|
10
|
+
/**
|
|
11
|
+
* Determines the name of the `webstorm` binary, based on the system bitness.
|
|
12
|
+
* @returns The correct name of the `webstorm` binary.
|
|
13
|
+
*/
|
|
14
|
+
webstormBinary() {
|
|
15
|
+
return process.arch === "x64" ? "webstorm64.exe" : "webstorm.exe";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Find the webstorm binary.
|
|
19
|
+
* @returns The path of the webstorm binary.
|
|
20
|
+
*/
|
|
21
|
+
findWebstorm() {
|
|
22
|
+
try {
|
|
23
|
+
return which.sync(this.webstormBinary());
|
|
24
|
+
}
|
|
25
|
+
catch (_error) {
|
|
26
|
+
// Not found on PATH, attempt manual lookup.
|
|
27
|
+
return this.findManual();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Find the webstorm binary asynchronously.
|
|
32
|
+
* @returns The path of the webstorm binary.
|
|
33
|
+
*/
|
|
34
|
+
async findWebstormAsync() {
|
|
35
|
+
try {
|
|
36
|
+
return await which(this.webstormBinary());
|
|
37
|
+
}
|
|
38
|
+
catch (_error) {
|
|
39
|
+
// Not found on PATH, attempt manual lookup.
|
|
40
|
+
return this.findManual();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Finds all product path names of JetBrains products.
|
|
45
|
+
* @returns A list of all JetBrains product paths on the system.
|
|
46
|
+
*/
|
|
47
|
+
findJetbrainsProducts() {
|
|
48
|
+
return readdirSync(join(mustExist(process.env["ProgramFiles(x86)"]), "JetBrains"));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Finds all product path names of JetBrains products asynchronously.
|
|
52
|
+
* @returns A list of all JetBrains product paths on the system.
|
|
53
|
+
*/
|
|
54
|
+
findJetbrainsProductsAsync() {
|
|
55
|
+
return promises.readdir(join(mustExist(process.env["ProgramFiles(x86)"]), "JetBrains"));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Searches WebStorm in the filesystem.
|
|
59
|
+
* @returns The path of the webstorm binary.
|
|
60
|
+
*/
|
|
61
|
+
findManual() {
|
|
62
|
+
switch (process.platform) {
|
|
63
|
+
case "win32":
|
|
64
|
+
return this.findManualWindows(this.findJetbrainsProducts());
|
|
65
|
+
default:
|
|
66
|
+
throw new Error(`Platform '${process.platform}' is not supported.`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Searches WebStorm in the filesystem asynchronously.
|
|
71
|
+
* @returns The path of the webstorm binary.
|
|
72
|
+
*/
|
|
73
|
+
async findManualAsync() {
|
|
74
|
+
switch (process.platform) {
|
|
75
|
+
case "win32":
|
|
76
|
+
return this.findManualWindows(await this.findJetbrainsProductsAsync());
|
|
77
|
+
default:
|
|
78
|
+
throw new Error(`Platform '${process.platform}' is not supported.`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Find a webstorm binary in a list of JetBrains products.
|
|
83
|
+
* @param jetbrainsProducts - A list of JetBrains product names found on the system.
|
|
84
|
+
* @returns The path of the webstorm binary.
|
|
85
|
+
*/
|
|
86
|
+
findManualWindows(jetbrainsProducts) {
|
|
87
|
+
return this.#getLatest(jetbrainsProducts
|
|
88
|
+
.filter(entry => entry.match(/WebStorm/))
|
|
89
|
+
.map(entry => {
|
|
90
|
+
return join(mustExist(process.env["ProgramFiles(x86)"]), "JetBrains", entry, "bin", this.webstormBinary());
|
|
91
|
+
})
|
|
92
|
+
.filter(candidate => existsSync(candidate))
|
|
93
|
+
.map(entry => {
|
|
94
|
+
const ver = entry.match(/WebStorm[^0-9]([0-9.]+)/) ?? ["", ""];
|
|
95
|
+
return {
|
|
96
|
+
version: mustExist(valid(coerce(ver[1]))),
|
|
97
|
+
path: entry,
|
|
98
|
+
};
|
|
99
|
+
})
|
|
100
|
+
.sort(this.#customSort.bind(this)));
|
|
101
|
+
}
|
|
102
|
+
#customSort(a, b) {
|
|
103
|
+
return gt(a.version, b.version) ? -1 : 1;
|
|
104
|
+
}
|
|
105
|
+
#getLatest(entries) {
|
|
106
|
+
if (entries.length === 0) {
|
|
107
|
+
throw new Error("WebStorm not found");
|
|
108
|
+
}
|
|
109
|
+
return entries[0].path;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const locator = new WebStormLocator();
|
|
113
|
+
const _export = Object.assign(locator.findWebstormAsync.bind(locator), {
|
|
114
|
+
sync: locator.findWebstorm.bind(locator),
|
|
115
|
+
webstormBinary: locator.webstormBinary.bind(locator),
|
|
116
|
+
});
|
|
117
|
+
export default _export;
|
|
118
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../source/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,OAAO,eAAe;IAC1B;;;OAGG;IACH,cAAc;QACZ,OAAO,OAAO,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,cAAc,CAAC;IACpE,CAAC;IAED;;;OAGG;IACH,YAAY;QACV,IAAI,CAAC;YACH,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QAC3C,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,4CAA4C;YAC5C,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAC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AM,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;IACrD,IAAI,EAAE,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC;IACxC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC;CACrD,CAAC,CAAC;AACL,eAAe,OAAO,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
|
3
3
|
"name": "which-webstorm",
|
|
4
|
-
"version": "4.1.
|
|
4
|
+
"version": "4.1.8",
|
|
5
5
|
"description": "Find WebStorm binary",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "https://github.com/oliversalzburg/which-webstorm.git"
|
|
10
|
+
"url": "git+https://github.com/oliversalzburg/which-webstorm.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/oliversalzburg/which-webstorm/issues"
|
|
11
14
|
},
|
|
12
15
|
"type": "module",
|
|
13
16
|
"main": "output/main.js",
|
|
@@ -16,50 +19,28 @@
|
|
|
16
19
|
"wstorm": "bin/webstorm.js"
|
|
17
20
|
},
|
|
18
21
|
"scripts": {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"lint": "yarn run lint:all",
|
|
22
|
-
"lint:all": "yarn run lint:eslint && yarn run lint:prettier && yarn run lint:tsc",
|
|
23
|
-
"lint:eslint": "eslint .",
|
|
24
|
-
"lint:prettier": "prettier --check .",
|
|
25
|
-
"lint:tsc": "tsc --noEmit",
|
|
26
|
-
"nextversion": "./.scripts/manifest-version.cjs",
|
|
27
|
-
"test": "yarn build && node $(yarn bin mocha) output/*.test.js",
|
|
28
|
-
"test:coverage": "tsc && c8 --reporter=html-spa node $(yarn bin mocha) output/*.test.js",
|
|
29
|
-
"preversion": "yarn run lint && yarn run build && yarn run test",
|
|
22
|
+
"preversion": "make lint test",
|
|
23
|
+
"prepack": "make",
|
|
30
24
|
"postversion": "git push"
|
|
31
25
|
},
|
|
32
26
|
"types": "output/main.d.ts",
|
|
33
27
|
"dependencies": {
|
|
34
|
-
"@oliversalzburg/js-utils": "0.
|
|
35
|
-
"execa": "9.5.
|
|
36
|
-
"semver": "7.
|
|
28
|
+
"@oliversalzburg/js-utils": "0.3.0",
|
|
29
|
+
"execa": "9.5.3",
|
|
30
|
+
"semver": "7.7.2",
|
|
37
31
|
"which": "5.0.0"
|
|
38
32
|
},
|
|
39
33
|
"devDependencies": {
|
|
40
|
-
"@
|
|
41
|
-
"@
|
|
42
|
-
"@types/chai": "5.0.1",
|
|
43
|
-
"@types/eslint": "9.6.1",
|
|
34
|
+
"@biomejs/biome": "1.9.4",
|
|
35
|
+
"@types/chai": "5.2.2",
|
|
44
36
|
"@types/mocha": "10.0.10",
|
|
45
|
-
"@types/node": "22.
|
|
46
|
-
"@types/semver": "7.
|
|
37
|
+
"@types/node": "22.15.18",
|
|
38
|
+
"@types/semver": "7.7.0",
|
|
47
39
|
"@types/which": "3.0.4",
|
|
48
40
|
"c8": "10.1.3",
|
|
49
|
-
"chai": "5.
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"eslint-plugin-jsdoc": "50.6.1",
|
|
53
|
-
"eslint-plugin-tsdoc": "0.4.0",
|
|
54
|
-
"globals": "15.14.0",
|
|
55
|
-
"lint-staged": "15.3.0",
|
|
56
|
-
"mocha": "11.0.1",
|
|
57
|
-
"prettier": "3.4.2",
|
|
58
|
-
"prettier-package-json": "2.8.0",
|
|
59
|
-
"prettier-plugin-organize-imports": "4.1.0",
|
|
60
|
-
"prettier-plugin-sh": "0.14.0",
|
|
61
|
-
"typescript": "5.7.2",
|
|
62
|
-
"typescript-eslint": "8.19.0"
|
|
41
|
+
"chai": "5.2.0",
|
|
42
|
+
"mocha": "11.3.0",
|
|
43
|
+
"typescript": "5.8.3"
|
|
63
44
|
},
|
|
64
45
|
"keywords": [
|
|
65
46
|
"webstorm"
|
|
@@ -70,5 +51,5 @@
|
|
|
70
51
|
"publishConfig": {
|
|
71
52
|
"registry": "https://registry.npmjs.org"
|
|
72
53
|
},
|
|
73
|
-
"packageManager": "yarn@4.
|
|
54
|
+
"packageManager": "yarn@4.9.1"
|
|
74
55
|
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
"use strict";
|
|
4
|
-
|
|
5
|
-
const { execSync } = require("node:child_process");
|
|
6
|
-
const { resolve } = require("node:path");
|
|
7
|
-
|
|
8
|
-
const pkg = require(resolve("./package.json"));
|
|
9
|
-
|
|
10
|
-
const options = process.argv.slice(2).reduce((args, arg) => {
|
|
11
|
-
const [key, value] = arg.split("=");
|
|
12
|
-
args[key.substring(2)] = value ?? true;
|
|
13
|
-
|
|
14
|
-
return args;
|
|
15
|
-
}, {});
|
|
16
|
-
|
|
17
|
-
function getRootVersion(bump = true) {
|
|
18
|
-
let rootVersion = pkg.version.replace(/^(\d+\.\d+\.\d+)-?.*$/, "$1");
|
|
19
|
-
|
|
20
|
-
if (bump) {
|
|
21
|
-
const parts = rootVersion.split(".");
|
|
22
|
-
const inc = bump ? 1 : 0;
|
|
23
|
-
|
|
24
|
-
switch (options.canary?.toLowerCase()) {
|
|
25
|
-
case "major": {
|
|
26
|
-
parts[0] = `${+parts[0] + inc}`;
|
|
27
|
-
parts[1] = 0;
|
|
28
|
-
parts[2] = 0;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case "minor": {
|
|
32
|
-
parts[1] = `${+parts[0] + inc}`;
|
|
33
|
-
parts[2] = 0;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case "patch":
|
|
37
|
-
default:
|
|
38
|
-
parts[2] = `${+parts[2] + inc}`;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
rootVersion = parts.join(".");
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return rootVersion;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getNextVersion() {
|
|
48
|
-
const versions = [];
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
const versionString = execSync(`npm show ${pkg.name} versions --json`, {
|
|
52
|
-
encoding: "utf8",
|
|
53
|
-
stdio: "pipe",
|
|
54
|
-
});
|
|
55
|
-
const parsed = JSON.parse(versionString);
|
|
56
|
-
versions.push(...parsed);
|
|
57
|
-
} catch {
|
|
58
|
-
// the package might not have been published yet
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const version = getRootVersion(options.canary ?? false);
|
|
62
|
-
|
|
63
|
-
if (versions.some(v => v === version)) {
|
|
64
|
-
process.stderr.write(
|
|
65
|
-
`before-deploy: A release with version ${version} already exists. Please increment version accordingly.\n`,
|
|
66
|
-
);
|
|
67
|
-
process.exit(1);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (!options.canary) {
|
|
71
|
-
return version;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const preid = options.preid ?? "dev";
|
|
75
|
-
const prereleaseNumbers = versions
|
|
76
|
-
.filter(v => v.startsWith(`${version}-${preid}.`))
|
|
77
|
-
.map(v => Number(v.match(/\.(\d+)$/)?.[1]));
|
|
78
|
-
const lastPrereleaseNumber = Math.max(-1, ...prereleaseNumbers);
|
|
79
|
-
|
|
80
|
-
return `${version}-${preid}.${lastPrereleaseNumber + 1}`;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const versionString = getNextVersion();
|
|
84
|
-
process.stdout.write(versionString);
|