@arcgis/node-toolkit 5.2.0-next.100

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.
@@ -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
+ };
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Set the target file to use when finding the root of the repository.
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
7
+ */
8
+ export declare function setRootTargetFile(target: string): void;
9
+ /**
10
+ * Locate the root directory by finding a target file.
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
14
+ */
15
+ export declare function findRepositoryRoot(): string;
16
+ /**
17
+ * Get the path to the Turbo CLI. This allows us to directly invoke it without incurring the overhead of going through
18
+ * the package manager.
19
+ *
20
+ * @public
21
+ * @param repositoryRoot
22
+ */
23
+ export declare function getTurboPath(repositoryRoot?: string): string;
24
+ /**
25
+ * Parse a version string into its components.
26
+ *
27
+ * @public
28
+ * @param version
29
+ * @example
30
+ * ```ts
31
+ * const parsed = parseVersion("4.34.0-next.123");
32
+ * // { major: 4, minor: 34, patch: 0, prerelease: ["next", 123], majorMinorVersion: "4.34", cdnVersion: "4.34.0-next" }
33
+ * const parsed = parseVersion("5.2.20");
34
+ * // { major: 5, minor: 2, patch: 20, prerelease: [], majorMinorVersion: "5.2", cdnVersion: "5.2.20" }
35
+ * ```
36
+ */
37
+ export declare const parseVersion: (version: string) => {
38
+ major: string;
39
+ minor: string;
40
+ patch: string;
41
+ prerelease: string[];
42
+ majorMinorVersion: string;
43
+ cdnVersion: string;
44
+ };
45
+ /**
46
+ * 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.
47
+ * The majorMinorVersion is major.minor version of the system version, and is used for deployment and publishing.
48
+ * The cdnVersion is the system version without any pre-release or build metadata, and is used for deployment and publishing
49
+ * (e.g. 1.2.3-next.4 becomes 1.2.3-next and 5.2.1 stays 5.2.1).
50
+ *
51
+ * @public
52
+ */
53
+ export declare function getSystemVersion(): ReturnType<typeof parseVersion> & {
54
+ version: string;
55
+ };
56
+ /**
57
+ * Detect if current repository/monorepo uses npm, pnpm, or yarn
58
+ *
59
+ * @public
60
+ * @param cwd
61
+ */
62
+ export declare function detectPackageManager(cwd?: string): string;
@@ -0,0 +1,78 @@
1
+ import { findPath } from "./file.js";
2
+ import { retrievePackageJson } from "./packageJson.js";
3
+ import { path } from "./path.js";
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ let rootTargetFile = "pnpm-lock.yaml";
6
+ function setRootTargetFile(target) {
7
+ rootTargetFile = target;
8
+ }
9
+ function findRepositoryRoot() {
10
+ const lockFilePath = findPath(rootTargetFile);
11
+ if (!lockFilePath) {
12
+ throw new Error(
13
+ `Unable to find root with target "${rootTargetFile}" from current working directory: ${process.cwd()}`
14
+ );
15
+ }
16
+ return path.dirname(lockFilePath);
17
+ }
18
+ function getTurboPath(repositoryRoot = findRepositoryRoot()) {
19
+ return path.join(repositoryRoot, "node_modules/turbo/bin/turbo");
20
+ }
21
+ const parseVersion = (version) => {
22
+ 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(
23
+ version
24
+ );
25
+ if (!versionParts?.groups) {
26
+ throw new Error(`Unable to parse version "${version}"`);
27
+ }
28
+ const { major, minor, patch, prereleaseParts } = versionParts.groups;
29
+ const prerelease = prereleaseParts ? prereleaseParts.split(".") : [];
30
+ const majorMinorVersion = `${major}.${minor}`;
31
+ const cdnVersion = prerelease[0] ? `${majorMinorVersion}.${patch}-${prerelease[0]}` : `${majorMinorVersion}.${patch}`;
32
+ return {
33
+ major,
34
+ minor,
35
+ patch,
36
+ prerelease,
37
+ majorMinorVersion,
38
+ cdnVersion
39
+ };
40
+ };
41
+ function getSystemVersion() {
42
+ const repositoryRoot = findRepositoryRoot();
43
+ const version = retrievePackageJson(repositoryRoot).version;
44
+ if (!version) {
45
+ throw new Error("Root package.json does not have a version defined");
46
+ }
47
+ return { version, ...parseVersion(version) };
48
+ }
49
+ function detectPackageManager(cwd = process.cwd()) {
50
+ let packageManager = void 0;
51
+ {
52
+ const pathParts = path.resolve(cwd).split(path.sep);
53
+ while (pathParts.length > 1) {
54
+ const packageJson = path.join(pathParts.join(path.sep), "package.json");
55
+ pathParts.pop();
56
+ if (!existsSync(packageJson)) {
57
+ continue;
58
+ }
59
+ const contents = JSON.parse(readFileSync(packageJson, "utf8"));
60
+ if (typeof contents !== "object" || Array.isArray(contents)) {
61
+ continue;
62
+ }
63
+ if (typeof contents.packageManager === "string") {
64
+ packageManager ??= contents.packageManager.match(/\w+/u)?.[0] ?? packageManager;
65
+ }
66
+ }
67
+ }
68
+ packageManager ??= "npm";
69
+ return packageManager;
70
+ }
71
+ export {
72
+ detectPackageManager,
73
+ findRepositoryRoot,
74
+ getSystemVersion,
75
+ getTurboPath,
76
+ parseVersion,
77
+ setRootTargetFile
78
+ };
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@arcgis/node-toolkit",
3
+ "version": "5.2.0-next.100",
4
+ "description": "Collection of common internal build-time patterns and utilities for ArcGIS Maps SDK for JavaScript components.",
5
+ "homepage": "https://developers.arcgis.com/javascript/latest/",
6
+ "type": "module",
7
+ "exports": {
8
+ "./file": "./dist/file.js",
9
+ "./shell": "./dist/shell.js",
10
+ "./glob": "./dist/glob.js",
11
+ "./path": "./dist/path.js",
12
+ "./packageJson": "./dist/packageJson.js",
13
+ "./vite/presetPlugin": "./dist/vite/presetPlugin.js",
14
+ "./vite/externalizeDependenciesPlugin": "./dist/vite/externalizeDependenciesPlugin.js",
15
+ "./vite/installPlaywright": "./dist/vite/installPlaywright.js",
16
+ "./vite/simpleTypesEmit": "./dist/vite/simpleTypesEmit.js",
17
+ "./vite/typeScript": "./dist/vite/typeScript.js",
18
+ "./workspace": "./dist/workspace.js",
19
+ "./package.json": "./package.json"
20
+ },
21
+ "files": [
22
+ "dist/"
23
+ ],
24
+ "license": "SEE LICENSE IN LICENSE.md",
25
+ "dependencies": {
26
+ "@types/node": "~24.11.2",
27
+ "tslib": "^2.8.1",
28
+ "typescript": "~6.0.3",
29
+ "vite": "^7.3.2",
30
+ "vite-plugin-dts": "^4.5.4"
31
+ }
32
+ }