quiesco 0.6.0 → 0.8.0
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 +2 -2
- package/dist/app-dir.d.ts +13 -0
- package/dist/app-dir.d.ts.map +1 -0
- package/dist/app-dir.js +22 -0
- package/dist/app-dir.js.map +1 -0
- package/dist/cli.d.ts +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +6 -5
- package/dist/cli.js.map +1 -1
- package/dist/commands/build.d.ts +1 -1
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +21 -11
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/doctor.d.ts +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +75 -37
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +91 -16
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +4 -2
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/test.d.ts +2 -2
- package/dist/commands/test.d.ts.map +1 -1
- package/dist/commands/test.js +4 -2
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/ui.d.ts +1 -1
- package/dist/commands/ui.d.ts.map +1 -1
- package/dist/commands/ui.js +4 -2
- package/dist/commands/ui.js.map +1 -1
- package/dist/commands/upgrade.d.ts.map +1 -1
- package/dist/commands/upgrade.js +58 -28
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/context.d.ts +8 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +22 -0
- package/dist/context.js.map +1 -1
- package/dist/dev-server.d.ts.map +1 -1
- package/dist/dev-server.js +4 -2
- package/dist/dev-server.js.map +1 -1
- package/dist/runner.d.ts +15 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +41 -0
- package/dist/runner.js.map +1 -0
- package/dist/setup-steps.d.ts +8 -3
- package/dist/setup-steps.d.ts.map +1 -1
- package/dist/setup-steps.js +18 -8
- package/dist/setup-steps.js.map +1 -1
- package/package.json +2 -2
- package/src/app-dir.ts +26 -0
- package/src/cli.ts +6 -5
- package/src/commands/build.ts +20 -11
- package/src/commands/doctor.ts +76 -38
- package/src/commands/init.ts +101 -15
- package/src/commands/list.ts +4 -2
- package/src/commands/test.ts +5 -3
- package/src/commands/ui.ts +4 -2
- package/src/commands/upgrade.ts +58 -27
- package/src/context.ts +23 -0
- package/src/dev-server.ts +4 -2
- package/src/runner.ts +47 -0
- package/src/setup-steps.ts +20 -8
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ The Quiesco command line.
|
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npm i -D quiesco
|
|
7
|
-
npx quiesco init # set Quiesco up in an Expo project
|
|
7
|
+
npx quiesco init # set Quiesco up in an Expo project (asks for the runner: Vitest, Jest or Cucumber)
|
|
8
8
|
npx quiesco doctor # check tools and project setup, with fixes
|
|
9
|
-
npx quiesco test --platform ios|android|web [--runner
|
|
9
|
+
npx quiesco test --platform ios|android|web [--runner vitest|jest|cucumber] # with a progress bar
|
|
10
10
|
npx quiesco ui --platform ios|android|web # the test UI in the browser (needs @quiesco/ui)
|
|
11
11
|
npx quiesco list # the tests the runner would run, without running them
|
|
12
12
|
npx quiesco tree # print the element tree of the running app
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CliContext } from './context.js';
|
|
2
|
+
/** The option the commands that work on the app take. */
|
|
3
|
+
export declare const APP_DIR_OPTION = "--app-dir";
|
|
4
|
+
/**
|
|
5
|
+
* The context for the app: `ctx` itself when the app is the project directory, else a copy whose `cwd`
|
|
6
|
+
* is the app's directory. `flag` (relative to the working directory) wins over `config.appDir`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function appContext(ctx: CliContext, config: {
|
|
9
|
+
appDir?: string;
|
|
10
|
+
} | null, flag?: string): CliContext;
|
|
11
|
+
/** How a path in the app is shown: relative to the working directory when near it, else absolute. */
|
|
12
|
+
export declare function inApp(ctx: CliContext, app: CliContext, file?: string): string;
|
|
13
|
+
//# sourceMappingURL=app-dir.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-dir.d.ts","sourceRoot":"","sources":["../src/app-dir.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,yDAAyD;AACzD,eAAO,MAAM,cAAc,cAAc,CAAC;AAE1C;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,UAAU,CAGzG;AAED,qGAAqG;AACrG,wBAAgB,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,SAAK,GAAG,MAAM,CAIzE"}
|
package/dist/app-dir.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the Expo app is (issue #54): the test project's directory, or `appDir` in quiesco.config (tests in
|
|
3
|
+
* a package of their own: a monorepo, or `app/` and `e2e/` side by side). `--app-dir` overrides it.
|
|
4
|
+
*/
|
|
5
|
+
import path from 'node:path';
|
|
6
|
+
/** The option the commands that work on the app take. */
|
|
7
|
+
export const APP_DIR_OPTION = '--app-dir';
|
|
8
|
+
/**
|
|
9
|
+
* The context for the app: `ctx` itself when the app is the project directory, else a copy whose `cwd`
|
|
10
|
+
* is the app's directory. `flag` (relative to the working directory) wins over `config.appDir`.
|
|
11
|
+
*/
|
|
12
|
+
export function appContext(ctx, config, flag) {
|
|
13
|
+
const dir = flag !== undefined ? path.resolve(ctx.cwd, flag) : config?.appDir !== undefined ? path.resolve(ctx.cwd, config.appDir) : ctx.cwd;
|
|
14
|
+
return path.resolve(dir) === path.resolve(ctx.cwd) ? ctx : { ...ctx, cwd: dir };
|
|
15
|
+
}
|
|
16
|
+
/** How a path in the app is shown: relative to the working directory when near it, else absolute. */
|
|
17
|
+
export function inApp(ctx, app, file = '') {
|
|
18
|
+
const abs = path.join(app.cwd, file);
|
|
19
|
+
const rel = path.relative(ctx.cwd, abs);
|
|
20
|
+
return rel === '' ? '.' : rel.split(path.sep).filter((p) => p === '..').length > 2 ? abs : rel;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=app-dir.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-dir.js","sourceRoot":"","sources":["../src/app-dir.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B,yDAAyD;AACzD,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe,EAAE,MAAkC,EAAE,IAAa;IAC3F,MAAM,GAAG,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IAC7I,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAClF,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,KAAK,CAAC,GAAe,EAAE,GAAe,EAAE,IAAI,GAAG,EAAE;IAC/D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACrC,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACxC,OAAO,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACjG,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Command dispatch for the `quiesco` binary (requirements.md §6.12). */
|
|
2
2
|
import type { CliContext } from './context.js';
|
|
3
|
-
export declare const HELP = "Usage: quiesco <command> [options]\n\nCommands:\n init Set Quiesco up in this Expo project (dependencies, config plugin, Metro, entry, config, features)\n --platforms ios,android,web --packages <dir> (install from tarballs) --skip-install\n --upgrade: bring a project set up by an older version to this one (packages, config, files)\n --dry-run (list the changes only)\n build Build the app for e2e tests (prebuild + xcodebuild / gradle) into apps.<platform>.binaryPath\n ios|android --force (also when the native inputs did not change)
|
|
3
|
+
export declare const HELP = "Usage: quiesco <command> [options]\n\nCommands:\n init Set Quiesco up in this Expo project (dependencies, config plugin, Metro, entry, config, features)\n --platforms ios,android,web --runner vitest|jest|cucumber (asked when not given; default vitest)\n --packages <dir> (install from tarballs) --skip-install\n --upgrade: bring a project set up by an older version to this one (packages, config, files)\n --dry-run (list the changes only) --app-dir <dir> (the app, when the tests are elsewhere)\n build Build the app for e2e tests (prebuild + xcodebuild / gradle) into apps.<platform>.binaryPath\n ios|android --force (also when the native inputs did not change) --app-dir <dir>\n test Run the tests with the project's runner (or --runner vitest|jest|cucumber); other arguments go to the runner unchanged\n --platform ios|android|web --workers N (N devices in parallel) (quiesco test --help for more)\n ui Open the test UI: run tests from the browser and watch them live (needs @quiesco/ui)\n --platform ios|android|web --runner \u2026 --port N --no-open\n list List the tests the runner would run, without running them\n --runner cucumber|jest|vitest --json\n doctor Check the tools and the project setup\n --platform ios|android|web --app-dir <dir> (the app, when the tests are elsewhere; or appDir in quiesco.config)\n tree Print the element tree of the running app (to find testIDs)\n --launch (boot the device and launch the app first) --json --timeout <ms> --platform \u2026\n devices List the simulators / AVDs Quiesco created for parallel workers\n --prune (shut them down and delete them)\n\nOptions:\n -h, --help Show this help\n -v, --version Show the version";
|
|
4
4
|
export declare function main(argv: readonly string[], ctx?: CliContext): Promise<number>;
|
|
5
5
|
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAUzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAUzE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,eAAO,MAAM,IAAI,21DAyBiB,CAAC;AAEnC,wBAAsB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,GAAE,UAA6B,GAAG,OAAO,CAAC,MAAM,CAAC,CAsCvG"}
|
package/dist/cli.js
CHANGED
|
@@ -12,19 +12,20 @@ export const HELP = `Usage: quiesco <command> [options]
|
|
|
12
12
|
|
|
13
13
|
Commands:
|
|
14
14
|
init Set Quiesco up in this Expo project (dependencies, config plugin, Metro, entry, config, features)
|
|
15
|
-
--platforms ios,android,web --
|
|
15
|
+
--platforms ios,android,web --runner vitest|jest|cucumber (asked when not given; default vitest)
|
|
16
|
+
--packages <dir> (install from tarballs) --skip-install
|
|
16
17
|
--upgrade: bring a project set up by an older version to this one (packages, config, files)
|
|
17
|
-
--dry-run (list the changes only)
|
|
18
|
+
--dry-run (list the changes only) --app-dir <dir> (the app, when the tests are elsewhere)
|
|
18
19
|
build Build the app for e2e tests (prebuild + xcodebuild / gradle) into apps.<platform>.binaryPath
|
|
19
|
-
ios|android --force (also when the native inputs did not change)
|
|
20
|
-
test Run the tests with
|
|
20
|
+
ios|android --force (also when the native inputs did not change) --app-dir <dir>
|
|
21
|
+
test Run the tests with the project's runner (or --runner vitest|jest|cucumber); other arguments go to the runner unchanged
|
|
21
22
|
--platform ios|android|web --workers N (N devices in parallel) (quiesco test --help for more)
|
|
22
23
|
ui Open the test UI: run tests from the browser and watch them live (needs @quiesco/ui)
|
|
23
24
|
--platform ios|android|web --runner … --port N --no-open
|
|
24
25
|
list List the tests the runner would run, without running them
|
|
25
26
|
--runner cucumber|jest|vitest --json
|
|
26
27
|
doctor Check the tools and the project setup
|
|
27
|
-
--platform ios|android|web
|
|
28
|
+
--platform ios|android|web --app-dir <dir> (the app, when the tests are elsewhere; or appDir in quiesco.config)
|
|
28
29
|
tree Print the element tree of the running app (to find testIDs)
|
|
29
30
|
--launch (boot the device and launch the app first) --json --timeout <ms> --platform …
|
|
30
31
|
devices List the simulators / AVDs Quiesco created for parallel workers
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,yEAAyE;AAEzE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,o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AAM;gBACT,OAAO,MAAM,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACtC,KAAK,IAAI;gBACP,OAAO,MAAM,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACpC,KAAK,MAAM;gBACT,OAAO,MAAM,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACtC,KAAK,QAAQ;gBACX,OAAO,MAAM,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACxC,KAAK,MAAM;gBACT,OAAO,MAAM,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACtC,KAAK,SAAS;gBACZ,OAAO,MAAM,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACzC,KAAK,IAAI,CAAC;YACV,KAAK,WAAW;gBACd,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;gBACrB,OAAO,CAAC,CAAC;YACX,KAAK,SAAS,CAAC;YACf,KAAK,IAAI,CAAC;YACV,KAAK,QAAQ,CAAC;YACd,KAAK,MAAM;gBACT,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACd,OAAO,CAAC,CAAC;YACX;gBACE,GAAG,CAAC,GAAG,CAAC,6BAA6B,OAAO,QAAQ,IAAI,EAAE,CAAC,CAAC;gBAC5D,OAAO,CAAC,CAAC;QACb,CAAC;IACH,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,GAAG,CAAC,GAAG,CAAC,WAAW,OAAO,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;QACvD,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC"}
|
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { QuiescoConfig } from '@quiesco/core';
|
|
2
2
|
import type { CliContext } from '../context.js';
|
|
3
|
-
export declare const BUILD_HELP = "Usage: quiesco build ios|android [--force]\n\nBuilds the app for e2e tests (EXPO_PUBLIC_QUIESCO=1: expo prebuild, then xcodebuild / gradle) and writes it\nto apps.<platform>.binaryPath in quiesco.config. A Debug build is skipped when the native inputs (app config,\ndependencies) did not change since the last one; --force builds anyway.";
|
|
3
|
+
export declare const BUILD_HELP = "Usage: quiesco build ios|android [--force] [--app-dir <dir>]\n\nBuilds the app for e2e tests (EXPO_PUBLIC_QUIESCO=1: expo prebuild, then xcodebuild / gradle) and writes it\nto apps.<platform>.binaryPath in quiesco.config. A Debug build is skipped when the native inputs (app config,\ndependencies) did not change since the last one; --force builds anyway. The app is the one in appDir\n(quiesco.config) or --app-dir when the tests are in a package of their own.";
|
|
4
4
|
export interface BuildDeps {
|
|
5
5
|
loadConfig: (cwd: string) => Promise<QuiescoConfig>;
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,eAAO,MAAM,UAAU,kdAKqD,CAAC;AAE7E,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;CACrD;AAMD,iHAAiH;AACjH,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAItH;AAED,mGAAmG;AACnG,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAEtE;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,GAAG,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAe1G;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,GAAE,SAA4B,GAAG,OAAO,CAAC,MAAM,CAAC,CAiFhI"}
|
package/dist/commands/build.js
CHANGED
|
@@ -8,17 +8,21 @@
|
|
|
8
8
|
* A Debug build is skipped when its native inputs (app config, dependencies and their installed versions)
|
|
9
9
|
* did not change since the last build and the binary is still there; `--force` builds anyway. Release builds
|
|
10
10
|
* embed the JS bundle, so they are always built.
|
|
11
|
+
* With `appDir` (or `--app-dir`, issue #54) the app is built in that directory; `binaryPath` stays relative
|
|
12
|
+
* to the working directory (the config's).
|
|
11
13
|
*/
|
|
12
14
|
import { createHash } from 'node:crypto';
|
|
13
15
|
import fs from 'node:fs';
|
|
14
16
|
import path from 'node:path';
|
|
15
17
|
import { loadConfig } from '@quiesco/core';
|
|
18
|
+
import { APP_DIR_OPTION, appContext } from '../app-dir.js';
|
|
16
19
|
import { takeOption } from '../context.js';
|
|
17
|
-
export const BUILD_HELP = `Usage: quiesco build ios|android [--force]
|
|
20
|
+
export const BUILD_HELP = `Usage: quiesco build ios|android [--force] [--app-dir <dir>]
|
|
18
21
|
|
|
19
22
|
Builds the app for e2e tests (EXPO_PUBLIC_QUIESCO=1: expo prebuild, then xcodebuild / gradle) and writes it
|
|
20
23
|
to apps.<platform>.binaryPath in quiesco.config. A Debug build is skipped when the native inputs (app config,
|
|
21
|
-
dependencies) did not change since the last one; --force builds anyway
|
|
24
|
+
dependencies) did not change since the last one; --force builds anyway. The app is the one in appDir
|
|
25
|
+
(quiesco.config) or --app-dir when the tests are in a package of their own.`;
|
|
22
26
|
const defaultBuildDeps = {
|
|
23
27
|
loadConfig: async (cwd) => (await loadConfig({ cwd, worker: { workerIndex: 0, workerCount: 1 } })).config,
|
|
24
28
|
};
|
|
@@ -61,7 +65,8 @@ export async function buildCommand(args, ctx, deps = defaultBuildDeps) {
|
|
|
61
65
|
return 0;
|
|
62
66
|
}
|
|
63
67
|
const force = args.includes('--force');
|
|
64
|
-
const
|
|
68
|
+
const appDirOpt = takeOption(args.filter((a) => a !== '--force'), APP_DIR_OPTION);
|
|
69
|
+
const rest = takeOption(appDirOpt.rest, '--platform');
|
|
65
70
|
const platform = rest.value ?? rest.rest[0];
|
|
66
71
|
if (platform !== 'ios' && platform !== 'android') {
|
|
67
72
|
ctx.err(`quiesco build: choose ios or android (quiesco build ios). The web needs no build: quiesco test starts Metro, or export it with EXPO_PUBLIC_QUIESCO=1 npx expo export --platform web.`);
|
|
@@ -75,6 +80,7 @@ export async function buildCommand(args, ctx, deps = defaultBuildDeps) {
|
|
|
75
80
|
ctx.err(`quiesco build: ${e.message}`);
|
|
76
81
|
return 1;
|
|
77
82
|
}
|
|
83
|
+
const app = appContext(ctx, config, appDirOpt.value);
|
|
78
84
|
const binaryPath = config.apps[platform]?.binaryPath;
|
|
79
85
|
if (binaryPath === undefined) {
|
|
80
86
|
ctx.err(`quiesco build: apps.${platform}.binaryPath is not set in quiesco.config: that is where the build goes (npx quiesco init writes it).`);
|
|
@@ -87,8 +93,8 @@ export async function buildCommand(args, ctx, deps = defaultBuildDeps) {
|
|
|
87
93
|
}
|
|
88
94
|
const release = platform === 'ios' ? !/^debug$/i.test(ios?.configuration ?? '') : androidVariant(binaryPath) === 'release';
|
|
89
95
|
const binary = path.resolve(ctx.cwd, binaryPath);
|
|
90
|
-
const stampFile = path.join(
|
|
91
|
-
const fingerprint = nativeFingerprint(
|
|
96
|
+
const stampFile = path.join(app.cwd, '.expo', 'quiesco', `build-${platform}.json`);
|
|
97
|
+
const fingerprint = nativeFingerprint(app, platform, binaryPath);
|
|
92
98
|
if (!force && !release && ctx.exists(binary)) {
|
|
93
99
|
const stamp = ctx.readFile(stampFile);
|
|
94
100
|
if (stamp !== null && JSON.parse(stamp).fingerprint === fingerprint) {
|
|
@@ -98,18 +104,22 @@ export async function buildCommand(args, ctx, deps = defaultBuildDeps) {
|
|
|
98
104
|
}
|
|
99
105
|
const env = { ...ctx.env, EXPO_PUBLIC_QUIESCO: '1' };
|
|
100
106
|
ctx.out(`quiesco build: expo prebuild --platform ${platform} (EXPO_PUBLIC_QUIESCO=1)`);
|
|
101
|
-
|
|
107
|
+
if (app !== ctx)
|
|
108
|
+
ctx.out(`quiesco build: the app in ${app.cwd}`);
|
|
109
|
+
let code = await ctx.run('npx', ['expo', 'prebuild', '--platform', platform], { cwd: app.cwd, env });
|
|
102
110
|
if (code !== 0)
|
|
103
111
|
return fail(ctx, 'expo prebuild', code);
|
|
104
112
|
if (ios !== null) {
|
|
105
113
|
const workspace = path.join('ios', `${ios.name}.xcworkspace`);
|
|
106
|
-
if (!
|
|
114
|
+
if (!app.exists(path.join(app.cwd, workspace))) {
|
|
107
115
|
ctx.err(`quiesco build: ${workspace} not found after prebuild. The .app name in apps.ios.binaryPath must be the Xcode scheme (expo prebuild names it after expo.name).`);
|
|
108
116
|
return 1;
|
|
109
117
|
}
|
|
110
|
-
|
|
118
|
+
// binaryPath (and so the derived data) is relative to the working directory; xcodebuild runs in the app.
|
|
119
|
+
const derivedData = path.relative(app.cwd, path.resolve(ctx.cwd, ios.derivedData)) || '.';
|
|
120
|
+
const xcode = ['-workspace', workspace, '-scheme', ios.name, '-configuration', ios.configuration, '-sdk', 'iphonesimulator', '-destination', 'generic/platform=iOS Simulator', '-derivedDataPath', derivedData, '-quiet', 'build'];
|
|
111
121
|
ctx.out(`quiesco build: xcodebuild ${xcode.join(' ')}`);
|
|
112
|
-
code = await ctx.run('xcodebuild', xcode, { cwd:
|
|
122
|
+
code = await ctx.run('xcodebuild', xcode, { cwd: app.cwd, env });
|
|
113
123
|
if (code !== 0)
|
|
114
124
|
return fail(ctx, 'xcodebuild', code);
|
|
115
125
|
}
|
|
@@ -118,10 +128,10 @@ export async function buildCommand(args, ctx, deps = defaultBuildDeps) {
|
|
|
118
128
|
const task = `assemble${variant === 'release' ? 'Release' : 'Debug'}`;
|
|
119
129
|
const gradlew = ctx.platform === 'win32' ? 'gradlew.bat' : './gradlew';
|
|
120
130
|
ctx.out(`quiesco build: ${gradlew} ${task} (in android/)`);
|
|
121
|
-
code = await ctx.run(gradlew, [task], { cwd: path.join(
|
|
131
|
+
code = await ctx.run(gradlew, [task], { cwd: path.join(app.cwd, 'android'), env });
|
|
122
132
|
if (code !== 0)
|
|
123
133
|
return fail(ctx, `gradle ${task}`, code);
|
|
124
|
-
const output = path.join(
|
|
134
|
+
const output = path.join(app.cwd, 'android', 'app', 'build', 'outputs', 'apk', variant, `app-${variant}.apk`);
|
|
125
135
|
if (path.resolve(output) !== binary) {
|
|
126
136
|
fs.mkdirSync(path.dirname(binary), { recursive: true });
|
|
127
137
|
fs.copyFileSync(output, binary);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,MAAM,CAAC,MAAM,UAAU,GAAG;;;;;4EAKkD,CAAC;AAM7E,MAAM,gBAAgB,GAAc;IAClC,UAAU,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,UAAU,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,CAAC,E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,CAAC;IACH,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,GAAG,CAAC,GAAG,CAAC,yCAAyC,UAAU,6BAA6B,QAAQ,cAAc,CAAC,CAAC;QAChH,OAAO,CAAC,CAAC;IACX,CAAC;IACD,GAAG,CAAC,SAAS,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;IACzH,GAAG,CAAC,GAAG,CAAC,kBAAkB,UAAU,YAAY,CAAC,CAAC;IAClD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,IAAI,CAAC,GAAe,EAAE,IAAY,EAAE,IAAY;IACvD,GAAG,CAAC,GAAG,CAAC,kBAAkB,IAAI,sBAAsB,IAAI,IAAI,CAAC,CAAC;IAC9D,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/B,CAAC"}
|
|
@@ -15,6 +15,6 @@ export interface DoctorDeps {
|
|
|
15
15
|
/** The entry module's first import / require target, ignoring comments. */
|
|
16
16
|
export declare function firstImport(source: string): string | null;
|
|
17
17
|
export declare const defaultDoctorDeps: DoctorDeps;
|
|
18
|
-
export declare function runChecks(ctx: CliContext, only: CliPlatform | undefined, deps?: DoctorDeps): Promise<CheckResult[]>;
|
|
18
|
+
export declare function runChecks(ctx: CliContext, only: CliPlatform | undefined, deps?: DoctorDeps, appDirFlag?: string): Promise<CheckResult[]>;
|
|
19
19
|
export declare function doctorCommand(args: readonly string[], ctx: CliContext, deps?: DoctorDeps): Promise<number>;
|
|
20
20
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAO7D,+FAA+F;AAC/F,MAAM,MAAM,WAAW,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C;AA4BD,2EAA2E;AAC3E,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAIzD;AA+ZD,eAAO,MAAM,iBAAiB,EAAE,UAQ/B,CAAC;AAEF,wBAAsB,SAAS,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,GAAG,SAAS,EAAE,IAAI,GAAE,UAA8B,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAqDjK;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,GAAE,UAA8B,GAAG,OAAO,CAAC,MAAM,CAAC,CAiBnI"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `quiesco doctor [--platform ios|android|web]` (requirements.md §6.12): check the
|
|
3
|
-
* project's Quiesco setup. Every check says what is wrong and how to fix it; exit code
|
|
4
|
-
* fails (warnings do not fail).
|
|
2
|
+
* `quiesco doctor [--platform ios|android|web] [--app-dir <dir>]` (requirements.md §6.12): check the
|
|
3
|
+
* environment and the project's Quiesco setup. Every check says what is wrong and how to fix it; exit code
|
|
4
|
+
* 1 when a check fails (warnings do not fail). With `appDir` (issue #54) the app's checks run in the app's
|
|
5
|
+
* directory and the test setup's (runner, config, features) in the working directory.
|
|
5
6
|
*/
|
|
6
7
|
import fs from 'node:fs';
|
|
7
8
|
import net from 'node:net';
|
|
8
9
|
import path from 'node:path';
|
|
9
10
|
import { loadConfig, serverPort } from '@quiesco/core';
|
|
11
|
+
import { APP_DIR_OPTION, appContext, inApp } from '../app-dir.js';
|
|
10
12
|
import { PLATFORMS, parsePlatform, takeOption } from '../context.js';
|
|
11
13
|
import { MIN_EXPO_SDK, UPGRADE_SDK_FIX, expoSdk } from '../expo-sdk.js';
|
|
12
14
|
import { CLI_COMMANDS, installedVersion, isQuiescoPackage, scriptCommands } from '../packages.js';
|
|
13
15
|
import { rootSourceFiles } from '../project.js';
|
|
16
|
+
import { RUNNER_PACKAGES, projectRunner } from '../runner.js';
|
|
14
17
|
const MIN_NODE_MAJOR = 24;
|
|
15
18
|
const ICON = { ok: '✅', info: 'ℹ️ ', warn: '⚠️ ', fail: '❌' };
|
|
16
19
|
/** How the fixes for older setups end (issues #34, #35). */
|
|
@@ -54,30 +57,49 @@ function expoCheck(ctx, pkg) {
|
|
|
54
57
|
const detail = `expo ${sdk.version} (SDK ${sdk.sdk}${sdk.installed ? '' : ', not installed'})`;
|
|
55
58
|
return sdk.sdk >= MIN_EXPO_SDK ? { name: 'Expo project', status: 'ok', detail } : { name: 'Expo project', status: 'fail', detail, fix: UPGRADE_SDK_FIX };
|
|
56
59
|
}
|
|
57
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The app (expo, @quiesco/agent, config plugin, Metro, entry) in `app`, the test setup (runner packages,
|
|
62
|
+
* older inits' files) in `ctx`: the same directory unless appDir is set (issue #54).
|
|
63
|
+
*/
|
|
64
|
+
function projectChecks(ctx, app) {
|
|
58
65
|
const results = [];
|
|
59
|
-
const
|
|
66
|
+
const separate = app !== ctx;
|
|
67
|
+
const pkg = readJson(app, path.join(app.cwd, 'package.json'));
|
|
60
68
|
if (pkg === null) {
|
|
61
|
-
return [
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
name: 'project',
|
|
72
|
+
status: 'fail',
|
|
73
|
+
detail: `no package.json in ${app.cwd}`,
|
|
74
|
+
fix: separate ? 'appDir (quiesco.config) or --app-dir must name the Expo app\'s directory.' : 'Run quiesco in the Expo app directory, or set appDir in quiesco.config to where the app is.',
|
|
75
|
+
},
|
|
76
|
+
];
|
|
62
77
|
}
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
const testPkg = separate ? readJson(ctx, path.join(ctx.cwd, 'package.json')) : pkg;
|
|
79
|
+
results.push(expoCheck(app, pkg));
|
|
80
|
+
// The app has the agent; the test project has the runner the commands use without --runner, with
|
|
81
|
+
// Quiesco's integration and the runner itself.
|
|
82
|
+
const runnerPkgs = RUNNER_PACKAGES[projectRunner(ctx)];
|
|
83
|
+
const missing = [
|
|
84
|
+
...(hasDep(pkg, '@quiesco/agent') ? [] : [`@quiesco/agent${separate ? ` (in ${inApp(ctx, app)})` : ''}`]),
|
|
85
|
+
...runnerPkgs.filter((d) => testPkg === null || !hasDep(testPkg, d)),
|
|
86
|
+
];
|
|
65
87
|
results.push(missing.length === 0
|
|
66
|
-
? { name: 'Quiesco packages', status: 'ok', detail: '@quiesco/agent,
|
|
88
|
+
? { name: 'Quiesco packages', status: 'ok', detail: ['@quiesco/agent', ...runnerPkgs].join(', ') }
|
|
67
89
|
: { name: 'Quiesco packages', status: 'fail', detail: `missing ${missing.join(', ')}`, fix: 'Run `npx quiesco init`, or install them.' });
|
|
68
|
-
results.push(...versionChecks(ctx, pkg));
|
|
90
|
+
results.push(...versionChecks(ctx, [{ ctx: app, pkg }, ...(separate && testPkg !== null ? [{ ctx, pkg: testPkg }] : [])]));
|
|
69
91
|
results.push(...legacyChecks(ctx));
|
|
70
|
-
const appJson = readJson(
|
|
92
|
+
const appJson = readJson(app, path.join(app.cwd, 'app.json'));
|
|
71
93
|
const plugins = appJson?.expo?.plugins ?? [];
|
|
72
94
|
const listed = plugins.some((p) => p === '@quiesco/expo-plugin' || (Array.isArray(p) && p[0] === '@quiesco/expo-plugin'));
|
|
73
|
-
const dynamic = ['app.config.ts', 'app.config.js', 'app.config.mjs'].some((f) =>
|
|
95
|
+
const dynamic = ['app.config.ts', 'app.config.js', 'app.config.mjs'].some((f) => app.exists(path.join(app.cwd, f)));
|
|
74
96
|
results.push(listed
|
|
75
97
|
? { name: 'config plugin', status: 'ok', detail: '@quiesco/expo-plugin in app.json' }
|
|
76
98
|
: dynamic
|
|
77
99
|
? { name: 'config plugin', status: 'warn', detail: 'app.config.* found; cannot check its plugins', fix: 'Make sure "@quiesco/expo-plugin" is in plugins (native e2e builds need it).' }
|
|
78
100
|
: { name: 'config plugin', status: 'warn', detail: '@quiesco/expo-plugin is not in app.json plugins', fix: 'Add "@quiesco/expo-plugin" to expo.plugins (needed for iOS / Android e2e builds, not for web).' });
|
|
79
|
-
const metro = ['metro.config.js', 'metro.config.cjs', 'metro.config.mjs', 'metro.config.ts'].map((f) => path.join(
|
|
80
|
-
const metroSrc = metro !== undefined ?
|
|
101
|
+
const metro = ['metro.config.js', 'metro.config.cjs', 'metro.config.mjs', 'metro.config.ts'].map((f) => path.join(app.cwd, f)).find((f) => app.exists(f));
|
|
102
|
+
const metroSrc = metro !== undefined ? app.readFile(metro) : null;
|
|
81
103
|
results.push(metroSrc !== null && metroSrc.includes('withQuiesco')
|
|
82
104
|
? { name: 'Metro', status: 'ok', detail: `${path.basename(metro)} uses withQuiesco()` }
|
|
83
105
|
: {
|
|
@@ -96,8 +118,8 @@ function projectChecks(ctx) {
|
|
|
96
118
|
});
|
|
97
119
|
}
|
|
98
120
|
else {
|
|
99
|
-
const entry = [main, `${main}.ts`, `${main}.tsx`, `${main}.js`].map((f) => path.join(
|
|
100
|
-
const src = entry !== undefined ?
|
|
121
|
+
const entry = [main, `${main}.ts`, `${main}.tsx`, `${main}.js`].map((f) => path.join(app.cwd, f)).find((f) => app.exists(f));
|
|
122
|
+
const src = entry !== undefined ? app.readFile(entry) : null;
|
|
101
123
|
const first = src !== null ? firstImport(src) : null;
|
|
102
124
|
results.push(first === '@quiesco/agent'
|
|
103
125
|
? { name: 'entry file', status: 'ok', detail: `${main} imports @quiesco/agent first` }
|
|
@@ -109,14 +131,17 @@ function projectChecks(ctx) {
|
|
|
109
131
|
}
|
|
110
132
|
/**
|
|
111
133
|
* Issue #17: every Quiesco package in package.json is installed at one version, and every `quiesco <cmd>`
|
|
112
|
-
* in the scripts exists in it.
|
|
134
|
+
* in the scripts exists in it. With appDir (issue #54) the app's and the test project's packages together.
|
|
113
135
|
*/
|
|
114
|
-
function versionChecks(ctx,
|
|
136
|
+
function versionChecks(ctx, projects) {
|
|
115
137
|
const results = [];
|
|
116
|
-
const
|
|
138
|
+
const declared = projects.flatMap((p) => [...new Set([...Object.keys(p.pkg.dependencies ?? {}), ...Object.keys(p.pkg.devDependencies ?? {})])].filter(isQuiescoPackage).map((name) => ({ name, dir: p.ctx })));
|
|
139
|
+
const names = [...new Set(declared.map((d) => d.name))].sort();
|
|
117
140
|
if (names.length === 0)
|
|
118
141
|
return results;
|
|
119
|
-
const installed =
|
|
142
|
+
const installed = declared
|
|
143
|
+
.sort((a, b) => a.name.localeCompare(b.name))
|
|
144
|
+
.map((d) => ({ name: d.dir === ctx ? d.name : `${d.name} (${inApp(ctx, d.dir)})`, version: installedVersion(d.dir, d.name) }));
|
|
120
145
|
const missing = installed.filter((p) => p.version === null).map((p) => p.name);
|
|
121
146
|
const versions = [...new Set(installed.flatMap((p) => (p.version !== null ? [p.version] : [])))];
|
|
122
147
|
const list = installed.map((p) => `${p.name} ${p.version ?? '(not installed)'}`).join(', ');
|
|
@@ -144,7 +169,7 @@ function versionChecks(ctx, pkg) {
|
|
|
144
169
|
fix: "Run the project's own CLI (npx quiesco doctor in the project directory), or upgrade the project with npx quiesco@latest init --upgrade.",
|
|
145
170
|
});
|
|
146
171
|
}
|
|
147
|
-
const unknown = scriptCommands(pkg.scripts).filter((c) => !CLI_COMMANDS.includes(c.command));
|
|
172
|
+
const unknown = projects.flatMap((p) => scriptCommands(p.pkg.scripts)).filter((c) => !CLI_COMMANDS.includes(c.command));
|
|
148
173
|
if (unknown.length > 0) {
|
|
149
174
|
results.push({
|
|
150
175
|
name: 'scripts',
|
|
@@ -217,7 +242,7 @@ function buildScriptChecks(pkg, config) {
|
|
|
217
242
|
* uses) and, when they exist, with the prebuilt Android project and the iOS build. Placeholders left by
|
|
218
243
|
* init fail.
|
|
219
244
|
*/
|
|
220
|
-
async function appIdChecks(ctx, config) {
|
|
245
|
+
async function appIdChecks(ctx, app, config) {
|
|
221
246
|
const { ios, android } = config.apps;
|
|
222
247
|
if (ios === undefined && android === undefined)
|
|
223
248
|
return [];
|
|
@@ -233,13 +258,13 @@ async function appIdChecks(ctx, config) {
|
|
|
233
258
|
},
|
|
234
259
|
];
|
|
235
260
|
}
|
|
236
|
-
const dynamic = DYNAMIC_APP_CONFIGS.find((f) =>
|
|
261
|
+
const dynamic = DYNAMIC_APP_CONFIGS.find((f) => app.exists(path.join(app.cwd, f)));
|
|
237
262
|
const results = [];
|
|
238
263
|
if (dynamic !== undefined) {
|
|
239
264
|
results.push({ name: 'app IDs', status: 'warn', detail: `${dynamic} found; cannot compare the app IDs with it`, fix: 'Make sure apps.ios.bundleId, apps.android.package and devClient.scheme are the values your app config sets.' });
|
|
240
265
|
}
|
|
241
266
|
else {
|
|
242
|
-
const expo = readJson(
|
|
267
|
+
const expo = readJson(app, path.join(app.cwd, 'app.json'))?.expo ?? {};
|
|
243
268
|
const schemes = expo.scheme === undefined ? [] : Array.isArray(expo.scheme) ? expo.scheme : [expo.scheme];
|
|
244
269
|
const problems = [];
|
|
245
270
|
const compare = (what, want, have) => {
|
|
@@ -262,9 +287,9 @@ async function appIdChecks(ctx, config) {
|
|
|
262
287
|
}
|
|
263
288
|
// The builds: an app built before the IDs changed is another app.
|
|
264
289
|
if (android !== undefined) {
|
|
265
|
-
const gradle =
|
|
290
|
+
const gradle = app.readFile(path.join(app.cwd, 'android/app/build.gradle'));
|
|
266
291
|
const built = gradle === null ? undefined : /applicationId\s*(?:=\s*)?['"]([^'"]+)['"]/.exec(gradle)?.[1];
|
|
267
|
-
const manifest =
|
|
292
|
+
const manifest = app.readFile(path.join(app.cwd, 'android/app/src/main/AndroidManifest.xml'));
|
|
268
293
|
const scheme = android.devClient?.scheme;
|
|
269
294
|
const wrong = [];
|
|
270
295
|
if (built !== undefined && built !== android.package)
|
|
@@ -407,7 +432,7 @@ export const defaultDoctorDeps = {
|
|
|
407
432
|
srv.listen(port, () => srv.close(() => resolve(true)));
|
|
408
433
|
}),
|
|
409
434
|
};
|
|
410
|
-
export async function runChecks(ctx, only, deps = defaultDoctorDeps) {
|
|
435
|
+
export async function runChecks(ctx, only, deps = defaultDoctorDeps, appDirFlag) {
|
|
411
436
|
const results = [];
|
|
412
437
|
const major = Number.parseInt(ctx.nodeVersion, 10);
|
|
413
438
|
results.push(major >= MIN_NODE_MAJOR
|
|
@@ -423,17 +448,29 @@ export async function runChecks(ctx, only, deps = defaultDoctorDeps) {
|
|
|
423
448
|
fix: 'Metro started with CI set does not watch files, so code changes do not reach the app under test. Unset it (unset CI) before EXPO_PUBLIC_QUIESCO=1 npx expo start.',
|
|
424
449
|
});
|
|
425
450
|
}
|
|
426
|
-
|
|
427
|
-
results.push(rootCheck(ctx, readJson(ctx, path.join(ctx.cwd, 'package.json'))?.main));
|
|
451
|
+
// The config first: its appDir says where the app is (issue #54).
|
|
428
452
|
let config = null;
|
|
453
|
+
let configError = null;
|
|
429
454
|
try {
|
|
430
455
|
config = await deps.loadConfig(ctx.cwd);
|
|
431
|
-
results.push({ name: 'quiesco.config', status: 'ok', detail: `apps: ${Object.keys(config.apps).join(', ') || 'none'}` });
|
|
432
|
-
results.push(...(await appIdChecks(ctx, config)));
|
|
433
|
-
results.push(...buildScriptChecks(readJson(ctx, path.join(ctx.cwd, 'package.json')), config));
|
|
434
456
|
}
|
|
435
457
|
catch (e) {
|
|
436
|
-
|
|
458
|
+
configError = e.message.split('\n')[0] ?? '';
|
|
459
|
+
}
|
|
460
|
+
const app = appContext(ctx, config, appDirFlag);
|
|
461
|
+
if (app !== ctx)
|
|
462
|
+
results.push({ name: 'app', status: 'ok', detail: `${inApp(ctx, app)} (${appDirFlag !== undefined ? APP_DIR_OPTION : 'appDir'}); the test setup in ${ctx.cwd}` });
|
|
463
|
+
results.push(...projectChecks(ctx, app));
|
|
464
|
+
results.push(rootCheck(app, readJson(app, path.join(app.cwd, 'package.json'))?.main));
|
|
465
|
+
if (config !== null) {
|
|
466
|
+
results.push({ name: 'quiesco.config', status: 'ok', detail: `apps: ${Object.keys(config.apps).join(', ') || 'none'}` });
|
|
467
|
+
results.push(...(await appIdChecks(ctx, app, config)));
|
|
468
|
+
// A script that builds may be in either package.json.
|
|
469
|
+
const scripts = { ...readJson(app, path.join(app.cwd, 'package.json'))?.scripts, ...readJson(ctx, path.join(ctx.cwd, 'package.json'))?.scripts };
|
|
470
|
+
results.push(...buildScriptChecks({ scripts }, config));
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
results.push({ name: 'quiesco.config', status: 'fail', detail: configError ?? '', fix: 'Create quiesco.config.mts (npx quiesco init writes one), in the test project when the app is elsewhere (appDir).' });
|
|
437
474
|
}
|
|
438
475
|
const platforms = only !== undefined ? [only] : PLATFORMS.filter((p) => config?.apps[p] !== undefined);
|
|
439
476
|
for (const p of platforms)
|
|
@@ -447,12 +484,13 @@ export async function runChecks(ctx, only, deps = defaultDoctorDeps) {
|
|
|
447
484
|
return results;
|
|
448
485
|
}
|
|
449
486
|
export async function doctorCommand(args, ctx, deps = defaultDoctorDeps) {
|
|
450
|
-
const { value, rest } = takeOption(args, '--platform');
|
|
451
|
-
|
|
452
|
-
|
|
487
|
+
const { value, rest: afterPlatform } = takeOption(args, '--platform');
|
|
488
|
+
const appDir = takeOption(afterPlatform, APP_DIR_OPTION);
|
|
489
|
+
if (appDir.rest.length > 0) {
|
|
490
|
+
ctx.err(`quiesco doctor: unknown arguments ${appDir.rest.join(' ')}`);
|
|
453
491
|
return 2;
|
|
454
492
|
}
|
|
455
|
-
const results = await runChecks(ctx, parsePlatform(value), deps);
|
|
493
|
+
const results = await runChecks(ctx, parsePlatform(value), deps, appDir.value);
|
|
456
494
|
for (const r of results) {
|
|
457
495
|
ctx.out(`${ICON[r.status]} ${r.name}: ${r.detail}`);
|
|
458
496
|
if (r.fix !== undefined && r.status !== 'ok')
|