@arcgis/node-toolkit 5.2.0-next.129 → 5.2.0-next.131
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/codeowners.d.ts +35 -0
- package/dist/codeowners.js +50 -0
- package/dist/file.js +1 -1
- package/dist/packageJson.d.ts +13 -0
- package/dist/packageJson.js +23 -1
- package/dist/vite/simpleTypesEmit.d.ts +7 -3
- package/dist/vite/simpleTypesEmit.js +28 -2
- package/package.json +3 -4
- package/dist/workspace.d.ts +0 -97
- package/dist/workspace.js +0 -128
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A pattern and its owners from a CODEOWNERS file.
|
|
3
|
+
*
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface CodeownersEntry {
|
|
7
|
+
pattern: string;
|
|
8
|
+
owners: string[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Resolves ownership using directory patterns, globs, and last-match precedence.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export interface Codeowners {
|
|
16
|
+
getOwners: (fileName: string) => string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Reads a CODEOWNERS file and returns its entries.
|
|
20
|
+
* Defaults to `.github/CODEOWNERS` in the nearest Git repository found from
|
|
21
|
+
* the current working directory. Throws if the repository or file is missing.
|
|
22
|
+
*
|
|
23
|
+
* @public
|
|
24
|
+
* @param codeownersPath Optional explicit path to a CODEOWNERS file.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readCodeownersEntries(codeownersPath?: string | undefined): CodeownersEntry[];
|
|
27
|
+
/**
|
|
28
|
+
* Loads `.github/CODEOWNERS` from the nearest Git repository found from the
|
|
29
|
+
* current working directory. Returns undefined if the repository or file is missing.
|
|
30
|
+
* Returned ownership lookups accept file paths relative to the current working
|
|
31
|
+
* directory or absolute file paths.
|
|
32
|
+
*
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
35
|
+
export declare function loadCodeowners(): Codeowners | undefined;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { path } from "./path.js";
|
|
2
|
+
import { findPath } from "./file.js";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import picomatch from "picomatch";
|
|
5
|
+
function readCodeownersEntries(codeownersPath = findCodeownersPath()) {
|
|
6
|
+
if (!codeownersPath) {
|
|
7
|
+
throw new Error(`Unable to find Git repository from current working directory: ${process.cwd()}`);
|
|
8
|
+
}
|
|
9
|
+
return parseCodeownersEntries(readFileSync(codeownersPath, "utf8"));
|
|
10
|
+
}
|
|
11
|
+
function loadCodeowners() {
|
|
12
|
+
const codeownersPath = findCodeownersPath();
|
|
13
|
+
return codeownersPath && existsSync(codeownersPath) ? createCodeowners(readCodeownersEntries(codeownersPath), path.dirname(path.dirname(codeownersPath))) : void 0;
|
|
14
|
+
}
|
|
15
|
+
function findCodeownersPath() {
|
|
16
|
+
const gitPath = findPath(".git");
|
|
17
|
+
return gitPath ? path.join(path.dirname(gitPath), ".github", "CODEOWNERS") : void 0;
|
|
18
|
+
}
|
|
19
|
+
function parseCodeownersEntries(contents) {
|
|
20
|
+
return contents.split(/\r?\n/u).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#")).map((line) => {
|
|
21
|
+
const [pattern, ...owners] = line.split(/\s+/u);
|
|
22
|
+
return { pattern, owners };
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function createCodeowners(rawEntries, repositoryRoot) {
|
|
26
|
+
const entries = rawEntries.map(({ pattern, owners }) => {
|
|
27
|
+
const normalizedPattern = pattern.startsWith("/") ? pattern.slice(1) : pattern;
|
|
28
|
+
const matcherPattern = normalizedPattern.includes("/") ? normalizedPattern : `**/${normalizedPattern}`;
|
|
29
|
+
return {
|
|
30
|
+
matches: picomatch([matcherPattern, `${matcherPattern.replace(/\/$/u, "")}/**`], { dot: true }),
|
|
31
|
+
owners
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
return {
|
|
35
|
+
getOwners(fileName) {
|
|
36
|
+
const relativeFileName = path.relative(repositoryRoot, fileName);
|
|
37
|
+
let owners = [];
|
|
38
|
+
for (const entry of entries) {
|
|
39
|
+
if (entry.matches(relativeFileName)) {
|
|
40
|
+
owners = entry.owners;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return owners;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
loadCodeowners,
|
|
49
|
+
readCodeownersEntries
|
|
50
|
+
};
|
package/dist/file.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { access, existsSync } from "node:fs";
|
|
2
|
-
import {
|
|
2
|
+
import { mkdir, writeFile, constants } from "node:fs/promises";
|
|
3
3
|
import { dirname, resolve, sep, join } from "path";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
5
|
const existsAsync = async (file) => (
|
package/dist/packageJson.d.ts
CHANGED
|
@@ -102,3 +102,16 @@ export declare function fetchPackageLocation(packageName: string, cwd?: string):
|
|
|
102
102
|
* @param packageName
|
|
103
103
|
*/
|
|
104
104
|
export declare function findPackageJson(packageName: string): PackageJson | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Detect the package manager from the nearest ancestor package.json with a packageManager field.
|
|
107
|
+
* Defaults to npm when no package manager is declared.
|
|
108
|
+
* Uses retrievePackageJson's cached manifest reads.
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const packageManager = detectPackageManager();
|
|
112
|
+
* console.log(packageManager); // e.g., "npm" or "pnpm"
|
|
113
|
+
* ```
|
|
114
|
+
* @public
|
|
115
|
+
* @param cwd The current working directory to start searching for the package manager from. Defaults to process.cwd().
|
|
116
|
+
*/
|
|
117
|
+
export declare function detectPackageManager(cwd?: string): string;
|
package/dist/packageJson.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { path } from "./path.js";
|
|
3
|
-
import {
|
|
3
|
+
import { findPath, asyncFindPath } from "./file.js";
|
|
4
4
|
import { readFileSync } from "node:fs";
|
|
5
5
|
const cachedPackageJson = {};
|
|
6
6
|
const cachedPackageJsonPromises = {};
|
|
@@ -50,8 +50,30 @@ function findPackageJson(packageName) {
|
|
|
50
50
|
}
|
|
51
51
|
return retrievePackageJson(path2);
|
|
52
52
|
}
|
|
53
|
+
function detectPackageManager(cwd = process.cwd()) {
|
|
54
|
+
let packageManager = void 0;
|
|
55
|
+
let directory = path.resolve(cwd);
|
|
56
|
+
for (; ; ) {
|
|
57
|
+
const packageJsonPath = findPath("package.json", directory);
|
|
58
|
+
if (packageJsonPath === void 0) {
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
const packageDirectory = path.dirname(packageJsonPath);
|
|
62
|
+
const contents = retrievePackageJson(packageDirectory);
|
|
63
|
+
if (typeof contents === "object" && !Array.isArray(contents) && typeof contents.packageManager === "string") {
|
|
64
|
+
packageManager ??= contents.packageManager.match(/\w+/u)?.[0] ?? packageManager;
|
|
65
|
+
}
|
|
66
|
+
directory = path.dirname(packageDirectory);
|
|
67
|
+
if (directory === packageDirectory) {
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
packageManager ??= "npm";
|
|
72
|
+
return packageManager;
|
|
73
|
+
}
|
|
53
74
|
export {
|
|
54
75
|
asyncRetrievePackageJson,
|
|
76
|
+
detectPackageManager,
|
|
55
77
|
fetchPackageLocation,
|
|
56
78
|
findPackageJson,
|
|
57
79
|
retrievePackageJson
|
|
@@ -6,8 +6,8 @@ import type { Plugin } from "vite";
|
|
|
6
6
|
* Do not use this plugin for new code.
|
|
7
7
|
* Use https://webgis.esri.com/references/api-extractor/integrations instead.
|
|
8
8
|
*
|
|
9
|
-
* This exists only for usage by `@arcgis/toolkit
|
|
10
|
-
* `@arcgis/node-toolkit` as they cannot use API Extractor to avoid a
|
|
9
|
+
* This exists only for usage by `@arcgis/toolkit`,
|
|
10
|
+
* `@arcgis/node-toolkit`, and `@webgis/monorepo-toolkit` as they cannot use API Extractor to avoid a
|
|
11
11
|
* cyclical dependency.
|
|
12
12
|
*
|
|
13
13
|
* This serves as a minimal replacement for vite-plugin-dts. For comparison,
|
|
@@ -15,5 +15,9 @@ import type { Plugin } from "vite";
|
|
|
15
15
|
* vite-plugin-dts.
|
|
16
16
|
*
|
|
17
17
|
* @public
|
|
18
|
+
* @param options Declaration emission options.
|
|
19
|
+
* @param options.mapDeclarationImport Optional mapping for module specifiers in emitted declarations.
|
|
18
20
|
*/
|
|
19
|
-
export declare function simpleTypesEmit(
|
|
21
|
+
export declare function simpleTypesEmit({ mapDeclarationImport, }?: {
|
|
22
|
+
mapDeclarationImport?: (specifier: string) => string;
|
|
23
|
+
}): Plugin;
|
|
@@ -2,7 +2,9 @@ import ts from "typescript";
|
|
|
2
2
|
import { loadTypeScriptConfig } from "./typeScript.js";
|
|
3
3
|
import { path } from "../path.js";
|
|
4
4
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
5
|
-
function simpleTypesEmit(
|
|
5
|
+
function simpleTypesEmit({
|
|
6
|
+
mapDeclarationImport
|
|
7
|
+
} = {}) {
|
|
6
8
|
let oldProgram;
|
|
7
9
|
let isWatchMode = false;
|
|
8
10
|
const sourcePrefix = path.join(process.cwd(), "src/");
|
|
@@ -42,7 +44,8 @@ function simpleTypesEmit() {
|
|
|
42
44
|
);
|
|
43
45
|
},
|
|
44
46
|
void 0,
|
|
45
|
-
true
|
|
47
|
+
true,
|
|
48
|
+
mapDeclarationImport ? { afterDeclarations: [createDeclarationImportTransformer(mapDeclarationImport)] } : void 0
|
|
46
49
|
);
|
|
47
50
|
allDiagnostics.push(...diagnostics.diagnostics);
|
|
48
51
|
}
|
|
@@ -66,6 +69,29 @@ function simpleTypesEmit() {
|
|
|
66
69
|
}
|
|
67
70
|
};
|
|
68
71
|
}
|
|
72
|
+
function createDeclarationImportTransformer(mapDeclarationImport) {
|
|
73
|
+
return (context) => {
|
|
74
|
+
let parent;
|
|
75
|
+
let importTypeArgument;
|
|
76
|
+
const visit = (node) => {
|
|
77
|
+
if (ts.isStringLiteral(node) && parent !== void 0 && (ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) || ts.isLiteralTypeNode(parent) && parent === importTypeArgument)) {
|
|
78
|
+
const specifier = mapDeclarationImport(node.text);
|
|
79
|
+
return specifier === node.text ? node : context.factory.createStringLiteral(specifier);
|
|
80
|
+
}
|
|
81
|
+
const previousParent = parent;
|
|
82
|
+
const previousImportTypeArgument = importTypeArgument;
|
|
83
|
+
parent = node;
|
|
84
|
+
if (ts.isImportTypeNode(node)) {
|
|
85
|
+
importTypeArgument = node.argument;
|
|
86
|
+
}
|
|
87
|
+
const result = ts.visitEachChild(node, visit, context);
|
|
88
|
+
parent = previousParent;
|
|
89
|
+
importTypeArgument = previousImportTypeArgument;
|
|
90
|
+
return result;
|
|
91
|
+
};
|
|
92
|
+
return (root) => ts.visitNode(root, visit);
|
|
93
|
+
};
|
|
94
|
+
}
|
|
69
95
|
const isIncludedFile = (filePath, prefix) => isPermittedFile(filePath) && isInIncludedFolder(filePath, prefix);
|
|
70
96
|
const isPermittedFile = (filePath) => (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) && !isTestFile(filePath) && !isStoryFile(filePath);
|
|
71
97
|
const isTestFile = (filePath) => filePath.includes("__test") || filePath.includes(".e2e.") || filePath.includes(".spec.") || filePath.includes(".test.");
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/node-toolkit",
|
|
3
|
-
"version": "5.2.0-next.
|
|
3
|
+
"version": "5.2.0-next.131",
|
|
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",
|
|
7
7
|
"exports": {
|
|
8
|
+
"./codeowners": "./dist/codeowners.js",
|
|
8
9
|
"./file": "./dist/file.js",
|
|
9
10
|
"./shell": "./dist/shell.js",
|
|
10
11
|
"./glob": "./dist/glob.js",
|
|
@@ -15,7 +16,6 @@
|
|
|
15
16
|
"./vite/installPlaywright": "./dist/vite/installPlaywright.js",
|
|
16
17
|
"./vite/simpleTypesEmit": "./dist/vite/simpleTypesEmit.js",
|
|
17
18
|
"./vite/typeScript": "./dist/vite/typeScript.js",
|
|
18
|
-
"./workspace": "./dist/workspace.js",
|
|
19
19
|
"./package.json": "./package.json"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
@@ -23,9 +23,8 @@
|
|
|
23
23
|
],
|
|
24
24
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@pnpm/workspace.read-manifest": "^1000.2.10",
|
|
27
26
|
"@types/node": "~24.11.2",
|
|
28
|
-
"
|
|
27
|
+
"picomatch": "^4.0.4",
|
|
29
28
|
"tslib": "^2.8.1",
|
|
30
29
|
"typescript": "~6.0.3",
|
|
31
30
|
"vite": "^7.3.2",
|
package/dist/workspace.d.ts
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { type PackageJson } from "./packageJson.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Set the target file to use when finding the root of the repository.
|
|
4
|
-
* By default, it looks for the pnpm-lock.yaml file, but you can specify a different target file if needed.
|
|
5
|
-
*
|
|
6
|
-
* @internal
|
|
7
|
-
* @param target
|
|
8
|
-
*/
|
|
9
|
-
export declare function setRootTargetFile(target: string): void;
|
|
10
|
-
/**
|
|
11
|
-
* Locate the root directory by finding a target file.
|
|
12
|
-
* By default, it looks for the pnpm-lock.yaml file, but you can call setRootTargetFile to specify a different target file if needed.
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
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>>[]>;
|
|
50
|
-
/**
|
|
51
|
-
* Get the path to the Turbo CLI. This allows us to directly invoke it without incurring the overhead of going through
|
|
52
|
-
* the package manager.
|
|
53
|
-
*
|
|
54
|
-
* @internal
|
|
55
|
-
* @param repositoryRoot
|
|
56
|
-
*/
|
|
57
|
-
export declare function getTurboPath(repositoryRoot?: string): string;
|
|
58
|
-
/**
|
|
59
|
-
* Parse a version string into its components.
|
|
60
|
-
*
|
|
61
|
-
* @internal
|
|
62
|
-
* @param version
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* const parsed = parseVersion("4.34.0-next.123");
|
|
66
|
-
* // { major: 4, minor: 34, patch: 0, prerelease: ["next", 123], majorMinorVersion: "4.34", cdnVersion: "4.34.0-next" }
|
|
67
|
-
* const parsed = parseVersion("5.2.20");
|
|
68
|
-
* // { major: 5, minor: 2, patch: 20, prerelease: [], majorMinorVersion: "5.2", cdnVersion: "5.2.20" }
|
|
69
|
-
* ```
|
|
70
|
-
*/
|
|
71
|
-
export declare const parseVersion: (version: string) => {
|
|
72
|
-
major: string;
|
|
73
|
-
minor: string;
|
|
74
|
-
patch: string;
|
|
75
|
-
prerelease: string[];
|
|
76
|
-
majorMinorVersion: string;
|
|
77
|
-
cdnVersion: string;
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Get the system version from the root package.json. The system version is the version of the monorepo as a whole, and is used for deployment and publishing.
|
|
81
|
-
* The majorMinorVersion is major.minor version of the system version, and is used for deployment and publishing.
|
|
82
|
-
* The cdnVersion is the system version without any pre-release or build metadata, and is used for deployment and publishing
|
|
83
|
-
* (e.g. 1.2.3-next.4 becomes 1.2.3-next and 5.2.1 stays 5.2.1).
|
|
84
|
-
*
|
|
85
|
-
* @internal
|
|
86
|
-
*/
|
|
87
|
-
export declare function getSystemVersion(): ReturnType<typeof parseVersion> & {
|
|
88
|
-
version: string;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Detect if current repository/monorepo uses npm, pnpm, or yarn
|
|
92
|
-
*
|
|
93
|
-
* @internal
|
|
94
|
-
* @param cwd
|
|
95
|
-
*/
|
|
96
|
-
export declare function detectPackageManager(cwd?: string): string;
|
|
97
|
-
export {};
|
package/dist/workspace.js
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { readWorkspaceManifest } from "@pnpm/workspace.read-manifest";
|
|
2
|
-
import { findPath } from "./file.js";
|
|
3
|
-
import { retrievePackageJson, asyncRetrievePackageJson } from "./packageJson.js";
|
|
4
|
-
import { path } from "./path.js";
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
6
|
-
import { styleText } from "node:util";
|
|
7
|
-
import { glob } from "tinyglobby";
|
|
8
|
-
let rootTargetFile = "pnpm-lock.yaml";
|
|
9
|
-
function setRootTargetFile(target) {
|
|
10
|
-
rootTargetFile = target;
|
|
11
|
-
}
|
|
12
|
-
function findRepositoryRoot() {
|
|
13
|
-
const lockFilePath = findPath(rootTargetFile);
|
|
14
|
-
if (!lockFilePath) {
|
|
15
|
-
throw new Error(
|
|
16
|
-
`Unable to find root with target "${rootTargetFile}" from current working directory: ${process.cwd()}`
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
return path.dirname(lockFilePath);
|
|
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
|
-
}
|
|
67
|
-
function getTurboPath(repositoryRoot = findRepositoryRoot()) {
|
|
68
|
-
return path.join(repositoryRoot, "node_modules/turbo/bin/turbo");
|
|
69
|
-
}
|
|
70
|
-
const parseVersion = (version) => {
|
|
71
|
-
const versionParts = /^(?<major>0|[1-9]\d*)\.(?<minor>0|[1-9]\d*)\.(?<patch>0|[1-9]\d*)(?:-(?<prereleaseParts>[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u.exec(
|
|
72
|
-
version
|
|
73
|
-
);
|
|
74
|
-
if (!versionParts?.groups) {
|
|
75
|
-
throw new Error(`Unable to parse version "${version}"`);
|
|
76
|
-
}
|
|
77
|
-
const { major, minor, patch, prereleaseParts } = versionParts.groups;
|
|
78
|
-
const prerelease = prereleaseParts ? prereleaseParts.split(".") : [];
|
|
79
|
-
const majorMinorVersion = `${major}.${minor}`;
|
|
80
|
-
const cdnVersion = prerelease[0] ? `${majorMinorVersion}.${patch}-${prerelease[0]}` : `${majorMinorVersion}.${patch}`;
|
|
81
|
-
return {
|
|
82
|
-
major,
|
|
83
|
-
minor,
|
|
84
|
-
patch,
|
|
85
|
-
prerelease,
|
|
86
|
-
majorMinorVersion,
|
|
87
|
-
cdnVersion
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
function getSystemVersion() {
|
|
91
|
-
const repositoryRoot = findRepositoryRoot();
|
|
92
|
-
const version = retrievePackageJson(repositoryRoot).version;
|
|
93
|
-
if (!version) {
|
|
94
|
-
throw new Error("Root package.json does not have a version defined");
|
|
95
|
-
}
|
|
96
|
-
return { version, ...parseVersion(version) };
|
|
97
|
-
}
|
|
98
|
-
function detectPackageManager(cwd = process.cwd()) {
|
|
99
|
-
let packageManager = void 0;
|
|
100
|
-
{
|
|
101
|
-
const pathParts = path.resolve(cwd).split(path.sep);
|
|
102
|
-
while (pathParts.length > 1) {
|
|
103
|
-
const packageJson = path.join(pathParts.join(path.sep), "package.json");
|
|
104
|
-
pathParts.pop();
|
|
105
|
-
if (!existsSync(packageJson)) {
|
|
106
|
-
continue;
|
|
107
|
-
}
|
|
108
|
-
const contents = JSON.parse(readFileSync(packageJson, "utf8"));
|
|
109
|
-
if (typeof contents !== "object" || Array.isArray(contents)) {
|
|
110
|
-
continue;
|
|
111
|
-
}
|
|
112
|
-
if (typeof contents.packageManager === "string") {
|
|
113
|
-
packageManager ??= contents.packageManager.match(/\w+/u)?.[0] ?? packageManager;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
packageManager ??= "npm";
|
|
118
|
-
return packageManager;
|
|
119
|
-
}
|
|
120
|
-
export {
|
|
121
|
-
detectPackageManager,
|
|
122
|
-
findRepositoryRoot,
|
|
123
|
-
getSystemVersion,
|
|
124
|
-
getTurboPath,
|
|
125
|
-
parseVersion,
|
|
126
|
-
setRootTargetFile,
|
|
127
|
-
workspacePackagesWalker
|
|
128
|
-
};
|