create-allwright 0.1.15 → 0.1.17
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 +17 -1
- package/dist/index.js +51 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,9 +15,25 @@ 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` and `Mobile
|
|
18
|
+
- one or more surfaces such as `Web`, `Mobile Android`, and `Mobile iOS`
|
|
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.
|
|
22
22
|
|
|
23
|
+
Select Mobile iOS interactively, or scaffold it non-interactively:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm init allwright@latest ios-tests -- --yes --ios
|
|
27
|
+
```
|
|
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.
|
|
32
|
+
|
|
33
|
+
This writes an `iosApp` starter test and configures the public universal
|
|
34
|
+
Simulator IPA at `https://allwright.dev/Flights-simulator.ipa`. On the first
|
|
35
|
+
test run, core installs the `mobile-ios` plugin and its bundled headless XCTest
|
|
36
|
+
agent, then the fixture downloads and installs the sample app. Users do not
|
|
37
|
+
install either component manually.
|
|
38
|
+
|
|
23
39
|
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
|
@@ -12,6 +12,7 @@ const ALLWRIGHT_VERSION = `^${PACKAGE_VERSION}`;
|
|
|
12
12
|
const SURFACE_OPTIONS = [
|
|
13
13
|
{ label: "Web", value: "web" },
|
|
14
14
|
{ label: "Mobile Android", value: "mobile-android" },
|
|
15
|
+
{ label: "Mobile iOS", value: "mobile-ios" },
|
|
15
16
|
];
|
|
16
17
|
async function main() {
|
|
17
18
|
const options = parseArgs(process.argv.slice(2));
|
|
@@ -95,9 +96,16 @@ function parseArgs(args) {
|
|
|
95
96
|
case "--mobile-android":
|
|
96
97
|
options.surfaces.push("mobile-android");
|
|
97
98
|
break;
|
|
99
|
+
case "--mobile-ios":
|
|
100
|
+
case "--ios":
|
|
101
|
+
options.surfaces.push("mobile-ios");
|
|
102
|
+
break;
|
|
98
103
|
case "--both":
|
|
99
104
|
options.surfaces.push("web", "mobile-android");
|
|
100
105
|
break;
|
|
106
|
+
case "--all":
|
|
107
|
+
options.surfaces.push("web", "mobile-android", "mobile-ios");
|
|
108
|
+
break;
|
|
101
109
|
case "--surface": {
|
|
102
110
|
const value = args[index + 1];
|
|
103
111
|
if (!value) {
|
|
@@ -150,7 +158,11 @@ async function selectSurfaces(interactive) {
|
|
|
150
158
|
message: "Which surfaces would you like to test?",
|
|
151
159
|
options: SURFACE_OPTIONS.map((surface) => ({
|
|
152
160
|
...surface,
|
|
153
|
-
hint: surface.value === "web"
|
|
161
|
+
hint: surface.value === "web"
|
|
162
|
+
? "browser automation"
|
|
163
|
+
: surface.value === "mobile-android"
|
|
164
|
+
? "Android app automation"
|
|
165
|
+
: "iOS Simulator automation",
|
|
154
166
|
})),
|
|
155
167
|
required: true,
|
|
156
168
|
});
|
|
@@ -218,7 +230,10 @@ function buildProjectFiles(input) {
|
|
|
218
230
|
files[`tests/web.spec.${extension}`] = webSpecContents(language);
|
|
219
231
|
}
|
|
220
232
|
if (hasSurface(surfaces, "mobile-android")) {
|
|
221
|
-
files[`tests/mobile.spec.${extension}`] =
|
|
233
|
+
files[`tests/mobile.spec.${extension}`] = androidSpecContents(language);
|
|
234
|
+
}
|
|
235
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
236
|
+
files[`tests/ios.spec.${extension}`] = iosSpecContents(language);
|
|
222
237
|
}
|
|
223
238
|
return files;
|
|
224
239
|
}
|
|
@@ -293,14 +308,22 @@ function allwrightConfigContents(surfaces) {
|
|
|
293
308
|
lines.push(" browser:");
|
|
294
309
|
lines.push(" name: chromium");
|
|
295
310
|
}
|
|
296
|
-
if (hasSurface(surfaces, "mobile-android")) {
|
|
311
|
+
if (hasSurface(surfaces, "mobile-android") || hasSurface(surfaces, "mobile-ios")) {
|
|
297
312
|
lines.push("");
|
|
298
313
|
lines.push("mobile:");
|
|
314
|
+
}
|
|
315
|
+
if (hasSurface(surfaces, "mobile-android")) {
|
|
299
316
|
lines.push(" android:");
|
|
300
317
|
lines.push(" app:");
|
|
301
318
|
lines.push(" id: com.example.airticket");
|
|
302
319
|
lines.push(' binary: "https://allwright.dev/Flights-debug.apk"');
|
|
303
320
|
}
|
|
321
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
322
|
+
lines.push(" ios:");
|
|
323
|
+
lines.push(" app:");
|
|
324
|
+
lines.push(" id: com.sedinqa.Flights");
|
|
325
|
+
lines.push(' binary: "https://allwright.dev/Flights-simulator.ipa"');
|
|
326
|
+
}
|
|
304
327
|
lines.push("");
|
|
305
328
|
lines.push("expect:");
|
|
306
329
|
lines.push(" timeoutMs: 7000");
|
|
@@ -325,7 +348,7 @@ test("opens the Form Inputs page", { timeout: 30_000 }, async ({ page }) => {
|
|
|
325
348
|
});
|
|
326
349
|
`;
|
|
327
350
|
}
|
|
328
|
-
function
|
|
351
|
+
function androidSpecContents(language) {
|
|
329
352
|
const importLine = language === "ts"
|
|
330
353
|
? 'import { test } from "@allwright.dev/vitest";'
|
|
331
354
|
: 'import { test } from "@allwright.dev/vitest";';
|
|
@@ -338,16 +361,32 @@ test("opens the Android demo app and navigates to sign up", { timeout: 180_000 }
|
|
|
338
361
|
});
|
|
339
362
|
`;
|
|
340
363
|
}
|
|
364
|
+
function iosSpecContents(language) {
|
|
365
|
+
const importLine = language === "ts"
|
|
366
|
+
? 'import { expect, test } from "@allwright.dev/vitest";'
|
|
367
|
+
: 'import { expect, test } from "@allwright.dev/vitest";';
|
|
368
|
+
return `${importLine}
|
|
369
|
+
|
|
370
|
+
test("opens the iOS Flights demo app", { timeout: 180_000 }, async ({ iosApp }) => {
|
|
371
|
+
await iosApp.locator("text=Login").click();
|
|
372
|
+
await expect(iosApp.locator("text=Welcome back")).toBeVisible();
|
|
373
|
+
});
|
|
374
|
+
`;
|
|
375
|
+
}
|
|
341
376
|
function generatedReadmeContents(surfaces) {
|
|
342
377
|
const nextSteps = [
|
|
343
378
|
"## Next steps",
|
|
344
379
|
"",
|
|
345
380
|
"1. Run `npm install`.",
|
|
346
|
-
"2. Run `npm test`.",
|
|
347
381
|
];
|
|
382
|
+
let step = 2;
|
|
348
383
|
if (hasSurface(surfaces, "mobile-android")) {
|
|
349
|
-
nextSteps.push(
|
|
384
|
+
nextSteps.push(`${step++}. Start an Android emulator or connect a device with USB debugging enabled.`, `${step++}. Confirm it is visible with \`adb devices -l\`.`, `${step++}. The first Android run downloads and installs the Airticket demo app configured in \`allwright.config.yaml\`.`);
|
|
385
|
+
}
|
|
386
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
387
|
+
nextSteps.push(`${step++}. Start an iOS Simulator.`, `${step++}. The first iOS run downloads and installs the Flights simulator IPA configured in \`allwright.config.yaml\`; no manual app or agent installation is needed.`);
|
|
350
388
|
}
|
|
389
|
+
nextSteps.push(`${step}. Run \`npm test\`.`);
|
|
351
390
|
return `# allwright project
|
|
352
391
|
|
|
353
392
|
Scaffolded with \`npm init allwright\`.
|
|
@@ -376,6 +415,9 @@ function parseSurfaceId(input) {
|
|
|
376
415
|
if (normalized === "mobile" || normalized === "mobile-android" || normalized === "android") {
|
|
377
416
|
return "mobile-android";
|
|
378
417
|
}
|
|
418
|
+
if (normalized === "mobile-ios" || normalized === "ios") {
|
|
419
|
+
return "mobile-ios";
|
|
420
|
+
}
|
|
379
421
|
throw new Error(`Unknown surface: ${input}`);
|
|
380
422
|
}
|
|
381
423
|
function parsePackageManager(input) {
|
|
@@ -459,6 +501,9 @@ function printSummary(absoluteTargetDir, relativeTargetDir, language, surfaces,
|
|
|
459
501
|
if (hasSurface(surfaces, "mobile-android")) {
|
|
460
502
|
console.log(" adb devices -l");
|
|
461
503
|
}
|
|
504
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
505
|
+
console.log(" xcrun simctl list devices available");
|
|
506
|
+
}
|
|
462
507
|
console.log(`${packageManager === "npm" ? " npm test" : ` ${packageManager} test`}`);
|
|
463
508
|
}
|
|
464
509
|
function formatSurfaceLabel(surface) {
|