@arcgis/components-build-utils 4.32.0-next.58 → 4.32.0-next.59

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/index.cjs CHANGED
@@ -39,6 +39,7 @@ __export(src_exports, {
39
39
  fetchPackageLocation: () => fetchPackageLocation,
40
40
  findPath: () => findPath,
41
41
  getCwd: () => getCwd,
42
+ gitIgnoreToGlob: () => gitIgnoreToGlob,
42
43
  isPosix: () => isPosix,
43
44
  normalizePath: () => normalizePath,
44
45
  path: () => path,
@@ -48,13 +49,81 @@ __export(src_exports, {
48
49
  toSystemPathSeparators: () => toSystemPathSeparators
49
50
  });
50
51
  module.exports = __toCommonJS(src_exports);
51
- var import_node_fs3 = require("fs");
52
52
 
53
- // src/path.ts
53
+ // src/file.ts
54
+ var import_node_fs = require("fs");
55
+ var import_promises = require("fs/promises");
56
+ var import_node_child_process = require("child_process");
54
57
  var import_path = require("path");
58
+ var import_node_url = require("url");
59
+ var existsAsync = async (file) => await (0, import_promises.access)(file, import_promises.constants.F_OK).then(() => true).catch(() => false);
60
+ var sh = (command, cwd) => (0, import_node_child_process.execSync)(command.trim(), { encoding: "utf8", cwd }).trim();
61
+ async function createFileIfNotExists(filePath, content) {
62
+ await (0, import_promises.mkdir)((0, import_path.dirname)(filePath), { recursive: true });
63
+ if (!await existsAsync(filePath)) {
64
+ await (0, import_promises.writeFile)(filePath, content, { encoding: "utf8" });
65
+ }
66
+ }
67
+ function findPath(target, startDirectory = process.cwd()) {
68
+ const resolvedStartDirectory = startDirectory.startsWith("file:///") ? (0, import_path.dirname)((0, import_node_url.fileURLToPath)(startDirectory)) : (0, import_path.resolve)(startDirectory);
69
+ const parentPath = resolvedStartDirectory.split(import_path.sep);
70
+ while (parentPath.length > 2) {
71
+ const fullPath = (0, import_path.join)(
72
+ ...import_path.sep === "/" ? ["/"] : [],
73
+ ...parentPath,
74
+ target
75
+ );
76
+ if ((0, import_node_fs.existsSync)(fullPath)) {
77
+ return fullPath;
78
+ }
79
+ parentPath.pop();
80
+ }
81
+ return void 0;
82
+ }
83
+ async function asyncFindPath(target, startDirectory = process.cwd()) {
84
+ const resolvedStartDirectory = startDirectory.startsWith("file:///") ? (0, import_path.dirname)((0, import_node_url.fileURLToPath)(startDirectory)) : (0, import_path.resolve)(startDirectory);
85
+ const parentPath = resolvedStartDirectory.split(import_path.sep);
86
+ while (parentPath.length > 2) {
87
+ const fullPath = (0, import_path.join)(
88
+ ...import_path.sep === "/" ? ["/"] : [],
89
+ ...parentPath,
90
+ target
91
+ );
92
+ if (await existsAsync(fullPath)) {
93
+ return fullPath;
94
+ }
95
+ parentPath.pop();
96
+ }
97
+ return void 0;
98
+ }
99
+
100
+ // src/glob.ts
101
+ var gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
102
+ function fixAbsoluteSyntax(pattern) {
103
+ if (pattern.startsWith("/")) {
104
+ return pattern.slice(1);
105
+ }
106
+ if (pattern.startsWith("!/")) {
107
+ return `!${pattern.slice(2)}`;
108
+ }
109
+ const isAlreadyCorrect = pattern.startsWith("**") || pattern.startsWith("!**");
110
+ const basePattern = pattern.startsWith("!") ? pattern.slice(1) : pattern;
111
+ return isAlreadyCorrect ? pattern : `${pattern.startsWith("!") ? "!" : ""}**/${basePattern}`;
112
+ }
113
+ function fixMatchFilesSyntax(pattern) {
114
+ const base = pattern.split("/").at(-1);
115
+ const isAlreadyCorrect = pattern.endsWith("**") || pattern.includes("{") || base?.includes(".");
116
+ if (isAlreadyCorrect) {
117
+ return pattern;
118
+ }
119
+ return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
120
+ }
121
+
122
+ // src/path.ts
123
+ var import_path2 = require("path");
55
124
  var import_posix = __toESM(require("path/posix"), 1);
56
125
  var import_win32 = __toESM(require("path/win32"), 1);
57
- var isPosix = import_path.sep === import_posix.default.sep;
126
+ var isPosix = import_path2.sep === import_posix.default.sep;
58
127
  var toPosixPathSeparators = (relativePath) => relativePath.includes(import_win32.default.sep) ? relativePath.replaceAll(import_win32.default.sep, import_posix.default.sep) : relativePath;
59
128
  var normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
60
129
  var toWin32PathSeparators = (relativePath) => relativePath.includes(import_posix.default.sep) ? relativePath.replaceAll(import_posix.default.sep, import_win32.default.sep) : relativePath;
@@ -90,56 +159,9 @@ var path = isPosix ? import_posix.default : {
90
159
  };
91
160
  var exportsForTests = { toWin32PathSeparators };
92
161
 
93
- // src/file.ts
94
- var import_node_fs = require("fs");
95
- var import_promises = require("fs/promises");
96
- var import_node_child_process = require("child_process");
97
- var import_path2 = require("path");
98
- var import_node_url = require("url");
99
- var existsAsync = async (file) => await (0, import_promises.access)(file, import_promises.constants.F_OK).then(() => true).catch(() => false);
100
- var sh = (command, cwd) => (0, import_node_child_process.execSync)(command.trim(), { encoding: "utf8", cwd }).trim();
101
- async function createFileIfNotExists(filePath, content) {
102
- await (0, import_promises.mkdir)((0, import_path2.dirname)(filePath), { recursive: true });
103
- if (!await existsAsync(filePath)) {
104
- await (0, import_promises.writeFile)(filePath, content, { encoding: "utf8" });
105
- }
106
- }
107
- function findPath(target, startDirectory = process.cwd()) {
108
- const resolvedStartDirectory = startDirectory.startsWith("file:///") ? (0, import_path2.dirname)((0, import_node_url.fileURLToPath)(startDirectory)) : (0, import_path2.resolve)(startDirectory);
109
- const parentPath = resolvedStartDirectory.split(import_path2.sep);
110
- while (parentPath.length > 2) {
111
- const fullPath = (0, import_path2.join)(
112
- ...import_path2.sep === "/" ? ["/"] : [],
113
- ...parentPath,
114
- target
115
- );
116
- if ((0, import_node_fs.existsSync)(fullPath)) {
117
- return fullPath;
118
- }
119
- parentPath.pop();
120
- }
121
- return void 0;
122
- }
123
- async function asyncFindPath(target, startDirectory = process.cwd()) {
124
- const resolvedStartDirectory = startDirectory.startsWith("file:///") ? (0, import_path2.dirname)((0, import_node_url.fileURLToPath)(startDirectory)) : (0, import_path2.resolve)(startDirectory);
125
- const parentPath = resolvedStartDirectory.split(import_path2.sep);
126
- while (parentPath.length > 2) {
127
- const fullPath = (0, import_path2.join)(
128
- ...import_path2.sep === "/" ? ["/"] : [],
129
- ...parentPath,
130
- target
131
- );
132
- if (await existsAsync(fullPath)) {
133
- return fullPath;
134
- }
135
- parentPath.pop();
136
- }
137
- return void 0;
138
- }
139
-
140
162
  // src/packageJson.ts
141
- var import_node_fs2 = require("fs");
142
163
  var import_promises2 = require("fs/promises");
164
+ var import_node_fs2 = require("fs");
143
165
  var cachedPackageJson = {};
144
166
  var cachedPackageJsonPromises = {};
145
167
  var rootPackageJsonLocation;
@@ -180,8 +202,6 @@ async function fetchPackageLocation(packageName, cwd) {
180
202
  cachedPackageLocation[packageName] ??= result;
181
203
  return cachedPackageLocation[packageName];
182
204
  }
183
-
184
- // src/index.ts
185
205
  function detectPackageManager(cwd = process.cwd()) {
186
206
  let packageManager = void 0;
187
207
  {
@@ -189,10 +209,10 @@ function detectPackageManager(cwd = process.cwd()) {
189
209
  while (pathParts.length > 1) {
190
210
  const packageJson = path.join(pathParts.join(path.sep), "package.json");
191
211
  pathParts.pop();
192
- if (!(0, import_node_fs3.existsSync)(packageJson)) {
212
+ if (!(0, import_node_fs2.existsSync)(packageJson)) {
193
213
  continue;
194
214
  }
195
- const contents = JSON.parse((0, import_node_fs3.readFileSync)(packageJson, "utf8"));
215
+ const contents = JSON.parse((0, import_node_fs2.readFileSync)(packageJson, "utf8"));
196
216
  if (typeof contents !== "object" || Array.isArray(contents)) {
197
217
  continue;
198
218
  }
@@ -215,6 +235,7 @@ function detectPackageManager(cwd = process.cwd()) {
215
235
  fetchPackageLocation,
216
236
  findPath,
217
237
  getCwd,
238
+ gitIgnoreToGlob,
218
239
  isPosix,
219
240
  normalizePath,
220
241
  path,
package/dist/index.d.cts CHANGED
@@ -15,6 +15,8 @@ declare function findPath(target: string, startDirectory?: string): string | und
15
15
  */
16
16
  declare function asyncFindPath(target: string, startDirectory?: string): Promise<string | undefined>;
17
17
 
18
+ declare const gitIgnoreToGlob: (pattern: string) => string;
19
+
18
20
  /**
19
21
  * This is called "isPosix" rather than "isNotWindows" because even if we are
20
22
  * on Windows, we could be running in a POSIX environment (e.g. WSL2)
@@ -61,10 +63,9 @@ declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackag
61
63
  * trailing slash.
62
64
  */
63
65
  declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
64
-
65
66
  /**
66
67
  * Detect if current repository/monorepo uses npm, yarn or pnpm
67
68
  */
68
69
  declare function detectPackageManager(cwd?: string): string;
69
70
 
70
- export { type MiniPackageJson, asyncFindPath, asyncRetrievePackageJson, createFileIfNotExists, detectPackageManager, existsAsync, exportsForTests, fetchPackageLocation, findPath, getCwd, isPosix, normalizePath, path, retrievePackageJson, sh, toPosixPathSeparators, toSystemPathSeparators };
71
+ export { type MiniPackageJson, asyncFindPath, asyncRetrievePackageJson, createFileIfNotExists, detectPackageManager, existsAsync, exportsForTests, fetchPackageLocation, findPath, getCwd, gitIgnoreToGlob, isPosix, normalizePath, path, retrievePackageJson, sh, toPosixPathSeparators, toSystemPathSeparators };
package/dist/index.d.ts CHANGED
@@ -15,6 +15,8 @@ declare function findPath(target: string, startDirectory?: string): string | und
15
15
  */
16
16
  declare function asyncFindPath(target: string, startDirectory?: string): Promise<string | undefined>;
17
17
 
18
+ declare const gitIgnoreToGlob: (pattern: string) => string;
19
+
18
20
  /**
19
21
  * This is called "isPosix" rather than "isNotWindows" because even if we are
20
22
  * on Windows, we could be running in a POSIX environment (e.g. WSL2)
@@ -61,10 +63,9 @@ declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackag
61
63
  * trailing slash.
62
64
  */
63
65
  declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
64
-
65
66
  /**
66
67
  * Detect if current repository/monorepo uses npm, yarn or pnpm
67
68
  */
68
69
  declare function detectPackageManager(cwd?: string): string;
69
70
 
70
- export { type MiniPackageJson, asyncFindPath, asyncRetrievePackageJson, createFileIfNotExists, detectPackageManager, existsAsync, exportsForTests, fetchPackageLocation, findPath, getCwd, isPosix, normalizePath, path, retrievePackageJson, sh, toPosixPathSeparators, toSystemPathSeparators };
71
+ export { type MiniPackageJson, asyncFindPath, asyncRetrievePackageJson, createFileIfNotExists, detectPackageManager, existsAsync, exportsForTests, fetchPackageLocation, findPath, getCwd, gitIgnoreToGlob, isPosix, normalizePath, path, retrievePackageJson, sh, toPosixPathSeparators, toSystemPathSeparators };
package/dist/index.js CHANGED
@@ -1,51 +1,8 @@
1
- // src/index.ts
2
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
3
-
4
- // src/path.ts
5
- import { sep } from "path";
6
- import posix from "path/posix";
7
- import win32 from "path/win32";
8
- var isPosix = sep === posix.sep;
9
- var toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
10
- var normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
11
- var toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
12
- var toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
13
- var getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
14
- var path = isPosix ? posix : {
15
- ...win32,
16
- sep: posix.sep,
17
- join(...paths) {
18
- const result = win32.join(...paths);
19
- return toPosixPathSeparators(result);
20
- },
21
- normalize(path2) {
22
- const result = win32.normalize(path2);
23
- return toPosixPathSeparators(result);
24
- },
25
- relative(from, to) {
26
- const result = win32.relative(from, to);
27
- return toPosixPathSeparators(result);
28
- },
29
- dirname(path2) {
30
- const result = win32.dirname(path2);
31
- return toPosixPathSeparators(result);
32
- },
33
- resolve(...paths) {
34
- const result = win32.resolve(...paths);
35
- return toPosixPathSeparators(result);
36
- },
37
- toNamespacedPath(path2) {
38
- const result = win32.toNamespacedPath(path2);
39
- return toPosixPathSeparators(result);
40
- }
41
- };
42
- var exportsForTests = { toWin32PathSeparators };
43
-
44
1
  // src/file.ts
45
2
  import { existsSync } from "node:fs";
46
3
  import { access, constants, mkdir, writeFile } from "node:fs/promises";
47
4
  import { execSync } from "node:child_process";
48
- import { dirname, join, resolve, sep as sep2 } from "path";
5
+ import { dirname, join, resolve, sep } from "path";
49
6
  import { fileURLToPath } from "node:url";
50
7
  var existsAsync = async (file) => await access(file, constants.F_OK).then(() => true).catch(() => false);
51
8
  var sh = (command, cwd) => execSync(command.trim(), { encoding: "utf8", cwd }).trim();
@@ -57,10 +14,10 @@ async function createFileIfNotExists(filePath, content) {
57
14
  }
58
15
  function findPath(target, startDirectory = process.cwd()) {
59
16
  const resolvedStartDirectory = startDirectory.startsWith("file:///") ? dirname(fileURLToPath(startDirectory)) : resolve(startDirectory);
60
- const parentPath = resolvedStartDirectory.split(sep2);
17
+ const parentPath = resolvedStartDirectory.split(sep);
61
18
  while (parentPath.length > 2) {
62
19
  const fullPath = join(
63
- ...sep2 === "/" ? ["/"] : [],
20
+ ...sep === "/" ? ["/"] : [],
64
21
  ...parentPath,
65
22
  target
66
23
  );
@@ -73,10 +30,10 @@ function findPath(target, startDirectory = process.cwd()) {
73
30
  }
74
31
  async function asyncFindPath(target, startDirectory = process.cwd()) {
75
32
  const resolvedStartDirectory = startDirectory.startsWith("file:///") ? dirname(fileURLToPath(startDirectory)) : resolve(startDirectory);
76
- const parentPath = resolvedStartDirectory.split(sep2);
33
+ const parentPath = resolvedStartDirectory.split(sep);
77
34
  while (parentPath.length > 2) {
78
35
  const fullPath = join(
79
- ...sep2 === "/" ? ["/"] : [],
36
+ ...sep === "/" ? ["/"] : [],
80
37
  ...parentPath,
81
38
  target
82
39
  );
@@ -88,9 +45,71 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
88
45
  return void 0;
89
46
  }
90
47
 
48
+ // src/glob.ts
49
+ var gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
50
+ function fixAbsoluteSyntax(pattern) {
51
+ if (pattern.startsWith("/")) {
52
+ return pattern.slice(1);
53
+ }
54
+ if (pattern.startsWith("!/")) {
55
+ return `!${pattern.slice(2)}`;
56
+ }
57
+ const isAlreadyCorrect = pattern.startsWith("**") || pattern.startsWith("!**");
58
+ const basePattern = pattern.startsWith("!") ? pattern.slice(1) : pattern;
59
+ return isAlreadyCorrect ? pattern : `${pattern.startsWith("!") ? "!" : ""}**/${basePattern}`;
60
+ }
61
+ function fixMatchFilesSyntax(pattern) {
62
+ const base = pattern.split("/").at(-1);
63
+ const isAlreadyCorrect = pattern.endsWith("**") || pattern.includes("{") || base?.includes(".");
64
+ if (isAlreadyCorrect) {
65
+ return pattern;
66
+ }
67
+ return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
68
+ }
69
+
70
+ // src/path.ts
71
+ import { sep as sep2 } from "path";
72
+ import posix from "path/posix";
73
+ import win32 from "path/win32";
74
+ var isPosix = sep2 === posix.sep;
75
+ var toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
76
+ var normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
77
+ var toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
78
+ var toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
79
+ var getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
80
+ var path = isPosix ? posix : {
81
+ ...win32,
82
+ sep: posix.sep,
83
+ join(...paths) {
84
+ const result = win32.join(...paths);
85
+ return toPosixPathSeparators(result);
86
+ },
87
+ normalize(path2) {
88
+ const result = win32.normalize(path2);
89
+ return toPosixPathSeparators(result);
90
+ },
91
+ relative(from, to) {
92
+ const result = win32.relative(from, to);
93
+ return toPosixPathSeparators(result);
94
+ },
95
+ dirname(path2) {
96
+ const result = win32.dirname(path2);
97
+ return toPosixPathSeparators(result);
98
+ },
99
+ resolve(...paths) {
100
+ const result = win32.resolve(...paths);
101
+ return toPosixPathSeparators(result);
102
+ },
103
+ toNamespacedPath(path2) {
104
+ const result = win32.toNamespacedPath(path2);
105
+ return toPosixPathSeparators(result);
106
+ }
107
+ };
108
+ var exportsForTests = { toWin32PathSeparators };
109
+
91
110
  // src/packageJson.ts
92
- import { readFileSync } from "node:fs";
93
111
  import { readFile } from "node:fs/promises";
112
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
94
113
  var cachedPackageJson = {};
95
114
  var cachedPackageJsonPromises = {};
96
115
  var rootPackageJsonLocation;
@@ -131,8 +150,6 @@ async function fetchPackageLocation(packageName, cwd) {
131
150
  cachedPackageLocation[packageName] ??= result;
132
151
  return cachedPackageLocation[packageName];
133
152
  }
134
-
135
- // src/index.ts
136
153
  function detectPackageManager(cwd = process.cwd()) {
137
154
  let packageManager = void 0;
138
155
  {
@@ -143,7 +160,7 @@ function detectPackageManager(cwd = process.cwd()) {
143
160
  if (!existsSync2(packageJson)) {
144
161
  continue;
145
162
  }
146
- const contents = JSON.parse(readFileSync2(packageJson, "utf8"));
163
+ const contents = JSON.parse(readFileSync(packageJson, "utf8"));
147
164
  if (typeof contents !== "object" || Array.isArray(contents)) {
148
165
  continue;
149
166
  }
@@ -165,6 +182,7 @@ export {
165
182
  fetchPackageLocation,
166
183
  findPath,
167
184
  getCwd,
185
+ gitIgnoreToGlob,
168
186
  isPosix,
169
187
  normalizePath,
170
188
  path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "4.32.0-next.58",
3
+ "version": "4.32.0-next.59",
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",