@arcgis/node-toolkit 5.2.0-next.90 → 5.2.0-next.91
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/file.d.ts +15 -0
- package/dist/glob.d.ts +4 -0
- package/dist/packageJson.d.ts +39 -0
- package/dist/path.d.ts +21 -1
- package/dist/path.js +1 -1
- package/dist/shell.d.ts +46 -10
- package/dist/vite/externalizeDependenciesPlugin.d.ts +11 -6
- package/dist/vite/installPlaywright.d.ts +1 -1
- package/dist/vite/presetPlugin.d.ts +13 -5
- package/dist/vite/simpleTypesEmit.d.ts +19 -0
- package/dist/vite/simpleTypesEmit.js +76 -0
- package/dist/vite/typeScript.d.ts +21 -0
- package/dist/vite/typeScript.js +40 -0
- package/dist/workspace.d.ts +15 -0
- package/package.json +4 -1
package/dist/file.d.ts
CHANGED
|
@@ -2,21 +2,36 @@
|
|
|
2
2
|
* Asynchronously check if a file or directory exists.
|
|
3
3
|
* Using un-promisified version because promises version creates exceptions
|
|
4
4
|
* which interferes with debugging when "Pause on caught exceptions" is enabled
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
* @param file
|
|
5
8
|
*/
|
|
6
9
|
export declare const existsAsync: (file: string) => Promise<boolean>;
|
|
7
10
|
/**
|
|
8
11
|
* Create a file with the specified content if it does not already exist.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
* @param filePath
|
|
15
|
+
* @param content
|
|
9
16
|
*/
|
|
10
17
|
export declare function createFileIfNotExists(filePath: string, content: string): Promise<void>;
|
|
11
18
|
/**
|
|
12
19
|
* Climb the directory tree upward, until it founds a directory that contains the
|
|
13
20
|
* target file, and return resulting full path.
|
|
14
21
|
* Returns `undefined` if the file is not found.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
* @param target
|
|
25
|
+
* @param startDirectory
|
|
15
26
|
*/
|
|
16
27
|
export declare function findPath(target: string, startDirectory?: string): string | undefined;
|
|
17
28
|
/**
|
|
18
29
|
* Asynchronously climb the directory tree upward, until it founds a directory that contains the
|
|
19
30
|
* target file, and return resulting full path.
|
|
20
31
|
* Returns `undefined` if the file is not found.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
* @param target
|
|
35
|
+
* @param startDirectory
|
|
21
36
|
*/
|
|
22
37
|
export declare function asyncFindPath(target: string, startDirectory?: string): Promise<string | undefined>;
|
package/dist/glob.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Read `.gitignore` files and convert it to globs that are accepted by ESLint
|
|
3
3
|
*
|
|
4
|
+
* @public
|
|
5
|
+
* @param filePath
|
|
4
6
|
* @example
|
|
5
7
|
* ```ts
|
|
6
8
|
* // eslint.config.js
|
|
@@ -18,6 +20,8 @@
|
|
|
18
20
|
*/
|
|
19
21
|
export declare function gitIgnoreFileToGlobs(filePath: string): string[];
|
|
20
22
|
/**
|
|
23
|
+
* @public
|
|
24
|
+
* @param pattern
|
|
21
25
|
* @deprecated Use gitIgnoreFileToGlobs from "@arcgis/node-toolkit/glob"
|
|
22
26
|
* instead
|
|
23
27
|
*/
|
package/dist/packageJson.d.ts
CHANGED
|
@@ -4,62 +4,101 @@
|
|
|
4
4
|
*
|
|
5
5
|
* The full package.json type is insanely large (20k lines):
|
|
6
6
|
* https://github.com/ffflorian/schemastore-updater/blob/main/schemas/package/index.d.ts#L20067
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
7
9
|
*/
|
|
8
10
|
export type PackageJson = {
|
|
11
|
+
/** @public */
|
|
9
12
|
"name": string;
|
|
13
|
+
/** @public */
|
|
10
14
|
"version": string;
|
|
15
|
+
/** @public */
|
|
11
16
|
"private"?: boolean;
|
|
17
|
+
/** @public */
|
|
12
18
|
"type"?: "commonjs" | "module";
|
|
19
|
+
/** @public */
|
|
13
20
|
"main"?: string;
|
|
21
|
+
/** @public */
|
|
14
22
|
"module"?: string;
|
|
23
|
+
/** @public */
|
|
15
24
|
"types"?: string;
|
|
25
|
+
/** @public */
|
|
16
26
|
"files"?: string[];
|
|
27
|
+
/** @public */
|
|
17
28
|
"bin"?: Record<string, string> | string;
|
|
29
|
+
/** @public */
|
|
18
30
|
"man"?: string[] | string;
|
|
19
31
|
/**
|
|
32
|
+
* @public
|
|
20
33
|
* @see https://pnpm.io/package_json#publishconfigdirectory
|
|
21
34
|
*/
|
|
22
35
|
"publishConfig"?: {
|
|
23
36
|
directory?: string;
|
|
24
37
|
linkDirectory?: boolean;
|
|
25
38
|
};
|
|
39
|
+
/** @public */
|
|
26
40
|
"dependencies"?: Record<string, string>;
|
|
41
|
+
/** @public */
|
|
27
42
|
"devDependencies"?: Record<string, string>;
|
|
43
|
+
/** @public */
|
|
28
44
|
"peerDependencies"?: Record<string, string>;
|
|
45
|
+
/** @public */
|
|
29
46
|
"peerDependenciesMeta"?: Record<string, {
|
|
30
47
|
optional?: boolean;
|
|
31
48
|
}>;
|
|
49
|
+
/** @public */
|
|
32
50
|
"optionalDependencies"?: Record<string, string>;
|
|
51
|
+
/** @public */
|
|
33
52
|
"css.customData"?: string[];
|
|
53
|
+
/** @public */
|
|
34
54
|
"customElements"?: string;
|
|
55
|
+
/** @public */
|
|
35
56
|
"html.customData"?: string[];
|
|
57
|
+
/** @public */
|
|
36
58
|
"web-types"?: string;
|
|
59
|
+
/** @public */
|
|
37
60
|
"exports"?: Record<string, Record<string, string> | string>;
|
|
61
|
+
/** @public */
|
|
38
62
|
"engines"?: {
|
|
39
63
|
node?: string;
|
|
40
64
|
};
|
|
65
|
+
/** @public */
|
|
41
66
|
"scripts"?: Record<string, string>;
|
|
67
|
+
/** @public */
|
|
42
68
|
"packageManager"?: string;
|
|
43
69
|
};
|
|
44
70
|
/**
|
|
45
71
|
* Synchronously retrieves the package.json file for the current project or a specified location.
|
|
46
72
|
* If the location is not specified, it will search for the package.json file starting from the current working directory.
|
|
47
73
|
* This function caches the package.json file for future calls to avoid unnecessary file system reads.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
* @param location
|
|
48
77
|
*/
|
|
49
78
|
export declare function retrievePackageJson(location?: string): PackageJson;
|
|
50
79
|
/**
|
|
51
80
|
* Asynchronously retrieves the package.json file for the current project or a specified location.
|
|
52
81
|
* If the location is not specified, it will search for the package.json file starting from the current working directory.
|
|
53
82
|
* This function caches the package.json file for future calls to avoid unnecessary file system reads.
|
|
83
|
+
*
|
|
84
|
+
* @public
|
|
85
|
+
* @param location
|
|
54
86
|
*/
|
|
55
87
|
export declare function asyncRetrievePackageJson(location?: string): Promise<PackageJson>;
|
|
56
88
|
/**
|
|
57
89
|
* Returns an absolute path to the root of a package in node_modules, without
|
|
58
90
|
* trailing slash.
|
|
91
|
+
*
|
|
92
|
+
* @public
|
|
93
|
+
* @param packageName
|
|
94
|
+
* @param cwd
|
|
59
95
|
*/
|
|
60
96
|
export declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
|
|
61
97
|
/**
|
|
62
98
|
* Find the package.json for a given package name in node_modules, and return the parsed JSON.
|
|
63
99
|
* Returns undefined if the package.json cannot be found.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
* @param packageName
|
|
64
103
|
*/
|
|
65
104
|
export declare function findPackageJson(packageName: string): PackageJson | undefined;
|
package/dist/path.d.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* See ../path.md for details about our path handling.
|
|
3
|
+
*
|
|
4
|
+
* DOCS: publish to webgis reference docs for this package, and the ./path.md file
|
|
5
|
+
*/
|
|
6
|
+
import { posix } from "path";
|
|
2
7
|
/**
|
|
3
8
|
* Determines if the current environment is POSIX (e.g., macOS, Linux) or not.
|
|
4
9
|
* This is called "isPosix" rather than "isNotWindows" because even if we are
|
|
5
10
|
* on Windows, we could be running in a POSIX environment (e.g. WSL2)
|
|
11
|
+
*
|
|
12
|
+
* @public
|
|
6
13
|
*/
|
|
7
14
|
export declare const isPosix: boolean;
|
|
8
15
|
/**
|
|
9
16
|
* Converts a Windows-style path to a POSIX-style path.
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
* @param relativePath The path to convert to POSIX-style separators.
|
|
10
20
|
*/
|
|
11
21
|
export declare const toPosixPathSeparators: (relativePath: string) => string;
|
|
12
22
|
/**
|
|
13
23
|
* Normalizes the path separators for the current runtime environment.
|
|
14
24
|
* On POSIX systems, this function returns the path unchanged.
|
|
15
25
|
* On Windows systems, it converts all `\` separators to `/`.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param path The path to normalize.
|
|
16
29
|
*/
|
|
17
30
|
export declare const normalizePath: (relativePath: string) => string;
|
|
18
31
|
/**
|
|
@@ -21,16 +34,23 @@ export declare const normalizePath: (relativePath: string) => string;
|
|
|
21
34
|
* wish to output the path in the console or error message.
|
|
22
35
|
* On POSIX system (macOS, Linux, ...), this does not change the path (because
|
|
23
36
|
* inside the compiler we use `/` everywhere).
|
|
37
|
+
*
|
|
38
|
+
* @public
|
|
39
|
+
* @param relativePath
|
|
24
40
|
*/
|
|
25
41
|
export declare const toSystemPathSeparators: (relativePath: string) => string;
|
|
26
42
|
/**
|
|
27
43
|
* Like `process.cwd()`, but always returns a POSIX-style path
|
|
28
44
|
* (with `/` as separator).
|
|
45
|
+
*
|
|
46
|
+
* @public
|
|
29
47
|
*/
|
|
30
48
|
export declare const getCwd: () => string;
|
|
31
49
|
/**
|
|
32
50
|
* A wrapper for Node.js's `path` module that always uses POSIX-style paths
|
|
33
51
|
* (with `/` as separator).
|
|
52
|
+
*
|
|
53
|
+
* @public
|
|
34
54
|
*/
|
|
35
55
|
export declare const path: typeof posix & {
|
|
36
56
|
sep: "/";
|
package/dist/path.js
CHANGED
|
@@ -6,7 +6,7 @@ const toPosixPathSeparators = (relativePath) => (
|
|
|
6
6
|
);
|
|
7
7
|
const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
|
|
8
8
|
const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
|
|
9
|
-
const toSystemPathSeparators = isPosix ? (
|
|
9
|
+
const toSystemPathSeparators = isPosix ? (relativePath) => relativePath : toWin32PathSeparators;
|
|
10
10
|
const getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
|
|
11
11
|
const path = isPosix ? posix : {
|
|
12
12
|
...win32,
|
package/dist/shell.d.ts
CHANGED
|
@@ -1,51 +1,67 @@
|
|
|
1
|
-
import { ExecOptionsWithStringEncoding, ExecSyncOptionsWithStringEncoding, SpawnSyncOptionsWithStringEncoding, SpawnOptions } from
|
|
1
|
+
import { type ExecOptionsWithStringEncoding, type ExecSyncOptionsWithStringEncoding, type SpawnSyncOptionsWithStringEncoding, type SpawnOptions } from "node:child_process";
|
|
2
|
+
/** @public */
|
|
2
3
|
type SyncProcessOptions = Omit<SpawnSyncOptionsWithStringEncoding, "stdio">;
|
|
4
|
+
/** @public */
|
|
3
5
|
type CollectOutputSyncOptions = SyncProcessOptions & {
|
|
6
|
+
/** @public */
|
|
4
7
|
stderr?: "ignore" | "inherit";
|
|
5
8
|
};
|
|
9
|
+
/** @public */
|
|
6
10
|
type AsyncProcessOptions = SpawnOptions & {
|
|
11
|
+
/** @public */
|
|
7
12
|
input?: NonNullable<SpawnSyncOptionsWithStringEncoding["input"]>;
|
|
8
13
|
};
|
|
9
14
|
/**
|
|
10
15
|
* Synchronously execute a shell command and return the output.
|
|
11
16
|
*
|
|
12
|
-
* Prefer {@link runCommandSync} for command-only execution, or {@link collectOutputSync}
|
|
13
|
-
* when you need to capture stdout. {@link sh} goes through a shell, which
|
|
17
|
+
* Prefer {@link shell!runCommandSync} for command-only execution, or {@link shell!collectOutputSync}
|
|
18
|
+
* when you need to capture stdout. {@link shell!sh} goes through a shell, which
|
|
14
19
|
* requires careful escaping and can mis-handle dynamic input with spaces or
|
|
15
20
|
* shell metacharacters.
|
|
16
21
|
*
|
|
17
|
-
* Use {@link sh} only when shell features are intentionally required, such as
|
|
22
|
+
* Use {@link shell!sh} only when shell features are intentionally required, such as
|
|
18
23
|
* pipes, redirects, `&&`, or command substitution.
|
|
19
24
|
*
|
|
20
25
|
* Example (shell features required):
|
|
21
26
|
* `sh("pnpm list | grep @arcgis/core")`
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
* @param command
|
|
30
|
+
* @param options
|
|
22
31
|
*/
|
|
23
32
|
export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
|
|
24
33
|
/**
|
|
25
34
|
* Asynchronously execute a shell command and return the output.
|
|
26
35
|
*
|
|
27
|
-
* Prefer {@link runCommand} for command-only execution, or {@link collectOutput}
|
|
28
|
-
* when you need to capture stdout. {@link asyncSh} executes through a shell,
|
|
36
|
+
* Prefer {@link shell!runCommand} for command-only execution, or {@link shell!collectOutput}
|
|
37
|
+
* when you need to capture stdout. {@link shell!asyncSh} executes through a shell,
|
|
29
38
|
* so callers must handle shell escaping and quoting correctly.
|
|
30
39
|
*
|
|
31
|
-
* Use {@link asyncSh} only when shell syntax is intentionally needed.
|
|
40
|
+
* Use {@link shell!asyncSh} only when shell syntax is intentionally needed.
|
|
32
41
|
*
|
|
33
42
|
* Example (shell features required):
|
|
34
43
|
* `await asyncSh("pnpm list | grep @arcgis/core")`
|
|
44
|
+
*
|
|
45
|
+
* @param command
|
|
46
|
+
* @param options
|
|
35
47
|
*/
|
|
36
48
|
export declare function asyncSh(command: string, options?: Partial<ExecOptionsWithStringEncoding>): Promise<string>;
|
|
37
49
|
/**
|
|
38
50
|
* Synchronously execute a command without shell interpolation and return the output.
|
|
39
51
|
*
|
|
40
|
-
* This is usually safer than {@link sh} because arguments are passed as
|
|
52
|
+
* This is usually safer than {@link shell!sh} because arguments are passed as
|
|
41
53
|
* discrete tokens, which avoids most shell escaping issues and command
|
|
42
54
|
* injection pitfalls.
|
|
43
55
|
*
|
|
44
56
|
* Example:
|
|
45
57
|
* `sp("git", ["show", `${baseRef}:pnpm-workspace.yaml`])`
|
|
46
58
|
*
|
|
47
|
-
* Avoid {@link sp} only when you explicitly need shell features.
|
|
48
|
-
* @
|
|
59
|
+
* Avoid {@link shell!sp} only when you explicitly need shell features.
|
|
60
|
+
* @public
|
|
61
|
+
* @deprecated Use {@link shell!collectOutputSync} or {@link shell!runCommandSync} instead.
|
|
62
|
+
* @param command
|
|
63
|
+
* @param args
|
|
64
|
+
* @param options
|
|
49
65
|
*/
|
|
50
66
|
export declare function sp(command: string, args: string[], options?: Partial<SpawnSyncOptionsWithStringEncoding>): string;
|
|
51
67
|
/**
|
|
@@ -55,6 +71,11 @@ export declare function sp(command: string, args: string[], options?: Partial<Sp
|
|
|
55
71
|
* if the `shell` option is not explicitly provided.
|
|
56
72
|
* Note 2:
|
|
57
73
|
* If the `input` option is provided, it will be piped to the child process's stdin.
|
|
74
|
+
*
|
|
75
|
+
* @public
|
|
76
|
+
* @param command
|
|
77
|
+
* @param args
|
|
78
|
+
* @param options
|
|
58
79
|
*/
|
|
59
80
|
export declare function runCommandSync(command: string, args: string[], options?: Partial<SyncProcessOptions>): void;
|
|
60
81
|
/**
|
|
@@ -64,16 +85,31 @@ export declare function runCommandSync(command: string, args: string[], options?
|
|
|
64
85
|
* if the `shell` option is not explicitly provided.
|
|
65
86
|
* Note 2:
|
|
66
87
|
* If the `input` option is provided, it will be piped to the child process's stdin.
|
|
88
|
+
*
|
|
89
|
+
* @public
|
|
90
|
+
* @param command
|
|
91
|
+
* @param args
|
|
92
|
+
* @param options
|
|
67
93
|
*/
|
|
68
94
|
export declare function runCommand(command: string, args: string[], options?: Partial<AsyncProcessOptions>): Promise<void>;
|
|
69
95
|
/**
|
|
70
96
|
* Synchronously execute a command and collect stdout while streaming stderr.
|
|
71
97
|
* Note that `pnpm` command will be automatically invoked with `shell: process.platform === "win32"`.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
* @param command
|
|
101
|
+
* @param args
|
|
102
|
+
* @param options
|
|
72
103
|
*/
|
|
73
104
|
export declare function collectOutputSync(command: string, args: string[], options?: Partial<CollectOutputSyncOptions>): string;
|
|
74
105
|
/**
|
|
75
106
|
* Asynchronously execute a command and collect stdout while streaming stderr.
|
|
76
107
|
* Note that `pnpm` command will be automatically invoked with `shell: process.platform === "win32"`.
|
|
108
|
+
*
|
|
109
|
+
* @public
|
|
110
|
+
* @param command
|
|
111
|
+
* @param args
|
|
112
|
+
* @param options
|
|
77
113
|
*/
|
|
78
114
|
export declare function collectOutput(command: string, args: string[], options?: Partial<AsyncProcessOptions>): Promise<string>;
|
|
79
115
|
export {};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
import { PackageJson } from
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import { type PackageJson } from "../packageJson.ts";
|
|
3
3
|
/**
|
|
4
4
|
* Options for managing dependencies in a Vite project.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
5
7
|
*/
|
|
6
8
|
export type DependencyManagementOptions = {
|
|
7
9
|
/**
|
|
8
10
|
* Force bundle in these dependencies even if they are declared as
|
|
9
11
|
* dependencies or peerDependencies.
|
|
10
12
|
*
|
|
13
|
+
* @public
|
|
11
14
|
* @example
|
|
12
15
|
* This is desirable if you wish to control the version of a dependency or
|
|
13
16
|
* need to post-process the dependency in some way. Usually, you will declare
|
|
@@ -25,6 +28,7 @@ export type DependencyManagementOptions = {
|
|
|
25
28
|
* Force externalize these dependencies, even if they are declared as
|
|
26
29
|
* devDependencies.
|
|
27
30
|
*
|
|
31
|
+
* @public
|
|
28
32
|
* @example
|
|
29
33
|
* This is desirable if you are sure the end user will have these dependencies
|
|
30
34
|
* available, yet do not wish to declare these as devDependencies for some
|
|
@@ -36,6 +40,7 @@ export type DependencyManagementOptions = {
|
|
|
36
40
|
* to avoid bundling in dependencies in a library. In application packages,
|
|
37
41
|
* bundling in everything is desirable, so enable this option.
|
|
38
42
|
*
|
|
43
|
+
* @public
|
|
39
44
|
* @default false
|
|
40
45
|
*/
|
|
41
46
|
readonly isApplication?: boolean;
|
|
@@ -61,11 +66,11 @@ export type DependencyManagementOptions = {
|
|
|
61
66
|
* For example, see this statement from Lit:
|
|
62
67
|
* https://lit.dev/docs/ssr/authoring/#:~:text=Don%27t%20bundle%20Lit,based%20on%20environment.
|
|
63
68
|
*
|
|
64
|
-
*
|
|
69
|
+
* > If a dependency is both a peerDependency and a devDependency, it will still
|
|
70
|
+
* > be externalized (because all peerDependencies are externalized).
|
|
65
71
|
*
|
|
66
|
-
* @
|
|
67
|
-
*
|
|
68
|
-
* be externalized (because all peerDependencies are externalized).
|
|
72
|
+
* @public
|
|
73
|
+
* @param options
|
|
69
74
|
*/
|
|
70
75
|
export declare function externalizeDependencies(options: DependencyManagementOptions): Plugin;
|
|
71
76
|
interface PluginShape extends Plugin {
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { Plugin } from
|
|
2
|
-
import
|
|
3
|
-
import { DependencyManagementOptions } from
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
import type dts from "vite-plugin-dts";
|
|
3
|
+
import { type DependencyManagementOptions } from "./externalizeDependenciesPlugin.ts";
|
|
4
|
+
/** @public */
|
|
4
5
|
export type VitePresetOptions = DependencyManagementOptions & {
|
|
5
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Options for `vite-plugin-dts`
|
|
8
|
+
*
|
|
9
|
+
* @public
|
|
10
|
+
* @deprecated Use https://webgis.esri.com/references/api-extractor/integrations instead
|
|
11
|
+
*/
|
|
6
12
|
dtsOptions?: Parameters<typeof dts>[0] | false;
|
|
7
13
|
};
|
|
8
14
|
/**
|
|
9
15
|
* Vite preset for all our support packages:
|
|
10
16
|
* - externalizes all non-dev-dependencies
|
|
11
|
-
*
|
|
17
|
+
*
|
|
18
|
+
* @public
|
|
19
|
+
* @param options
|
|
12
20
|
*/
|
|
13
21
|
export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, isApplication }?: VitePresetOptions): [Plugin, Plugin, Promise<Plugin> | undefined];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* A barebones tsc integration for Vite.
|
|
4
|
+
* This emits types for all .ts and .tsx files in src/ using tsconfig.json.
|
|
5
|
+
*
|
|
6
|
+
* Do not use this plugin for new code.
|
|
7
|
+
* Use https://webgis.esri.com/references/api-extractor/integrations instead.
|
|
8
|
+
*
|
|
9
|
+
* This exists only for usage by `@arcgis/toolkit` and
|
|
10
|
+
* `@arcgis/node-toolkit` as they cannot use API Extractor to avoid a
|
|
11
|
+
* cyclical dependency.
|
|
12
|
+
*
|
|
13
|
+
* This serves as a minimal replacement for vite-plugin-dts. For comparison,
|
|
14
|
+
* node-toolkit build using this package in 1s compared to 1.3s for
|
|
15
|
+
* vite-plugin-dts.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare function simpleTypesEmit(): Plugin;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { loadTypeScriptConfig } from "./typeScript.js";
|
|
3
|
+
import { path } from "../path.js";
|
|
4
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
+
function simpleTypesEmit() {
|
|
6
|
+
let oldProgram;
|
|
7
|
+
let isWatchMode = false;
|
|
8
|
+
const sourcePrefix = path.join(process.cwd(), "src/");
|
|
9
|
+
const distPrefix = path.join(process.cwd(), "dist/");
|
|
10
|
+
const distSrcPrefix = path.join(distPrefix, "src/");
|
|
11
|
+
return {
|
|
12
|
+
name: "simple-types-emit",
|
|
13
|
+
apply: "build",
|
|
14
|
+
configResolved(viteConfig) {
|
|
15
|
+
const isBuildMode = viteConfig.command === "build";
|
|
16
|
+
isWatchMode = (isBuildMode ? viteConfig.build.watch : viteConfig.server.watch) != null;
|
|
17
|
+
},
|
|
18
|
+
writeBundle: {
|
|
19
|
+
sequential: true,
|
|
20
|
+
async handler() {
|
|
21
|
+
const { config } = loadTypeScriptConfig(void 0, void 0, true);
|
|
22
|
+
const compilerHost = ts.createCompilerHost(config.options);
|
|
23
|
+
const program = ts.createProgram(
|
|
24
|
+
config.fileNames,
|
|
25
|
+
{ ...config.options, noEmit: false, declaration: true, emitDeclarationOnly: true },
|
|
26
|
+
compilerHost,
|
|
27
|
+
oldProgram
|
|
28
|
+
);
|
|
29
|
+
oldProgram = program;
|
|
30
|
+
const allDiagnostics = [...ts.getPreEmitDiagnostics(program)];
|
|
31
|
+
const writeQueue = [];
|
|
32
|
+
for (const sourceFile of program.getSourceFiles()) {
|
|
33
|
+
if (!isIncludedFile(sourceFile.fileName, sourcePrefix)) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const diagnostics = program.emit(
|
|
37
|
+
sourceFile,
|
|
38
|
+
(name, text) => {
|
|
39
|
+
const filePath = distPrefix + name.slice(distSrcPrefix.length);
|
|
40
|
+
writeQueue.push(
|
|
41
|
+
mkdir(path.dirname(filePath), { recursive: true }).then(async () => await writeFile(filePath, text))
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
void 0,
|
|
45
|
+
true
|
|
46
|
+
);
|
|
47
|
+
allDiagnostics.push(...diagnostics.diagnostics);
|
|
48
|
+
}
|
|
49
|
+
await Promise.all(writeQueue);
|
|
50
|
+
const deduplicatedDiagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
|
|
51
|
+
const hasErrors = deduplicatedDiagnostics.length > 0;
|
|
52
|
+
const stopBuild = hasErrors && !isWatchMode;
|
|
53
|
+
if (stopBuild) {
|
|
54
|
+
console.error(
|
|
55
|
+
ts.formatDiagnosticsWithColorAndContext(deduplicatedDiagnostics, {
|
|
56
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
57
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
58
|
+
getNewLine: () => ts.sys.newLine
|
|
59
|
+
})
|
|
60
|
+
);
|
|
61
|
+
const error = new Error("TypeScript errors reported. See error messages above");
|
|
62
|
+
error.stack = "";
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const isIncludedFile = (filePath, prefix) => isPermittedFile(filePath) && isInIncludedFolder(filePath, prefix);
|
|
70
|
+
const isPermittedFile = (filePath) => (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) && !isTestFile(filePath) && !isStoryFile(filePath);
|
|
71
|
+
const isTestFile = (filePath) => filePath.includes("__test") || filePath.includes(".e2e.") || filePath.includes(".spec.") || filePath.includes(".test.");
|
|
72
|
+
const isStoryFile = (filePath) => filePath.includes(".stories.");
|
|
73
|
+
const isInIncludedFolder = (fileOrFolderPath, prefix) => fileOrFolderPath.startsWith(prefix) && !fileOrFolderPath.includes("node_modules");
|
|
74
|
+
export {
|
|
75
|
+
simpleTypesEmit
|
|
76
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/** @public */
|
|
3
|
+
export interface TypeScriptConfigResult {
|
|
4
|
+
/**
|
|
5
|
+
* Absolute path to the resolved tsconfig.json file.
|
|
6
|
+
*
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
configPath: string;
|
|
10
|
+
/** @public */
|
|
11
|
+
config: ts.ParsedCommandLine;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @public
|
|
15
|
+
* @param cwd Defaults to process.cwd()
|
|
16
|
+
* @param configPath Optional absolute or relative path to a tsconfig.json file.
|
|
17
|
+
* @param resolveIncludedFiles If true, will resolve tsconfig's include, exclude,
|
|
18
|
+
* and files globs. Resolved files can be accessed via
|
|
19
|
+
* TypeScriptConfigResult.config.fileNames.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadTypeScriptConfig(cwd: string | undefined, configPath: string | undefined, resolveIncludedFiles: boolean): TypeScriptConfigResult;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { findPath } from "../file.js";
|
|
3
|
+
import { path, toSystemPathSeparators } from "../path.js";
|
|
4
|
+
function loadTypeScriptConfig(cwd = process.cwd(), configPath, resolveIncludedFiles) {
|
|
5
|
+
const tsConfigFile = configPath === void 0 ? findPath("tsconfig.json", cwd) : path.resolve(cwd, configPath);
|
|
6
|
+
if (tsConfigFile === void 0) {
|
|
7
|
+
throw Error(
|
|
8
|
+
`Unable to find ${toSystemPathSeparators(String(configPath))}. Please make sure the file exists, or provide types.tsconfigPath option to useLumina()`
|
|
9
|
+
);
|
|
10
|
+
}
|
|
11
|
+
const parsed = ts.readConfigFile(tsConfigFile, ts.sys.readFile);
|
|
12
|
+
if (parsed.error !== void 0) {
|
|
13
|
+
throw Error(ts.formatDiagnosticsWithColorAndContext([parsed.error], diagnosticsContext));
|
|
14
|
+
}
|
|
15
|
+
const typedResolvedConfig = parsed.config;
|
|
16
|
+
const fastConfig = resolveIncludedFiles ? typedResolvedConfig : {
|
|
17
|
+
...typedResolvedConfig,
|
|
18
|
+
include: [],
|
|
19
|
+
files: [],
|
|
20
|
+
exclude: []
|
|
21
|
+
};
|
|
22
|
+
const resolved = ts.parseJsonConfigFileContent(fastConfig, ts.sys, path.dirname(tsConfigFile));
|
|
23
|
+
const noFilesFoundErrorCode = 18002;
|
|
24
|
+
const filteredErrors = resolveIncludedFiles ? resolved.errors : resolved.errors.filter((error) => error.code !== noFilesFoundErrorCode);
|
|
25
|
+
if (filteredErrors.length > 0) {
|
|
26
|
+
throw Error(ts.formatDiagnosticsWithColorAndContext(filteredErrors, diagnosticsContext));
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
configPath: tsConfigFile,
|
|
30
|
+
config: resolved
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const diagnosticsContext = {
|
|
34
|
+
getCurrentDirectory: process.cwd,
|
|
35
|
+
getCanonicalFileName: (fileName) => fileName,
|
|
36
|
+
getNewLine: () => ts.sys.newLine
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
loadTypeScriptConfig
|
|
40
|
+
};
|
package/dist/workspace.d.ts
CHANGED
|
@@ -1,21 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Set the target file to use when finding the root of the repository.
|
|
3
3
|
* By default, it looks for the pnpm-lock.yaml file, but you can specify a different target file if needed.
|
|
4
|
+
*
|
|
5
|
+
* @public
|
|
6
|
+
* @param target
|
|
4
7
|
*/
|
|
5
8
|
export declare function setRootTargetFile(target: string): void;
|
|
6
9
|
/**
|
|
7
10
|
* Locate the root directory by finding a target file.
|
|
8
11
|
* By default, it looks for the pnpm-lock.yaml file, but you can call setRootTargetFile to specify a different target file if needed.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
9
14
|
*/
|
|
10
15
|
export declare function findRepositoryRoot(): string;
|
|
11
16
|
/**
|
|
12
17
|
* Get the path to the Turbo CLI. This allows us to directly invoke it without incurring the overhead of going through
|
|
13
18
|
* the package manager.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @param repositoryRoot
|
|
14
22
|
*/
|
|
15
23
|
export declare function getTurboPath(repositoryRoot?: string): string;
|
|
16
24
|
/**
|
|
17
25
|
* Parse a version string into its components.
|
|
18
26
|
*
|
|
27
|
+
* @public
|
|
28
|
+
* @param version
|
|
19
29
|
* @example
|
|
20
30
|
* ```ts
|
|
21
31
|
* const parsed = parseVersion("4.34.0-next.123");
|
|
@@ -37,11 +47,16 @@ export declare const parseVersion: (version: string) => {
|
|
|
37
47
|
* The majorMinorVersion is major.minor version of the system version, and is used for deployment and publishing.
|
|
38
48
|
* The cdnVersion is the system version without any pre-release or build metadata, and is used for deployment and publishing
|
|
39
49
|
* (e.g. 1.2.3-next.4 becomes 1.2.3-next and 5.2.1 stays 5.2.1).
|
|
50
|
+
*
|
|
51
|
+
* @public
|
|
40
52
|
*/
|
|
41
53
|
export declare function getSystemVersion(): ReturnType<typeof parseVersion> & {
|
|
42
54
|
version: string;
|
|
43
55
|
};
|
|
44
56
|
/**
|
|
45
57
|
* Detect if current repository/monorepo uses npm, pnpm, or yarn
|
|
58
|
+
*
|
|
59
|
+
* @public
|
|
60
|
+
* @param cwd
|
|
46
61
|
*/
|
|
47
62
|
export declare function detectPackageManager(cwd?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/node-toolkit",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.91",
|
|
4
4
|
"description": "Collection of common internal build-time patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
|
|
5
5
|
"homepage": "https://developers.arcgis.com/javascript/latest/",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"./vite/presetPlugin": "./dist/vite/presetPlugin.js",
|
|
14
14
|
"./vite/externalizeDependenciesPlugin": "./dist/vite/externalizeDependenciesPlugin.js",
|
|
15
15
|
"./vite/installPlaywright": "./dist/vite/installPlaywright.js",
|
|
16
|
+
"./vite/simpleTypesEmit": "./dist/vite/simpleTypesEmit.js",
|
|
17
|
+
"./vite/typeScript": "./dist/vite/typeScript.js",
|
|
16
18
|
"./workspace": "./dist/workspace.js",
|
|
17
19
|
"./package.json": "./package.json"
|
|
18
20
|
},
|
|
@@ -23,6 +25,7 @@
|
|
|
23
25
|
"dependencies": {
|
|
24
26
|
"@types/node": "~24.11.2",
|
|
25
27
|
"tslib": "^2.8.1",
|
|
28
|
+
"typescript": "~6.0.3",
|
|
26
29
|
"vite": "^7.3.2",
|
|
27
30
|
"vite-plugin-dts": "^4.5.4"
|
|
28
31
|
}
|