@arcgis/components-build-utils 5.0.0-next.7 → 5.0.0-next.70

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.
@@ -1,10 +1,10 @@
1
1
  import { Command } from 'commander';
2
2
  /**
3
3
  * !important
4
- * The class makes a TLS request to qawebgis
5
- * You need to make sure node trusts the certificate authority that signed the certificate used by qawebgis.esri.com
4
+ * The class makes a TLS request to webgis
5
+ * You need to make sure node trusts the certificate authority that signed the certificate used by webgis.esri.com
6
6
  *
7
7
  * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
8
- * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
8
+ * Reference: https://webgis.esri.com/webgis/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
9
9
  */
10
10
  export declare const registerCommand: (command: Command) => undefined;
@@ -1,10 +1,10 @@
1
1
  import { Command } from 'commander';
2
2
  /**
3
3
  * !important
4
- * The class makes a TLS request to qawebgis
5
- * You need to make sure node trusts the certificate authority that signed the certificate used by qawebgis.esri.com
4
+ * The class makes a TLS request to webgis
5
+ * You need to make sure node trusts the certificate authority that signed the certificate used by webgis.esri.com
6
6
  *
7
7
  * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
8
- * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
8
+ * Reference: https://webgis.esri.com/webgis/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
9
9
  */
10
10
  export declare const registerCommand: (command: Command) => undefined;
@@ -0,0 +1,7 @@
1
+ export declare const markdownLog: string[];
2
+ export declare function addKeyValueToOutput(key: string, value: string[] | string): void;
3
+ export declare function addMarkdownToOutput(key?: string): void;
4
+ export declare function addHeadingToSummary(text: string, level?: 1 | 2 | 3): void;
5
+ export declare function addListToSummary(items: string[], ordered?: boolean): void;
6
+ export declare function addNewlineToSummary(): void;
7
+ export declare function writeSummary(): void;
@@ -0,0 +1,7 @@
1
+ export declare const markdownLog: string[];
2
+ export declare function addKeyValueToOutput(key: string, value: string[] | string): void;
3
+ export declare function addMarkdownToOutput(key?: string): void;
4
+ export declare function addHeadingToSummary(text: string, level?: 1 | 2 | 3): void;
5
+ export declare function addListToSummary(items: string[], ordered?: boolean): void;
6
+ export declare function addNewlineToSummary(): void;
7
+ export declare function writeSummary(): void;
@@ -7,10 +7,10 @@ export interface Issue {
7
7
  };
8
8
  }
9
9
  declare class Devtopia {
10
- readonly owner: string;
11
- readonly name: string;
12
10
  private issuesPerPage;
13
11
  constructor(owner: string, name: string);
12
+ readonly owner: string;
13
+ readonly name: string;
14
14
  /**
15
15
  * Requests to github graphql server
16
16
  */
@@ -7,10 +7,10 @@ export interface Issue {
7
7
  };
8
8
  }
