@arcgis/components-build-utils 4.32.0-next.9 → 4.32.0-next.90

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,7 +39,9 @@ __export(src_exports, {
39
39
  fetchPackageLocation: () => fetchPackageLocation,
40
40
  findPath: () => findPath,
41
41
  getCwd: () => getCwd,
42
+ gitIgnoreToGlob: () => gitIgnoreToGlob,
42
43
  isPosix: () => isPosix,
44
+ normalizePath: () => normalizePath,
43
45
  path: () => path,
44
46
  retrievePackageJson: () => retrievePackageJson,
45
47
  sh: () => sh,
@@ -47,8 +49,6 @@ __export(src_exports, {
47
49
  toSystemPathSeparators: () => toSystemPathSeparators
48
50
  });
49
51
  module.exports = __toCommonJS(src_exports);
50
- var import_node_fs3 = require("fs");
51
- var import_node_path = require("path");
52
52
 
53
53
  // src/file.ts
54
54
  var import_node_fs = require("fs");
@@ -97,12 +97,35 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
97
97
  return void 0;
98
98
  }
99
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
+
100
122
  // src/path.ts
101
123
  var import_path2 = require("path");
102
124
  var import_posix = __toESM(require("path/posix"), 1);
103
125
  var import_win32 = __toESM(require("path/win32"), 1);
104
126
  var isPosix = import_path2.sep === import_posix.default.sep;
105
127
  var toPosixPathSeparators = (relativePath) => relativePath.includes(import_win32.default.sep) ? relativePath.replaceAll(import_win32.default.sep, import_posix.default.sep) : relativePath;
128
+ var normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
106
129
  var toWin32PathSeparators = (relativePath) => relativePath.includes(import_posix.default.sep) ? relativePath.replaceAll(import_posix.default.sep, import_win32.default.sep) : relativePath;
107
130
  var toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
108
131
  var getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
@@ -137,8 +160,8 @@ var path = isPosix ? import_posix.default : {
137
160
  var exportsForTests = { toWin32PathSeparators };
138
161
 
139
162
  // src/packageJson.ts
140
- var import_node_fs2 = require("fs");
141
163
  var import_promises2 = require("fs/promises");
164
+ var import_node_fs2 = require("fs");
142
165
  var cachedPackageJson = {};
143
166
  var cachedPackageJsonPromises = {};
144
167
  var rootPackageJsonLocation;
@@ -179,19 +202,17 @@ async function fetchPackageLocation(packageName, cwd) {
179
202
  cachedPackageLocation[packageName] ??= result;
180
203
  return cachedPackageLocation[packageName];
181
204
  }
182
-
183
- // src/index.ts
184
205
  function detectPackageManager(cwd = process.cwd()) {
185
206
  let packageManager = void 0;
186
207
  {
187
- const pathParts = cwd.split(import_node_path.sep);
208
+ const pathParts = path.resolve(cwd).split(path.sep);
188
209
  while (pathParts.length > 1) {
189
- const packageJson = (0, import_node_path.join)(pathParts.join(import_node_path.sep), "package.json");
210
+ const packageJson = path.join(pathParts.join(path.sep), "package.json");
190
211
  pathParts.pop();
191
- if (!(0, import_node_fs3.existsSync)(packageJson)) {
212
+ if (!(0, import_node_fs2.existsSync)(packageJson)) {
192
213
  continue;
193
214
  }
194
- const contents = JSON.parse((0, import_node_fs3.readFileSync)(packageJson, "utf8"));
215
+ const contents = JSON.parse((0, import_node_fs2.readFileSync)(packageJson, "utf8"));
195
216
  if (typeof contents !== "object" || Array.isArray(contents)) {
196
217
  continue;
197
218
  }
@@ -214,7 +235,9 @@ function detectPackageManager(cwd = process.cwd()) {
214
235
  fetchPackageLocation,
215
236
  findPath,
216
237
  getCwd,
238
+ gitIgnoreToGlob,
217
239
  isPosix,
240
+ normalizePath,
218
241
  path,
219
242
  retrievePackageJson,
220
243
  sh,
package/dist/index.d.cts CHANGED
@@ -15,12 +15,15 @@ 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)
21
23
  */
22
24
  declare const isPosix: boolean;
23
25
  declare const toPosixPathSeparators: (relativePath: string) => string;
26
+ declare const normalizePath: (relativePath: string) => string;
24
27
  /**
25
28
  * On Windows, replace all `/` in the path back with `\\`. Do this only if you
26
29
  * wish to output the path in the console or error message.
@@ -60,10 +63,9 @@ declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackag
60
63
  * trailing slash.
61
64
  */
62
65
  declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
63
-
64
66
  /**
65
67
  * Detect if current repository/monorepo uses npm, yarn or pnpm
66
68
  */
67
69
  declare function detectPackageManager(cwd?: string): string;
68
70
 
69
- export { type MiniPackageJson, asyncFindPath, asyncRetrievePackageJson, createFileIfNotExists, detectPackageManager, existsAsync, exportsForTests, fetchPackageLocation, findPath, getCwd, isPosix, 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,12 +15,15 @@ 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)
21
23
  */
22
24
  declare const isPosix: boolean;
23
25
  declare const toPosixPathSeparators: (relativePath: string) => string;
26
+ declare const normalizePath: (relativePath: string) => string;
24
27
  /**
25
28
  * On Windows, replace all `/` in the path back with `\\`. Do this only if you
26
29
  * wish to output the path in the console or error message.
@@ -60,10 +63,9 @@ declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackag
60
63
  * trailing slash.
61
64
  */
62
65
  declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
63
-
64
66
  /**
65
67
  * Detect if current repository/monorepo uses npm, yarn or pnpm
66
68
  */
67
69
  declare function detectPackageManager(cwd?: string): string;
68
70
 
69
- export { type MiniPackageJson, asyncFindPath, asyncRetrievePackageJson, createFileIfNotExists, detectPackageManager, existsAsync, exportsForTests, fetchPackageLocation, findPath, getCwd, isPosix, 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,7 +1,3 @@
1
- // src/index.ts
2
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
3
- import { join as join2, sep as sep3 } from "node:path";
4
-
5
1
  // src/file.ts
6
2
  import { existsSync } from "node:fs";
7
3
  import { access, constants, mkdir, writeFile } from "node:fs/promises";
@@ -49,12 +45,35 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
49
45
  return void 0;
50
46
  }
51
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
+
52
70
  // src/path.ts
53
71
  import { sep as sep2 } from "path";
54
72
  import posix from "path/posix";
55
73
  import win32 from "path/win32";
56
74
  var isPosix = sep2 === posix.sep;
57
75
  var toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
76
+ var normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
58
77
  var toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
59
78
  var toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
60
79
  var getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
@@ -89,8 +108,8 @@ var path = isPosix ? posix : {
89
108
  var exportsForTests = { toWin32PathSeparators };
90
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,19 +150,17 @@ 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
  {
139
- const pathParts = cwd.split(sep3);
156
+ const pathParts = path.resolve(cwd).split(path.sep);
140
157
  while (pathParts.length > 1) {
141
- const packageJson = join2(pathParts.join(sep3), "package.json");
158
+ const packageJson = path.join(pathParts.join(path.sep), "package.json");
142
159
  pathParts.pop();
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,7 +182,9 @@ export {
165
182
  fetchPackageLocation,
166
183
  findPath,
167
184
  getCwd,
185
+ gitIgnoreToGlob,
168
186
  isPosix,
187
+ normalizePath,
169
188
  path,
170
189
  retrievePackageJson,
171
190
  sh,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "4.32.0-next.9",
3
+ "version": "4.32.0-next.90",
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,11 @@
22
22
  },
23
23
  "license": "SEE LICENSE IN LICENSE.md",
24
24
  "dependencies": {
25
+ "@commander-js/extra-typings": "^11.1.0",
26
+ "chalk": "^5.3.0",
27
+ "commander": "^11.1.0",
28
+ "glob": "^11.0.0",
29
+ "split2": "^4.2.0",
25
30
  "tslib": "^2.7.0"
26
31
  }
27
32
  }
@@ -1,9 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { spawn } from "node:child_process";
3
3
  import { join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
4
 
6
- const scriptPath = join(fileURLToPath(import.meta.url), "..", "run.ts");
5
+ const scriptPath = join(import.meta.dirname, "run.ts");
7
6
  const commandArguments = process.argv.slice(2);
8
7
 
9
8
  const child = spawn("npx", ["tsx", scriptPath, ...commandArguments], {