@xylabs/ts-scripts-yarn3 7.4.24 → 7.4.26

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.
@@ -1,8 +1,48 @@
1
1
  // src/xy/xyParseOptions.ts
2
2
  import yargs from "yargs";
3
3
  import { hideBin } from "yargs/helpers";
4
+
5
+ // src/lib/tryRunLocalScript.ts
6
+ import { spawnSync } from "child_process";
7
+ import { readFileSync } from "fs";
8
+ import PATH from "path";
9
+ import chalk from "chalk";
10
+ function tryRunLocalScript(commandName) {
11
+ if (process.env.XY_LOCAL_SCRIPT === "1") return void 0;
12
+ const rootPkgPath = PATH.resolve(process.cwd(), "package.json");
13
+ let rootPkg;
14
+ try {
15
+ rootPkg = JSON.parse(readFileSync(rootPkgPath, "utf8"));
16
+ } catch {
17
+ return void 0;
18
+ }
19
+ if (!rootPkg.scripts?.[commandName]) return void 0;
20
+ console.log(chalk.blue(`Delegating "${commandName}" to local script`));
21
+ const result = spawnSync("yarn", ["run", commandName], {
22
+ cwd: process.cwd(),
23
+ encoding: "utf8",
24
+ env: {
25
+ FORCE_COLOR: "3",
26
+ ...process.env,
27
+ XY_LOCAL_SCRIPT: "1"
28
+ },
29
+ shell: true,
30
+ stdio: "inherit"
31
+ });
32
+ return result.status ?? 1;
33
+ }
34
+
35
+ // src/xy/xyParseOptions.ts
4
36
  var xyParseOptions = () => {
5
- return yargs(hideBin(process.argv)).scriptName("yarn xy").option("jobs", {
37
+ return yargs(hideBin(process.argv)).scriptName("yarn xy").middleware((argv) => {
38
+ const commandName = argv._[0];
39
+ if (commandName && argv._.length <= 1) {
40
+ const result = tryRunLocalScript(commandName);
41
+ if (result !== void 0) {
42
+ process.exit(result);
43
+ }
44
+ }
45
+ }, true).option("jobs", {
6
46
  alias: "j",
7
47
  default: void 0,
8
48
  description: "Max parallel jobs",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/xy/xyParseOptions.ts"],"sourcesContent":["import type { Argv } from 'yargs'\nimport yargs from 'yargs'\n// eslint-disable-next-line import-x/no-internal-modules\nimport { hideBin } from 'yargs/helpers'\n\nexport const xyParseOptions = (): Argv => {\n return yargs(hideBin(process.argv))\n .scriptName('yarn xy')\n .option('jobs', {\n alias: 'j',\n default: undefined,\n description: 'Max parallel jobs',\n type: 'number',\n })\n .option('verbose', {\n alias: 'v',\n default: false,\n description: 'Run with verbose logging',\n type: 'boolean',\n })\n .option('incremental', {\n alias: 'i',\n default: false,\n description: 'Attempt to perform the action only on changed packages',\n type: 'boolean',\n })\n .option('profile', {\n alias: 'p',\n default: false,\n description: 'Profile action',\n type: 'boolean',\n })\n}\n"],"mappings":";AACA,OAAO,WAAW;AAElB,SAAS,eAAe;AAEjB,IAAM,iBAAiB,MAAY;AACxC,SAAO,MAAM,QAAQ,QAAQ,IAAI,CAAC,EAC/B,WAAW,SAAS,EACpB,OAAO,QAAQ;AAAA,IACd,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,EACR,CAAC,EACA,OAAO,WAAW;AAAA,IACjB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,EACR,CAAC,EACA,OAAO,eAAe;AAAA,IACrB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,EACR,CAAC,EACA,OAAO,WAAW;AAAA,IACjB,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,MAAM;AAAA,EACR,CAAC;AACL;","names":[]}
1
+ {"version":3,"sources":["../../src/xy/xyParseOptions.ts","../../src/lib/tryRunLocalScript.ts"],"sourcesContent":["import type { Argv } from 'yargs'\nimport yargs from 'yargs'\nimport { hideBin } from 'yargs/helpers'\n\nimport { tryRunLocalScript } from '../lib/index.ts'\n\nexport const xyParseOptions = (): Argv => {\n return yargs(hideBin(process.argv))\n .scriptName('yarn xy')\n .middleware((argv) => {\n const commandName = argv._[0] as string\n if (commandName && argv._.length <= 1) {\n const result = tryRunLocalScript(commandName)\n if (result !== undefined) {\n process.exit(result)\n }\n }\n }, true)\n .option('jobs', {\n alias: 'j',\n default: undefined,\n description: 'Max parallel jobs',\n type: 'number',\n })\n .option('verbose', {\n alias: 'v',\n default: false,\n description: 'Run with verbose logging',\n type: 'boolean',\n })\n .option('incremental', {\n alias: 'i',\n default: false,\n description: 'Attempt to perform the action only on changed packages',\n type: 'boolean',\n })\n .option('profile', {\n alias: 'p',\n default: false,\n description: 'Profile action',\n type: 'boolean',\n })\n}\n","import { spawnSync } from 'node:child_process'\nimport { readFileSync } from 'node:fs'\nimport PATH from 'node:path'\n\nimport chalk from 'chalk'\n\n/**\n * Attempts to run a local root package.json script instead of the built-in\n * xy command. Returns the exit code if the override ran, or undefined if\n * no override applies (no matching script or recursion guard).\n */\nexport function tryRunLocalScript(commandName: string): number | undefined {\n // Prevent infinite recursion if the local script calls yarn xy\n if (process.env.XY_LOCAL_SCRIPT === '1') return undefined\n\n // Check if root package.json has a matching script\n const rootPkgPath = PATH.resolve(process.cwd(), 'package.json')\n let rootPkg: { scripts?: Record<string, string> }\n try {\n rootPkg = JSON.parse(readFileSync(rootPkgPath, 'utf8'))\n } catch {\n return undefined\n }\n\n if (!rootPkg.scripts?.[commandName]) return undefined\n\n console.log(chalk.blue(`Delegating \"${commandName}\" to local script`))\n const result = spawnSync('yarn', ['run', commandName], {\n cwd: process.cwd(),\n encoding: 'utf8',\n env: {\n FORCE_COLOR: '3', ...process.env, XY_LOCAL_SCRIPT: '1',\n },\n shell: true,\n stdio: 'inherit',\n })\n return result.status ?? 1\n}\n"],"mappings":";AACA,OAAO,WAAW;AAClB,SAAS,eAAe;;;ACFxB,SAAS,iBAAiB;AAC1B,SAAS,oBAAoB;AAC7B,OAAO,UAAU;AAEjB,OAAO,WAAW;AAOX,SAAS,kBAAkB,aAAyC;AAEzE,MAAI,QAAQ,IAAI,oBAAoB,IAAK,QAAO;AAGhD,QAAM,cAAc,KAAK,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;AAAA,IACb,MAAM;AAAA,EACR,CAAC;AACL;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xylabs/ts-scripts-yarn3",
3
- "version": "7.4.24",
3
+ "version": "7.4.26",
4
4
  "description": "TypeScript project scripts",
5
5
  "keywords": [
6
6
  "xylabs",
@@ -67,37 +67,37 @@
67
67
  "cosmiconfig-typescript-loader": "~6.2.0",
68
68
  "cpy": "~13.2.1",
69
69
  "deepmerge": "~4.3.1",
70
- "dependency-cruiser": "~17.3.8",
71
- "eslint": "^10.0.3",
70
+ "dependency-cruiser": "~17.3.9",
71
+ "eslint": "^10.1.0",
72
72
  "find-up": "~8.0.0",
73
- "get-tsconfig": "~4.13.6",
73
+ "get-tsconfig": "~4.13.7",
74
74
  "glob": "~13.0.6",
75
75
  "license-checker": "~25.0.1",
76
76
  "parse-git-config": "~3.0.0",
77
77
  "picomatch": "~4.0.3",
78
78
  "publint": "~0.3.18",
79
- "rollup": "~4.59.0",
80
- "rollup-plugin-dts": "~6.3.0",
79
+ "rollup": "~4.60.0",
80
+ "rollup-plugin-dts": "~6.4.1",
81
81
  "rollup-plugin-node-externals": "~8.1.2",
82
82
  "sort-package-json": "~3.6.1",
83
83
  "tsc-prog": "~2.3.0",
84
84
  "tsup": "~8.5.1",
85
- "typedoc": "~0.28.17",
85
+ "typedoc": "~0.28.18",
86
86
  "types-package-json": "~2.0.39",
87
87
  "yargs": "~18.0.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@types/eslint": "~9.6.1",
91
91
  "@types/license-checker": "~25.0.6",
92
- "@types/node": "~25.4.0",
92
+ "@types/node": "~25.5.0",
93
93
  "@types/parse-git-config": "~3.0.4",
94
94
  "@types/picomatch": "~4.0.2",
95
95
  "@types/yargs": "~17.0.35",
96
- "@xylabs/tsconfig": "~7.4.24",
97
- "esbuild": "0.27.3",
96
+ "@xylabs/tsconfig": "~7.4.26",
97
+ "esbuild": "0.27.4",
98
98
  "types-package-json": "~2.0.39",
99
- "typescript": "~5.9.3",
100
- "vitest": "^4.0.18"
99
+ "typescript": "^5.9.3",
100
+ "vitest": "^4.1.1"
101
101
  },
102
102
  "peerDependencies": {
103
103
  "typescript": "~5"
@@ -104,7 +104,7 @@ export default defineConfig({
104
104
  })
105
105
  ```
106
106
  ### `packages/e2e/pages/BasePage.ts`
107
- The `goto` base method navigates and waits for `networkidle`. Subclasses override `goto()` with
107
+ The `goto` base method navigates and waits for `domcontentloaded`. Subclasses override `goto()` with
108
108
  no arguments and call `super.goto('/<path>')`.
109
109
  ```typescript
110
110
  import type { Page } from '@playwright/test'
@@ -115,7 +115,7 @@ export class BasePage {
115
115
  }
116
116
  async goto(path: string): Promise<void> {
117
117
  await this.page.goto(path)
118
- await this.page.waitForLoadState('networkidle')
118
+ await this.page.waitForLoadState('domcontentloaded')
119
119
  }
120
120
  }
121
121
  ```
@@ -180,17 +180,31 @@ into `packages/e2e`. Use the e2e package name you derived in Step 1.
180
180
  ```
181
181
  Only add scripts that don't already exist.
182
182
  ---
183
- ## Step 4 — Install Playwright browsers and CLI tool
183
+ ## Step 4 — Update root `.gitignore`
184
+ Playwright generates several output directories that should never be committed. Read the root
185
+ `.gitignore` and append the following block **only if the entries are not already present**:
186
+ ```gitignore
187
+ # Playwright
188
+ /packages/e2e/test-results/
189
+ /packages/e2e/playwright-report/
190
+ /packages/e2e/blob-report/
191
+ /packages/e2e/.playwright/
192
+ ```
193
+ Do not create a new `.gitignore` if one doesn't exist — if there is no root `.gitignore`, skip
194
+ this step and note it to the user.
195
+
196
+ ---
197
+ ## Step 5 — Install Playwright browsers and CLI tool
184
198
  After scaffolding, run the following two commands via the Bash tool:
185
199
 
186
- **4a — Install browser binaries:**
200
+ **5a — Install browser binaries:**
187
201
  ```bash
188
202
  yarn workspace <derived-e2e-name> playwright install
189
203
  ```
190
204
  This downloads the Chromium, Firefox, and WebKit browser binaries. Without this step the tests
191
205
  will fail immediately with a "browser not found" error.
192
206
 
193
- **4b — Install the `@playwright/cli` package and its skills:**
207
+ **5b — Install the `@playwright/cli` package and its skills:**
194
208
  ```bash
195
209
  yarn workspace <derived-e2e-name> add @playwright/cli@latest && yarn workspace <derived-e2e-name> playwright-cli install --skills
196
210
  ```
@@ -204,7 +218,6 @@ the setup.
204
218
  ---
205
219
  ## Conventions to preserve
206
220
  - All files use ESM (`import`/`export`), never CommonJS.
207
- - Import paths include the `.js` extension (e.g. `'./BasePage.js'`) — required for ESM + `moduleResolution: bundler`.
208
221
  - Playwright bracket notation for env vars: `process.env['CI']`, not `process.env.CI` — avoids TypeScript strict-mode complaints.
209
222
  - `strict: true` in `tsconfig.json`.
210
223
  - No `dist/` output — `noEmit: true` because Playwright compiles on the fly via its own ESM loader.