@arcgis/node-toolkit 6.0.0-next.4 → 6.0.0-next.41
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/env.d.ts +6 -0
- package/dist/env.js +10 -0
- package/dist/glob.d.ts +15 -9
- package/dist/glob.js +12 -5
- package/dist/markdown.d.ts +9 -0
- package/dist/markdown.js +108 -0
- package/dist/packageJson.d.ts +1 -1
- package/dist/shell.d.ts +0 -18
- package/dist/shell.js +1 -22
- package/dist/testTimezone.d.ts +2 -0
- package/dist/testTimezone.js +4 -0
- package/dist/vite/installPlaywright.js +16 -3
- package/dist/vite/presetPlugin.d.ts +3 -11
- package/dist/vite/presetPlugin.js +4 -50
- package/dist/vite/testTimezone.d.ts +8 -0
- package/dist/vite/testTimezone.js +35 -0
- package/package.json +6 -3
package/dist/env.d.ts
ADDED
package/dist/env.js
ADDED
package/dist/glob.d.ts
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
|
+
export interface GitIgnoreFileToGlobsOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Names of `#region name` / `#endregion` comment regions to skip from the
|
|
4
|
+
* parsed output.
|
|
5
|
+
* Example use case:
|
|
6
|
+
* - .prettierignore file can be read by Prettier, ESLint, and standalone CLI
|
|
7
|
+
* scripts. Most ignores are shared between tools, but some ignores are only
|
|
8
|
+
* applicable for Prettier (files that prettier doesn't support), and can
|
|
9
|
+
* be gated behind prettier-only region.
|
|
10
|
+
*/
|
|
11
|
+
ignoreRegions?: string[];
|
|
12
|
+
}
|
|
1
13
|
/**
|
|
2
14
|
* Read `.gitignore` files and convert it to globs that are accepted by ESLint
|
|
3
15
|
*
|
|
4
16
|
* @public
|
|
5
17
|
* @param filePath
|
|
18
|
+
* @param options
|
|
6
19
|
* @example
|
|
7
20
|
* ```ts
|
|
8
21
|
* // eslint.config.js
|
|
@@ -12,17 +25,10 @@
|
|
|
12
25
|
* export default [
|
|
13
26
|
* globalIgnores([
|
|
14
27
|
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.gitignore"),
|
|
15
|
-
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.prettierignore"),
|
|
28
|
+
* ...gitIgnoreFileToGlobs(import.meta.dirname + "/.prettierignore", { ignoreRegions: ["prettier-only"] }),
|
|
16
29
|
* ]),
|
|
17
30
|
* // ...
|
|
18
31
|
* ];
|
|
19
32
|
* ```
|
|
20
33
|
*/
|
|
21
|
-
export declare function gitIgnoreFileToGlobs(filePath: string): string[];
|
|
22
|
-
/**
|
|
23
|
-
* @public
|
|
24
|
-
* @param pattern
|
|
25
|
-
* @deprecated Use gitIgnoreFileToGlobs from "@arcgis/node-toolkit/glob"
|
|
26
|
-
* instead
|
|
27
|
-
*/
|
|
28
|
-
export declare const gitIgnoreToGlob: (pattern: string) => string;
|
|
34
|
+
export declare function gitIgnoreFileToGlobs(filePath: string, { ignoreRegions }?: GitIgnoreFileToGlobsOptions): string[];
|
package/dist/glob.js
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
function gitIgnoreFileToGlobs(filePath) {
|
|
3
|
-
|
|
2
|
+
function gitIgnoreFileToGlobs(filePath, { ignoreRegions = [] } = {}) {
|
|
3
|
+
const regions = [];
|
|
4
|
+
return readFileSync(filePath, "utf8").split("\n").map((line) => line.trim()).filter((line) => {
|
|
5
|
+
const region = /^#region\s+(.+)$/u.exec(line)?.[1];
|
|
6
|
+
if (region) {
|
|
7
|
+
regions.push(region);
|
|
8
|
+
} else if (line === "#endregion") {
|
|
9
|
+
regions.pop();
|
|
10
|
+
}
|
|
11
|
+
return line.length > 0 && !line.startsWith("#") && !regions.some((name) => ignoreRegions.includes(name));
|
|
12
|
+
}).map((pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern)));
|
|
4
13
|
}
|
|
5
|
-
const gitIgnoreToGlob = (pattern) => fixAbsoluteSyntax(fixMatchFilesSyntax(pattern.trim()));
|
|
6
14
|
function fixAbsoluteSyntax(pattern) {
|
|
7
15
|
if (pattern.startsWith("/")) {
|
|
8
16
|
return pattern.slice(1);
|
|
@@ -23,6 +31,5 @@ function fixMatchFilesSyntax(pattern) {
|
|
|
23
31
|
return pattern.endsWith("/*") ? `${pattern}*` : pattern.endsWith("/") ? `${pattern}**` : `${pattern}/**`;
|
|
24
32
|
}
|
|
25
33
|
export {
|
|
26
|
-
gitIgnoreFileToGlobs
|
|
27
|
-
gitIgnoreToGlob
|
|
34
|
+
gitIgnoreFileToGlobs
|
|
28
35
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const markdownTextLimit = 65000;
|
|
2
|
+
/**
|
|
3
|
+
* Split markdown to fit into GitHub comment length limit. Splits at best available
|
|
4
|
+
* places: headings (higher levels first), code blocks and details sections, blank lines.
|
|
5
|
+
*
|
|
6
|
+
* Use cases: automated reports in issues, pull request check status comments,
|
|
7
|
+
* reporting public API diff inside a pr comment.
|
|
8
|
+
*/
|
|
9
|
+
export declare function splitMarkdown(content: string, limit?: number): string[];
|
package/dist/markdown.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const markdownTextLimit = 65e3;
|
|
2
|
+
const boundaryKinds = ["heading", "block", "blank", "line", "text"];
|
|
3
|
+
function splitMarkdown(content, limit = markdownTextLimit) {
|
|
4
|
+
if (!Number.isSafeInteger(limit) || limit < 2) {
|
|
5
|
+
throw new Error("Markdown limit must be an integer of at least 2.");
|
|
6
|
+
}
|
|
7
|
+
const chunks = [];
|
|
8
|
+
let start = 0;
|
|
9
|
+
let blocks = [];
|
|
10
|
+
let prefix = "";
|
|
11
|
+
while (prefix.length + content.length - start > limit) {
|
|
12
|
+
const remaining = content.slice(start);
|
|
13
|
+
const split = getBoundary(remaining, limit - prefix.length, blocks, start === 0 || content[start - 1] === "\n");
|
|
14
|
+
chunks.push(
|
|
15
|
+
prefix + remaining.slice(0, split.index) + closeBlocks(split.blocks, remaining[split.index - 1] === "\n")
|
|
16
|
+
);
|
|
17
|
+
start += split.index;
|
|
18
|
+
blocks = split.blocks;
|
|
19
|
+
prefix = openBlocks(blocks);
|
|
20
|
+
}
|
|
21
|
+
chunks.push(prefix + content.slice(start));
|
|
22
|
+
return chunks;
|
|
23
|
+
}
|
|
24
|
+
function getBoundary(content, limit, initialBlocks, atLineStart) {
|
|
25
|
+
const blocks = [...initialBlocks];
|
|
26
|
+
let best;
|
|
27
|
+
let skipEnd = 0;
|
|
28
|
+
let afterHeading = false;
|
|
29
|
+
for (const match of content.matchAll(/[^\n]*(?:\n|$)/gu)) {
|
|
30
|
+
const index = match.index;
|
|
31
|
+
if (index > limit) {
|
|
32
|
+
break;
|
|
33
|
+
}
|
|
34
|
+
const line = match[0];
|
|
35
|
+
const end = index + line.length;
|
|
36
|
+
let textStart = Math.max(index, skipEnd);
|
|
37
|
+
if (end <= textStart) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const aligned = textStart === index && (index > 0 || atLineStart);
|
|
41
|
+
const fence = aligned ? /^ {0,3}(`{3,}|~{3,})([^\r\n]*)/u.exec(line) : null;
|
|
42
|
+
const activeFence = blocks.at(-1)?.fence;
|
|
43
|
+
const heading = aligned && activeFence === void 0 ? /^ {0,3}(#{1,6})\s/u.exec(line) : null;
|
|
44
|
+
const opening = aligned && activeFence === void 0 ? /^[ \t]*<details\b[^>]*>(?:\s*<summary\b[^>]*>[\s\S]*?<\/summary\s*>)?/iu.exec(content.slice(index)) : null;
|
|
45
|
+
const blankLine = /^\s*$/u.test(line);
|
|
46
|
+
const kind = !aligned ? "text" : activeFence !== void 0 ? "line" : opening !== null || fence !== null ? "block" : heading !== null ? "heading" : blankLine ? "blank" : "line";
|
|
47
|
+
if (!afterHeading) {
|
|
48
|
+
consider(textStart, kind, heading?.[1].length);
|
|
49
|
+
}
|
|
50
|
+
afterHeading = heading !== null || afterHeading && blankLine;
|
|
51
|
+
if (activeFence !== void 0) {
|
|
52
|
+
if (fence !== null && fence[1].startsWith(activeFence[0]) && fence[1].length >= activeFence.length && fence[2].trim() === "") {
|
|
53
|
+
blocks.pop();
|
|
54
|
+
textStart = end;
|
|
55
|
+
}
|
|
56
|
+
} else if (fence !== null) {
|
|
57
|
+
blocks.push({ opening: line.trimEnd(), closing: fence[1], fence: fence[1] });
|
|
58
|
+
textStart = end;
|
|
59
|
+
} else if (aligned && /^\s*<!--/u.test(line)) {
|
|
60
|
+
const closing = content.indexOf("-->", index);
|
|
61
|
+
textStart = closing === -1 ? content.length : closing + 3;
|
|
62
|
+
} else if (opening !== null) {
|
|
63
|
+
if (/<\/details\s*>/iu.test(line)) {
|
|
64
|
+
textStart = end;
|
|
65
|
+
} else {
|
|
66
|
+
blocks.push({ opening: opening[0], closing: "</details>" });
|
|
67
|
+
textStart = index + opening[0].length;
|
|
68
|
+
}
|
|
69
|
+
} else if (aligned && /^\s*<\/details\s*>/iu.test(line)) {
|
|
70
|
+
blocks.pop();
|
|
71
|
+
textStart = end;
|
|
72
|
+
}
|
|
73
|
+
skipEnd = textStart;
|
|
74
|
+
if (textStart <= end && (!afterHeading || end > limit)) {
|
|
75
|
+
consider(end, line.endsWith("\n") ? "line" : "text");
|
|
76
|
+
let exact = Math.min(end, limit - closeBlocks(blocks).length);
|
|
77
|
+
if (/[\uD800-\uDBFF]/u.test(content[exact - 1]) && /[\uDC00-\uDFFF]/u.test(content[exact])) {
|
|
78
|
+
exact--;
|
|
79
|
+
}
|
|
80
|
+
if (exact >= textStart) {
|
|
81
|
+
consider(exact, "text");
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (best === void 0) {
|
|
86
|
+
throw new Error("Markdown limit is too small to split the enclosing blocks.");
|
|
87
|
+
}
|
|
88
|
+
return best;
|
|
89
|
+
function consider(index, kind, headingLevel = 0) {
|
|
90
|
+
if (index <= 0 || index + closeBlocks(blocks, content[index - 1] === "\n").length > limit) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (best === void 0 || boundaryKinds.indexOf(kind) < boundaryKinds.indexOf(best.kind) || kind === best.kind && (headingLevel < best.headingLevel || headingLevel === best.headingLevel && index > best.index)) {
|
|
94
|
+
best = { index, kind, headingLevel, blocks: [...blocks] };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function closeBlocks(blocks, endsWithNewline = false) {
|
|
99
|
+
return blocks.length === 0 ? "" : `${endsWithNewline ? "" : "\n"}${blocks.toReversed().map(({ closing }) => closing).join("\n")}
|
|
100
|
+
`;
|
|
101
|
+
}
|
|
102
|
+
function openBlocks(blocks) {
|
|
103
|
+
return blocks.map(({ opening, fence }) => opening + (fence === void 0 ? "\n\n" : "\n")).join("");
|
|
104
|
+
}
|
|
105
|
+
export {
|
|
106
|
+
markdownTextLimit,
|
|
107
|
+
splitMarkdown
|
|
108
|
+
};
|
package/dist/packageJson.d.ts
CHANGED
package/dist/shell.d.ts
CHANGED
|
@@ -46,24 +46,6 @@ export declare function sh(command: string, options?: Partial<ExecSyncOptionsWit
|
|
|
46
46
|
* @param options
|
|
47
47
|
*/
|
|
48
48
|
export declare function asyncSh(command: string, options?: Partial<ExecOptionsWithStringEncoding>): Promise<string>;
|
|
49
|
-
/**
|
|
50
|
-
* Synchronously execute a command without shell interpolation and return the output.
|
|
51
|
-
*
|
|
52
|
-
* This is usually safer than {@link shell!sh} because arguments are passed as
|
|
53
|
-
* discrete tokens, which avoids most shell escaping issues and command
|
|
54
|
-
* injection pitfalls.
|
|
55
|
-
*
|
|
56
|
-
* Example:
|
|
57
|
-
* `sp("git", ["show", `${baseRef}:pnpm-workspace.yaml`])`
|
|
58
|
-
*
|
|
59
|
-
* Avoid {@link shell!sp} only when you explicitly need shell features.
|
|
60
|
-
* @public
|
|
61
|
-
* @deprecated Use {@link shell!collectOutputSync} or {@link shell!runCommandSync} instead.
|
|
62
|
-
* @param command
|
|
63
|
-
* @param args
|
|
64
|
-
* @param options
|
|
65
|
-
*/
|
|
66
|
-
export declare function sp(command: string, args: string[], options?: Partial<SpawnSyncOptionsWithStringEncoding>): string;
|
|
67
49
|
/**
|
|
68
50
|
* Synchronously execute a command and stream output to the current process.
|
|
69
51
|
* Note 1:
|
package/dist/shell.js
CHANGED
|
@@ -43,26 +43,6 @@ ${output}`;
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function sp(command, args, options = {}) {
|
|
47
|
-
if (process.platform === "win32" && command === "pnpm" && // Allow explicit shell config including shell:false for environment-specific handling.
|
|
48
|
-
!("shell" in options)) {
|
|
49
|
-
throw Error(
|
|
50
|
-
'If invoking pnpm on Windows, provide { shell: true } or { shell: process.platform === "win32" } and handle shell escaping.'
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
const normalizedOptions = { encoding: "utf8", ...options };
|
|
54
|
-
const result = spawnSync(command, args, normalizedOptions);
|
|
55
|
-
if (result.error) {
|
|
56
|
-
throw result.error;
|
|
57
|
-
}
|
|
58
|
-
const sep = result.stdout && result.stderr ? "\n" : "";
|
|
59
|
-
const output = `${result.stdout ?? ""}${sep}${result.stderr ?? ""}`.trim();
|
|
60
|
-
const exitCode = result.status ?? 0;
|
|
61
|
-
if (exitCode !== 0) {
|
|
62
|
-
throw makeSpawnError(command, args, exitCode, result.signal, output);
|
|
63
|
-
}
|
|
64
|
-
return output;
|
|
65
|
-
}
|
|
66
46
|
function runCommandSync(command, args, options = {}) {
|
|
67
47
|
const fixedOptions = fixPnpmUsage(command, options);
|
|
68
48
|
const { input } = fixedOptions;
|
|
@@ -155,6 +135,5 @@ export {
|
|
|
155
135
|
collectOutputSync,
|
|
156
136
|
runCommand,
|
|
157
137
|
runCommandSync,
|
|
158
|
-
sh
|
|
159
|
-
sp
|
|
138
|
+
sh
|
|
160
139
|
};
|
|
@@ -2,7 +2,7 @@ import { mkdir, rm, stat } from "node:fs/promises";
|
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { findPath, existsAsync } from "../file.js";
|
|
5
|
-
import { runCommand } from "../shell.js";
|
|
5
|
+
import { runCommand, collectOutput } from "../shell.js";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
let installPromise;
|
|
8
8
|
function installPlaywright() {
|
|
@@ -26,7 +26,20 @@ async function ensureInstalled() {
|
|
|
26
26
|
throw new Error("Playwright not found in node_modules. Please install it first.");
|
|
27
27
|
}
|
|
28
28
|
const { chromium } = await import(pathToFileURL(join(playwrightCwd, "index.mjs")).href);
|
|
29
|
-
|
|
29
|
+
const executablePath = chromium.executablePath();
|
|
30
|
+
const isReady = async () => {
|
|
31
|
+
if (!await existsAsync(executablePath)) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (process.platform === "linux" && process.env.CI) {
|
|
35
|
+
const dependencies = await collectOutput("ldd", [executablePath], {
|
|
36
|
+
env: { ...process.env, [`LC_ALL`]: "C" }
|
|
37
|
+
});
|
|
38
|
+
return !dependencies.includes("=> not found");
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
if (await isReady()) {
|
|
30
43
|
return;
|
|
31
44
|
}
|
|
32
45
|
const home = homedir();
|
|
@@ -36,7 +49,7 @@ async function ensureInstalled() {
|
|
|
36
49
|
await mkdir(stateDir, { recursive: true });
|
|
37
50
|
const releaseLock = await acquireLock(lockPath);
|
|
38
51
|
try {
|
|
39
|
-
if (await
|
|
52
|
+
if (await isReady()) {
|
|
40
53
|
return;
|
|
41
54
|
}
|
|
42
55
|
const installArgs = [
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import type { Plugin } from "vite";
|
|
2
|
-
import type dts from "vite-plugin-dts";
|
|
3
2
|
import { type DependencyManagementOptions } from "./externalizeDependenciesPlugin.ts";
|
|
4
3
|
/** @public */
|
|
5
|
-
export type VitePresetOptions = DependencyManagementOptions
|
|
6
|
-
/**
|
|
7
|
-
* Options for `vite-plugin-dts`
|
|
8
|
-
*
|
|
9
|
-
* @public
|
|
10
|
-
* @deprecated Use https://webgis.esri.com/references/api-extractor/integrations instead
|
|
11
|
-
*/
|
|
12
|
-
dtsOptions?: Parameters<typeof dts>[0] | false;
|
|
13
|
-
};
|
|
4
|
+
export type VitePresetOptions = DependencyManagementOptions;
|
|
14
5
|
/**
|
|
15
6
|
* Vite preset for all our support packages:
|
|
16
7
|
* - externalizes all non-dev-dependencies
|
|
8
|
+
* - sets the default timezone for tests
|
|
17
9
|
*
|
|
18
10
|
* @public
|
|
19
11
|
* @param options
|
|
20
12
|
*/
|
|
21
|
-
export declare function vitePresetPlugin({
|
|
13
|
+
export declare function vitePresetPlugin({ externalize, bundleIn, isApplication }?: VitePresetOptions): [Plugin, Plugin];
|
|
@@ -1,29 +1,20 @@
|
|
|
1
|
-
import { path } from "../path.js";
|
|
2
1
|
import { externalizeDependencies } from "./externalizeDependenciesPlugin.js";
|
|
3
|
-
|
|
4
|
-
return id.includes("__test") || id.includes(".e2e.") || id.includes(".spec.") || id.includes(".test.") || id.includes(".stories.");
|
|
5
|
-
}
|
|
2
|
+
import { configureTestTimezone } from "./testTimezone.js";
|
|
6
3
|
const hashlessOutputNames = {
|
|
7
4
|
assetFileNames: "assets/[name][extname]",
|
|
8
5
|
chunkFileNames: "chunks/[name].js"
|
|
9
6
|
};
|
|
10
|
-
function vitePresetPlugin({
|
|
11
|
-
externalize: [],
|
|
12
|
-
dtsOptions: {}
|
|
13
|
-
}) {
|
|
14
|
-
const dist = `${path.resolve("dist")}/`;
|
|
15
|
-
const distSrc = `${dist}src/`;
|
|
16
|
-
let command = void 0;
|
|
7
|
+
function vitePresetPlugin({ externalize, bundleIn, isApplication } = { externalize: [] }) {
|
|
17
8
|
return [
|
|
18
9
|
{
|
|
19
10
|
name: "vite-preset-config",
|
|
20
11
|
config(config, env) {
|
|
21
|
-
command = env.command;
|
|
22
12
|
const { rollupOptions, ssr, target } = config.build ?? {};
|
|
23
13
|
const isBrowserApplication = isApplication && !ssr && !env.isSsrBuild;
|
|
24
14
|
const output = rollupOptions?.output;
|
|
25
15
|
const hashlessOutput = Array.isArray(output) ? output.map((entry) => ({ ...hashlessOutputNames, ...entry })) : { ...hashlessOutputNames, ...output };
|
|
26
16
|
return {
|
|
17
|
+
...configureTestTimezone(config, env),
|
|
27
18
|
build: {
|
|
28
19
|
// REFACTOR: get this from tsconfig
|
|
29
20
|
// It's a best practice to let the final bundler down-level as needed.
|
|
@@ -40,44 +31,7 @@ function vitePresetPlugin({ dtsOptions = {}, externalize, bundleIn, isApplicatio
|
|
|
40
31
|
externalize,
|
|
41
32
|
bundleIn,
|
|
42
33
|
isApplication
|
|
43
|
-
})
|
|
44
|
-
// This dependency pulls in many others. Since components-build-utils has a
|
|
45
|
-
// single entry point, we load a large module tree needlessly. To avoid,
|
|
46
|
-
// load the plugin on demand.
|
|
47
|
-
dtsOptions === false ? void 0 : import("vite-plugin-dts").then(
|
|
48
|
-
({ default: dts }) => dts({
|
|
49
|
-
logLevel: "warn",
|
|
50
|
-
...dtsOptions,
|
|
51
|
-
compilerOptions: {
|
|
52
|
-
rootDir: ".",
|
|
53
|
-
...dtsOptions.compilerOptions
|
|
54
|
-
},
|
|
55
|
-
/**
|
|
56
|
-
* Do not emit any .d.ts files for files outside the dist directory
|
|
57
|
-
* (i.e vite.config.ts, storybook stories and etc)
|
|
58
|
-
* This also applies for references to node_modules/.../components.d.ts files in
|
|
59
|
-
* tsconfig.json - these must be included in TypeScript program to provide
|
|
60
|
-
* types, but should not be re-emitted during build.
|
|
61
|
-
*/
|
|
62
|
-
beforeWriteFile: async (filePath, content) => {
|
|
63
|
-
if (filePath.startsWith(distSrc) && !shouldSkip(filePath)) {
|
|
64
|
-
const filePathRelativeToDist = `${dist}${filePath.slice(distSrc.length)}`;
|
|
65
|
-
return dtsOptions?.beforeWriteFile ? await dtsOptions.beforeWriteFile(filePathRelativeToDist, content) : { filePath: filePathRelativeToDist, content };
|
|
66
|
-
} else {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
afterDiagnostic(diagnostics) {
|
|
71
|
-
const hasErrors = diagnostics.length > 0;
|
|
72
|
-
const isBuilding = command === "build";
|
|
73
|
-
const stopBuild = hasErrors && isBuilding;
|
|
74
|
-
if (stopBuild) {
|
|
75
|
-
throw new Error("TypeScript errors reported. See error messages above");
|
|
76
|
-
}
|
|
77
|
-
return dtsOptions?.afterDiagnostic?.(diagnostics);
|
|
78
|
-
}
|
|
79
|
-
})
|
|
80
|
-
)
|
|
34
|
+
})
|
|
81
35
|
];
|
|
82
36
|
}
|
|
83
37
|
export {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ConfigEnv, Plugin, UserConfig } from "vite";
|
|
2
|
+
export declare function configureTestTimezone(config: UserConfig, env: ConfigEnv): UserConfig | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Apply the repository's timezone policy to Vitest processes and Playwright contexts.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare function testTimezonePlugin(): Plugin;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { testTimezone } from "../testTimezone.js";
|
|
2
|
+
function configureTestTimezone(config, env) {
|
|
3
|
+
if (env.command !== "serve" || process.env.VITEST !== "true") {
|
|
4
|
+
return void 0;
|
|
5
|
+
}
|
|
6
|
+
const timezone = config.test?.env?.TZ ?? testTimezone;
|
|
7
|
+
process.env.TZ = timezone;
|
|
8
|
+
const browser = config.test?.browser;
|
|
9
|
+
configurePlaywrightTimezone(browser?.provider, timezone);
|
|
10
|
+
for (const instance of browser?.instances ?? []) {
|
|
11
|
+
configurePlaywrightTimezone(instance.provider, timezone);
|
|
12
|
+
}
|
|
13
|
+
return { test: { env: { TZ: timezone } } };
|
|
14
|
+
}
|
|
15
|
+
function testTimezonePlugin() {
|
|
16
|
+
return {
|
|
17
|
+
name: "@arcgis/node-toolkit:test-timezone",
|
|
18
|
+
enforce: "post",
|
|
19
|
+
config: configureTestTimezone
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function configurePlaywrightTimezone(provider, timezone) {
|
|
23
|
+
if (!isPlaywrightProvider(provider)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
provider.options.contextOptions ??= {};
|
|
27
|
+
provider.options.contextOptions.timezoneId ??= timezone;
|
|
28
|
+
}
|
|
29
|
+
function isPlaywrightProvider(provider) {
|
|
30
|
+
return provider?.name === "playwright";
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
configureTestTimezone,
|
|
34
|
+
testTimezonePlugin
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcgis/node-toolkit",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.41",
|
|
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",
|
|
7
7
|
"exports": {
|
|
8
8
|
"./codeowners": "./dist/codeowners.js",
|
|
9
|
+
"./env": "./dist/env.js",
|
|
9
10
|
"./file": "./dist/file.js",
|
|
11
|
+
"./markdown": "./dist/markdown.js",
|
|
10
12
|
"./shell": "./dist/shell.js",
|
|
11
13
|
"./glob": "./dist/glob.js",
|
|
12
14
|
"./path": "./dist/path.js",
|
|
13
15
|
"./packageJson": "./dist/packageJson.js",
|
|
16
|
+
"./testTimezone": "./dist/testTimezone.js",
|
|
14
17
|
"./vite/presetPlugin": "./dist/vite/presetPlugin.js",
|
|
18
|
+
"./vite/testTimezone": "./dist/vite/testTimezone.js",
|
|
15
19
|
"./vite/externalizeDependenciesPlugin": "./dist/vite/externalizeDependenciesPlugin.js",
|
|
16
20
|
"./vite/installPlaywright": "./dist/vite/installPlaywright.js",
|
|
17
21
|
"./vite/simpleTypesEmit": "./dist/vite/simpleTypesEmit.js",
|
|
@@ -27,7 +31,6 @@
|
|
|
27
31
|
"picomatch": "^4.0.4",
|
|
28
32
|
"tslib": "^2.8.1",
|
|
29
33
|
"typescript": "~6.0.3",
|
|
30
|
-
"vite": "^7.3.2"
|
|
31
|
-
"vite-plugin-dts": "^4.5.4"
|
|
34
|
+
"vite": "^7.3.2"
|
|
32
35
|
}
|
|
33
36
|
}
|