@optique/discover 1.2.0-dev.2169 → 1.2.0-dev.2179
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/README.md +27 -0
- package/dist/chunk-CUT6urMc.cjs +30 -0
- package/dist/cli.cjs +144 -0
- package/dist/cli.d.cts +10 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +143 -0
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +1 -1
- package/dist/generator-C12pIuFe.js +270 -0
- package/dist/generator-e4RwnDKG.cjs +288 -0
- package/dist/generator.cjs +7 -0
- package/dist/generator.d.cts +136 -0
- package/dist/generator.d.ts +136 -0
- package/dist/generator.js +5 -0
- package/dist/index.cjs +7 -780
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -751
- package/dist/main-check-CwunSNpK.cjs +60 -0
- package/dist/main-check-mMnKfUZs.js +48 -0
- package/dist/main-check.cjs +4 -0
- package/dist/main-check.d.cts +72 -0
- package/dist/main-check.d.ts +72 -0
- package/dist/main-check.js +3 -0
- package/dist/src-BYGxdHGJ.cjs +784 -0
- package/dist/src-Ci75oZo-.js +754 -0
- package/package.json +18 -3
- /package/dist/{command-B0lV6NBO.cjs → command-CUn2_NIA.cjs} +0 -0
- /package/dist/{command-DyiVIMUh.d.ts → command-DrmNW0HO.d.ts} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
const require_chunk = require('./chunk-CUT6urMc.cjs');
|
|
2
|
+
const node_url = require_chunk.__toESM(require("node:url"));
|
|
3
|
+
const node_fs = require_chunk.__toESM(require("node:fs"));
|
|
4
|
+
|
|
5
|
+
//#region src/main-check.ts
|
|
6
|
+
/**
|
|
7
|
+
* Checks whether a module is the current process entry point.
|
|
8
|
+
*
|
|
9
|
+
* @param options Main-module check inputs.
|
|
10
|
+
* @returns Whether the module should run as the process entry point.
|
|
11
|
+
* @internal
|
|
12
|
+
* @since 1.2.0
|
|
13
|
+
*/
|
|
14
|
+
function isMainModule(options) {
|
|
15
|
+
if (options.importMetaMain != null) return options.importMetaMain;
|
|
16
|
+
if (options.argvEntry == null) return false;
|
|
17
|
+
const realpath = options.realpath ?? node_fs.realpathSync;
|
|
18
|
+
return realpathOrOriginal(options.argvEntry, realpath) === realpathOrOriginal(options.modulePath, realpath);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether a module URL is the current process entry point.
|
|
22
|
+
*
|
|
23
|
+
* Non-file module URLs rely on `import.meta.main` because process entry points
|
|
24
|
+
* are file-system paths.
|
|
25
|
+
*
|
|
26
|
+
* @param options Main-module URL check inputs.
|
|
27
|
+
* @returns Whether the module should run as the process entry point.
|
|
28
|
+
* @internal
|
|
29
|
+
* @since 1.2.0
|
|
30
|
+
*/
|
|
31
|
+
function isMainModuleUrl(options) {
|
|
32
|
+
if (options.importMetaMain != null) return options.importMetaMain;
|
|
33
|
+
if (!options.moduleUrl.startsWith("file:")) return false;
|
|
34
|
+
return isMainModule({
|
|
35
|
+
modulePath: (0, node_url.fileURLToPath)(options.moduleUrl),
|
|
36
|
+
argvEntry: options.argvEntry,
|
|
37
|
+
realpath: options.realpath
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function realpathOrOriginal(path, realpath) {
|
|
41
|
+
try {
|
|
42
|
+
return realpath(path);
|
|
43
|
+
} catch {
|
|
44
|
+
return path;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
//#endregion
|
|
49
|
+
Object.defineProperty(exports, 'isMainModule', {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function () {
|
|
52
|
+
return isMainModule;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
Object.defineProperty(exports, 'isMainModuleUrl', {
|
|
56
|
+
enumerable: true,
|
|
57
|
+
get: function () {
|
|
58
|
+
return isMainModuleUrl;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region src/main-check.ts
|
|
5
|
+
/**
|
|
6
|
+
* Checks whether a module is the current process entry point.
|
|
7
|
+
*
|
|
8
|
+
* @param options Main-module check inputs.
|
|
9
|
+
* @returns Whether the module should run as the process entry point.
|
|
10
|
+
* @internal
|
|
11
|
+
* @since 1.2.0
|
|
12
|
+
*/
|
|
13
|
+
function isMainModule(options) {
|
|
14
|
+
if (options.importMetaMain != null) return options.importMetaMain;
|
|
15
|
+
if (options.argvEntry == null) return false;
|
|
16
|
+
const realpath = options.realpath ?? realpathSync;
|
|
17
|
+
return realpathOrOriginal(options.argvEntry, realpath) === realpathOrOriginal(options.modulePath, realpath);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Checks whether a module URL is the current process entry point.
|
|
21
|
+
*
|
|
22
|
+
* Non-file module URLs rely on `import.meta.main` because process entry points
|
|
23
|
+
* are file-system paths.
|
|
24
|
+
*
|
|
25
|
+
* @param options Main-module URL check inputs.
|
|
26
|
+
* @returns Whether the module should run as the process entry point.
|
|
27
|
+
* @internal
|
|
28
|
+
* @since 1.2.0
|
|
29
|
+
*/
|
|
30
|
+
function isMainModuleUrl(options) {
|
|
31
|
+
if (options.importMetaMain != null) return options.importMetaMain;
|
|
32
|
+
if (!options.moduleUrl.startsWith("file:")) return false;
|
|
33
|
+
return isMainModule({
|
|
34
|
+
modulePath: fileURLToPath(options.moduleUrl),
|
|
35
|
+
argvEntry: options.argvEntry,
|
|
36
|
+
realpath: options.realpath
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function realpathOrOriginal(path, realpath) {
|
|
40
|
+
try {
|
|
41
|
+
return realpath(path);
|
|
42
|
+
} catch {
|
|
43
|
+
return path;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
export { isMainModule, isMainModuleUrl };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/main-check.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Options for checking whether an ESM module is the process entry point.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
* @since 1.2.0
|
|
7
|
+
*/
|
|
8
|
+
interface MainModuleOptions {
|
|
9
|
+
/**
|
|
10
|
+
* `import.meta.main` when the current runtime provides it.
|
|
11
|
+
*/
|
|
12
|
+
readonly importMetaMain?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Path to the current module.
|
|
15
|
+
*/
|
|
16
|
+
readonly modulePath: string;
|
|
17
|
+
/**
|
|
18
|
+
* Process entry-point path.
|
|
19
|
+
*/
|
|
20
|
+
readonly argvEntry?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Function used to resolve symlinks.
|
|
23
|
+
*/
|
|
24
|
+
readonly realpath?: (path: string) => string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for checking whether an ESM module URL is the process entry point.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
* @since 1.2.0
|
|
31
|
+
*/
|
|
32
|
+
interface MainModuleUrlOptions {
|
|
33
|
+
/**
|
|
34
|
+
* `import.meta.main` when the current runtime provides it.
|
|
35
|
+
*/
|
|
36
|
+
readonly importMetaMain?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* URL of the current module.
|
|
39
|
+
*/
|
|
40
|
+
readonly moduleUrl: string;
|
|
41
|
+
/**
|
|
42
|
+
* Process entry-point path.
|
|
43
|
+
*/
|
|
44
|
+
readonly argvEntry?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Function used to resolve symlinks.
|
|
47
|
+
*/
|
|
48
|
+
readonly realpath?: (path: string) => string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether a module is the current process entry point.
|
|
52
|
+
*
|
|
53
|
+
* @param options Main-module check inputs.
|
|
54
|
+
* @returns Whether the module should run as the process entry point.
|
|
55
|
+
* @internal
|
|
56
|
+
* @since 1.2.0
|
|
57
|
+
*/
|
|
58
|
+
declare function isMainModule(options: MainModuleOptions): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether a module URL is the current process entry point.
|
|
61
|
+
*
|
|
62
|
+
* Non-file module URLs rely on `import.meta.main` because process entry points
|
|
63
|
+
* are file-system paths.
|
|
64
|
+
*
|
|
65
|
+
* @param options Main-module URL check inputs.
|
|
66
|
+
* @returns Whether the module should run as the process entry point.
|
|
67
|
+
* @internal
|
|
68
|
+
* @since 1.2.0
|
|
69
|
+
*/
|
|
70
|
+
declare function isMainModuleUrl(options: MainModuleUrlOptions): boolean;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { MainModuleOptions, MainModuleUrlOptions, isMainModule, isMainModuleUrl };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
//#region src/main-check.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Options for checking whether an ESM module is the process entry point.
|
|
4
|
+
*
|
|
5
|
+
* @internal
|
|
6
|
+
* @since 1.2.0
|
|
7
|
+
*/
|
|
8
|
+
interface MainModuleOptions {
|
|
9
|
+
/**
|
|
10
|
+
* `import.meta.main` when the current runtime provides it.
|
|
11
|
+
*/
|
|
12
|
+
readonly importMetaMain?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Path to the current module.
|
|
15
|
+
*/
|
|
16
|
+
readonly modulePath: string;
|
|
17
|
+
/**
|
|
18
|
+
* Process entry-point path.
|
|
19
|
+
*/
|
|
20
|
+
readonly argvEntry?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Function used to resolve symlinks.
|
|
23
|
+
*/
|
|
24
|
+
readonly realpath?: (path: string) => string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Options for checking whether an ESM module URL is the process entry point.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
* @since 1.2.0
|
|
31
|
+
*/
|
|
32
|
+
interface MainModuleUrlOptions {
|
|
33
|
+
/**
|
|
34
|
+
* `import.meta.main` when the current runtime provides it.
|
|
35
|
+
*/
|
|
36
|
+
readonly importMetaMain?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* URL of the current module.
|
|
39
|
+
*/
|
|
40
|
+
readonly moduleUrl: string;
|
|
41
|
+
/**
|
|
42
|
+
* Process entry-point path.
|
|
43
|
+
*/
|
|
44
|
+
readonly argvEntry?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Function used to resolve symlinks.
|
|
47
|
+
*/
|
|
48
|
+
readonly realpath?: (path: string) => string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Checks whether a module is the current process entry point.
|
|
52
|
+
*
|
|
53
|
+
* @param options Main-module check inputs.
|
|
54
|
+
* @returns Whether the module should run as the process entry point.
|
|
55
|
+
* @internal
|
|
56
|
+
* @since 1.2.0
|
|
57
|
+
*/
|
|
58
|
+
declare function isMainModule(options: MainModuleOptions): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Checks whether a module URL is the current process entry point.
|
|
61
|
+
*
|
|
62
|
+
* Non-file module URLs rely on `import.meta.main` because process entry points
|
|
63
|
+
* are file-system paths.
|
|
64
|
+
*
|
|
65
|
+
* @param options Main-module URL check inputs.
|
|
66
|
+
* @returns Whether the module should run as the process entry point.
|
|
67
|
+
* @internal
|
|
68
|
+
* @since 1.2.0
|
|
69
|
+
*/
|
|
70
|
+
declare function isMainModuleUrl(options: MainModuleUrlOptions): boolean;
|
|
71
|
+
//#endregion
|
|
72
|
+
export { MainModuleOptions, MainModuleUrlOptions, isMainModule, isMainModuleUrl };
|