@arcgis/node-toolkit 5.2.0-next.111 → 5.2.0-next.113
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/workspace.d.ts +41 -6
- package/dist/workspace.js +52 -2
- package/package.json +3 -1
package/dist/workspace.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { type PackageJson } from "./packageJson.ts";
|
|
1
2
|
/**
|
|
2
3
|
* Set the target file to use when finding the root of the repository.
|
|
3
4
|
* By default, it looks for the pnpm-lock.yaml file, but you can specify a different target file if needed.
|
|
4
5
|
*
|
|
5
|
-
* @
|
|
6
|
+
* @internal
|
|
6
7
|
* @param target
|
|
7
8
|
*/
|
|
8
9
|
export declare function setRootTargetFile(target: string): void;
|
|
@@ -10,21 +11,54 @@ export declare function setRootTargetFile(target: string): void;
|
|
|
10
11
|
* Locate the root directory by finding a target file.
|
|
11
12
|
* 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
|
*
|
|
13
|
-
* @
|
|
14
|
+
* @internal
|
|
14
15
|
*/
|
|
15
16
|
export declare function findRepositoryRoot(): string;
|
|
17
|
+
/** @internal */
|
|
18
|
+
export type PackageWalkerItem = {
|
|
19
|
+
/** @internal */
|
|
20
|
+
packagePath: string;
|
|
21
|
+
/** @internal */
|
|
22
|
+
manifest: PackageJson;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
* @param item
|
|
27
|
+
*/
|
|
28
|
+
type PackageWalkerCallback<T> = (item: PackageWalkerItem) => T;
|
|
29
|
+
/** @internal */
|
|
30
|
+
type WorkspacePackagesWalkerOptions = {
|
|
31
|
+
/**
|
|
32
|
+
* Whether to include the root package. By default, it is not included.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
includeRootPackage?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The repository root. By default, it is the directory containing pnpm-lock.yaml.
|
|
39
|
+
*
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
repositoryRoot?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Walk all pnpm workspace packages and collect non-null callback results.
|
|
46
|
+
*
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare function workspacePackagesWalker<T>(callback: PackageWalkerCallback<T>, { includeRootPackage, repositoryRoot }?: WorkspacePackagesWalkerOptions): Promise<NonNullable<Awaited<T>>[]>;
|
|
16
50
|
/**
|
|
17
51
|
* Get the path to the Turbo CLI. This allows us to directly invoke it without incurring the overhead of going through
|
|
18
52
|
* the package manager.
|
|
19
53
|
*
|
|
20
|
-
* @
|
|
54
|
+
* @internal
|
|
21
55
|
* @param repositoryRoot
|
|
22
56
|
*/
|
|
23
57
|
export declare function getTurboPath(repositoryRoot?: string): string;
|
|
24
58
|
/**
|
|
25
59
|
* Parse a version string into its components.
|
|
26
60
|
*
|
|
27
|
-
* @
|
|
61
|
+
* @internal
|
|
28
62
|
* @param version
|
|
29
63
|
* @example
|
|
30
64
|
* ```ts
|
|
@@ -48,7 +82,7 @@ export declare const parseVersion: (version: string) => {
|
|
|
48
82
|
* The cdnVersion is the system version without any pre-release or build metadata, and is used for deployment and publishing
|
|
49
83
|
* (e.g. 1.2.3-next.4 becomes 1.2.3-next and 5.2.1 stays 5.2.1).
|
|
50
84
|
*
|
|
51
|
-
* @
|
|
85
|
+
* @internal
|
|
52
86
|
*/
|
|
53
87
|
export declare function getSystemVersion(): ReturnType<typeof parseVersion> & {
|
|
54
88
|
version: string;
|
|
@@ -56,7 +90,8 @@ export declare function getSystemVersion(): ReturnType<typeof parseVersion> & {
|
|
|
56
90
|
/**
|
|
57
91
|
* Detect if current repository/monorepo uses npm, pnpm, or yarn
|
|
58
92
|
*
|
|
59
|
-
* @
|
|
93
|
+
* @internal
|
|
60
94
|
* @param cwd
|
|
61
95
|
*/
|
|
62
96
|
export declare function detectPackageManager(cwd?: string): string;
|
|
97
|
+
export {};
|
package/dist/workspace.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { readWorkspaceManifest } from "@pnpm/workspace.read-manifest";
|
|
1
2
|
import { findPath } from "./file.js";
|
|
2
|
-
import { retrievePackageJson } from "./packageJson.js";
|
|
3
|
+
import { retrievePackageJson, asyncRetrievePackageJson } from "./packageJson.js";
|
|
3
4
|
import { path } from "./path.js";
|
|
4
5
|
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
+
import { styleText } from "node:util";
|
|
7
|
+
import { glob } from "tinyglobby";
|
|
5
8
|
let rootTargetFile = "pnpm-lock.yaml";
|
|
6
9
|
function setRootTargetFile(target) {
|
|
7
10
|
rootTargetFile = target;
|
|
@@ -15,6 +18,52 @@ function findRepositoryRoot() {
|
|
|
15
18
|
}
|
|
16
19
|
return path.dirname(lockFilePath);
|
|
17
20
|
}
|
|
21
|
+
async function getWorkspacePackagePaths(includeRootPackage = true, repositoryRoot = findRepositoryRoot()) {
|
|
22
|
+
const packagePatterns = (await readWorkspaceManifest(repositoryRoot))?.packages ?? [];
|
|
23
|
+
const packageJsonPatterns = packagePatterns.map((packagePattern) => `${packagePattern}/package.json`);
|
|
24
|
+
if (includeRootPackage) {
|
|
25
|
+
packageJsonPatterns.push("package.json");
|
|
26
|
+
}
|
|
27
|
+
const packageJsonPaths = await glob(packageJsonPatterns, {
|
|
28
|
+
dot: true,
|
|
29
|
+
onlyFiles: true,
|
|
30
|
+
absolute: false,
|
|
31
|
+
cwd: repositoryRoot,
|
|
32
|
+
followSymbolicLinks: false
|
|
33
|
+
});
|
|
34
|
+
return packageJsonPaths.map((packageJsonPath) => path.dirname(packageJsonPath));
|
|
35
|
+
}
|
|
36
|
+
async function workspacePackagesWalker(callback, { includeRootPackage = false, repositoryRoot = findRepositoryRoot() } = {}) {
|
|
37
|
+
const packagePaths = await getWorkspacePackagePaths(includeRootPackage, repositoryRoot);
|
|
38
|
+
const results = [];
|
|
39
|
+
try {
|
|
40
|
+
await Promise.all(
|
|
41
|
+
packagePaths.map(async (packagePath) => {
|
|
42
|
+
try {
|
|
43
|
+
const manifest = await asyncRetrievePackageJson(path.join(repositoryRoot, packagePath));
|
|
44
|
+
if (!manifest) {
|
|
45
|
+
console.error(styleText("red", `Failed to read package manifest at ${packagePath}, skipping.`));
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const output = await callback({ packagePath, manifest }) ?? void 0;
|
|
49
|
+
if (output !== void 0) {
|
|
50
|
+
results.push(output);
|
|
51
|
+
}
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error(styleText("red", `Error processing package ${packagePath}:`));
|
|
54
|
+
console.error(error);
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error(String(error));
|
|
61
|
+
const workspaceError = new Error("Error occurred during workspace package walking.");
|
|
62
|
+
workspaceError.stack = "";
|
|
63
|
+
throw workspaceError;
|
|
64
|
+
}
|
|
65
|
+
return results;
|
|
66
|
+
}
|
|
18
67
|
function getTurboPath(repositoryRoot = findRepositoryRoot()) {
|
|
19
68
|
return path.join(repositoryRoot, "node_modules/turbo/bin/turbo");
|
|
20
69
|
}
|
|
@@ -74,5 +123,6 @@ export {
|
|
|
74
123
|
getSystemVersion,
|
|
75
124
|
getTurboPath,
|
|
76
125
|
parseVersion,
|
|
77
|
-
setRootTargetFile
|
|
126
|
+
setRootTargetFile,
|
|
127
|
+
workspacePackagesWalker
|
|
78
128
|
};
|
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.113",
|
|
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",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
25
25
|
"dependencies": {
|
|
26
|
+
"@pnpm/workspace.read-manifest": "^1000.2.10",
|
|
26
27
|
"@types/node": "~24.11.2",
|
|
28
|
+
"tinyglobby": "~0.2.17",
|
|
27
29
|
"tslib": "^2.8.1",
|
|
28
30
|
"typescript": "~6.0.3",
|
|
29
31
|
"vite": "^7.3.2",
|