9
9
  declare class Devtopia {
10
- readonly owner: string;
11
- readonly name: string;
12
10
  private issuesPerPage;
13
11
  constructor(owner: string, name: string);
12
+ readonly owner: string;
13
+ readonly name: string;
14
14
  /**
15
15
  * Requests to github graphql server
16
16
  */
@@ -1,4 +1,4 @@
1
- import { Issue } from './devtopia';
1
+ import { Issue } from './devtopia.ts';
2
2
  export type IssueWithZenhub = {
3
3
  gitHubId: string;
4
4
  zenhubId: string;
@@ -30,17 +30,17 @@ export type IssueWithZenhub = {
30
30
  * You need to make sure node trusts the certificate authority that signed the certificate used by zentopia.esri.com
31
31
  *
32
32
  * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
33
- * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
33
+ * Reference: https://webgis.esri.com/webgis/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
34
34
  */
35
35
  declare class Zentopia {
36
- readonly repoId: number;
37
- readonly workspaceId: string;
38
- readonly token?: string | undefined;
39
36
  private _issueIdCache;
40
37
  private _pipelinesCache?;
41
38
  private _sprintsCache?;
42
39
  private _releasesCache?;
43
- constructor(repoId: number, workspaceId: string, token?: string | undefined);
40
+ constructor(repoId: number, workspaceId: string, token?: string);
41
+ readonly repoId: number;
42
+ readonly workspaceId: string;
43
+ readonly token?: string;
44
44
  /**
45
45
  * Requests to graphql server
46
46
  */
@@ -1,4 +1,4 @@
1
- import { Issue } from './devtopia';
1
+ import { Issue } from './devtopia.ts';
2
2
  export type IssueWithZenhub = {
3
3
  gitHubId: string;
4
4
  zenhubId: string;
@@ -30,17 +30,17 @@ export type IssueWithZenhub = {
30
30
  * You need to make sure node trusts the certificate authority that signed the certificate used by zentopia.esri.com
31
31
  *
32
32
  * Include your certificate authority in the NODE_EXTRA_CA_CERTS environment variable
33
- * Reference: https://qawebgis.esri.com/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
33
+ * Reference: https://webgis.esri.com/webgis/components/devops/troubleshoot/troubleshoot#certificate-verification-failure
34
34
  */
35
35
  declare class Zentopia {
36
- readonly repoId: number;
37
- readonly workspaceId: string;
38
- readonly token?: string | undefined;
39
36
  private _issueIdCache;
40
37
  private _pipelinesCache?;
41
38
  private _sprintsCache?;
42
39
  private _releasesCache?;
43
- constructor(repoId: number, workspaceId: string, token?: string | undefined);
40
+ constructor(repoId: number, workspaceId: string, token?: string);
41
+ readonly repoId: number;
42
+ readonly workspaceId: string;
43
+ readonly token?: string;
44
44
  /**
45
45
  * Requests to graphql server
46
46
  */
@@ -1,5 +1,5 @@
1
1
  import { Command } from '@commander-js/extra-typings';
2
- import { PackageWalkerItem } from './utils';
2
+ import { PackageWalkerItem } from './utils.ts';
3
3
  export declare const registerCommand: (command: Command) => undefined;
4
4
  export declare function scanDist({ blocklistedNames }: {
5
5
  blocklistedNames?: string[];
@@ -1,5 +1,5 @@
1
1
  import { Command } from '@commander-js/extra-typings';
2
- import { PackageWalkerItem } from './utils';
2
+ import { PackageWalkerItem } from './utils.ts';
3
3
  export declare const registerCommand: (command: Command) => undefined;
4
4
  export declare function scanDist({ blocklistedNames }: {
5
5
  blocklistedNames?: string[];
@@ -1,5 +1,5 @@
1
1
  import { ExecSyncOptionsWithStringEncoding } from 'node:child_process';
2
- import { MiniPackageJson } from '../packageJson';
2
+ import { MiniPackageJson } from '../packageJson.ts';
3
3
  /**
4
4
  * Sets the exit code to 1 and prints the error message to stderr.
5
5
  * This is used to indicate an error condition in the script.
@@ -10,7 +10,7 @@ export declare function error(...messages: unknown[]): void;
10
10
  * This is used to indicate a fatal error that cannot be recovered from.
11
11
  */
12
12
  export declare function errorAndExit(...messages: unknown[]): never;
13
- export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
13
+ export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>, quiet?: boolean): string;
14
14
  export declare function findRepositoryRoot(): string;
15
15
  export declare function isURL(source: string): boolean;
16
16
  /**
@@ -63,4 +63,9 @@ export declare function getAffectedPackages(changed: Iterable<string>, options?:
63
63
  * Helper to check if an error is a SIGINT (interrupt) error.
64
64
  */
65
65
  export declare function isSigint(err: unknown): boolean;
66
+ export declare function getBranchName(): string;
67
+ export declare function getStagedFiles(options?: Partial<ExecSyncOptionsWithStringEncoding>): string[];
68
+ export declare function getModifiedFiles(options?: Partial<ExecSyncOptionsWithStringEncoding>): string[];
69
+ export declare function commitStagedFiles(messages: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): void;
70
+ export declare function pushCommits(options?: Partial<ExecSyncOptionsWithStringEncoding>): void;
66
71
  export {};
@@ -1,5 +1,5 @@
1
1
  import { ExecSyncOptionsWithStringEncoding } from 'node:child_process';
2
- import { MiniPackageJson } from '../packageJson';
2
+ import { MiniPackageJson } from '../packageJson.ts';
3
3
  /**
4
4
  * Sets the exit code to 1 and prints the error message to stderr.
5
5
  * This is used to indicate an error condition in the script.
@@ -10,7 +10,7 @@ export declare function error(...messages: unknown[]): void;
10
10
  * This is used to indicate a fatal error that cannot be recovered from.
11
11
  */
12
12
  export declare function errorAndExit(...messages: unknown[]): never;
13
- export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): string;
13
+ export declare function sh(command: string, options?: Partial<ExecSyncOptionsWithStringEncoding>, quiet?: boolean): string;
14
14
  export declare function findRepositoryRoot(): string;
15
15
  export declare function isURL(source: string): boolean;
16
16
  /**
@@ -63,4 +63,9 @@ export declare function getAffectedPackages(changed: Iterable<string>, options?:
63
63
  * Helper to check if an error is a SIGINT (interrupt) error.
64
64
  */
65
65
  export declare function isSigint(err: unknown): boolean;
66
+ export declare function getBranchName(): string;
67
+ export declare function getStagedFiles(options?: Partial<ExecSyncOptionsWithStringEncoding>): string[];
68
+ export declare function getModifiedFiles(options?: Partial<ExecSyncOptionsWithStringEncoding>): string[];
69
+ export declare function commitStagedFiles(messages: string, options?: Partial<ExecSyncOptionsWithStringEncoding>): void;
70
+ export declare function pushCommits(options?: Partial<ExecSyncOptionsWithStringEncoding>): void;
66
71
  export {};
package/dist/index.cjs CHANGED
@@ -1,13 +1,32 @@
1
1
  "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
2
24
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
25
  const node_fs = require("node:fs");
4
26
  const promises = require("node:fs/promises");
5
27
  const node_child_process = require("node:child_process");
6
28
  const path$1 = require("path");
7
29
  const node_url = require("node:url");
8
- const posix = require("path/posix");
9
- const win32 = require("path/win32");
10
- const dts = require("vite-plugin-dts");
11
30
  const node_module = require("node:module");
12
31
  const existsAsync = async (file) => (
13
32
  // Using un-promisified version because promises version creates exceptions
@@ -24,7 +43,7 @@ async function createFileIfNotExists(filePath, content) {
24
43
  function findPath(target, startDirectory = process.cwd()) {
25
44
  const resolvedStartDirectory = startDirectory.startsWith("file:///") ? path$1.dirname(node_url.fileURLToPath(startDirectory)) : path$1.resolve(startDirectory);
26
45
  const parentPath = resolvedStartDirectory.split(path$1.sep);
27
- while (parentPath.length > 2) {
46
+ while (parentPath.length > searchStopIndex) {
28
47
  const fullPath = path$1.join(
29
48
  ...path$1.sep === "/" ? ["/"] : [],
30
49
  ...parentPath,
@@ -37,10 +56,11 @@ function findPath(target, startDirectory = process.cwd()) {
37
56
  }
38
57
  return void 0;
39
58
  }
59
+ const searchStopIndex = path$1.sep === "/" ? 2 : 0;
40
60
  async function asyncFindPath(target, startDirectory = process.cwd()) {
41
61
  const resolvedStartDirectory = startDirectory.startsWith("file:///") ? path$1.dirname(node_url.fileURLToPath(startDirectory)) : path$1.resolve(startDirectory);
42
62
  const parentPath = resolvedStartDirectory.split(path$1.sep);
43
- while (parentPath.length > 2) {
63
+ while (parentPath.length > searchStopIndex) {
44
64
  const fullPath = path$1.join(
45
65
  ...path$1.sep === "/" ? ["/"] : [],
46
66
  ...parentPath,
@@ -76,50 +96,53 @@ function fixMatchFilesSyntax(pattern) {
76
96
  }
77
97
  return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
78
98
  }
79
- const isPosix = path$1.sep === posix.sep;
80
- const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
99
+ const isPosix = path$1.sep === path$1.posix.sep;
100
+ const toPosixPathSeparators = (relativePath) => relativePath.includes(path$1.win32.sep) ? relativePath.replaceAll(path$1.win32.sep, path$1.posix.sep) : relativePath;
81
101
  const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
82
- const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
102
+ const toWin32PathSeparators = (relativePath) => relativePath.includes(path$1.posix.sep) ? relativePath.replaceAll(path$1.posix.sep, path$1.win32.sep) : relativePath;
83
103
  const toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
84
104
  const getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
85
- const path = isPosix ? posix : {
86
- ...win32,
87
- sep: posix.sep,
105
+ const path = isPosix ? path$1.posix : {
106
+ ...path$1.win32,
107
+ sep: path$1.posix.sep,
88
108
  join(...paths) {
89
- const result = win32.join(...paths);
109
+ const result = path$1.win32.join(...paths);
90
110
  return toPosixPathSeparators(result);
91
111
  },
92
112
  normalize(path2) {
93
- const result = win32.normalize(path2);
113
+ const result = path$1.win32.normalize(path2);
94
114
  return toPosixPathSeparators(result);
95
115
  },
96
116
  relative(from, to) {
97
- const result = win32.relative(from, to);
117
+ const result = path$1.win32.relative(from, to);
98
118
  return toPosixPathSeparators(result);
99
119
  },
100
120
  dirname(path2) {
101
- const result = win32.dirname(path2);
121
+ const result = path$1.win32.dirname(path2);
102
122
  return toPosixPathSeparators(result);
103
123
  },
104
124
  resolve(...paths) {
105
- const result = win32.resolve(...paths);
125
+ const result = path$1.win32.resolve(...paths);
106
126
  return toPosixPathSeparators(result);
107
127
  },
108
128
  toNamespacedPath(path2) {
109
- const result = win32.toNamespacedPath(path2);
129
+ const result = path$1.win32.toNamespacedPath(path2);
110
130
  return toPosixPathSeparators(result);
111
131
  }
112
132
  };
113
133
  const cachedPackageJson = {};
114
134
  const cachedPackageJsonPromises = {};
115
135
  let rootPackageJsonLocation;
116
- function retrievePackageJson(location) {
136
+ function retrievePackageJson(location, cache = true) {
117
137
  const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
118
- cachedPackageJson[packageJsonPath] ??= JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
119
- return cachedPackageJson[packageJsonPath];
138
+ if (cache) {
139
+ cachedPackageJson[packageJsonPath] ??= JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
140
+ return cachedPackageJson[packageJsonPath];
141
+ }
142
+ return JSON.parse(node_fs.readFileSync(packageJsonPath, "utf-8"));
120
143
  }
121
- async function asyncRetrievePackageJson(location = getCwd()) {
122
- const packageJsonPath = path.resolve(location, "package.json");
144
+ async function asyncRetrievePackageJson(location) {
145
+ const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
123
146
  if (packageJsonPath in cachedPackageJson) {
124
147
  return cachedPackageJson[packageJsonPath];
125
148
  }
@@ -193,7 +216,7 @@ function vitePresetPlugin({
193
216
  build: {
194
217
  // REFACTOR: get this from tsconfig
195
218
  // It's a best practice to let the final bundler down-level as needed.
196
- target: target ?? "es2022"
219
+ target: target ?? "es2024"
197
220
  },
198
221
  define: env.mode === "test" ? {
199
222
  "process.env.ESRI_INTERNAL": true
@@ -208,54 +231,59 @@ function vitePresetPlugin({
208
231
  externalize,
209
232
  bundleIn
210
233
  }),
211
- dts({
212
- logLevel: "warn",
213
- // Copies .d.ts files to d.cjs file for CommonJS.
214
- // Adds a performance hit as it occurs after the build
215
- async afterBuild(emitted) {
216
- if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
217
- await Promise.all(
218
- emitted.entries().map(async ([filePath, content]) => {
219
- if (filePath.endsWith(".d.ts")) {
220
- await promises.writeFile(filePath.replace(".d.ts", ".d.cts"), content);
221
- }
222
- })
223
- );
224
- }
225
- await dtsOptions?.afterBuild?.(emitted);
226
- },
227
- ...dtsOptions,
228
- compilerOptions: {
229
- // For details, see comment above excludeOutsideFiles in
230
- // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
231
- rootDir: ".",
232
- ...dtsOptions.compilerOptions
233
- },
234
- /**
235
- * Do not emit any .d.ts files for files outside the dist directory
236
- * (i.e vite.config.ts, storybook stories and etc)
237
- * This also applies for references to node_modules/.../components.d.ts files in
238
- * tsconfig.json - these must be included in TypeScript program to provide
239
- * types, but should not be re-emitted during build.
240
- */
241
- beforeWriteFile: async (filePath, content) => {
242
- if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
243
- const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
244
- return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
245
- } else {
246
- return false;
247
- }
248
- },
249
- afterDiagnostic(diagnostics) {
250
- const hasErrors = diagnostics.length > 0;
251
- const isBuilding = command === "build";
252
- const stopBuild = hasErrors && isBuilding;
253
- if (stopBuild) {
254
- throw new Error("TypeScript errors reported. See error messages above");
234
+ // This dependency pulls in many others. Since components-build-utils has a
235
+ // single entry point, we load a large module tree needlessly. To avoid,
236
+ // load the plugin on demand.
237
+ import("vite-plugin-dts").then(
238
+ ({ default: dts }) => dts({
239
+ logLevel: "warn",
240
+ // Copies .d.ts files to d.cjs file for CommonJS.
241
+ // Adds a performance hit as it occurs after the build
242
+ async afterBuild(emitted) {
243
+ if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
244
+ await Promise.all(
245
+ emitted.entries().map(async ([filePath, content]) => {
246
+ if (filePath.endsWith(".d.ts")) {
247
+ await promises.writeFile(filePath.replace(".d.ts", ".d.cts"), content);
248
+ }
249
+ })
250
+ );
251
+ }
252
+ await dtsOptions?.afterBuild?.(emitted);
253
+ },
254
+ ...dtsOptions,
255
+ compilerOptions: {
256
+ // For details, see comment above excludeOutsideFiles in
257
+ // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
258
+ rootDir: ".",
259
+ ...dtsOptions.compilerOptions
260
+ },
261
+ /**
262
+ * Do not emit any .d.ts files for files outside the dist directory
263
+ * (i.e vite.config.ts, storybook stories and etc)
264
+ * This also applies for references to node_modules/.../components.d.ts files in
265
+ * tsconfig.json - these must be included in TypeScript program to provide
266
+ * types, but should not be re-emitted during build.
267
+ */
268
+ beforeWriteFile: async (filePath, content) => {
269
+ if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
270
+ const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
271
+ return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
272
+ } else {
273
+ return false;
274
+ }
275
+ },
276
+ afterDiagnostic(diagnostics) {
277
+ const hasErrors = diagnostics.length > 0;
278
+ const isBuilding = command === "build";
279
+ const stopBuild = hasErrors && isBuilding;
280
+ if (stopBuild) {
281
+ throw new Error("TypeScript errors reported. See error messages above");
282
+ }
283
+ return dtsOptions?.afterDiagnostic?.(diagnostics);
255
284
  }
256
- return dtsOptions?.afterDiagnostic?.(diagnostics);
257
- }
258
- })
285
+ })
286
+ )
259
287
  ];
260
288
  }
261
289
  function shouldSkip(id) {
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- export { existsAsync, sh, createFileIfNotExists, findPath, asyncFindPath } from './file';
2
- export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob';
3
- export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path';
4
- export { type MiniPackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson';
5
- export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite';
1
+ export { existsAsync, sh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
2
+ export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob.ts';
3
+ export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path.ts';
4
+ export { type MiniPackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson.ts';
5
+ export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite.ts';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { existsAsync, sh, createFileIfNotExists, findPath, asyncFindPath } from './file';
2
- export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob';
3
- export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path';
4
- export { type MiniPackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson';
5
- export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite';
1
+ export { existsAsync, sh, createFileIfNotExists, findPath, asyncFindPath } from './file.ts';
2
+ export { gitIgnoreFileToGlobs, gitIgnoreToGlob } from './glob.ts';
3
+ export { isPosix, toPosixPathSeparators, normalizePath, toSystemPathSeparators, getCwd, path } from './path.ts';
4
+ export { type MiniPackageJson, retrievePackageJson, asyncRetrievePackageJson, fetchPackageLocation, detectPackageManager, } from './packageJson.ts';
5
+ export { vitePresetPlugin, type DependencyManagementOptions, externalizeDependencies } from './vite.ts';
package/dist/index.js CHANGED
@@ -1,11 +1,8 @@
1
1
  import { access, existsSync, readFileSync } from "node:fs";
2
2
  import { constants, mkdir, writeFile, readFile } from "node:fs/promises";
3
3
  import { execSync } from "node:child_process";
4
- import { dirname, resolve, sep, join } from "path";
4
+ import { dirname, resolve, sep, join, posix, win32 } from "path";
5
5
  import { fileURLToPath } from "node:url";
6
- import posix from "path/posix";
7
- import win32 from "path/win32";
8
- import dts from "vite-plugin-dts";
9
6
  import { builtinModules } from "node:module";
10
7
  const existsAsync = async (file) => (
11
8
  // Using un-promisified version because promises version creates exceptions
@@ -22,7 +19,7 @@ async function createFileIfNotExists(filePath, content) {
22
19
  function findPath(target, startDirectory = process.cwd()) {
23
20
  const resolvedStartDirectory = startDirectory.startsWith("file:///") ? dirname(fileURLToPath(startDirectory)) : resolve(startDirectory);
24
21
  const parentPath = resolvedStartDirectory.split(sep);
25
- while (parentPath.length > 2) {
22
+ while (parentPath.length > searchStopIndex) {
26
23
  const fullPath = join(
27
24
  ...sep === "/" ? ["/"] : [],
28
25
  ...parentPath,
@@ -35,10 +32,11 @@ function findPath(target, startDirectory = process.cwd()) {
35
32
  }
36
33
  return void 0;
37
34
  }
35
+ const searchStopIndex = sep === "/" ? 2 : 0;
38
36
  async function asyncFindPath(target, startDirectory = process.cwd()) {
39
37
  const resolvedStartDirectory = startDirectory.startsWith("file:///") ? dirname(fileURLToPath(startDirectory)) : resolve(startDirectory);
40
38
  const parentPath = resolvedStartDirectory.split(sep);
41
- while (parentPath.length > 2) {
39
+ while (parentPath.length > searchStopIndex) {
42
40
  const fullPath = join(
43
41
  ...sep === "/" ? ["/"] : [],
44
42
  ...parentPath,
@@ -111,13 +109,16 @@ const path = isPosix ? posix : {
111
109
  const cachedPackageJson = {};
112
110
  const cachedPackageJsonPromises = {};
113
111
  let rootPackageJsonLocation;
114
- function retrievePackageJson(location) {
112
+ function retrievePackageJson(location, cache = true) {
115
113
  const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
116
- cachedPackageJson[packageJsonPath] ??= JSON.parse(readFileSync(packageJsonPath, "utf-8"));
117
- return cachedPackageJson[packageJsonPath];
114
+ if (cache) {
115
+ cachedPackageJson[packageJsonPath] ??= JSON.parse(readFileSync(packageJsonPath, "utf-8"));
116
+ return cachedPackageJson[packageJsonPath];
117
+ }
118
+ return JSON.parse(readFileSync(packageJsonPath, "utf-8"));
118
119
  }
119
- async function asyncRetrievePackageJson(location = getCwd()) {
120
- const packageJsonPath = path.resolve(location, "package.json");
120
+ async function asyncRetrievePackageJson(location) {
121
+ const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
121
122
  if (packageJsonPath in cachedPackageJson) {
122
123
  return cachedPackageJson[packageJsonPath];
123
124
  }
@@ -191,7 +192,7 @@ function vitePresetPlugin({
191
192
  build: {
192
193
  // REFACTOR: get this from tsconfig
193
194
  // It's a best practice to let the final bundler down-level as needed.
194
- target: target ?? "es2022"
195
+ target: target ?? "es2024"
195
196
  },
196
197
  define: env.mode === "test" ? {
197
198
  "process.env.ESRI_INTERNAL": true
@@ -206,54 +207,59 @@ function vitePresetPlugin({
206
207
  externalize,
207
208
  bundleIn
208
209
  }),
209
- dts({
210
- logLevel: "warn",
211
- // Copies .d.ts files to d.cjs file for CommonJS.
212
- // Adds a performance hit as it occurs after the build
213
- async afterBuild(emitted) {
214
- if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
215
- await Promise.all(
216
- emitted.entries().map(async ([filePath, content]) => {
217
- if (filePath.endsWith(".d.ts")) {
218
- await writeFile(filePath.replace(".d.ts", ".d.cts"), content);
219
- }
220
- })
221
- );
222
- }
223
- await dtsOptions?.afterBuild?.(emitted);
224
- },
225
- ...dtsOptions,
226
- compilerOptions: {
227
- // For details, see comment above excludeOutsideFiles in
228
- // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
229
- rootDir: ".",
230
- ...dtsOptions.compilerOptions
231
- },
232
- /**
233
- * Do not emit any .d.ts files for files outside the dist directory
234
- * (i.e vite.config.ts, storybook stories and etc)
235
- * This also applies for references to node_modules/.../components.d.ts files in
236
- * tsconfig.json - these must be included in TypeScript program to provide
237
- * types, but should not be re-emitted during build.
238
- */
239
- beforeWriteFile: async (filePath, content) => {
240
- if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
241
- const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
242
- return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
243
- } else {
244
- return false;
245
- }
246
- },
247
- afterDiagnostic(diagnostics) {
248
- const hasErrors = diagnostics.length > 0;
249
- const isBuilding = command === "build";
250
- const stopBuild = hasErrors && isBuilding;
251
- if (stopBuild) {
252
- throw new Error("TypeScript errors reported. See error messages above");
210
+ // This dependency pulls in many others. Since components-build-utils has a
211
+ // single entry point, we load a large module tree needlessly. To avoid,
212
+ // load the plugin on demand.
213
+ import("vite-plugin-dts").then(
214
+ ({ default: dts }) => dts({
215
+ logLevel: "warn",
216
+ // Copies .d.ts files to d.cjs file for CommonJS.
217
+ // Adds a performance hit as it occurs after the build
218
+ async afterBuild(emitted) {
219
+ if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
220
+ await Promise.all(
221
+ emitted.entries().map(async ([filePath, content]) => {
222
+ if (filePath.endsWith(".d.ts")) {
223
+ await writeFile(filePath.replace(".d.ts", ".d.cts"), content);
224
+ }
225
+ })
226
+ );
227
+ }
228
+ await dtsOptions?.afterBuild?.(emitted);
229
+ },
230
+ ...dtsOptions,
231
+ compilerOptions: {
232
+ // For details, see comment above excludeOutsideFiles in
233
+ // https://devtopia.esri.com/WebGIS/arcgis-web-components/blob/main/packages/support-packages/lit-compiler/src/types/textTransformers.ts
234
+ rootDir: ".",
235
+ ...dtsOptions.compilerOptions
236
+ },
237
+ /**
238
+ * Do not emit any .d.ts files for files outside the dist directory
239
+ * (i.e vite.config.ts, storybook stories and etc)
240
+ * This also applies for references to node_modules/.../components.d.ts files in
241
+ * tsconfig.json - these must be included in TypeScript program to provide
242
+ * types, but should not be re-emitted during build.
243
+ */
244
+ beforeWriteFile: async (filePath, content) => {
245
+ if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
246
+ const baseBeforeWriteFile = dtsOptions?.beforeWriteFile ?? ((filePath2, content2) => ({ filePath: filePath2, content: content2 }));
247
+ return await baseBeforeWriteFile(`${dist}${filePath.slice(distSrc.length)}`, content);
248
+ } else {
249
+ return false;
250
+ }
251
+ },
252
+ afterDiagnostic(diagnostics) {
253
+ const hasErrors = diagnostics.length > 0;
254
+ const isBuilding = command === "build";
255
+ const stopBuild = hasErrors && isBuilding;
256
+ if (stopBuild) {
257
+ throw new Error("TypeScript errors reported. See error messages above");
258
+ }
259
+ return dtsOptions?.afterDiagnostic?.(diagnostics);
253
260
  }
254
- return dtsOptions?.afterDiagnostic?.(diagnostics);
255
- }
256
- })
261
+ })
262
+ )
257
263
  ];
258
264
  }
259
265
  function shouldSkip(id) {
@@ -32,8 +32,9 @@ export type MiniPackageJson = {
32
32
  deployBuilds?: Record<string, unknown>;
33
33
  };
34
34
  };
35
- export declare function retrievePackageJson(location?: string): MiniPackageJson;
35
+ export declare function retrievePackageJson(location?: string, cache?: boolean): MiniPackageJson;
36
36
  export declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackageJson>;
37
+ export declare function asyncWritePackageJson(location: string, content: MiniPackageJson): Promise<string>;
37
38
  /**
38
39
  * Returns an absolute path to the root of a package in node_modules, without
39
40
  * trailing slash.
@@ -32,8 +32,9 @@ export type MiniPackageJson = {
32
32
  deployBuilds?: Record<string, unknown>;
33
33
  };
34
34
  };
35
- export declare function retrievePackageJson(location?: string): MiniPackageJson;
35
+ export declare function retrievePackageJson(location?: string, cache?: boolean): MiniPackageJson;
36
36
  export declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackageJson>;
37
+ export declare function asyncWritePackageJson(location: string, content: MiniPackageJson): Promise<string>;
37
38
  /**
38
39
  * Returns an absolute path to the root of a package in node_modules, without
39
40
  * trailing slash.
package/dist/path.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { default as posix } from 'path/posix';
1
+ import { posix } from 'path';
2
2
  /**
3
3
  * This is called "isPosix" rather than "isNotWindows" because even if we are
4
4
  * on Windows, we could be running in a POSIX environment (e.g. WSL2)
package/dist/path.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { default as posix } from 'path/posix';
1
+ import { posix } from 'path';
2
2
  /**
3
3
  * This is called "isPosix" rather than "isNotWindows" because even if we are
4
4
  * on Windows, we could be running in a POSIX environment (e.g. WSL2)
package/dist/vite.d.cts CHANGED
@@ -8,7 +8,7 @@ import { default as dts } from 'vite-plugin-dts';
8
8
  export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
9
9
  /** Additional options for `vite-plugin-dts` */
10
10
  dtsOptions?: Parameters<typeof dts>[0];
11
- }): [Plugin, Plugin, Plugin];
11
+ }): [Plugin, Plugin, Promise<Plugin>];
12
12
  /**
13
13
  * Options for externalizing dependencies.
14
14
  */
package/dist/vite.d.ts CHANGED
@@ -8,7 +8,7 @@ import { default as dts } from 'vite-plugin-dts';
8
8
  export declare function vitePresetPlugin({ dtsOptions, externalize, bundleIn, }?: DependencyManagementOptions & {
9
9
  /** Additional options for `vite-plugin-dts` */
10
10
  dtsOptions?: Parameters<typeof dts>[0];
11
- }): [Plugin, Plugin, Plugin];
11
+ }): [Plugin, Plugin, Promise<Plugin>];
12
12
  /**
13
13
  * Options for externalizing dependencies.
14
14
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "5.0.0-next.7",
3
+ "version": "5.0.0-next.70",
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",
@@ -22,6 +22,7 @@
22
22
  },
23
23
  "license": "SEE LICENSE IN LICENSE.md",
24
24
  "dependencies": {
25
+ "@actions/core": "^1.11.0",
25
26
  "@commander-js/extra-typings": "^14.0.0",
26
27
  "chalk": "^5.4.1",
27
28
  "commander": "^14.0.0",
@@ -33,7 +34,7 @@
33
34
  "semver": "^7.7.2",
34
35
  "split2": "^4.2.0",
35
36
  "tslib": "^2.8.1",
36
- "vite": "^7.0.0",
37
+ "vite": "^7.2.2",
37
38
  "vite-plugin-dts": "^4.5.4"
38
39
  }
39
40
  }