@nx-devkit/playwright 0.0.0 → 0.0.2

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/README.md CHANGED
@@ -1,3 +1,64 @@
1
1
  # @nx-devkit/playwright
2
2
 
3
- Placeholder for @nx-devkit/playwright published by @nx-devkit/prepare-for-release.
3
+ Standalone Nx plugin: any `playwright.config.*` becomes a cached `e2e` target (plus `e2e:ui` and `e2e:update-snapshots`) on the owning project. No `project.json` needed.
4
+
5
+ Part of [nx-devkit](https://github.com/nx-devkit/nx.ts).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ bun add -D @nx-devkit/playwright @playwright/test
11
+ ```
12
+
13
+ Depends on `@nx/devkit` `^22 || ^23`. Requires `@playwright/test` `^1.40` as a peer. Browsers are installed separately — `npx playwright install` is a one-time consumer step, not part of the target.
14
+
15
+ ## Register
16
+
17
+ ```bash
18
+ nx add @nx-devkit/playwright # runs the init generator — registers the plugin in nx.json
19
+ ```
20
+
21
+ Or manually:
22
+
23
+ ```jsonc
24
+ // nx.json
25
+ { "plugins": ["@nx-devkit/playwright"] }
26
+ ```
27
+
28
+ ## What it infers
29
+
30
+ <!-- target table consistent with src/plugin.ts createNodesV2 -->
31
+
32
+ | Trigger | Target | Command | Cacheable | Outputs |
33
+ |---|---|---|---|---|
34
+ | `playwright.config.{ts,js,mts,mjs,cjs,cts}` | `e2e` | `npx playwright test` (cwd = `{projectRoot}`) | yes | `test-results/`, `playwright-report/`, `blob-report/` |
35
+ | same | `e2e:ui` | `npx playwright test --ui` | no | — |
36
+ | same | `e2e:update-snapshots` | `npx playwright test --update-snapshots` | no | — |
37
+
38
+ Playwright auto-discovers its config from the working directory, so the plugin never passes `--config`. Multiple configs in one directory merge into a single target set. Inputs cover the whole project tree — an app rebuild busts the e2e cache, which is what you want.
39
+
40
+ ## Options
41
+
42
+ ```jsonc
43
+ // nx.json
44
+ {
45
+ "plugins": [
46
+ {
47
+ "plugin": "@nx-devkit/playwright",
48
+ "options": {
49
+ "targetName": "e2e", // rename the target set
50
+ "extraTargets": false // skip e2e:ui / e2e:update-snapshots (default: true)
51
+ }
52
+ }
53
+ ]
54
+ }
55
+ ```
56
+
57
+ ## Inspect
58
+
59
+ ```bash
60
+ npx nx show project my-app # see inferred targets
61
+ npx nx run my-app:e2e # run browser tests (cached)
62
+ npx nx affected -t e2e # CI: only affected projects
63
+ npx nx run my-app:e2e:update-snapshots # refresh snapshots
64
+ ```
@@ -0,0 +1,10 @@
1
+ import { GeneratorCallback, Tree } from "@nx/devkit";
2
+
3
+ //#region src/generators/init/generator.d.ts
4
+ interface NxPlaywrightInitOptions {
5
+ pluginPath?: string;
6
+ }
7
+ declare function initGenerator(tree: Tree, options?: NxPlaywrightInitOptions): Promise<GeneratorCallback>;
8
+ //#endregion
9
+ export { NxPlaywrightInitOptions, initGenerator as default, initGenerator };
10
+ //# sourceMappingURL=generator.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.mts","names":[],"sources":["../../../src/generators/init/generator.ts"],"mappings":";;;UAGiB,uBAAA;EACf,UAAU;AAAA;AAAA,iBAOU,aAAA,CACpB,IAAA,EAAM,IAAA,EACN,OAAA,GAAS,uBAAA,GACR,OAAA,CAAQ,iBAAA"}
@@ -0,0 +1,301 @@
1
+ import { createRequire } from "node:module";
2
+ import { addDependenciesToPackageJson, formatFiles } from "@nx/devkit";
3
+ //#region \0rolldown/runtime.js
4
+ var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
5
+ var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
6
+ //#endregion
7
+ //#region ../internal/src/jsonc.ts
8
+ var import_main = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
9
+ (function(factory) {
10
+ if (typeof module === "object" && typeof module.exports === "object") {
11
+ var v = factory(__require, exports);
12
+ if (v !== void 0) module.exports = v;
13
+ } else if (typeof define === "function" && define.amd) define([
14
+ "require",
15
+ "exports",
16
+ "./impl/format",
17
+ "./impl/edit",
18
+ "./impl/scanner",
19
+ "./impl/parser"
20
+ ], factory);
21
+ })(function(require, exports$1) {
22
+ "use strict";
23
+ Object.defineProperty(exports$1, "__esModule", { value: true });
24
+ exports$1.applyEdits = exports$1.modify = exports$1.format = exports$1.printParseErrorCode = exports$1.ParseErrorCode = exports$1.stripComments = exports$1.visit = exports$1.getNodeValue = exports$1.getNodePath = exports$1.findNodeAtOffset = exports$1.findNodeAtLocation = exports$1.parseTree = exports$1.parse = exports$1.getLocation = exports$1.SyntaxKind = exports$1.ScanError = exports$1.createScanner = void 0;
25
+ const formatter = require("./impl/format");
26
+ const edit = require("./impl/edit");
27
+ const scanner = require("./impl/scanner");
28
+ const parser = require("./impl/parser");
29
+ /**
30
+ * Creates a JSON scanner on the given text.
31
+ * If ignoreTrivia is set, whitespaces or comments are ignored.
32
+ */
33
+ exports$1.createScanner = scanner.createScanner;
34
+ var ScanError;
35
+ (function(ScanError) {
36
+ ScanError[ScanError["None"] = 0] = "None";
37
+ ScanError[ScanError["UnexpectedEndOfComment"] = 1] = "UnexpectedEndOfComment";
38
+ ScanError[ScanError["UnexpectedEndOfString"] = 2] = "UnexpectedEndOfString";
39
+ ScanError[ScanError["UnexpectedEndOfNumber"] = 3] = "UnexpectedEndOfNumber";
40
+ ScanError[ScanError["InvalidUnicode"] = 4] = "InvalidUnicode";
41
+ ScanError[ScanError["InvalidEscapeCharacter"] = 5] = "InvalidEscapeCharacter";
42
+ ScanError[ScanError["InvalidCharacter"] = 6] = "InvalidCharacter";
43
+ })(ScanError || (exports$1.ScanError = ScanError = {}));
44
+ var SyntaxKind;
45
+ (function(SyntaxKind) {
46
+ SyntaxKind[SyntaxKind["OpenBraceToken"] = 1] = "OpenBraceToken";
47
+ SyntaxKind[SyntaxKind["CloseBraceToken"] = 2] = "CloseBraceToken";
48
+ SyntaxKind[SyntaxKind["OpenBracketToken"] = 3] = "OpenBracketToken";
49
+ SyntaxKind[SyntaxKind["CloseBracketToken"] = 4] = "CloseBracketToken";
50
+ SyntaxKind[SyntaxKind["CommaToken"] = 5] = "CommaToken";
51
+ SyntaxKind[SyntaxKind["ColonToken"] = 6] = "ColonToken";
52
+ SyntaxKind[SyntaxKind["NullKeyword"] = 7] = "NullKeyword";
53
+ SyntaxKind[SyntaxKind["TrueKeyword"] = 8] = "TrueKeyword";
54
+ SyntaxKind[SyntaxKind["FalseKeyword"] = 9] = "FalseKeyword";
55
+ SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral";
56
+ SyntaxKind[SyntaxKind["NumericLiteral"] = 11] = "NumericLiteral";
57
+ SyntaxKind[SyntaxKind["LineCommentTrivia"] = 12] = "LineCommentTrivia";
58
+ SyntaxKind[SyntaxKind["BlockCommentTrivia"] = 13] = "BlockCommentTrivia";
59
+ SyntaxKind[SyntaxKind["LineBreakTrivia"] = 14] = "LineBreakTrivia";
60
+ SyntaxKind[SyntaxKind["Trivia"] = 15] = "Trivia";
61
+ SyntaxKind[SyntaxKind["Unknown"] = 16] = "Unknown";
62
+ SyntaxKind[SyntaxKind["EOF"] = 17] = "EOF";
63
+ })(SyntaxKind || (exports$1.SyntaxKind = SyntaxKind = {}));
64
+ /**
65
+ * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
66
+ */
67
+ exports$1.getLocation = parser.getLocation;
68
+ /**
69
+ * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
70
+ * Therefore, always check the errors list to find out if the input was valid.
71
+ */
72
+ exports$1.parse = parser.parse;
73
+ /**
74
+ * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
75
+ */
76
+ exports$1.parseTree = parser.parseTree;
77
+ /**
78
+ * Finds the node at the given path in a JSON DOM.
79
+ */
80
+ exports$1.findNodeAtLocation = parser.findNodeAtLocation;
81
+ /**
82
+ * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
83
+ */
84
+ exports$1.findNodeAtOffset = parser.findNodeAtOffset;
85
+ /**
86
+ * Gets the JSON path of the given JSON DOM node
87
+ */
88
+ exports$1.getNodePath = parser.getNodePath;
89
+ /**
90
+ * Evaluates the JavaScript object of the given JSON DOM node
91
+ */
92
+ exports$1.getNodeValue = parser.getNodeValue;
93
+ /**
94
+ * Parses the given text and invokes the visitor functions for each object, array and literal reached.
95
+ */
96
+ exports$1.visit = parser.visit;
97
+ /**
98
+ * Takes JSON with JavaScript-style comments and remove
99
+ * them. Optionally replaces every none-newline character
100
+ * of comments with a replaceCharacter
101
+ */
102
+ exports$1.stripComments = parser.stripComments;
103
+ var ParseErrorCode;
104
+ (function(ParseErrorCode) {
105
+ ParseErrorCode[ParseErrorCode["InvalidSymbol"] = 1] = "InvalidSymbol";
106
+ ParseErrorCode[ParseErrorCode["InvalidNumberFormat"] = 2] = "InvalidNumberFormat";
107
+ ParseErrorCode[ParseErrorCode["PropertyNameExpected"] = 3] = "PropertyNameExpected";
108
+ ParseErrorCode[ParseErrorCode["ValueExpected"] = 4] = "ValueExpected";
109
+ ParseErrorCode[ParseErrorCode["ColonExpected"] = 5] = "ColonExpected";
110
+ ParseErrorCode[ParseErrorCode["CommaExpected"] = 6] = "CommaExpected";
111
+ ParseErrorCode[ParseErrorCode["CloseBraceExpected"] = 7] = "CloseBraceExpected";
112
+ ParseErrorCode[ParseErrorCode["CloseBracketExpected"] = 8] = "CloseBracketExpected";
113
+ ParseErrorCode[ParseErrorCode["EndOfFileExpected"] = 9] = "EndOfFileExpected";
114
+ ParseErrorCode[ParseErrorCode["InvalidCommentToken"] = 10] = "InvalidCommentToken";
115
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfComment"] = 11] = "UnexpectedEndOfComment";
116
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfString"] = 12] = "UnexpectedEndOfString";
117
+ ParseErrorCode[ParseErrorCode["UnexpectedEndOfNumber"] = 13] = "UnexpectedEndOfNumber";
118
+ ParseErrorCode[ParseErrorCode["InvalidUnicode"] = 14] = "InvalidUnicode";
119
+ ParseErrorCode[ParseErrorCode["InvalidEscapeCharacter"] = 15] = "InvalidEscapeCharacter";
120
+ ParseErrorCode[ParseErrorCode["InvalidCharacter"] = 16] = "InvalidCharacter";
121
+ })(ParseErrorCode || (exports$1.ParseErrorCode = ParseErrorCode = {}));
122
+ function printParseErrorCode(code) {
123
+ switch (code) {
124
+ case 1: return "InvalidSymbol";
125
+ case 2: return "InvalidNumberFormat";
126
+ case 3: return "PropertyNameExpected";
127
+ case 4: return "ValueExpected";
128
+ case 5: return "ColonExpected";
129
+ case 6: return "CommaExpected";
130
+ case 7: return "CloseBraceExpected";
131
+ case 8: return "CloseBracketExpected";
132
+ case 9: return "EndOfFileExpected";
133
+ case 10: return "InvalidCommentToken";
134
+ case 11: return "UnexpectedEndOfComment";
135
+ case 12: return "UnexpectedEndOfString";
136
+ case 13: return "UnexpectedEndOfNumber";
137
+ case 14: return "InvalidUnicode";
138
+ case 15: return "InvalidEscapeCharacter";
139
+ case 16: return "InvalidCharacter";
140
+ }
141
+ return "<unknown ParseErrorCode>";
142
+ }
143
+ exports$1.printParseErrorCode = printParseErrorCode;
144
+ /**
145
+ * Computes the edit operations needed to format a JSON document.
146
+ *
147
+ * @param documentText The input text
148
+ * @param range The range to format or `undefined` to format the full content
149
+ * @param options The formatting options
150
+ * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.
151
+ * To apply the edit operations to the input, use {@linkcode applyEdits}.
152
+ */
153
+ function format(documentText, range, options) {
154
+ return formatter.format(documentText, range, options);
155
+ }
156
+ exports$1.format = format;
157
+ /**
158
+ * Computes the edit operations needed to modify a value in the JSON document.
159
+ *
160
+ * @param documentText The input text
161
+ * @param path The path of the value to change. The path represents either to the document root, a property or an array item.
162
+ * If the path points to an non-existing property or item, it will be created.
163
+ * @param value The new value for the specified property or item. If the value is undefined,
164
+ * the property or item will be removed.
165
+ * @param options Options
166
+ * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.
167
+ * To apply the edit operations to the input, use {@linkcode applyEdits}.
168
+ */
169
+ function modify(text, path, value, options) {
170
+ return edit.setProperty(text, path, value, options);
171
+ }
172
+ exports$1.modify = modify;
173
+ /**
174
+ * Applies edits to an input string.
175
+ * @param text The input text
176
+ * @param edits Edit operations following the format described in {@linkcode EditResult}.
177
+ * @returns The text with the applied edits.
178
+ * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.
179
+ */
180
+ function applyEdits(text, edits) {
181
+ let sortedEdits = edits.slice(0).sort((a, b) => {
182
+ const diff = a.offset - b.offset;
183
+ if (diff === 0) return a.length - b.length;
184
+ return diff;
185
+ });
186
+ let lastModifiedOffset = text.length;
187
+ for (let i = sortedEdits.length - 1; i >= 0; i--) {
188
+ let e = sortedEdits[i];
189
+ if (e.offset + e.length <= lastModifiedOffset) text = edit.applyEdit(text, e);
190
+ else throw new Error("Overlapping edit");
191
+ lastModifiedOffset = e.offset;
192
+ }
193
+ return text;
194
+ }
195
+ exports$1.applyEdits = applyEdits;
196
+ });
197
+ })))();
198
+ function parseJsonObject(text, path) {
199
+ const errors = [];
200
+ const data = (0, import_main.parse)(text, errors, { allowTrailingComma: true });
201
+ if (errors.length > 0) {
202
+ const details = errors.map((e) => `${(0, import_main.printParseErrorCode)(e.error)} at offset ${e.offset}`).join("; ");
203
+ throw new Error(`Cannot parse ${path}: ${details}`);
204
+ }
205
+ if (typeof data !== "object" || data === null || Array.isArray(data)) throw new Error(`Cannot parse ${path}: expected a JSON object`);
206
+ return data;
207
+ }
208
+ function detectIndent(text) {
209
+ const firstProp = (0, import_main.parseTree)(text)?.children?.[0]?.children?.[0];
210
+ const lineStart = firstProp ? text.lastIndexOf("\n", firstProp.offset) + 1 : -1;
211
+ const leading = firstProp ? text.slice(lineStart, firstProp.offset) : "";
212
+ const indent = /^[ \t]+$/.test(leading) ? leading : " ";
213
+ return {
214
+ eol: text.includes("\r\n") ? "\r\n" : "\n",
215
+ insertSpaces: !indent.startsWith(" "),
216
+ tabSize: indent.startsWith(" ") ? 1 : indent.length
217
+ };
218
+ }
219
+ //#endregion
220
+ //#region ../internal/src/init-generator.ts
221
+ function readJson(tree, path) {
222
+ if (!tree.exists(path)) return null;
223
+ const text = tree.read(path, "utf8");
224
+ if (text == null) return null;
225
+ return parseJsonObject(text, path);
226
+ }
227
+ /**
228
+ * Registers `plugin` in nx.json as `{ plugin, options: {} }`, preserving
229
+ * JSONC comments and the file's own indentation. Dedupes string, tuple,
230
+ * and object plugin forms; creates nx.json when missing.
231
+ */
232
+ function registerPlugin(tree, pluginPath) {
233
+ const text = tree.exists("nx.json") ? tree.read("nx.json", "utf8") : null;
234
+ const nxJson = text == null ? {} : parseJsonObject(text, "nx.json");
235
+ const plugins = Array.isArray(nxJson.plugins) ? nxJson.plugins : [];
236
+ if (plugins.some((entry) => typeof entry === "string" && entry === pluginPath || Array.isArray(entry) && entry[0] === pluginPath || typeof entry === "object" && entry !== null && !Array.isArray(entry) && entry.plugin === pluginPath)) return;
237
+ const entry = {
238
+ options: {},
239
+ plugin: pluginPath
240
+ };
241
+ if (text == null) {
242
+ tree.write("nx.json", `${JSON.stringify({ plugins: [entry] }, null, 2)}\n`);
243
+ return;
244
+ }
245
+ const formattingOptions = detectIndent(text);
246
+ const updated = (0, import_main.applyEdits)(text, (0, import_main.modify)(text, Array.isArray(nxJson.plugins) ? ["plugins", plugins.length] : ["plugins"], Array.isArray(nxJson.plugins) ? entry : [entry], {
247
+ formattingOptions,
248
+ isArrayInsertion: true
249
+ }));
250
+ tree.write("nx.json", updated);
251
+ }
252
+ /** Nx names the root project from project.json, then nx.json, then package.json. */
253
+ function resolveRootProjectName(tree) {
254
+ for (const path of [
255
+ "project.json",
256
+ "nx.json",
257
+ "package.json"
258
+ ]) {
259
+ const name = readJson(tree, path)?.name;
260
+ if (typeof name === "string" && name) return name;
261
+ }
262
+ }
263
+ /**
264
+ * Returns a GeneratorCallback that installs `deps` as devDependencies in the
265
+ * consumer's package.json, skipping deps already declared in dependencies or
266
+ * devDependencies. Returns a no-op callback when nothing is missing.
267
+ */
268
+ function installPeerDeps(tree, deps) {
269
+ const pkg = readJson(tree, "package.json") ?? {};
270
+ const existing = {
271
+ ...pkg.dependencies,
272
+ ...pkg.devDependencies
273
+ };
274
+ const missing = {};
275
+ for (const [name, range] of Object.entries(deps)) if (!(name in existing)) missing[name] = range;
276
+ if (Object.keys(missing).length === 0) return () => {};
277
+ return addDependenciesToPackageJson(tree, {}, missing);
278
+ }
279
+ //#endregion
280
+ //#region src/generators/init/generator.ts
281
+ const PEER_DEPS = { "@playwright/test": "^1.40.0" };
282
+ const DEFAULT_PLUGIN_PATH = "@nx-devkit/playwright";
283
+ async function initGenerator(tree, options = {}) {
284
+ const pluginPath = options.pluginPath || DEFAULT_PLUGIN_PATH;
285
+ const projectName = resolveRootProjectName(tree) ?? "{root-project}";
286
+ registerPlugin(tree, pluginPath);
287
+ const installDeps = installPeerDeps(tree, PEER_DEPS);
288
+ const checklist = [
289
+ `1. The plugin is registered (${pluginPath}) — projects containing a playwright config now have playwright targets.`,
290
+ "2. Inspect inferred targets:",
291
+ " bunx nx show projects",
292
+ `3. Run a target: bunx nx run ${projectName}:e2e`
293
+ ];
294
+ for (const line of checklist) console.log(line);
295
+ await formatFiles(tree);
296
+ return () => installDeps();
297
+ }
298
+ //#endregion
299
+ export { initGenerator as default, initGenerator };
300
+
301
+ //# sourceMappingURL=generator.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.mjs","names":["exports"],"sources":["../../../../../node_modules/.bun/jsonc-parser@3.3.1/node_modules/jsonc-parser/lib/umd/main.js","../../../../internal/src/jsonc.ts","../../../../internal/src/init-generator.ts","../../../src/generators/init/generator.ts"],"sourcesContent":["(function (factory) {\n if (typeof module === \"object\" && typeof module.exports === \"object\") {\n var v = factory(require, exports);\n if (v !== undefined) module.exports = v;\n }\n else if (typeof define === \"function\" && define.amd) {\n define([\"require\", \"exports\", \"./impl/format\", \"./impl/edit\", \"./impl/scanner\", \"./impl/parser\"], factory);\n }\n})(function (require, exports) {\n /*---------------------------------------------------------------------------------------------\n * Copyright (c) Microsoft Corporation. All rights reserved.\n * Licensed under the MIT License. See License.txt in the project root for license information.\n *--------------------------------------------------------------------------------------------*/\n 'use strict';\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.applyEdits = exports.modify = exports.format = exports.printParseErrorCode = exports.ParseErrorCode = exports.stripComments = exports.visit = exports.getNodeValue = exports.getNodePath = exports.findNodeAtOffset = exports.findNodeAtLocation = exports.parseTree = exports.parse = exports.getLocation = exports.SyntaxKind = exports.ScanError = exports.createScanner = void 0;\n const formatter = require(\"./impl/format\");\n const edit = require(\"./impl/edit\");\n const scanner = require(\"./impl/scanner\");\n const parser = require(\"./impl/parser\");\n /**\n * Creates a JSON scanner on the given text.\n * If ignoreTrivia is set, whitespaces or comments are ignored.\n */\n exports.createScanner = scanner.createScanner;\n var ScanError;\n (function (ScanError) {\n ScanError[ScanError[\"None\"] = 0] = \"None\";\n ScanError[ScanError[\"UnexpectedEndOfComment\"] = 1] = \"UnexpectedEndOfComment\";\n ScanError[ScanError[\"UnexpectedEndOfString\"] = 2] = \"UnexpectedEndOfString\";\n ScanError[ScanError[\"UnexpectedEndOfNumber\"] = 3] = \"UnexpectedEndOfNumber\";\n ScanError[ScanError[\"InvalidUnicode\"] = 4] = \"InvalidUnicode\";\n ScanError[ScanError[\"InvalidEscapeCharacter\"] = 5] = \"InvalidEscapeCharacter\";\n ScanError[ScanError[\"InvalidCharacter\"] = 6] = \"InvalidCharacter\";\n })(ScanError || (exports.ScanError = ScanError = {}));\n var SyntaxKind;\n (function (SyntaxKind) {\n SyntaxKind[SyntaxKind[\"OpenBraceToken\"] = 1] = \"OpenBraceToken\";\n SyntaxKind[SyntaxKind[\"CloseBraceToken\"] = 2] = \"CloseBraceToken\";\n SyntaxKind[SyntaxKind[\"OpenBracketToken\"] = 3] = \"OpenBracketToken\";\n SyntaxKind[SyntaxKind[\"CloseBracketToken\"] = 4] = \"CloseBracketToken\";\n SyntaxKind[SyntaxKind[\"CommaToken\"] = 5] = \"CommaToken\";\n SyntaxKind[SyntaxKind[\"ColonToken\"] = 6] = \"ColonToken\";\n SyntaxKind[SyntaxKind[\"NullKeyword\"] = 7] = \"NullKeyword\";\n SyntaxKind[SyntaxKind[\"TrueKeyword\"] = 8] = \"TrueKeyword\";\n SyntaxKind[SyntaxKind[\"FalseKeyword\"] = 9] = \"FalseKeyword\";\n SyntaxKind[SyntaxKind[\"StringLiteral\"] = 10] = \"StringLiteral\";\n SyntaxKind[SyntaxKind[\"NumericLiteral\"] = 11] = \"NumericLiteral\";\n SyntaxKind[SyntaxKind[\"LineCommentTrivia\"] = 12] = \"LineCommentTrivia\";\n SyntaxKind[SyntaxKind[\"BlockCommentTrivia\"] = 13] = \"BlockCommentTrivia\";\n SyntaxKind[SyntaxKind[\"LineBreakTrivia\"] = 14] = \"LineBreakTrivia\";\n SyntaxKind[SyntaxKind[\"Trivia\"] = 15] = \"Trivia\";\n SyntaxKind[SyntaxKind[\"Unknown\"] = 16] = \"Unknown\";\n SyntaxKind[SyntaxKind[\"EOF\"] = 17] = \"EOF\";\n })(SyntaxKind || (exports.SyntaxKind = SyntaxKind = {}));\n /**\n * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.\n */\n exports.getLocation = parser.getLocation;\n /**\n * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n * Therefore, always check the errors list to find out if the input was valid.\n */\n exports.parse = parser.parse;\n /**\n * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.\n */\n exports.parseTree = parser.parseTree;\n /**\n * Finds the node at the given path in a JSON DOM.\n */\n exports.findNodeAtLocation = parser.findNodeAtLocation;\n /**\n * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.\n */\n exports.findNodeAtOffset = parser.findNodeAtOffset;\n /**\n * Gets the JSON path of the given JSON DOM node\n */\n exports.getNodePath = parser.getNodePath;\n /**\n * Evaluates the JavaScript object of the given JSON DOM node\n */\n exports.getNodeValue = parser.getNodeValue;\n /**\n * Parses the given text and invokes the visitor functions for each object, array and literal reached.\n */\n exports.visit = parser.visit;\n /**\n * Takes JSON with JavaScript-style comments and remove\n * them. Optionally replaces every none-newline character\n * of comments with a replaceCharacter\n */\n exports.stripComments = parser.stripComments;\n var ParseErrorCode;\n (function (ParseErrorCode) {\n ParseErrorCode[ParseErrorCode[\"InvalidSymbol\"] = 1] = \"InvalidSymbol\";\n ParseErrorCode[ParseErrorCode[\"InvalidNumberFormat\"] = 2] = \"InvalidNumberFormat\";\n ParseErrorCode[ParseErrorCode[\"PropertyNameExpected\"] = 3] = \"PropertyNameExpected\";\n ParseErrorCode[ParseErrorCode[\"ValueExpected\"] = 4] = \"ValueExpected\";\n ParseErrorCode[ParseErrorCode[\"ColonExpected\"] = 5] = \"ColonExpected\";\n ParseErrorCode[ParseErrorCode[\"CommaExpected\"] = 6] = \"CommaExpected\";\n ParseErrorCode[ParseErrorCode[\"CloseBraceExpected\"] = 7] = \"CloseBraceExpected\";\n ParseErrorCode[ParseErrorCode[\"CloseBracketExpected\"] = 8] = \"CloseBracketExpected\";\n ParseErrorCode[ParseErrorCode[\"EndOfFileExpected\"] = 9] = \"EndOfFileExpected\";\n ParseErrorCode[ParseErrorCode[\"InvalidCommentToken\"] = 10] = \"InvalidCommentToken\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfComment\"] = 11] = \"UnexpectedEndOfComment\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfString\"] = 12] = \"UnexpectedEndOfString\";\n ParseErrorCode[ParseErrorCode[\"UnexpectedEndOfNumber\"] = 13] = \"UnexpectedEndOfNumber\";\n ParseErrorCode[ParseErrorCode[\"InvalidUnicode\"] = 14] = \"InvalidUnicode\";\n ParseErrorCode[ParseErrorCode[\"InvalidEscapeCharacter\"] = 15] = \"InvalidEscapeCharacter\";\n ParseErrorCode[ParseErrorCode[\"InvalidCharacter\"] = 16] = \"InvalidCharacter\";\n })(ParseErrorCode || (exports.ParseErrorCode = ParseErrorCode = {}));\n function printParseErrorCode(code) {\n switch (code) {\n case 1 /* ParseErrorCode.InvalidSymbol */: return 'InvalidSymbol';\n case 2 /* ParseErrorCode.InvalidNumberFormat */: return 'InvalidNumberFormat';\n case 3 /* ParseErrorCode.PropertyNameExpected */: return 'PropertyNameExpected';\n case 4 /* ParseErrorCode.ValueExpected */: return 'ValueExpected';\n case 5 /* ParseErrorCode.ColonExpected */: return 'ColonExpected';\n case 6 /* ParseErrorCode.CommaExpected */: return 'CommaExpected';\n case 7 /* ParseErrorCode.CloseBraceExpected */: return 'CloseBraceExpected';\n case 8 /* ParseErrorCode.CloseBracketExpected */: return 'CloseBracketExpected';\n case 9 /* ParseErrorCode.EndOfFileExpected */: return 'EndOfFileExpected';\n case 10 /* ParseErrorCode.InvalidCommentToken */: return 'InvalidCommentToken';\n case 11 /* ParseErrorCode.UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';\n case 12 /* ParseErrorCode.UnexpectedEndOfString */: return 'UnexpectedEndOfString';\n case 13 /* ParseErrorCode.UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';\n case 14 /* ParseErrorCode.InvalidUnicode */: return 'InvalidUnicode';\n case 15 /* ParseErrorCode.InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';\n case 16 /* ParseErrorCode.InvalidCharacter */: return 'InvalidCharacter';\n }\n return '<unknown ParseErrorCode>';\n }\n exports.printParseErrorCode = printParseErrorCode;\n /**\n * Computes the edit operations needed to format a JSON document.\n *\n * @param documentText The input text\n * @param range The range to format or `undefined` to format the full content\n * @param options The formatting options\n * @returns The edit operations describing the formatting changes to the original document following the format described in {@linkcode EditResult}.\n * To apply the edit operations to the input, use {@linkcode applyEdits}.\n */\n function format(documentText, range, options) {\n return formatter.format(documentText, range, options);\n }\n exports.format = format;\n /**\n * Computes the edit operations needed to modify a value in the JSON document.\n *\n * @param documentText The input text\n * @param path The path of the value to change. The path represents either to the document root, a property or an array item.\n * If the path points to an non-existing property or item, it will be created.\n * @param value The new value for the specified property or item. If the value is undefined,\n * the property or item will be removed.\n * @param options Options\n * @returns The edit operations describing the changes to the original document, following the format described in {@linkcode EditResult}.\n * To apply the edit operations to the input, use {@linkcode applyEdits}.\n */\n function modify(text, path, value, options) {\n return edit.setProperty(text, path, value, options);\n }\n exports.modify = modify;\n /**\n * Applies edits to an input string.\n * @param text The input text\n * @param edits Edit operations following the format described in {@linkcode EditResult}.\n * @returns The text with the applied edits.\n * @throws An error if the edit operations are not well-formed as described in {@linkcode EditResult}.\n */\n function applyEdits(text, edits) {\n let sortedEdits = edits.slice(0).sort((a, b) => {\n const diff = a.offset - b.offset;\n if (diff === 0) {\n return a.length - b.length;\n }\n return diff;\n });\n let lastModifiedOffset = text.length;\n for (let i = sortedEdits.length - 1; i >= 0; i--) {\n let e = sortedEdits[i];\n if (e.offset + e.length <= lastModifiedOffset) {\n text = edit.applyEdit(text, e);\n }\n else {\n throw new Error('Overlapping edit');\n }\n lastModifiedOffset = e.offset;\n }\n return text;\n }\n exports.applyEdits = applyEdits;\n});\n","import { parse, type ParseError, parseTree, printParseErrorCode } from 'jsonc-parser'\n\nexport function parseJsonObject(text: string, path: string): Record<string, unknown> {\n const errors: ParseError[] = []\n const data = parse(text, errors, { allowTrailingComma: true }) as unknown\n if (errors.length > 0) {\n const details = errors\n .map((e) => `${printParseErrorCode(e.error)} at offset ${e.offset}`)\n .join('; ')\n throw new Error(`Cannot parse ${path}: ${details}`)\n }\n if (typeof data !== 'object' || data === null || Array.isArray(data)) {\n throw new Error(`Cannot parse ${path}: expected a JSON object`)\n }\n return data as Record<string, unknown>\n}\n\nexport function detectIndent(text: string): {\n eol: string\n insertSpaces: boolean\n tabSize: number\n} {\n // Anchor on the first real property of the root object so quoted lines\n // Inside comments cannot skew the detected indentation.\n const root = parseTree(text)\n const firstProp = root?.children?.[0]?.children?.[0]\n const lineStart = firstProp ? text.lastIndexOf('\\n', firstProp.offset) + 1 : -1\n const leading = firstProp ? text.slice(lineStart, firstProp.offset) : ''\n const indent = /^[ \\t]+$/.test(leading) ? leading : ' '\n return {\n eol: text.includes('\\r\\n') ? '\\r\\n' : '\\n',\n insertSpaces: !indent.startsWith('\\t'),\n tabSize: indent.startsWith('\\t') ? 1 : indent.length,\n }\n}\n","import { addDependenciesToPackageJson, type GeneratorCallback, type Tree } from '@nx/devkit'\nimport { applyEdits, modify } from 'jsonc-parser'\nimport { detectIndent, parseJsonObject } from './jsonc.ts'\n\nexport function readJson(tree: Tree, path: string): Record<string, unknown> | null {\n if (!tree.exists(path)) {\n return null\n }\n const text = tree.read(path, 'utf8')\n if (text == null) {\n return null\n }\n return parseJsonObject(text, path)\n}\n\n/**\n * Registers `plugin` in nx.json as `{ plugin, options: {} }`, preserving\n * JSONC comments and the file's own indentation. Dedupes string, tuple,\n * and object plugin forms; creates nx.json when missing.\n */\nexport function registerPlugin(tree: Tree, pluginPath: string): void {\n const text = tree.exists('nx.json') ? tree.read('nx.json', 'utf8') : null\n const nxJson = text == null ? {} : parseJsonObject(text, 'nx.json')\n const plugins = Array.isArray(nxJson.plugins) ? (nxJson.plugins as unknown[]) : []\n const alreadyRegistered = plugins.some(\n (entry) =>\n (typeof entry === 'string' && entry === pluginPath) ||\n (Array.isArray(entry) && entry[0] === pluginPath) ||\n (typeof entry === 'object' &&\n entry !== null &&\n !Array.isArray(entry) &&\n (entry as { plugin?: string }).plugin === pluginPath),\n )\n if (alreadyRegistered) {\n return\n }\n\n const entry = { options: {}, plugin: pluginPath }\n if (text == null) {\n tree.write('nx.json', `${JSON.stringify({ plugins: [entry] }, null, 2)}\\n`)\n return\n }\n const formattingOptions = detectIndent(text)\n const updated = applyEdits(\n text,\n modify(\n text,\n Array.isArray(nxJson.plugins) ? ['plugins', plugins.length] : ['plugins'],\n Array.isArray(nxJson.plugins) ? entry : [entry],\n { formattingOptions, isArrayInsertion: true },\n ),\n )\n tree.write('nx.json', updated)\n}\n\n/** Nx names the root project from project.json, then nx.json, then package.json. */\nexport function resolveRootProjectName(tree: Tree): string | undefined {\n for (const path of ['project.json', 'nx.json', 'package.json']) {\n const name = readJson(tree, path)?.name\n if (typeof name === 'string' && name) {\n return name\n }\n }\n return undefined\n}\n\n/**\n * Returns a GeneratorCallback that installs `deps` as devDependencies in the\n * consumer's package.json, skipping deps already declared in dependencies or\n * devDependencies. Returns a no-op callback when nothing is missing.\n */\nexport function installPeerDeps(tree: Tree, deps: Record<string, string>): GeneratorCallback {\n const pkg = readJson(tree, 'package.json') ?? {}\n const existing = {\n ...(pkg.dependencies as Record<string, string> | undefined),\n ...(pkg.devDependencies as Record<string, string> | undefined),\n }\n const missing: Record<string, string> = {}\n for (const [name, range] of Object.entries(deps)) {\n if (!(name in existing)) missing[name] = range\n }\n if (Object.keys(missing).length === 0) {\n return () => {}\n }\n return addDependenciesToPackageJson(tree, {}, missing)\n}\n","import { formatFiles, type GeneratorCallback, type Tree } from '@nx/devkit'\nimport { installPeerDeps, registerPlugin, resolveRootProjectName } from '@nx-devkit/internal'\n\nexport interface NxPlaywrightInitOptions {\n pluginPath?: string\n}\n\nconst PEER_DEPS: Record<string, string> = { '@playwright/test': '^1.40.0' }\n\nconst DEFAULT_PLUGIN_PATH = '@nx-devkit/playwright'\n\nexport async function initGenerator(\n tree: Tree,\n options: NxPlaywrightInitOptions = {},\n): Promise<GeneratorCallback> {\n const pluginPath = options.pluginPath || DEFAULT_PLUGIN_PATH\n const projectName = resolveRootProjectName(tree) ?? '{root-project}'\n\n registerPlugin(tree, pluginPath)\n const installDeps = installPeerDeps(tree, PEER_DEPS)\n\n const checklist = [\n `1. The plugin is registered (${pluginPath}) — projects containing a playwright config now have playwright targets.`,\n '2. Inspect inferred targets:',\n ' bunx nx show projects',\n `3. Run a target: bunx nx run ${projectName}:e2e`,\n ]\n for (const line of checklist) {\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AAc,GAAG;EAC9D,MAAM,OAAO,SAAS,MAAM,IAAI,CAAC,EAAE;EACnC,IAAI,OAAO,SAAS,YAAY,MAC9B,OAAO;CAEX;AAEF;;;;;;AAOA,SAAgB,gBAAgB,MAAY,MAAiD;CAC3F,MAAM,MAAM,SAAS,MAAM,cAAc,KAAK,CAAC;CAC/C,MAAM,WAAW;EACf,GAAI,IAAI;EACR,GAAI,IAAI;CACV;CACA,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,IAAI,GAC7C,IAAI,EAAE,QAAQ,WAAW,QAAQ,QAAQ;CAE3C,IAAI,OAAO,KAAK,OAAO,CAAC,CAAC,WAAW,GAClC,aAAa,CAAC;CAEhB,OAAO,6BAA6B,MAAM,CAAC,GAAG,OAAO;AACvD;;;AC9EA,MAAM,YAAoC,EAAE,oBAAoB,UAAU;AAE1E,MAAM,sBAAsB;AAE5B,eAAsB,cACpB,MACA,UAAmC,CAAC,GACR;CAC5B,MAAM,aAAa,QAAQ,cAAc;CACzC,MAAM,cAAc,uBAAuB,IAAI,KAAK;CAEpD,eAAe,MAAM,UAAU;CAC/B,MAAM,cAAc,gBAAgB,MAAM,SAAS;CAEnD,MAAM,YAAY;EAChB,gCAAgC,WAAW;EAC3C;EACA;EACA,iCAAiC,YAAY;CAC/C;CACA,KAAK,MAAM,QAAQ,WACjB,QAAQ,IAAI,IAAI;CAElB,MAAM,YAAY,IAAI;CAEtB,aAAa,YAAY;AAC3B"}
@@ -0,0 +1,13 @@
1
+ import { CreateNodesV2 } from "@nx/devkit";
2
+
3
+ //#region src/plugin.d.ts
4
+ interface NxPlaywrightPluginOptions {
5
+ /** Name of the e2e target. Default: "e2e". */
6
+ targetName?: string;
7
+ /** Also infer `<targetName>:ui` and `<targetName>:update-snapshots`. Default: true. */
8
+ extraTargets?: boolean;
9
+ }
10
+ declare const createNodesV2: CreateNodesV2<NxPlaywrightPluginOptions>;
11
+ //#endregion
12
+ export { NxPlaywrightPluginOptions, createNodesV2, createNodesV2 as default };
13
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"mappings":";;;UAGiB,yBAAA;;EAEf,UAAA;EAFwC;EAIxC,YAAY;AAAA;AAAA,cAaD,aAAA,EAAe,aAAa,CAAC,yBAAA"}
@@ -0,0 +1,72 @@
1
+ import { dirname, relative, resolve } from "node:path";
2
+ //#region src/plugin.ts
3
+ const CONFIG_GLOB = "**/playwright.config.{ts,js,mts,mjs,cjs,cts}";
4
+ function shouldSkipDir(projectRoot, workspaceRoot) {
5
+ const rel = relative(workspaceRoot, resolve(workspaceRoot, projectRoot || "."));
6
+ if (rel === "") return false;
7
+ const segments = rel.split(/[\\/]/);
8
+ return segments.includes("..") || segments.includes("node_modules");
9
+ }
10
+ const createNodesV2 = [CONFIG_GLOB, (configFiles, options = {}, context) => {
11
+ const workspaceRoot = context.workspaceRoot;
12
+ const targetName = options.targetName ?? "e2e";
13
+ const extraTargets = options.extraTargets ?? true;
14
+ const byDir = /* @__PURE__ */ new Map();
15
+ for (const configFile of [...configFiles].sort()) {
16
+ const dir = dirname(configFile).replace(/\\/g, "/");
17
+ const key = dir === "." ? "" : dir;
18
+ const list = byDir.get(key) ?? [];
19
+ list.push(configFile);
20
+ byDir.set(key, list);
21
+ }
22
+ const results = [];
23
+ for (const [dir, files] of [...byDir.entries()].sort(([a], [b]) => a.localeCompare(b))) {
24
+ if (shouldSkipDir(dir, workspaceRoot)) continue;
25
+ const sorted = files.toSorted((a, b) => a.localeCompare(b));
26
+ const winner = sorted.at(0);
27
+ if (winner === void 0) continue;
28
+ const prefix = dir ? "{projectRoot}" : "{workspaceRoot}";
29
+ const configInputs = sorted.map((f) => `${prefix}/${dir ? f.slice(dir.length + 1) : f}`);
30
+ const targets = { [targetName]: {
31
+ executor: "nx:run-commands",
32
+ cache: true,
33
+ inputs: [`${prefix}/**/*`, ...configInputs],
34
+ outputs: [
35
+ "{projectRoot}/test-results",
36
+ "{projectRoot}/playwright-report",
37
+ "{projectRoot}/blob-report"
38
+ ],
39
+ options: {
40
+ command: "npx playwright test",
41
+ cwd: "{projectRoot}"
42
+ }
43
+ } };
44
+ if (extraTargets) {
45
+ targets[`${targetName}:ui`] = {
46
+ executor: "nx:run-commands",
47
+ cache: false,
48
+ options: {
49
+ command: "npx playwright test --ui",
50
+ cwd: "{projectRoot}"
51
+ }
52
+ };
53
+ targets[`${targetName}:update-snapshots`] = {
54
+ executor: "nx:run-commands",
55
+ cache: false,
56
+ options: {
57
+ command: "npx playwright test --update-snapshots",
58
+ cwd: "{projectRoot}"
59
+ }
60
+ };
61
+ }
62
+ results.push([winner, { projects: { [dir]: {
63
+ root: dir,
64
+ targets
65
+ } } }]);
66
+ }
67
+ return results;
68
+ }];
69
+ //#endregion
70
+ export { createNodesV2, createNodesV2 as default };
71
+
72
+ //# sourceMappingURL=plugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["import { dirname, relative, resolve } from 'node:path'\nimport type { CreateNodesV2, ProjectConfiguration, TargetConfiguration } from '@nx/devkit'\n\nexport interface NxPlaywrightPluginOptions {\n /** Name of the e2e target. Default: \"e2e\". */\n targetName?: string\n /** Also infer `<targetName>:ui` and `<targetName>:update-snapshots`. Default: true. */\n extraTargets?: boolean\n}\n\n// Playwright auto-discovers playwright.config.* in the working directory.\nconst CONFIG_GLOB = '**/playwright.config.{ts,js,mts,mjs,cjs,cts}'\n\nfunction shouldSkipDir(projectRoot: string, workspaceRoot: string): boolean {\n const rel = relative(workspaceRoot, resolve(workspaceRoot, projectRoot || '.'))\n if (rel === '') return false\n const segments = rel.split(/[\\\\/]/)\n return segments.includes('..') || segments.includes('node_modules')\n}\n\nexport const createNodesV2: CreateNodesV2<NxPlaywrightPluginOptions> = [\n CONFIG_GLOB,\n (configFiles, options = {}, context) => {\n const workspaceRoot = context.workspaceRoot\n const targetName = options.targetName ?? 'e2e'\n const extraTargets = options.extraTargets ?? true\n\n // One target set per owning directory — the lexically first config wins.\n const byDir = new Map<string, string[]>()\n for (const configFile of [...configFiles].sort()) {\n const dir = dirname(configFile).replace(/\\\\/g, '/')\n const key = dir === '.' ? '' : dir\n const list = byDir.get(key) ?? []\n list.push(configFile)\n byDir.set(key, list)\n }\n\n const results: Array<readonly [string, { projects: Record<string, ProjectConfiguration> }]> = []\n for (const [dir, files] of [...byDir.entries()].sort(([a], [b]) => a.localeCompare(b))) {\n if (shouldSkipDir(dir, workspaceRoot)) continue\n\n const sorted = files.toSorted((a, b) => a.localeCompare(b))\n const winner = sorted.at(0)\n if (winner === undefined) continue\n\n const prefix = dir ? '{projectRoot}' : '{workspaceRoot}'\n // Every playwright.config in the dir is an input so edits bust the cache.\n const configInputs = sorted.map((f) => `${prefix}/${dir ? f.slice(dir.length + 1) : f}`)\n\n const targets: Record<string, TargetConfiguration> = {\n [targetName]: {\n executor: 'nx:run-commands',\n cache: true,\n inputs: [`${prefix}/**/*`, ...configInputs],\n outputs: [\n '{projectRoot}/test-results',\n '{projectRoot}/playwright-report',\n '{projectRoot}/blob-report',\n ],\n options: { command: 'npx playwright test', cwd: '{projectRoot}' },\n },\n }\n if (extraTargets) {\n targets[`${targetName}:ui`] = {\n executor: 'nx:run-commands',\n cache: false,\n options: { command: 'npx playwright test --ui', cwd: '{projectRoot}' },\n }\n targets[`${targetName}:update-snapshots`] = {\n executor: 'nx:run-commands',\n cache: false,\n options: { command: 'npx playwright test --update-snapshots', cwd: '{projectRoot}' },\n }\n }\n\n results.push([winner, { projects: { [dir]: { root: dir, targets } } }])\n }\n return results\n },\n]\n\nexport default createNodesV2\n"],"mappings":";;AAWA,MAAM,cAAc;AAEpB,SAAS,cAAc,aAAqB,eAAgC;CAC1E,MAAM,MAAM,SAAS,eAAe,QAAQ,eAAe,eAAe,GAAG,CAAC;CAC9E,IAAI,QAAQ,IAAI,OAAO;C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IAAI,cAAc;GAChB,QAAQ,GAAG,WAAW,QAAQ;IAC5B,UAAU;IACV,OAAO;IACP,SAAS;KAAE,SAAS;KAA4B,KAAK;IAAgB;GACvE;GACA,QAAQ,GAAG,WAAW,sBAAsB;IAC1C,UAAU;IACV,OAAO;IACP,SAAS;KAAE,SAAS;KAA0C,KAAK;IAAgB;GACrF;EACF;EAEA,QAAQ,KAAK,CAAC,QAAQ,EAAE,UAAU,GAAG,MAAM;GAAE,MAAM;GAAK;EAAQ,EAAE,EAAE,CAAC,CAAC;CACxE;CACA,OAAO;AACT,CACF"}
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "generators": {
4
+ "init": {
5
+ "factory": "./dist/generators/init/generator.mjs",
6
+ "schema": "./src/generators/init/schema.json",
7
+ "description": "Registers @nx-devkit/playwright in nx.json plugins."
8
+ }
9
+ }
10
+ }
package/package.json CHANGED
@@ -1,10 +1,8 @@
1
1
  {
2
- "bugs": {
3
- "url": "https://github.com/nx-devkit/nx.ts/issues"
4
- },
5
- "description": "Placeholder for @nx-devkit/playwright published by @nx-devkit/prepare-for-release.",
6
- "homepage": "https://github.com/nx-devkit/nx.ts/tree/main/packages/playwright",
2
+ "name": "@nx-devkit/playwright",
3
+ "version": "0.0.2",
7
4
  "license": "MIT",
5
+ "description": "Nx plugin: playwright.config files infer a cached e2e target (plus e2e:ui and e2e:update-snapshots) — Playwright without project.json.",
8
6
  "keywords": [
9
7
  "nx",
10
8
  "nx-plugin",
@@ -14,16 +12,53 @@
14
12
  "monorepo",
15
13
  "zero-config"
16
14
  ],
17
- "name": "@nx-devkit/playwright",
18
- "publishConfig": {
19
- "access": "public",
20
- "registry": "https://registry.npmjs.org/"
15
+ "private": false,
16
+ "type": "module",
17
+ "main": "./dist/plugin.mjs",
18
+ "module": "./dist/plugin.mjs",
19
+ "types": "./dist/plugin.d.mts",
20
+ "exports": {
21
+ ".": {
22
+ "types": "./dist/plugin.d.mts",
23
+ "default": "./dist/plugin.mjs"
24
+ },
25
+ "./package.json": "./package.json",
26
+ "./generators/init": {
27
+ "types": "./dist/generators/init/generator.d.mts",
28
+ "default": "./dist/generators/init/generator.mjs"
29
+ }
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "generators.json",
34
+ "src/generators/init/schema.json",
35
+ "README.md"
36
+ ],
37
+ "scripts": {
38
+ "build": "tsdown",
39
+ "test": "vitest run"
40
+ },
41
+ "peerDependencies": {
42
+ "@playwright/test": "^1.40.0"
43
+ },
44
+ "devDependencies": {
45
+ "@nx-devkit/internal": "0.0.0",
46
+ "@types/node": "^26.0.0",
47
+ "tsdown": "^0.22.3",
48
+ "typescript": "^6.0.3",
49
+ "vitest": "^4.1.11"
21
50
  },
22
51
  "repository": {
23
52
  "type": "git",
24
53
  "url": "https://github.com/nx-devkit/nx.ts",
25
54
  "directory": "packages/playwright"
26
55
  },
27
- "type": "module",
28
- "version": "0.0.0"
29
- }
56
+ "bugs": {
57
+ "url": "https://github.com/nx-devkit/nx.ts/issues"
58
+ },
59
+ "homepage": "https://github.com/nx-devkit/nx.ts/tree/main/packages/playwright",
60
+ "dependencies": {
61
+ "@nx/devkit": "^22.0.0 || ^23.0.0"
62
+ },
63
+ "generators": "./generators.json"
64
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "https://json-schema.org/schema",
3
+ "type": "object",
4
+ "title": "Init generator",
5
+ "description": "Registers @nx-devkit/playwright in nx.json plugins.",
6
+ "properties": {
7
+ "pluginPath": {
8
+ "type": "string",
9
+ "default": "@nx-devkit/playwright",
10
+ "minLength": 1,
11
+ "description": "Plugin specifier to register (e.g. a local path during development)."
12
+ }
13
+ },
14
+ "additionalProperties": false
15
+ }