@boneskull/bargs 3.6.1 → 3.6.2
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/dist/version.cjs +50 -5
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.cts +6 -3
- package/dist/version.d.cts.map +1 -1
- package/dist/version.d.ts +6 -3
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +52 -7
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/version.cjs
CHANGED
|
@@ -13,6 +13,46 @@ exports.readPackageInfoSync = exports.detectVersionSync = exports.detectVersion
|
|
|
13
13
|
const node_fs_1 = require("node:fs");
|
|
14
14
|
const promises_1 = require("node:fs/promises");
|
|
15
15
|
const node_path_1 = require("node:path");
|
|
16
|
+
/**
|
|
17
|
+
* Get the real path of the entry script, resolving symlinks. Falls back to cwd
|
|
18
|
+
* if process.argv[1] is unavailable.
|
|
19
|
+
*
|
|
20
|
+
* @function
|
|
21
|
+
*/
|
|
22
|
+
const getScriptDir = () => {
|
|
23
|
+
try {
|
|
24
|
+
// process.argv[1] is the script being executed
|
|
25
|
+
const scriptPath = process.argv[1];
|
|
26
|
+
if (scriptPath) {
|
|
27
|
+
// Resolve symlinks to find the real location
|
|
28
|
+
const realPath = (0, node_fs_1.realpathSync)(scriptPath);
|
|
29
|
+
return (0, node_path_1.dirname)(realPath);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// Fall through to cwd
|
|
34
|
+
}
|
|
35
|
+
return process.cwd();
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Get the real path of the entry script asynchronously, resolving symlinks.
|
|
39
|
+
* Falls back to cwd if process.argv[1] is unavailable.
|
|
40
|
+
*
|
|
41
|
+
* @function
|
|
42
|
+
*/
|
|
43
|
+
const getScriptDirAsync = async () => {
|
|
44
|
+
try {
|
|
45
|
+
const scriptPath = process.argv[1];
|
|
46
|
+
if (scriptPath) {
|
|
47
|
+
const realPath = await (0, promises_1.realpath)(scriptPath);
|
|
48
|
+
return (0, node_path_1.dirname)(realPath);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Fall through to cwd
|
|
53
|
+
}
|
|
54
|
+
return process.cwd();
|
|
55
|
+
};
|
|
16
56
|
/**
|
|
17
57
|
* Normalize a repository URL to clean HTTPS format. Strips leading `git+` and
|
|
18
58
|
* trailing `.git`.
|
|
@@ -124,14 +164,17 @@ const readVersionFromPackageJsonSync = (pkgPath) => {
|
|
|
124
164
|
};
|
|
125
165
|
/**
|
|
126
166
|
* Detect version: use provided version or read from nearest package.json.
|
|
167
|
+
* Starts from the entry script's real location (resolving symlinks) by
|
|
168
|
+
* default.
|
|
127
169
|
*
|
|
128
170
|
* @function
|
|
129
171
|
*/
|
|
130
|
-
const detectVersion = async (providedVersion, startDir
|
|
172
|
+
const detectVersion = async (providedVersion, startDir) => {
|
|
131
173
|
if (providedVersion) {
|
|
132
174
|
return providedVersion;
|
|
133
175
|
}
|
|
134
|
-
const
|
|
176
|
+
const dir = startDir ?? (await getScriptDirAsync());
|
|
177
|
+
const pkgPath = await findPackageJson(dir);
|
|
135
178
|
if (!pkgPath) {
|
|
136
179
|
return undefined;
|
|
137
180
|
}
|
|
@@ -140,15 +183,17 @@ const detectVersion = async (providedVersion, startDir = process.cwd()) => {
|
|
|
140
183
|
exports.detectVersion = detectVersion;
|
|
141
184
|
/**
|
|
142
185
|
* Detect version synchronously: use provided version or read from nearest
|
|
143
|
-
* package.json.
|
|
186
|
+
* package.json. Starts from the entry script's real location (resolving
|
|
187
|
+
* symlinks) by default.
|
|
144
188
|
*
|
|
145
189
|
* @function
|
|
146
190
|
*/
|
|
147
|
-
const detectVersionSync = (providedVersion, startDir
|
|
191
|
+
const detectVersionSync = (providedVersion, startDir) => {
|
|
148
192
|
if (providedVersion) {
|
|
149
193
|
return providedVersion;
|
|
150
194
|
}
|
|
151
|
-
const
|
|
195
|
+
const dir = startDir ?? getScriptDir();
|
|
196
|
+
const pkgPath = findPackageJsonSync(dir);
|
|
152
197
|
if (!pkgPath) {
|
|
153
198
|
return undefined;
|
|
154
199
|
}
|
package/dist/version.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEH,qCAAqD;AACrD,+CAAsD;AACtD,yCAA0C;AAE1C;;;;;GAKG;AACH,MAAM,YAAY,GAAG,GAAW,EAAE;IAChC,IAAI,CAAC;QACH,+CAA+C;QAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,UAAU,EAAE,CAAC;YACf,6CAA6C;YAC7C,MAAM,QAAQ,GAAG,IAAA,sBAAY,EAAC,UAAU,CAAC,CAAC;YAC1C,OAAO,IAAA,mBAAO,EAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;AACvB,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,KAAK,IAAqB,EAAE;IACpD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,MAAM,IAAA,mBAAQ,EAAC,UAAU,CAAC,CAAC;YAC5C,OAAO,IAAA,mBAAO,EAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,sBAAsB;IACxB,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,EAAE,CAA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C,CAAC;IAC9C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAA,sBAAY,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAmB,CAAC;QAElD,OAAO;YACL,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;YACxC,UAAU,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC;SAC3C,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC,CAAC;AAnBW,QAAA,mBAAmB,uBAmB9B"}
|
package/dist/version.d.cts
CHANGED
|
@@ -16,17 +16,20 @@ interface PackageInfo {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Detect version: use provided version or read from nearest package.json.
|
|
19
|
+
* Starts from the entry script's real location (resolving symlinks) by
|
|
20
|
+
* default.
|
|
19
21
|
*
|
|
20
22
|
* @function
|
|
21
23
|
*/
|
|
22
|
-
export declare const detectVersion: (providedVersion
|
|
24
|
+
export declare const detectVersion: (providedVersion?: string, startDir?: string) => Promise<string | undefined>;
|
|
23
25
|
/**
|
|
24
26
|
* Detect version synchronously: use provided version or read from nearest
|
|
25
|
-
* package.json.
|
|
27
|
+
* package.json. Starts from the entry script's real location (resolving
|
|
28
|
+
* symlinks) by default.
|
|
26
29
|
*
|
|
27
30
|
* @function
|
|
28
31
|
*/
|
|
29
|
-
export declare const detectVersionSync: (providedVersion
|
|
32
|
+
export declare const detectVersionSync: (providedVersion?: string, startDir?: string) => string | undefined;
|
|
30
33
|
/**
|
|
31
34
|
* Read package info (homepage, repository) from package.json synchronously.
|
|
32
35
|
* Returns only HTTPS URLs; other URL schemes are omitted.
|
package/dist/version.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8CH;;GAEG;AACH,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkJD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,kBAAkB,MAAM,EACxB,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAY5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,kBAAkB,MAAM,EACxB,WAAW,MAAM,KAChB,MAAM,GAAG,SAYX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAU,MAAsB,KAC/B,WAiBF,CAAC"}
|
package/dist/version.d.ts
CHANGED
|
@@ -16,17 +16,20 @@ interface PackageInfo {
|
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Detect version: use provided version or read from nearest package.json.
|
|
19
|
+
* Starts from the entry script's real location (resolving symlinks) by
|
|
20
|
+
* default.
|
|
19
21
|
*
|
|
20
22
|
* @function
|
|
21
23
|
*/
|
|
22
|
-
export declare const detectVersion: (providedVersion
|
|
24
|
+
export declare const detectVersion: (providedVersion?: string, startDir?: string) => Promise<string | undefined>;
|
|
23
25
|
/**
|
|
24
26
|
* Detect version synchronously: use provided version or read from nearest
|
|
25
|
-
* package.json.
|
|
27
|
+
* package.json. Starts from the entry script's real location (resolving
|
|
28
|
+
* symlinks) by default.
|
|
26
29
|
*
|
|
27
30
|
* @function
|
|
28
31
|
*/
|
|
29
|
-
export declare const detectVersionSync: (providedVersion
|
|
32
|
+
export declare const detectVersionSync: (providedVersion?: string, startDir?: string) => string | undefined;
|
|
30
33
|
/**
|
|
31
34
|
* Read package info (homepage, repository) from package.json synchronously.
|
|
32
35
|
* Returns only HTTPS URLs; other URL schemes are omitted.
|
package/dist/version.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA8CH;;GAEG;AACH,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkJD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,kBAAkB,MAAM,EACxB,WAAW,MAAM,KAChB,OAAO,CAAC,MAAM,GAAG,SAAS,CAY5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,kBAAkB,MAAM,EACxB,WAAW,MAAM,KAChB,MAAM,GAAG,SAYX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAC9B,WAAU,MAAsB,KAC/B,WAiBF,CAAC"}
|
package/dist/version.js
CHANGED
|
@@ -7,9 +7,49 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @packageDocumentation
|
|
9
9
|
*/
|
|
10
|
-
import { readFileSync } from 'node:fs';
|
|
11
|
-
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
11
|
+
import { readFile, realpath } from 'node:fs/promises';
|
|
12
12
|
import { dirname, join } from 'node:path';
|
|
13
|
+
/**
|
|
14
|
+
* Get the real path of the entry script, resolving symlinks. Falls back to cwd
|
|
15
|
+
* if process.argv[1] is unavailable.
|
|
16
|
+
*
|
|
17
|
+
* @function
|
|
18
|
+
*/
|
|
19
|
+
const getScriptDir = () => {
|
|
20
|
+
try {
|
|
21
|
+
// process.argv[1] is the script being executed
|
|
22
|
+
const scriptPath = process.argv[1];
|
|
23
|
+
if (scriptPath) {
|
|
24
|
+
// Resolve symlinks to find the real location
|
|
25
|
+
const realPath = realpathSync(scriptPath);
|
|
26
|
+
return dirname(realPath);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Fall through to cwd
|
|
31
|
+
}
|
|
32
|
+
return process.cwd();
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Get the real path of the entry script asynchronously, resolving symlinks.
|
|
36
|
+
* Falls back to cwd if process.argv[1] is unavailable.
|
|
37
|
+
*
|
|
38
|
+
* @function
|
|
39
|
+
*/
|
|
40
|
+
const getScriptDirAsync = async () => {
|
|
41
|
+
try {
|
|
42
|
+
const scriptPath = process.argv[1];
|
|
43
|
+
if (scriptPath) {
|
|
44
|
+
const realPath = await realpath(scriptPath);
|
|
45
|
+
return dirname(realPath);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Fall through to cwd
|
|
50
|
+
}
|
|
51
|
+
return process.cwd();
|
|
52
|
+
};
|
|
13
53
|
/**
|
|
14
54
|
* Normalize a repository URL to clean HTTPS format. Strips leading `git+` and
|
|
15
55
|
* trailing `.git`.
|
|
@@ -121,14 +161,17 @@ const readVersionFromPackageJsonSync = (pkgPath) => {
|
|
|
121
161
|
};
|
|
122
162
|
/**
|
|
123
163
|
* Detect version: use provided version or read from nearest package.json.
|
|
164
|
+
* Starts from the entry script's real location (resolving symlinks) by
|
|
165
|
+
* default.
|
|
124
166
|
*
|
|
125
167
|
* @function
|
|
126
168
|
*/
|
|
127
|
-
export const detectVersion = async (providedVersion, startDir
|
|
169
|
+
export const detectVersion = async (providedVersion, startDir) => {
|
|
128
170
|
if (providedVersion) {
|
|
129
171
|
return providedVersion;
|
|
130
172
|
}
|
|
131
|
-
const
|
|
173
|
+
const dir = startDir ?? (await getScriptDirAsync());
|
|
174
|
+
const pkgPath = await findPackageJson(dir);
|
|
132
175
|
if (!pkgPath) {
|
|
133
176
|
return undefined;
|
|
134
177
|
}
|
|
@@ -136,15 +179,17 @@ export const detectVersion = async (providedVersion, startDir = process.cwd()) =
|
|
|
136
179
|
};
|
|
137
180
|
/**
|
|
138
181
|
* Detect version synchronously: use provided version or read from nearest
|
|
139
|
-
* package.json.
|
|
182
|
+
* package.json. Starts from the entry script's real location (resolving
|
|
183
|
+
* symlinks) by default.
|
|
140
184
|
*
|
|
141
185
|
* @function
|
|
142
186
|
*/
|
|
143
|
-
export const detectVersionSync = (providedVersion, startDir
|
|
187
|
+
export const detectVersionSync = (providedVersion, startDir) => {
|
|
144
188
|
if (providedVersion) {
|
|
145
189
|
return providedVersion;
|
|
146
190
|
}
|
|
147
|
-
const
|
|
191
|
+
const dir = startDir ?? getScriptDir();
|
|
192
|
+
const pkgPath = findPackageJsonSync(dir);
|
|
148
193
|
if (!pkgPath) {
|
|
149
194
|
return undefined;
|
|
150
195
|
}
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,YAAY,GAAG,GAAW,EAAE;IAChC,IAAI,CAAC;QACH,+CAA+C;QAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,UAAU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