create-allwright 0.1.21 → 0.1.22

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 (3) hide show
  1. package/README.md +17 -4
  2. package/dist/index.js +44 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -15,7 +15,7 @@ npm create allwright@latest
15
15
  The initializer prompts for:
16
16
 
17
17
  - `TypeScript` or `JavaScript`
18
- - one or more surfaces such as `Web`, `Mobile Android`, and `Mobile iOS`
18
+ - one or more surfaces such as `Web`, `Mobile Android`, `Mobile iOS`, and `Desktop macOS`
19
19
  - an optional target directory
20
20
 
21
21
  It scaffolds a Node project with `package.json`, Vitest config, shared allwright config, starter tests, and a short README for the generated app.
@@ -26,9 +26,16 @@ Select Mobile iOS interactively, or scaffold it non-interactively:
26
26
  npm init allwright@latest ios-tests -- --yes --ios
27
27
  ```
28
28
 
29
- Use `--all` to scaffold Web, Mobile Android, and Mobile iOS together. The
30
- repeatable `--surface` flag supports the ids `web`, `mobile-android`, and
31
- `mobile-ios` for explicit combinations.
29
+ Select Desktop macOS interactively, or scaffold a `macosApp` project
30
+ non-interactively:
31
+
32
+ ```bash
33
+ npm init allwright@latest macos-tests -- --yes --macos
34
+ ```
35
+
36
+ Use `--all` to scaffold Web, Mobile Android, Mobile iOS, and Desktop macOS
37
+ together. The repeatable `--surface` flag supports the ids `web`,
38
+ `mobile-android`, `mobile-ios`, and `desktop-mac` for explicit combinations.
32
39
 
33
40
  This writes an `iosApp` starter test and configures the public universal
34
41
  Simulator IPA at `https://allwright.dev/Flights-simulator.ipa`. On the first
@@ -36,4 +43,10 @@ test run, core installs the `mobile-ios` plugin and its bundled headless XCTest
36
43
  agent, then the fixture downloads and installs the sample app. Users do not
37
44
  install either component manually.
38
45
 
46
+ The Desktop macOS starter configures the installed Calculator app and writes a
47
+ lazy `macosApp` screenshot test. Its first run installs `desktop-mac`, starts a
48
+ locally signed copy of the bundled XCUITest runner, and launches Calculator.
49
+ It requires macOS 14 or newer, Xcode, and UI Automation permission for the
50
+ process running Xcode.
51
+
39
52
  Dependencies are installed automatically with the package manager that ran the initializer. Existing lockfiles take precedence; use `--package-manager npm|yarn|pnpm|bun` to override detection, or `--no-install` to scaffold without installing.
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ const SURFACE_OPTIONS = [
13
13
  { label: "Web", value: "web" },
14
14
  { label: "Mobile Android", value: "mobile-android" },
15
15
  { label: "Mobile iOS", value: "mobile-ios" },
16
+ { label: "Desktop macOS", value: "desktop-mac" },
16
17
  ];
17
18
  async function main() {
18
19
  const options = parseArgs(process.argv.slice(2));
@@ -100,11 +101,16 @@ function parseArgs(args) {
100
101
  case "--ios":
101
102
  options.surfaces.push("mobile-ios");
102
103
  break;
104
+ case "--desktop-mac":
105
+ case "--macos":
106
+ case "--mac":
107
+ options.surfaces.push("desktop-mac");
108
+ break;
103
109
  case "--both":
104
110
  options.surfaces.push("web", "mobile-android");
105
111
  break;
106
112
  case "--all":
107
- options.surfaces.push("web", "mobile-android", "mobile-ios");
113
+ options.surfaces.push("web", "mobile-android", "mobile-ios", "desktop-mac");
108
114
  break;
109
115
  case "--surface": {
110
116
  const value = args[index + 1];
@@ -162,7 +168,9 @@ async function selectSurfaces(interactive) {
162
168
  ? "browser automation"
163
169
  : surface.value === "mobile-android"
164
170
  ? "Android app automation"
165
- : "iOS app automation",
171
+ : surface.value === "mobile-ios"
172
+ ? "iOS app automation"
173
+ : "native macOS app automation",
166
174
  })),
167
175
  required: true,
168
176
  });
