@arcgis/components-build-utils 4.33.0-next.8 → 4.33.0-next.81

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.
Files changed (51) hide show
  1. package/dist/commands/copy-folder.d.cts +2 -0
  2. package/dist/commands/copy-folder.d.ts +2 -0
  3. package/dist/commands/create-mock-doc.d.cts +2 -0
  4. package/dist/commands/create-mock-doc.d.ts +2 -0
  5. package/dist/commands/detect-broken-links.d.cts +2 -0
  6. package/dist/commands/detect-broken-links.d.ts +2 -0
  7. package/dist/commands/detect-large-files.d.cts +3 -0
  8. package/dist/commands/detect-large-files.d.ts +3 -0
  9. package/dist/commands/ensure-working-tree-clean.d.cts +5 -0
  10. package/dist/commands/ensure-working-tree-clean.d.ts +5 -0
  11. package/dist/commands/generate-t9n-manifest.d.cts +2 -0
  12. package/dist/commands/generate-t9n-manifest.d.ts +2 -0
  13. package/dist/commands/git-copy/dumpSizes.d.cts +1 -0
  14. package/dist/commands/git-copy/dumpSizes.d.ts +1 -0
  15. package/dist/commands/git-copy/getFileNames.d.cts +4 -0
  16. package/dist/commands/git-copy/getFileNames.d.ts +4 -0
  17. package/dist/commands/git-copy/helpers.d.cts +4 -0
  18. package/dist/commands/git-copy/helpers.d.ts +4 -0
  19. package/dist/commands/git-copy/index.d.cts +15 -0
  20. package/dist/commands/git-copy/index.d.ts +15 -0
  21. package/dist/commands/git-copy/updateReferences.d.cts +4 -0
  22. package/dist/commands/git-copy/updateReferences.d.ts +4 -0
  23. package/dist/commands/git-copy/utils.d.cts +9 -0
  24. package/dist/commands/git-copy/utils.d.ts +9 -0
  25. package/dist/commands/git-copy.d.cts +2 -0
  26. package/dist/commands/git-copy.d.ts +2 -0
  27. package/dist/commands/migrate-repo-issues/devtopia.d.cts +44 -0
  28. package/dist/commands/migrate-repo-issues/devtopia.d.ts +44 -0
  29. package/dist/commands/migrate-repo-issues/zentopia.d.cts +89 -0
  30. package/dist/commands/migrate-repo-issues/zentopia.d.ts +89 -0
  31. package/dist/commands/migrate-repo-issues.d.cts +2 -0
  32. package/dist/commands/migrate-repo-issues.d.ts +2 -0
  33. package/dist/commands/run-lint-test.d.cts +3 -0
  34. package/dist/commands/run-lint-test.d.ts +3 -0
  35. package/dist/commands/run.d.cts +1 -0
  36. package/dist/commands/run.d.ts +1 -0
  37. package/dist/file.d.cts +14 -0
  38. package/dist/file.d.ts +14 -0
  39. package/dist/glob.d.cts +1 -0
  40. package/dist/glob.d.ts +1 -0
  41. package/dist/index.cjs +159 -106
  42. package/dist/index.d.cts +5 -71
  43. package/dist/index.d.ts +5 -71
  44. package/dist/index.js +119 -35
  45. package/dist/packageJson.d.cts +28 -0
  46. package/dist/packageJson.d.ts +28 -0
  47. package/dist/path.d.cts +22 -0
  48. package/dist/path.d.ts +22 -0
  49. package/dist/vite.d.cts +24 -0
  50. package/dist/vite.d.ts +24 -0
  51. package/package.json +5 -2
package/dist/index.js CHANGED
@@ -1,11 +1,13 @@
1
- // src/file.ts
2
- import { existsSync } from "node:fs";
3
- import { access, constants, mkdir, writeFile } from "node:fs/promises";
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { access, constants, mkdir, writeFile, readFile } from "node:fs/promises";
4
3
  import { execSync } from "node:child_process";
5
- import { dirname, join, resolve, sep } from "path";
4
+ import { dirname, resolve, sep, join } from "node:path";
6
5
  import { fileURLToPath } from "node:url";
