which-webstorm 4.1.6-dev-1653a6e → 4.1.6-dev-bbb36e3

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 ADDED
@@ -0,0 +1,32 @@
1
+ .PHONY: default build clean docs pretty lint test run
2
+
3
+ default: clean build
4
+
5
+ build: output
6
+
7
+ clean:
8
+ rm -rf ./output
9
+
10
+ docs:
11
+ @echo "This project has no documentation."
12
+
13
+ pretty:
14
+ yarn biome check --write --no-errors-on-unmatched
15
+
16
+ lint:
17
+ yarn biome check .
18
+ yarn tsc --noEmit
19
+
20
+ test: clean
21
+ yarn tsc
22
+ yarn c8 --reporter=html-spa mocha output/*.test.js
23
+
24
+ run: clean build
25
+ node ./output/main.js
26
+
27
+
28
+ node_modules:
29
+ yarn install
30
+
31
+ output: node_modules
32
+ yarn tsc
@@ -0,0 +1,52 @@
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;
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;IACD;;;OAGG;IACH,KAAK,CAAC,iBAAiB;QACrB,IAAI,CAAC;YACH,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,4CAA4C;YAC5C,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,qBAAqB;QACnB,OAAO,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC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AAG,CAAC,KAAK,CAAC,EAAE;YACX,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;YAC/D,OAAO;gBACL,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzC,IAAI,EAAE,KAAK;aACZ,CAAC;QACJ,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CACrC,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,CAAsB,EAAE,CAAsB;QACxD,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,CAAC;IAED,UAAU,CAAC,OAAgC;QACzC,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACzB,CAAC;CACF;AAED,MAAM,OAAO,GAAG,IAAI,eAAe,EAAE,CAAC;AACtC,MAAM,OAAO,GACX,MAAM,CAAC,MAAM,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,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "which-webstorm",
4
- "version": "4.1.6-dev-1653a6e",
4
+ "version": "4.1.6-dev-bbb36e3",
5
5
  "description": "Find WebStorm binary",
6
6
  "license": "MIT",
7
7
  "author": "Oliver Salzburg <oliver.salzburg@gmail.com>",
@@ -16,16 +16,8 @@
16
16
  "wstorm": "bin/webstorm.js"
17
17
  },
18
18
  "scripts": {
19
- "build": "tsc",
20
- "clean": "rm -rf ./output",
21
- "lint": "yarn run lint:all",
22
- "lint:all": "yarn run lint:biome && yarn run lint:tsc",
23
- "lint:biome": "biome check .",
24
- "lint:tsc": "tsc --noEmit",
25
- "nextversion": "./.scripts/manifest-version.cjs",
26
- "test": "yarn build && node $(yarn bin mocha) output/*.test.js",
27
- "test:coverage": "tsc && c8 --reporter=html-spa node $(yarn bin mocha) output/*.test.js",
28
- "preversion": "yarn run lint && yarn run build && yarn run test",
19
+ "preversion": "make lint test",
20
+ "prepack": "make",
29
21
  "postversion": "git push"
30
22
  },
31
23
  "types": "output/main.d.ts",
@@ -43,7 +35,7 @@
43
35
  "@types/semver": "7.5.8",
44
36
  "@types/which": "3.0.4",
45
37
  "c8": "10.1.3",
46
- "chai": "5.1.2",
38
+ "chai": "5.2.0",
47
39
  "lint-staged": "15.3.0",
48
40
  "mocha": "11.0.1",
49
41
  "typescript": "5.7.3"
@@ -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);