@@ -235,6 +243,9 @@ function buildProjectFiles(input) {
235
243
  if (hasSurface(surfaces, "mobile-ios")) {
236
244
  files[`tests/ios.spec.${extension}`] = iosSpecContents(language);
237
245
  }
246
+ if (hasSurface(surfaces, "desktop-mac")) {
247
+ files[`tests/macos.spec.${extension}`] = macosSpecContents(language);
248
+ }
238
249
  return files;
239
250
  }
240
251
  function packageJsonContents(packageName, language) {
@@ -324,6 +335,13 @@ function allwrightConfigContents(surfaces) {
324
335
  lines.push(" id: com.sedinqa.Flights");
325
336
  lines.push(' binary: "https://allwright.dev/Flights-simulator.ipa"');
326
337
  }
338
+ if (hasSurface(surfaces, "desktop-mac")) {
339
+ lines.push("");
340
+ lines.push("desktop:");
341
+ lines.push(" mac:");
342
+ lines.push(" app:");
343
+ lines.push(" id: com.apple.calculator");
344
+ }
327
345
  lines.push("");
328
346
  lines.push("expect:");
329
347
  lines.push(" timeoutMs: 7000");
@@ -373,6 +391,18 @@ test("opens the iOS Flights demo app", { timeout: 180_000 }, async ({ iosApp })
373
391
  });
374
392
  `;
375
393
  }
394
+ function macosSpecContents(language) {
395
+ const importLine = language === "ts"
396
+ ? 'import { expect, test } from "@allwright.dev/vitest";'
397
+ : 'import { expect, test } from "@allwright.dev/vitest";';
398
+ return `${importLine}
399
+
400
+ test("opens Calculator through the macOS desktop agent", { timeout: 90_000 }, async ({ macosApp }) => {
401
+ const screenshot = await macosApp.screenshot();
402
+ expect(screenshot.byteLength).toBeGreaterThan(0);
403
+ });
404
+ `;
405
+ }
376
406
  function generatedReadmeContents(surfaces) {
377
407
  const nextSteps = [
378
408
  "## Next steps",
@@ -386,6 +416,9 @@ function generatedReadmeContents(surfaces) {
386
416
  if (hasSurface(surfaces, "mobile-ios")) {
387
417
  nextSteps.push(`${step++}. Start an iOS Simulator, or connect a registered physical device with Developer Mode and UI Automation enabled.`, `${step++}. The first Simulator run downloads and installs the Flights IPA configured in \`allwright.config.yaml\`; physical-device apps must use a signed device build. No manual app or agent installation is needed.`);
388
418
  }
419
+ if (hasSurface(surfaces, "desktop-mac")) {
420
+ nextSteps.push(`${step++}. Run the suite on macOS 14 or newer with Xcode installed and UI Automation enabled for the process running Xcode.`, `${step++}. The first macOS run installs the desktop plugin, starts its bundled XCUITest runner, and launches Calculator by bundle identifier.`);
421
+ }
389
422
  nextSteps.push(`${step}. Run \`npm test\`.`);
390
423
  return `# allwright project
391
424
 
@@ -418,6 +451,12 @@ function parseSurfaceId(input) {
418
451
  if (normalized === "mobile-ios" || normalized === "ios") {
419
452
  return "mobile-ios";
420
453
  }
454
+ if (normalized === "desktop-mac" ||
455
+ normalized === "desktop-macos" ||
456
+ normalized === "macos" ||
457
+ normalized === "mac") {
458
+ return "desktop-mac";
459
+ }
421
460
  throw new Error(`Unknown surface: ${input}`);
422
461
  }
423
462
  function parsePackageManager(input) {
@@ -504,6 +543,9 @@ function printSummary(absoluteTargetDir, relativeTargetDir, language, surfaces,
504
543
  if (hasSurface(surfaces, "mobile-ios")) {
505
544
  console.log(" xcrun simctl list devices available");
506
545
  }
546
+ if (hasSurface(surfaces, "desktop-mac")) {
547
+ console.log(" xcodebuild -version");
548
+ }
507
549
  console.log(`${packageManager === "npm" ? " npm test" : ` ${packageManager} test`}`);
508
550
  }
509
551
  function formatSurfaceLabel(surface) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-allwright",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "Create a new allwright test project with npm init allwright.",
5
5
  "license": "MIT",
6
6
  "type": "module",