7
- var existsAsync = async (file) => await access(file, constants.F_OK).then(() => true).catch(() => false);
8
- var sh = (command, cwd) => execSync(command.trim(), { encoding: "utf8", cwd }).trim();
6
+ import posix from "node:path/posix";
7
+ import win32 from "node:path/win32";
8
+ import dts from "vite-plugin-dts";
9
+ const existsAsync = async (file) => await access(file, constants.F_OK).then(() => true).catch(() => false);
10
+ const sh = (command, cwd) => execSync(command.trim(), { encoding: "utf8", cwd }).trim();
9
11
  async function createFileIfNotExists(filePath, content) {
10
12
  await mkdir(dirname(filePath), { recursive: true });
11
13
  if (!await existsAsync(filePath)) {
@@ -44,9 +46,7 @@ async function asyncFindPath(target, startDirectory = process.cwd()) {
44
46
  }
45
47
  return void 0;
46
48
  }
47
-
48
- // src/glob.ts
49
- var gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
49
+ const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern));
50
50
  function fixAbsoluteSyntax(pattern) {
51
51
  if (pattern.startsWith("/")) {
52
52
  return pattern.slice(1);
@@ -66,18 +66,13 @@ function fixMatchFilesSyntax(pattern) {
66
66
  }
67
67
  return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
68
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 : {
69
+ const isPosix = sep === posix.sep;
70
+ const toPosixPathSeparators = (relativePath) => relativePath.includes(win32.sep) ? relativePath.replaceAll(win32.sep, posix.sep) : relativePath;
71
+ const normalizePath = isPosix ? (path2) => path2 : toPosixPathSeparators;
72
+ const toWin32PathSeparators = (relativePath) => relativePath.includes(posix.sep) ? relativePath.replaceAll(posix.sep, win32.sep) : relativePath;
73
+ const toSystemPathSeparators = isPosix ? (path2) => path2 : toWin32PathSeparators;
74
+ const getCwd = isPosix ? process.cwd : () => toPosixPathSeparators(process.cwd());
75
+ const path = isPosix ? posix : {
81
76
  ...win32,
82
77
  sep: posix.sep,
83
78
  join(...paths) {
@@ -105,14 +100,10 @@ var path = isPosix ? posix : {
105
100
  return toPosixPathSeparators(result);
106
101
  }
107
102
  };
108
- var exportsForTests = { toWin32PathSeparators };
109
-
110
- // src/packageJson.ts
111
- import { readFile } from "node:fs/promises";
112
- import { existsSync as existsSync2, readFileSync } from "node:fs";
113
- var cachedPackageJson = {};
114
- var cachedPackageJsonPromises = {};
115
- var rootPackageJsonLocation;
103
+ const exportsForTests = { toWin32PathSeparators };
104
+ const cachedPackageJson = {};
105
+ const cachedPackageJsonPromises = {};
106
+ let rootPackageJsonLocation;
116
107
  function retrievePackageJson(location) {
117
108
  const packageJsonPath = location ? path.resolve(location, "package.json") : rootPackageJsonLocation ??= findPath("package.json");
118
109
  cachedPackageJson[packageJsonPath] ??= JSON.parse(readFileSync(packageJsonPath, "utf-8"));
@@ -128,9 +119,9 @@ async function asyncRetrievePackageJson(location = getCwd()) {
128
119
  cachedPackageJson[packageJsonPath] ??= result;
129
120
  return result;
130
121
  }
131
- var asyncReadPackageJson = async (location) => JSON.parse(await readFile(location, "utf-8"));
132
- var cachedPackageLocation = {};
133
- var cachedPackageLocationPromises = {};
122
+ const asyncReadPackageJson = async (location) => JSON.parse(await readFile(location, "utf-8"));
123
+ const cachedPackageLocation = {};
124
+ const cachedPackageLocationPromises = {};
134
125
  async function fetchPackageLocation(packageName, cwd) {
135
126
  if (packageName in cachedPackageLocation) {
136
127
  return cachedPackageLocation[packageName];
@@ -141,7 +132,7 @@ async function fetchPackageLocation(packageName, cwd) {
141
132
  ).then((packageJsonLocation) => {
142
133
  if (packageJsonLocation === void 0) {
143
134
  throw new Error(
144
- `@arcgis/lumina-compiler: Unable to resolve package.json location for "${packageName}" package. Current working directory: ${process.cwd()}`
135
+ `@arcgis/components-build-utils: Unable to resolve package.json location for "${packageName}" package. Current working directory: ${process.cwd()}`
145
136
  );
146
137
  }
147
138
  return path.dirname(packageJsonLocation);
@@ -157,7 +148,7 @@ function detectPackageManager(cwd = process.cwd()) {
157
148
  while (pathParts.length > 1) {
158
149
  const packageJson = path.join(pathParts.join(path.sep), "package.json");
159
150
  pathParts.pop();
160
- if (!existsSync2(packageJson)) {
151
+ if (!existsSync(packageJson)) {
161
152
  continue;
162
153
  }
163
154
  const contents = JSON.parse(readFileSync(packageJson, "utf8"));
@@ -172,6 +163,97 @@ function detectPackageManager(cwd = process.cwd()) {
172
163
  packageManager ??= "npm";
173
164
  return packageManager;
174
165
  }
166
+ function vitePresetPlugin({
167
+ externalize = [],
168
+ dtsOptions = {}
169
+ } = {
170
+ externalize: [],
171
+ dtsOptions: {}
172
+ }) {
173
+ const rootDir = path.resolve("src");
174
+ const outputDir = path.resolve("dist");
175
+ let userConfig = void 0;
176
+ let command = void 0;
177
+ return [
178
+ {
179
+ name: "vite-preset-config",
180
+ config({ build: { target } = {} }, env) {
181
+ command = env.command;
182
+ return {
183
+ build: {
184
+ // REFACTOR: get this from tsconfig
185
+ // It's a best practice to let the final bundler down-level as needed.
186
+ target: target ?? "es2022"
187
+ },
188
+ define: env.mode === "test" ? {
189
+ "process.env.ESRI_INTERNAL": true
190
+ } : void 0
191
+ };
192
+ },
193
+ configResolved(config) {
194
+ userConfig = config;
195
+ }
196
+ },
197
+ /**
198
+ * We use a dynamic import here because of how Rollup processes and transforms imports.
199
+ * This dependency (rollup-plugin-node-externals) will not be bundled into the output,
200
+ * as specified in vite.config.ts.
201
+ *
202
+ * rollup-plugin-node-externals is an ES module, and Stencil throws an error when it encounters
203
+ * a require() statement for an ES module.
204
+ *
205
+ * If we used a static import, Rollup's cjs build would transform it into a require() statement,
206
+ * causing Stencil to throw an error. Using a dynamic import prevents this issue.
207
+ */
208
+ import("rollup-plugin-node-externals").then(
209
+ ({ nodeExternals }) => nodeExternals({
210
+ include: externalize.map(stringToStartsWithGlob)
211
+ })
212
+ ),
213
+ dts({
214
+ logLevel: "warn",
215
+ /**
216
+ * Do not emit any .d.ts files for files outside the dist directory
217
+ * (i.e vite.config.ts, storybook stories and etc)
218
+ * This also applies for references to node_modules/.../components.d.ts files in
219
+ * tsconfig.json - these must be included in TypeScript program to provide
220
+ * types, but should not be re-emitted during build.
221
+ */
222
+ beforeWriteFile: (filePath, content) => filePath.startsWith(outputDir) && !shouldSkip(filePath) ? { filePath, content } : false,
223
+ // Copies .d.ts files to d.cjs file for CommonJS.
224
+ // Adds a performance hit as it occurs after the build
225
+ async afterBuild(emitted) {
226
+ if (userConfig?.build?.lib && userConfig.build.lib.formats?.includes("cjs")) {
227
+ await Promise.all(
228
+ emitted.entries().map(async ([filePath, content]) => {
229
+ if (filePath.endsWith(".d.ts")) {
230
+ await writeFile(filePath.replace(".d.ts", ".d.cts"), content);
231
+ }
232
+ })
233
+ );
234
+ }
235
+ },
236
+ ...dtsOptions,
237
+ compilerOptions: {
238
+ rootDir,
239
+ ...dtsOptions.compilerOptions
240
+ },
241
+ afterDiagnostic(diagnostics) {
242
+ const hasErrors = diagnostics.length > 0;
243
+ const isBuilding = command === "build";
244
+ const stopBuild = hasErrors && isBuilding;
245
+ if (stopBuild) {
246
+ throw new Error("TypeScript errors reported. See error messages above");
247
+ }
248
+ return dtsOptions?.afterDiagnostic?.(diagnostics);
249
+ }
250
+ })
251
+ ];
252
+ }
253
+ function shouldSkip(id) {
254
+ return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
255
+ }
256
+ const stringToStartsWithGlob = (option) => option ? typeof option === "string" ? new RegExp(`^${option.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&")}`, "u") : option : void 0;
175
257
  export {
176
258
  asyncFindPath,
177
259
  asyncRetrievePackageJson,
@@ -188,6 +270,8 @@ export {
188
270
  path,
189
271
  retrievePackageJson,
190
272
  sh,
273
+ stringToStartsWithGlob,
191
274
  toPosixPathSeparators,
192
- toSystemPathSeparators
275
+ toSystemPathSeparators,
276
+ vitePresetPlugin
193
277
  };
@@ -0,0 +1,28 @@
1
+ /**
2
+ * A subset of the package.json typing that is interesting to Lumina.
3
+ *
4
+ * The full package.json type is insanely large (20k lines):
5
+ * https://github.com/ffflorian/schemastore-updater/blob/main/schemas/package/index.d.ts#L20067
6
+ */
7
+ export type MiniPackageJson = {
8
+ "name": string;
9
+ "version": string;
10
+ "dependencies"?: Record<string, string | undefined>;
11
+ "devDependencies"?: Record<string, string | undefined>;
12
+ "peerDependencies"?: Record<string, string | undefined>;
13
+ "css.customData"?: string[];
14
+ "customElements"?: string;
15
+ "html.customData"?: string[];
16
+ "web-types"?: string;
17
+ };
18
+ export declare function retrievePackageJson(location?: string): MiniPackageJson;
19
+ export declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackageJson>;
20
+ /**
21
+ * Returns an absolute path to the root of a package in node_modules, without
22
+ * trailing slash.
23
+ */
24
+ export declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
25
+ /**
26
+ * Detect if current repository/monorepo uses npm, yarn or pnpm
27
+ */
28
+ export declare function detectPackageManager(cwd?: string): string;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * A subset of the package.json typing that is interesting to Lumina.
3
+ *
4
+ * The full package.json type is insanely large (20k lines):
5
+ * https://github.com/ffflorian/schemastore-updater/blob/main/schemas/package/index.d.ts#L20067
6
+ */
7
+ export type MiniPackageJson = {
8
+ "name": string;
9
+ "version": string;
10
+ "dependencies"?: Record<string, string | undefined>;
11
+ "devDependencies"?: Record<string, string | undefined>;
12
+ "peerDependencies"?: Record<string, string | undefined>;
13
+ "css.customData"?: string[];
14
+ "customElements"?: string;
15
+ "html.customData"?: string[];
16
+ "web-types"?: string;
17
+ };
18
+ export declare function retrievePackageJson(location?: string): MiniPackageJson;
19
+ export declare function asyncRetrievePackageJson(location?: string): Promise<MiniPackageJson>;
20
+ /**
21
+ * Returns an absolute path to the root of a package in node_modules, without
22
+ * trailing slash.
23
+ */
24
+ export declare function fetchPackageLocation(packageName: string, cwd?: string): Promise<string>;
25
+ /**
26
+ * Detect if current repository/monorepo uses npm, yarn or pnpm
27
+ */
28
+ export declare function detectPackageManager(cwd?: string): string;
@@ -0,0 +1,22 @@
1
+ import { default as posix } from 'path/posix';
2
+ /**
3
+ * This is called "isPosix" rather than "isNotWindows" because even if we are
4
+ * on Windows, we could be running in a POSIX environment (e.g. WSL2)
5
+ */
6
+ export declare const isPosix: boolean;
7
+ export declare const toPosixPathSeparators: (relativePath: string) => string;
8
+ export declare const normalizePath: (relativePath: string) => string;
9
+ /**
10
+ * On Windows, replace all `/` in the path back with `\\`. Do this only if you
11
+ * wish to output the path in the console or error message.
12
+ * On POSIX system (macOS, Linux, ...), this does not change the path (because
13
+ * inside the compiler we use `/` everywhere).
14
+ */
15
+ export declare const toSystemPathSeparators: (relativePath: string) => string;
16
+ export declare const getCwd: () => string;
17
+ export declare const path: typeof posix & {
18
+ sep: "/";
19
+ };
20
+ export declare const exportsForTests: {
21
+ toWin32PathSeparators: (relativePath: string) => string;
22
+ };
package/dist/path.d.ts ADDED
@@ -0,0 +1,22 @@
1
+ import { default as posix } from 'path/posix';
2
+ /**
3
+ * This is called "isPosix" rather than "isNotWindows" because even if we are
4
+ * on Windows, we could be running in a POSIX environment (e.g. WSL2)
5
+ */
6
+ export declare const isPosix: boolean;
7
+ export declare const toPosixPathSeparators: (relativePath: string) => string;
8
+ export declare const normalizePath: (relativePath: string) => string;
9
+ /**
10
+ * On Windows, replace all `/` in the path back with `\\`. Do this only if you
11
+ * wish to output the path in the console or error message.
12
+ * On POSIX system (macOS, Linux, ...), this does not change the path (because
13
+ * inside the compiler we use `/` everywhere).
14
+ */
15
+ export declare const toSystemPathSeparators: (relativePath: string) => string;
16
+ export declare const getCwd: () => string;
17
+ export declare const path: typeof posix & {
18
+ sep: "/";
19
+ };
20
+ export declare const exportsForTests: {
21
+ toWin32PathSeparators: (relativePath: string) => string;
22
+ };
@@ -0,0 +1,24 @@
1
+ import { Plugin } from 'vite';
2
+ import { default as dts } from 'vite-plugin-dts';
3
+ /**
4
+ * Vite preset for all our support packages:
5
+ * - externalizes all devDependencies (using `rollup-plugin-node-externals`)
6
+ * - generates type declarations (using `vite-plugin-dts`)
7
+ */
8
+ export declare function vitePresetPlugin({ externalize, dtsOptions, }?: {
9
+ /** The list of dependencies to externalize besides devDependencies */
10
+ externalize?: string[];
11
+ /** Additional options for `vite-plugin-dts` */
12
+ dtsOptions?: Parameters<typeof dts>[0];
13
+ }): [Plugin, Promise<Plugin>, Plugin];
14
+ /**
15
+ * By default this plugin converts string values to RegExp that only matches if
16
+ * path is "equal" not "starts with", which is not intuitive.
17
+ *
18
+ * I.e, this would only exclude "monaco-editor", not any
19
+ * "monaco-editor/sub-path" by default:
20
+ * "bundleIn": ["monaco-editor"]
21
+ *
22
+ * We fix it to match using "starts with" instead
23
+ */
24
+ export declare const stringToStartsWithGlob: (option: RegExp | string | false | null | undefined) => RegExp | undefined;
package/dist/vite.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { Plugin } from 'vite';
2
+ import { default as dts } from 'vite-plugin-dts';
3
+ /**
4
+ * Vite preset for all our support packages:
5
+ * - externalizes all devDependencies (using `rollup-plugin-node-externals`)
6
+ * - generates type declarations (using `vite-plugin-dts`)
7
+ */
8
+ export declare function vitePresetPlugin({ externalize, dtsOptions, }?: {
9
+ /** The list of dependencies to externalize besides devDependencies */
10
+ externalize?: string[];
11
+ /** Additional options for `vite-plugin-dts` */
12
+ dtsOptions?: Parameters<typeof dts>[0];
13
+ }): [Plugin, Promise<Plugin>, Plugin];
14
+ /**
15
+ * By default this plugin converts string values to RegExp that only matches if
16
+ * path is "equal" not "starts with", which is not intuitive.
17
+ *
18
+ * I.e, this would only exclude "monaco-editor", not any
19
+ * "monaco-editor/sub-path" by default:
20
+ * "bundleIn": ["monaco-editor"]
21
+ *
22
+ * We fix it to match using "starts with" instead
23
+ */
24
+ export declare const stringToStartsWithGlob: (option: RegExp | string | false | null | undefined) => RegExp | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/components-build-utils",
3
- "version": "4.33.0-next.8",
3
+ "version": "4.33.0-next.81",
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",
@@ -26,7 +26,10 @@
26
26
  "chalk": "^5.3.0",
27
27
  "commander": "^11.1.0",
28
28
  "glob": "^11.0.0",
29
+ "rollup-plugin-node-externals": "^7.1.3",
29
30
  "split2": "^4.2.0",
30
- "tslib": "^2.7.0"
31
+ "tslib": "^2.7.0",
32
+ "vite": "^5.4.8",
33
+ "vite-plugin-dts": "^4.3.0"
31
34
  }
32
35
  }