@gnuechtel/nx-cucumber 24.2.0 → 24.3.0-17590857434
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 +27 -9
- package/internal/shared-coverage/src/index.d.ts +3 -0
- package/internal/shared-coverage/src/index.js +7 -0
- package/internal/shared-coverage/src/index.js.map +1 -0
- package/internal/shared-coverage/src/lib/create-istanbul-coverage-reports.d.ts +28 -0
- package/internal/shared-coverage/src/lib/create-istanbul-coverage-reports.js +212 -0
- package/internal/shared-coverage/src/lib/create-istanbul-coverage-reports.js.map +1 -0
- package/internal/shared-coverage/src/lib/merge-coverage.d.ts +1 -0
- package/internal/shared-coverage/src/lib/merge-coverage.js +134 -0
- package/internal/shared-coverage/src/lib/merge-coverage.js.map +1 -0
- package/internal/shared-coverage/src/lib/playwright-coverage.d.ts +4 -0
- package/internal/shared-coverage/src/lib/playwright-coverage.js +62 -0
- package/internal/shared-coverage/src/lib/playwright-coverage.js.map +1 -0
- package/internal/shared-util/src/index.d.ts +7 -0
- package/internal/shared-util/src/index.js +11 -0
- package/internal/shared-util/src/index.js.map +1 -0
- package/internal/shared-util/src/lib/create-process.d.ts +20 -0
- package/internal/shared-util/src/lib/create-process.js +119 -0
- package/internal/shared-util/src/lib/create-process.js.map +1 -0
- package/internal/shared-util/src/lib/error-message.d.ts +7 -0
- package/internal/shared-util/src/lib/error-message.js +25 -0
- package/internal/shared-util/src/lib/error-message.js.map +1 -0
- package/internal/shared-util/src/lib/get-package-version.d.ts +1 -0
- package/internal/shared-util/src/lib/get-package-version.js +17 -0
- package/internal/shared-util/src/lib/get-package-version.js.map +1 -0
- package/internal/shared-util/src/lib/kill-process-tree.d.ts +6 -0
- package/internal/shared-util/src/lib/kill-process-tree.js +28 -0
- package/internal/shared-util/src/lib/kill-process-tree.js.map +1 -0
- package/internal/shared-util/src/lib/replace-in-file.d.ts +1 -0
- package/internal/shared-util/src/lib/replace-in-file.js +12 -0
- package/internal/shared-util/src/lib/replace-in-file.js.map +1 -0
- package/internal/shared-util/src/lib/root-directory.d.ts +1 -0
- package/internal/shared-util/src/lib/root-directory.js +24 -0
- package/internal/shared-util/src/lib/root-directory.js.map +1 -0
- package/internal/shared-util/src/lib/wait-for-url.d.ts +1 -0
- package/internal/shared-util/src/lib/wait-for-url.js +27 -0
- package/internal/shared-util/src/lib/wait-for-url.js.map +1 -0
- package/package.json +18 -8
- package/src/core/output-directories.js +1 -1
- package/src/playwright/playwright-hooks.js +3 -3
- package/src/playwright/playwright-world.js +1 -1
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ npx nx g @gnuechtel/nx-cucumber:convert-playwright-bdd --project=shop-e2e --name
|
|
|
91
91
|
Remove `--dry-run` to create a converted copy. Original tests are preserved;
|
|
92
92
|
`migration-report.json` identifies manual work. The generated project uses local
|
|
93
93
|
fixtures and native reporters and needs no nx-cucumber runtime after generation.
|
|
94
|
-
See the [migration guide](https://gitlab.com/gnuechtel/
|
|
94
|
+
See the [migration guide](https://gitlab.com/gnuechtel/nx-cucumber/-/blob/main/docs/playwright-bdd-migration.md)
|
|
95
95
|
for supported step/world mappings, configuration review, UI regeneration and
|
|
96
96
|
reporting/coverage limitations. This is a migration of test execution within Nx.
|
|
97
97
|
|
|
@@ -100,7 +100,7 @@ uninstalled if no remaining project depends on it. First remove its unused
|
|
|
100
100
|
registration from `nx.json`; keep Nx, `@nx/playwright`, Playwright-BDD and
|
|
101
101
|
Playwright Test installed. The converter deliberately leaves original projects
|
|
102
102
|
and dependency cleanup to us. Follow the
|
|
103
|
-
[cleanup and uninstall steps](https://gitlab.com/gnuechtel/
|
|
103
|
+
[cleanup and uninstall steps](https://gitlab.com/gnuechtel/nx-cucumber/-/blob/main/docs/playwright-bdd-migration.md#remove-nx-cucumber-after-migration).
|
|
104
104
|
|
|
105
105
|
## API-only Playwright-BDD tests
|
|
106
106
|
|
|
@@ -112,6 +112,24 @@ Our [local API example](../../apps/example/api-app-bdd-e2e/README.md) demonstrat
|
|
|
112
112
|
health checks, authenticated requests and rejection without a token.
|
|
113
113
|
The [24.2.0 release notes](../../docs/release-notes/24.2.0.md) summarize the changes.
|
|
114
114
|
|
|
115
|
+
## Single-package distribution
|
|
116
|
+
|
|
117
|
+
From 24.3.0, only `@gnuechtel/nx-cucumber` is published. Required utility and
|
|
118
|
+
coverage implementations are included internally in that package. Existing
|
|
119
|
+
plugin imports, generated Cucumber runtime paths, worlds/hooks and native
|
|
120
|
+
Playwright-BDD execution retain their behavior. No additional public helper
|
|
121
|
+
entrypoints are introduced.
|
|
122
|
+
|
|
123
|
+
The Nx monorepo, `libs/nx-cucumber`, internal libraries and examples remain.
|
|
124
|
+
The previous `@gnuechtel/shared-util`, `@gnuechtel/shared-coverage` and
|
|
125
|
+
`@gnuechtel/shared-e2e` versions stay available for older plugin versions and
|
|
126
|
+
direct consumers; they are not deprecated by this release. Direct imports of
|
|
127
|
+
those packages still refer to their legacy npm versions.
|
|
128
|
+
|
|
129
|
+
Install optional `nyc` in the consuming workspace when using Istanbul coverage
|
|
130
|
+
reporting or merging. Its optional peer requirement is preserved in the product
|
|
131
|
+
package, together with the optional source-map peers.
|
|
132
|
+
|
|
115
133
|
## Dependency security notice
|
|
116
134
|
|
|
117
135
|
**Known upstream dependency risk: accepted release exception.** As checked on October
|
|
@@ -146,7 +164,7 @@ affected until a repaired Nx patch is adopted. See
|
|
|
146
164
|
|
|
147
165
|
## Prerequisites
|
|
148
166
|
|
|
149
|
-
This plugin requires [Node.js](https://nodejs.org/), [Nx](https://nx.dev/) and [Cucumber](https://github.com/cucumber/cucumber-js). Version 24.
|
|
167
|
+
This plugin requires [Node.js](https://nodejs.org/), [Nx](https://nx.dev/) and [Cucumber](https://github.com/cucumber/cucumber-js). Version 24.3.0 targets Nx `>=24 <25` and Node.js 24 or 26; published 2.x packages remain the Nx-22 path. Plugin 23.x remains available for Nx 23. Browser automation uses the [Playwright library](https://playwright.dev/docs/library) when selected by the generator. Consult `package.json` for all dependency requirements and `.gitlab-ci.yml` for the pinned CI versions. Minor and patch versions follow this plugin's changes independently of Nx.
|
|
150
168
|
|
|
151
169
|
## Quick start
|
|
152
170
|
|
|
@@ -258,7 +276,7 @@ The `e2e` target behavior depends on the selected test runner:
|
|
|
258
276
|
|
|
259
277
|
### Additional project generator options
|
|
260
278
|
|
|
261
|
-
All possible project generator options may be passed as command-line parameters and are stored in the related [schema file](https://gitlab.com/gnuechtel/
|
|
279
|
+
All possible project generator options may be passed as command-line parameters and are stored in the related [schema file](https://gitlab.com/gnuechtel/nx-cucumber/-/blob/main/libs/nx-cucumber/src/generators/project/schema.json). They can also be displayed on the command-line with the following command: `npx nx g @gnuechtel/nx-cucumber:project --help`.
|
|
262
280
|
|
|
263
281
|
## Execute Cucumber projects
|
|
264
282
|
|
|
@@ -482,16 +500,16 @@ All [example projects](#example-projects) demonstrate code coverage configuratio
|
|
|
482
500
|
|
|
483
501
|
### Main examples
|
|
484
502
|
|
|
485
|
-
This repository contains [example projects](https://gitlab.com/gnuechtel/
|
|
503
|
+
This repository contains [example projects](https://gitlab.com/gnuechtel/nx-cucumber/-/tree/main/apps/example) that can be used directly to see nx-cucumber in action.
|
|
486
504
|
|
|
487
505
|
| | example react application and cucumber project | example Node.js app and cucumber project |
|
|
488
506
|
| ---------------------------- | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
489
507
|
| **Execute cucumber project** | `npx nx e2e example-react-app-e2e` | `npx nx e2e example-node-app-e2e` |
|
|
490
|
-
| **Source cucumber project** | [apps/example/react-app-e2e](https://gitlab.com/gnuechtel/
|
|
508
|
+
| **Source cucumber project** | [apps/example/react-app-e2e](https://gitlab.com/gnuechtel/nx-cucumber/-/tree/main/apps/example/react-app-e2e) | [apps/example/node-app-e2e](https://gitlab.com/gnuechtel/nx-cucumber/-/tree/main/apps/example/node-app-e2e) |
|
|
491
509
|
|
|
492
510
|
## End-to-end tests of this project
|
|
493
511
|
|
|
494
|
-
The [Cucumber scenarios](https://gitlab.com/gnuechtel/
|
|
512
|
+
The [Cucumber scenarios](https://gitlab.com/gnuechtel/nx-cucumber/-/blob/main/apps/nx-cucumber-e2e/features/nx-cucumber.feature)
|
|
495
513
|
exercise generation, migration and installed-package behavior.
|
|
496
514
|
|
|
497
515
|
Generation coverage includes validation for unknown `--project` ids and execution against real Nx project ids detected in the test workspace.
|
|
@@ -521,7 +539,7 @@ are retained under `dist/e2e/apps/nx-cucumber-e2e/playwright-bdd`.
|
|
|
521
539
|
|
|
522
540
|
## Continuous delivery pipeline
|
|
523
541
|
|
|
524
|
-
Our [continuous delivery pipeline](https://gitlab.com/gnuechtel/
|
|
542
|
+
Our [continuous delivery pipeline](https://gitlab.com/gnuechtel/nx-cucumber/-/pipelines/latest) runs builds and tests on Node.js 24 for Linux and macOS, and Node.js 26 for Windows.
|
|
525
543
|
|
|
526
544
|
The end-to-end tests use the pinned Nx/framework versions in [`.gitlab-ci.yml`](../../.gitlab-ci.yml). Current CI jobs exclude the historical `@migration` scenario. These checks validate the existing implementation; they do not establish compatibility with future upstream releases.
|
|
527
545
|
|
|
@@ -649,7 +667,7 @@ npx nx e2e my-project-e2e -- --profile homepage
|
|
|
649
667
|
|
|
650
668
|
## Logging
|
|
651
669
|
|
|
652
|
-
Logging messages are produced by the [debug](https://www.npmjs.com/package/debug) library. The project generator creates a [.env file](https://gitlab.com/gnuechtel/
|
|
670
|
+
Logging messages are produced by the [debug](https://www.npmjs.com/package/debug) library. The project generator creates a [.env file](https://gitlab.com/gnuechtel/nx-cucumber/-/blob/main/libs/nx-cucumber/src/generators/project/files/all/.env.template?ref_type=heads) which contains the default logging configuration. By changing the `.env` file in the generated Cucumber project, the verbosity of the log output may be decreased or increased.
|
|
653
671
|
|
|
654
672
|
## Contribution
|
|
655
673
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/create-istanbul-coverage-reports"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/merge-coverage"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/playwright-coverage"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/shared-coverage/src/index.ts"],"names":[],"mappings":";;;AAAA,iFAAuD;AACvD,+DAAqC;AACrC,oEAA0C"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates the final Istanbul coverage reports with nyc.
|
|
3
|
+
* Raw coverage must has been already collected in a `.nyc_output` directory.
|
|
4
|
+
*
|
|
5
|
+
* How is raw coverage collected? Either by a tool like a jest-playwright or by own code.
|
|
6
|
+
* Here is an example for playwright, how coverage may be collected in frontend application code:
|
|
7
|
+
*
|
|
8
|
+
* <code>
|
|
9
|
+
* // Create a client-side JavaScript function which stores coverage data in the file system
|
|
10
|
+
* await context.exposeFunction('collectIstanbulCoverage', (coverageJSON: string) => {
|
|
11
|
+
* // Create a unique coverage file for the current context
|
|
12
|
+
* fs.writeFileSync(path.join('.nyc_output', `playwright_coverage_${generateUUID()}.json`), coverageJSON);
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // The init script is registered on the context, but used for every page
|
|
16
|
+
* // The code is executed before the page will is unloaded
|
|
17
|
+
* await context.addInitScript(() =>
|
|
18
|
+
* window.addEventListener('beforeunload', () =>
|
|
19
|
+
* // Pass coverage data of Istanbul to the exposed function
|
|
20
|
+
* (window as any).collectIstanbulCoverage(JSON.stringify((window as any).__coverage__))
|
|
21
|
+
* ),
|
|
22
|
+
* );
|
|
23
|
+
* </code>
|
|
24
|
+
*
|
|
25
|
+
* @param rootDirectory the directory where the `.nyc_output` must exist
|
|
26
|
+
* @param projectDirectory the directory where an additional `.nycrc.json` may exist
|
|
27
|
+
*/
|
|
28
|
+
export declare function createIstanbulCoverageReports(rootDirectory?: string, projectDirectory?: string): Promise<void>;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createIstanbulCoverageReports = createIstanbulCoverageReports;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const path = tslib_1.__importStar(require("path"));
|
|
7
|
+
/**
|
|
8
|
+
* Creates the final Istanbul coverage reports with nyc.
|
|
9
|
+
* Raw coverage must has been already collected in a `.nyc_output` directory.
|
|
10
|
+
*
|
|
11
|
+
* How is raw coverage collected? Either by a tool like a jest-playwright or by own code.
|
|
12
|
+
* Here is an example for playwright, how coverage may be collected in frontend application code:
|
|
13
|
+
*
|
|
14
|
+
* <code>
|
|
15
|
+
* // Create a client-side JavaScript function which stores coverage data in the file system
|
|
16
|
+
* await context.exposeFunction('collectIstanbulCoverage', (coverageJSON: string) => {
|
|
17
|
+
* // Create a unique coverage file for the current context
|
|
18
|
+
* fs.writeFileSync(path.join('.nyc_output', `playwright_coverage_${generateUUID()}.json`), coverageJSON);
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // The init script is registered on the context, but used for every page
|
|
22
|
+
* // The code is executed before the page will is unloaded
|
|
23
|
+
* await context.addInitScript(() =>
|
|
24
|
+
* window.addEventListener('beforeunload', () =>
|
|
25
|
+
* // Pass coverage data of Istanbul to the exposed function
|
|
26
|
+
* (window as any).collectIstanbulCoverage(JSON.stringify((window as any).__coverage__))
|
|
27
|
+
* ),
|
|
28
|
+
* );
|
|
29
|
+
* </code>
|
|
30
|
+
*
|
|
31
|
+
* @param rootDirectory the directory where the `.nyc_output` must exist
|
|
32
|
+
* @param projectDirectory the directory where an additional `.nycrc.json` may exist
|
|
33
|
+
*/
|
|
34
|
+
function createIstanbulCoverageReports() {
|
|
35
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (rootDirectory = '.', projectDirectory = '.') {
|
|
36
|
+
// Default options to process Istanbul JSON files
|
|
37
|
+
const defaultNycOptions = {
|
|
38
|
+
cwd: rootDirectory,
|
|
39
|
+
reportDir: './coverage',
|
|
40
|
+
reporter: ['lcov', 'clover', 'json', 'json-summary'],
|
|
41
|
+
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
|
|
42
|
+
excludeAfterRemap: false,
|
|
43
|
+
};
|
|
44
|
+
// Combine default options with optional options from config file
|
|
45
|
+
const nycrcJsonFilename = path.join(projectDirectory, '.nycrc.json');
|
|
46
|
+
const nycrcJson = fs.existsSync(nycrcJsonFilename) ? JSON.parse(fs.readFileSync(nycrcJsonFilename, 'utf8')) : {};
|
|
47
|
+
const nycOptions = Object.assign({}, defaultNycOptions, nycrcJson);
|
|
48
|
+
const NYC = loadNycConstructor();
|
|
49
|
+
// Patch coverage files to fill source map gaps before nyc processes them.
|
|
50
|
+
// Vite's JSX transpiler (OXC) omits source map entries for closing bracket positions,
|
|
51
|
+
// which causes istanbul-lib-source-maps to drop files when it can't resolve statement
|
|
52
|
+
// end positions. Filling those gaps allows the remapping to succeed.
|
|
53
|
+
patchCoverageFilesForSourceMapGaps(path.join(rootDirectory, '.nyc_output'));
|
|
54
|
+
console.log('Creating istanbul coverage reports: %o', nycOptions);
|
|
55
|
+
// Use nyc to convert Istanbul coverage JSON to different output formats
|
|
56
|
+
const nyc = new NYC(nycOptions);
|
|
57
|
+
yield nyc.report();
|
|
58
|
+
console.log('Coverage reports created');
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Patches coverage JSON files in the nyc output directory to fill gaps in inputSourceMap
|
|
63
|
+
* between consecutively mapped lines. This is necessary when the JSX transpiler (OXC/Rolldown)
|
|
64
|
+
* omits source map entries for closing tag positions, which would otherwise cause
|
|
65
|
+
* istanbul-lib-source-maps to drop entire files from the coverage report.
|
|
66
|
+
*/
|
|
67
|
+
function patchCoverageFilesForSourceMapGaps(nycOutputDir) {
|
|
68
|
+
if (!fs.existsSync(nycOutputDir))
|
|
69
|
+
return;
|
|
70
|
+
let TraceMap;
|
|
71
|
+
let eachMapping;
|
|
72
|
+
let GenMapping;
|
|
73
|
+
let addMappingFn;
|
|
74
|
+
let toEncodedMapFn;
|
|
75
|
+
try {
|
|
76
|
+
// These packages are transitively available via istanbul-lib-source-maps
|
|
77
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
78
|
+
const traceMapping = require('@jridgewell/trace-mapping');
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
80
|
+
const genMapping = require('@jridgewell/gen-mapping');
|
|
81
|
+
TraceMap = traceMapping.TraceMap;
|
|
82
|
+
eachMapping = traceMapping.eachMapping;
|
|
83
|
+
GenMapping = genMapping.GenMapping;
|
|
84
|
+
addMappingFn = genMapping.addMapping;
|
|
85
|
+
toEncodedMapFn = genMapping.toEncodedMap;
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
return; // packages unavailable, skip patching
|
|
89
|
+
}
|
|
90
|
+
const files = fs
|
|
91
|
+
.readdirSync(nycOutputDir)
|
|
92
|
+
.filter((f) => f.endsWith('.json') && !fs.statSync(path.join(nycOutputDir, f)).isDirectory());
|
|
93
|
+
for (const file of files) {
|
|
94
|
+
const filePath = path.join(nycOutputDir, file);
|
|
95
|
+
let coverageData;
|
|
96
|
+
try {
|
|
97
|
+
coverageData = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
98
|
+
}
|
|
99
|
+
catch (_b) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
let changed = false;
|
|
103
|
+
for (const entry of Object.values(coverageData)) {
|
|
104
|
+
if (!entry || typeof entry !== 'object' || !entry.inputSourceMap)
|
|
105
|
+
continue;
|
|
106
|
+
const patched = fillSourceMapGaps(entry, TraceMap, eachMapping, GenMapping, addMappingFn, toEncodedMapFn);
|
|
107
|
+
if (patched) {
|
|
108
|
+
entry.inputSourceMap = patched;
|
|
109
|
+
changed = true;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
if (changed) {
|
|
113
|
+
fs.writeFileSync(filePath, JSON.stringify(coverageData), 'utf8');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
function fillSourceMapGaps(entry, TraceMap, eachMapping, GenMapping, addMappingFn, toEncodedMapFn) {
|
|
118
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
119
|
+
const sm = entry.inputSourceMap;
|
|
120
|
+
if (!sm)
|
|
121
|
+
return null;
|
|
122
|
+
const traceMap = new TraceMap(sm);
|
|
123
|
+
// Track the last known original position for each mapped generated line
|
|
124
|
+
const lastMappingByLine = new Map();
|
|
125
|
+
eachMapping(traceMap, (m) => {
|
|
126
|
+
if (m.source !== null && m.originalLine !== null && m.originalColumn !== null) {
|
|
127
|
+
const current = lastMappingByLine.get(m.generatedLine);
|
|
128
|
+
if (!current || m.generatedColumn > current.col) {
|
|
129
|
+
lastMappingByLine.set(m.generatedLine, { line: m.originalLine, col: m.originalColumn, source: m.source });
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (lastMappingByLine.size === 0)
|
|
134
|
+
return null;
|
|
135
|
+
const sortedMappedLines = [...lastMappingByLine.keys()].sort((a, b) => a - b);
|
|
136
|
+
const lastMappedLine = sortedMappedLines[sortedMappedLines.length - 1];
|
|
137
|
+
// Collect all end lines referenced by statements, functions, and branches
|
|
138
|
+
const neededLines = new Set();
|
|
139
|
+
for (const loc of Object.values((_a = entry.statementMap) !== null && _a !== void 0 ? _a : {})) {
|
|
140
|
+
if ((_b = loc.end) === null || _b === void 0 ? void 0 : _b.line)
|
|
141
|
+
neededLines.add(loc.end.line);
|
|
142
|
+
}
|
|
143
|
+
for (const fn of Object.values((_c = entry.fnMap) !== null && _c !== void 0 ? _c : {})) {
|
|
144
|
+
if ((_e = (_d = fn.loc) === null || _d === void 0 ? void 0 : _d.end) === null || _e === void 0 ? void 0 : _e.line)
|
|
145
|
+
neededLines.add(fn.loc.end.line);
|
|
146
|
+
if ((_g = (_f = fn.decl) === null || _f === void 0 ? void 0 : _f.end) === null || _g === void 0 ? void 0 : _g.line)
|
|
147
|
+
neededLines.add(fn.decl.end.line);
|
|
148
|
+
}
|
|
149
|
+
for (const branch of Object.values((_h = entry.branchMap) !== null && _h !== void 0 ? _h : {})) {
|
|
150
|
+
if ((_k = (_j = branch.loc) === null || _j === void 0 ? void 0 : _j.end) === null || _k === void 0 ? void 0 : _k.line)
|
|
151
|
+
neededLines.add(branch.loc.end.line);
|
|
152
|
+
for (const loc of (_l = branch.locations) !== null && _l !== void 0 ? _l : []) {
|
|
153
|
+
if ((_m = loc.end) === null || _m === void 0 ? void 0 : _m.line)
|
|
154
|
+
neededLines.add(loc.end.line);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
// Only fill gaps for lines that are between two consecutive mapped lines (not after the last).
|
|
158
|
+
// Lines after the last mapped line are typically transpiler-injected code (e.g. React Fast Refresh)
|
|
159
|
+
// that should remain unmapped so they are excluded from the remapped coverage.
|
|
160
|
+
const unmappedNeeded = [...neededLines].filter((l) => !lastMappingByLine.has(l) && l < lastMappedLine);
|
|
161
|
+
if (unmappedNeeded.length === 0)
|
|
162
|
+
return null;
|
|
163
|
+
// Build a new source map with existing mappings plus gap-filler entries
|
|
164
|
+
const gen = new GenMapping();
|
|
165
|
+
eachMapping(traceMap, (m) => {
|
|
166
|
+
var _a;
|
|
167
|
+
if (m.source !== null && m.originalLine !== null && m.originalColumn !== null) {
|
|
168
|
+
addMappingFn(gen, {
|
|
169
|
+
generated: { line: m.generatedLine, column: m.generatedColumn },
|
|
170
|
+
source: m.source,
|
|
171
|
+
original: { line: m.originalLine, column: m.originalColumn },
|
|
172
|
+
name: (_a = m.name) !== null && _a !== void 0 ? _a : undefined,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
for (const neededLine of unmappedNeeded) {
|
|
177
|
+
// Find the nearest preceding mapped line
|
|
178
|
+
let lastMapLine = null;
|
|
179
|
+
for (const ml of sortedMappedLines) {
|
|
180
|
+
if (ml < neededLine)
|
|
181
|
+
lastMapLine = ml;
|
|
182
|
+
else
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
if (lastMapLine === null)
|
|
186
|
+
continue;
|
|
187
|
+
const lastMap = lastMappingByLine.get(lastMapLine);
|
|
188
|
+
if (!lastMap)
|
|
189
|
+
continue;
|
|
190
|
+
addMappingFn(gen, {
|
|
191
|
+
generated: { line: neededLine, column: 0 },
|
|
192
|
+
source: lastMap.source,
|
|
193
|
+
original: { line: lastMap.line, column: lastMap.col },
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return toEncodedMapFn(gen);
|
|
197
|
+
}
|
|
198
|
+
function loadNycConstructor() {
|
|
199
|
+
try {
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
201
|
+
return require('nyc');
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
const requiresInstall = error instanceof Error &&
|
|
205
|
+
(error.message.includes('Cannot find module') || error.message.includes('Cannot find package'));
|
|
206
|
+
if (requiresInstall) {
|
|
207
|
+
throw new Error('Coverage generation requires package "nyc". Install it with: npm i -D nyc');
|
|
208
|
+
}
|
|
209
|
+
throw error;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
//# sourceMappingURL=create-istanbul-coverage-reports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-istanbul-coverage-reports.js","sourceRoot":"","sources":["../../../../../libs/shared-coverage/src/lib/create-istanbul-coverage-reports.ts"],"names":[],"mappings":";;AAoCA,sEA2BC;;AA/DD,+CAAyB;AACzB,mDAA6B;AAQ7B;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAsB,6BAA6B;iEAAC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AC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC,CAAC;QAElG,IAAI,eAAe,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,2EAA2E,CAAC,CAAC;QAC/F,CAAC;QAED,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function mergeCoverage(): Promise<void>;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeCoverage = mergeCoverage;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const shared_util_1 = require("../../../shared-util/src/index.js");
|
|
6
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
7
|
+
const path = tslib_1.__importStar(require("path"));
|
|
8
|
+
function mergeCoverage() {
|
|
9
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
10
|
+
const sourceDirs = yield detectSourceDirs();
|
|
11
|
+
const minSourceDirsLength = 2;
|
|
12
|
+
if (sourceDirs.length >= minSourceDirsLength) {
|
|
13
|
+
console.log('found coverage source dirs: %o', sourceDirs);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
// Not enough coverage files found
|
|
17
|
+
console.log(`Nothing to merge: ${sourceDirs.length} source dir(s) found, but ${minSourceDirsLength} required`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
// Create an empty merged and temp directory
|
|
21
|
+
prepareMergedDir();
|
|
22
|
+
// Copy coverage json sources
|
|
23
|
+
copyCoverageFiles(sourceDirs);
|
|
24
|
+
ensureNycIsInstalled();
|
|
25
|
+
// Coverage command
|
|
26
|
+
const nyc = 'nyc';
|
|
27
|
+
// merge
|
|
28
|
+
const mergeParams = ['merge', tempDir, path.join(tempDir, coverageJsonFileName)];
|
|
29
|
+
yield (0, shared_util_1.createProcess)(nyc, mergeParams);
|
|
30
|
+
// report
|
|
31
|
+
const reportParams = [
|
|
32
|
+
'report',
|
|
33
|
+
'-t',
|
|
34
|
+
tempDir,
|
|
35
|
+
'--report-dir',
|
|
36
|
+
mergedDir,
|
|
37
|
+
'--reporter=lcov',
|
|
38
|
+
'--reporter=cobertura',
|
|
39
|
+
'--reporter=text',
|
|
40
|
+
'--reporter=clover',
|
|
41
|
+
'--reporter=json',
|
|
42
|
+
];
|
|
43
|
+
yield (0, shared_util_1.createProcess)(nyc, reportParams);
|
|
44
|
+
console.log(`merged report created in ${mergedDir}`);
|
|
45
|
+
// The temp directory is not required anymore
|
|
46
|
+
removeTempDir();
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function ensureNycIsInstalled() {
|
|
50
|
+
try {
|
|
51
|
+
require.resolve('nyc/package.json');
|
|
52
|
+
}
|
|
53
|
+
catch (_a) {
|
|
54
|
+
throw new Error('Coverage merge requires package "nyc". Install it with: npm i -D nyc');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const coverageJsonFileName = 'coverage-final.json';
|
|
58
|
+
const coverageRoot = path.join((0, shared_util_1.rootDirectory)(), 'dist', 'coverage');
|
|
59
|
+
const mergedDir = path.join(coverageRoot, 'merged');
|
|
60
|
+
const tempDir = path.join(mergedDir, 'temp');
|
|
61
|
+
function getFiles(dir) {
|
|
62
|
+
return tslib_1.__asyncGenerator(this, arguments, function* getFiles_1() {
|
|
63
|
+
const readdir = fs.promises.readdir;
|
|
64
|
+
const dirents = yield tslib_1.__await(readdir(dir, { withFileTypes: true }));
|
|
65
|
+
for (const dirent of dirents) {
|
|
66
|
+
const res = path.resolve(dir, dirent.name);
|
|
67
|
+
if (dirent.isDirectory()) {
|
|
68
|
+
yield tslib_1.__await(yield* tslib_1.__asyncDelegator(tslib_1.__asyncValues(getFiles(res))));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
yield yield tslib_1.__await(res);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function detectSourceDirs() {
|
|
77
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a, e_1, _b, _c;
|
|
79
|
+
// Do not include target and temp directory in source dirs
|
|
80
|
+
const excludeDirs = [mergedDir, tempDir];
|
|
81
|
+
const sourceDirs = [];
|
|
82
|
+
try {
|
|
83
|
+
for (var _d = true, _e = tslib_1.__asyncValues(getFiles(coverageRoot)), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
84
|
+
_c = _f.value;
|
|
85
|
+
_d = false;
|
|
86
|
+
const fullFileName = _c;
|
|
87
|
+
const baseName = path.basename(fullFileName);
|
|
88
|
+
const dirName = path.dirname(fullFileName);
|
|
89
|
+
if (baseName == coverageJsonFileName && !excludeDirs.includes(dirName)) {
|
|
90
|
+
sourceDirs.push(dirName);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
95
|
+
finally {
|
|
96
|
+
try {
|
|
97
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
98
|
+
}
|
|
99
|
+
finally { if (e_1) throw e_1.error; }
|
|
100
|
+
}
|
|
101
|
+
return sourceDirs;
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function prepareMergedDir() {
|
|
105
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
106
|
+
if (!fs.existsSync(mergedDir)) {
|
|
107
|
+
fs.mkdirSync(mergedDir);
|
|
108
|
+
}
|
|
109
|
+
removeTempDir();
|
|
110
|
+
fs.mkdirSync(tempDir);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
function copyCoverageFiles(sourceDirs) {
|
|
114
|
+
let i = 0;
|
|
115
|
+
for (const sourceDir of sourceDirs) {
|
|
116
|
+
if (fs.existsSync(sourceDir)) {
|
|
117
|
+
i++;
|
|
118
|
+
const source = path.join(sourceDir, coverageJsonFileName);
|
|
119
|
+
const target = path.join(tempDir, `${i}.json`);
|
|
120
|
+
// Complete coverage json file for merging
|
|
121
|
+
fs.copyFileSync(source, target);
|
|
122
|
+
console.log(`${path.basename(path.dirname(source))} coverage json file copied to ${path.basename(target)}`);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.warn(`coverage source dir ${sourceDir} does not exist`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function removeTempDir() {
|
|
130
|
+
if (fs.existsSync(tempDir)) {
|
|
131
|
+
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=merge-coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge-coverage.js","sourceRoot":"","sources":["../../../../../libs/shared-coverage/src/lib/merge-coverage.ts"],"names":[],"mappings":";;AAIA,sCA4CC;;AAhDD,wDAAsE;AACtE,+CAAyB;AACzB,mDAA6B;AAE7B,SAAsB,aAAa;;QACjC,MAAM,UAAU,GAAG,MAAM,gBAAgB,EAAE,CAAC;QAE5C,MAAM,mBAAmB,GAAG,CAAC,CAAC;QAC9B,IAAI,UAAU,CAAC,MAAM,IAAI,mBAAmB,EAAE,CAAC;YAC7C,OAAO,CAAC,GAAG,CAAC,gCAAgC,EAAE,UAAU,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACN,kCAAkC;YAClC,OAAO,CAAC,GAAG,CAAC,qBAAqB,UAAU,CAAC,MAAM,6BAA6B,mBAAmB,WAAW,CAAC,CAAC;YAC/G,OAAO;QACT,CAAC;QAED,4CAA4C;QAC5C,gBAAgB,EAAE,CAAC;QAEnB,6BAA6B;QAC7B,iBAAiB,CAAC,UAAU,CAAC,CAAC;QAC9B,oBAAoB,EAAE,CAAC;QAEvB,mBAAmB;QACnB,MAAM,GAAG,GAAG,KAAK,CAAC;QAElB,QAAQ;QACR,MAAM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;IACxB,CAAC;CAAA;AAED,SAAS,iBAAiB,CAAC,UAAoB;IAC7C,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7B,CAAC,EAAE,CAAC;YACJ,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;YAC/C,0CAA0C;YAC1C,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAChC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,iCAAiC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QAC9G,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,uBAAuB,SAAS,iBAAiB,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,aAAa;IACpB,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3B,EAAE,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BrowserContext } from 'playwright';
|
|
2
|
+
export declare function prepareContextForIstanbulCoverage(context: BrowserContext): Promise<void>;
|
|
3
|
+
export declare function collectIstanbulCoverageForContext(context: BrowserContext): Promise<void>;
|
|
4
|
+
export declare function deleteExistingPlaywrightCoverageFiles(): void;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareContextForIstanbulCoverage = prepareContextForIstanbulCoverage;
|
|
4
|
+
exports.collectIstanbulCoverageForContext = collectIstanbulCoverageForContext;
|
|
5
|
+
exports.deleteExistingPlaywrightCoverageFiles = deleteExistingPlaywrightCoverageFiles;
|
|
6
|
+
const tslib_1 = require("tslib");
|
|
7
|
+
const node_crypto_1 = require("node:crypto");
|
|
8
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
9
|
+
const path = tslib_1.__importStar(require("path"));
|
|
10
|
+
const shared_util_1 = require("../../../shared-util/src/index.js");
|
|
11
|
+
const coverageOutputDirectory = path.join((0, shared_util_1.rootDirectory)(), '.nyc_output');
|
|
12
|
+
const playwrightCoverageFileNameStart = 'playwright_coverage_';
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
14
|
+
const debug = require('debug')('e2e:coverage');
|
|
15
|
+
function prepareContextForIstanbulCoverage(context) {
|
|
16
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
yield context.exposeFunction('collectIstanbulCoverage', (coverageJSON) => {
|
|
18
|
+
if (!fs.existsSync(coverageOutputDirectory)) {
|
|
19
|
+
fs.mkdirSync(coverageOutputDirectory);
|
|
20
|
+
}
|
|
21
|
+
if (!coverageJSON) {
|
|
22
|
+
debug('Browser coverage data is not available. Did you enable client-side coverage via window.__coverage__?');
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
// Create a unique coverage file for the current context
|
|
26
|
+
fs.writeFileSync(path.join(coverageOutputDirectory, `${playwrightCoverageFileNameStart}${(0, node_crypto_1.randomUUID)()}.json`), coverageJSON);
|
|
27
|
+
});
|
|
28
|
+
// The init script is registered on the context, but used for every page
|
|
29
|
+
// The code is executed before the page is unloaded
|
|
30
|
+
yield context.addInitScript(() => window.addEventListener('beforeunload', () =>
|
|
31
|
+
// Pass coverage data of Istanbul to the exposed function
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
window.collectIstanbulCoverage(JSON.stringify(window.__coverage__))));
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function collectIstanbulCoverageForContext(context) {
|
|
37
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
for (const page of context.pages()) {
|
|
39
|
+
/* istanbul ignore next */
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
yield page.evaluate(() => window.collectIstanbulCoverage(JSON.stringify(window.__coverage__)));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function deleteExistingPlaywrightCoverageFiles() {
|
|
46
|
+
if (fs.existsSync(coverageOutputDirectory)) {
|
|
47
|
+
fs.readdirSync(coverageOutputDirectory)
|
|
48
|
+
.filter((f) => f.startsWith(playwrightCoverageFileNameStart))
|
|
49
|
+
.forEach((f) => {
|
|
50
|
+
const file = path.join(coverageOutputDirectory, f);
|
|
51
|
+
try {
|
|
52
|
+
fs.unlinkSync(file);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
const code = error.code;
|
|
56
|
+
if (code !== 'ENOENT')
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=playwright-coverage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"playwright-coverage.js","sourceRoot":"","sources":["../../../../../libs/shared-coverage/src/lib/playwright-coverage.ts"],"names":[],"mappings":";;AAYA,8EA2BC;AAED,8EAMC;AAED,sFAcC;;AA9DD,6CAAyC;AACzC,+CAAyB;AACzB,mDAA6B;AAC7B,wDAAuD;AAEvD,MAAM,uBAAuB,GAAG,IAAI,CAAC,IAAI,CAAC,IAAA,2BAAa,GAAE,EAAE,aAAa,CAAC,CAAC;AAC1E,MAAM,+BAA+B,GAAG,sB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SAAgB,qCAAqC;IACnD,IAAI,EAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE,CAAC;QAC3C,EAAE,CAAC,WAAW,CAAC,uBAAuB,CAAC;aACpC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC;aAC5D,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACb,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,CAAC,CAAC,CAAC;YACnD,IAAI,CAAC;gBACH,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YACtB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,CAAC;gBACnD,IAAI,IAAI,KAAK,QAAQ;oBAAE,MAAM,KAAK,CAAC;YACrC,CAAC;QACH,CAAC,CAAC,CAAC;IACP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './lib/create-process';
|
|
2
|
+
export * from './lib/kill-process-tree';
|
|
3
|
+
export * from './lib/error-message';
|
|
4
|
+
export * from './lib/get-package-version';
|
|
5
|
+
export * from './lib/replace-in-file';
|
|
6
|
+
export * from './lib/root-directory';
|
|
7
|
+
export * from './lib/wait-for-url';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/create-process"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/kill-process-tree"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/error-message"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/get-package-version"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./lib/replace-in-file"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./lib/root-directory"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./lib/wait-for-url"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/shared-util/src/index.ts"],"names":[],"mappings":";;;AAAA,+DAAqC;AACrC,kEAAwC;AACxC,8DAAoC;AACpC,oEAA0C;AAC1C,gEAAsC;AACtC,+DAAqC;AACrC,6DAAmC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChildProcess } from 'child_process';
|
|
2
|
+
type ProcessState = undefined | 'running' | 'ready' | 'stopping' | 'stopped';
|
|
3
|
+
export type Process = {
|
|
4
|
+
state: () => ProcessState;
|
|
5
|
+
stop: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type ProcessOptions = {
|
|
8
|
+
cwd?: string;
|
|
9
|
+
useFork?: boolean;
|
|
10
|
+
background?: boolean;
|
|
11
|
+
readyWhen?: string;
|
|
12
|
+
silent?: boolean;
|
|
13
|
+
onStarted?: (childProcess: ChildProcess) => void;
|
|
14
|
+
onReady?: (readyMessage: string) => void;
|
|
15
|
+
onStopping?: (childProcessKilled: boolean) => void;
|
|
16
|
+
onStopped?: (childProcessKilled: boolean) => void;
|
|
17
|
+
name?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare function createProcess(command: string, params: string[], processOptions?: ProcessOptions | undefined): Promise<Process>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createProcess = createProcess;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const child_process_1 = require("child_process");
|
|
6
|
+
const kill_process_tree_1 = require("./kill-process-tree");
|
|
7
|
+
const outputLimit = 200000;
|
|
8
|
+
function appendOutput(current, next) {
|
|
9
|
+
const nextAsString = Buffer.isBuffer(next) ? next.toString() : `${next || ''}`;
|
|
10
|
+
if (!nextAsString)
|
|
11
|
+
return current;
|
|
12
|
+
const merged = current + nextAsString;
|
|
13
|
+
return merged.length <= outputLimit ? merged : merged.slice(-outputLimit);
|
|
14
|
+
}
|
|
15
|
+
function createProcess(command_1, params_1) {
|
|
16
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (command, params, processOptions = undefined) {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
let processState;
|
|
20
|
+
let childProcessKilled = false;
|
|
21
|
+
let stdoutOutput = '';
|
|
22
|
+
let stderrOutput = '';
|
|
23
|
+
const isSilent = () => (processOptions === null || processOptions === void 0 ? void 0 : processOptions.silent) || processState === 'stopped'; // ignore output when process was stopped or silent is true
|
|
24
|
+
const nameOrCommand = (processOptions === null || processOptions === void 0 ? void 0 : processOptions.name) || command;
|
|
25
|
+
const options = { env: Object.assign({}, process.env), cwd: processOptions === null || processOptions === void 0 ? void 0 : processOptions.cwd };
|
|
26
|
+
const paramsAsString = params.join(' ');
|
|
27
|
+
const commandWithParams = command + (paramsAsString ? ` ${paramsAsString}` : '');
|
|
28
|
+
const childProcess = !(processOptions === null || processOptions === void 0 ? void 0 : processOptions.useFork)
|
|
29
|
+
? (0, child_process_1.exec)(commandWithParams, options)
|
|
30
|
+
: (0, child_process_1.fork)(command, params, Object.assign(Object.assign({}, options), { stdio: 'pipe' }));
|
|
31
|
+
processState = 'running';
|
|
32
|
+
if (processOptions === null || processOptions === void 0 ? void 0 : processOptions.onStarted)
|
|
33
|
+
processOptions.onStarted(childProcess);
|
|
34
|
+
function terminateProcess(childProcessInstance) {
|
|
35
|
+
if (childProcessInstance.exitCode !== null || childProcessInstance.killed)
|
|
36
|
+
return true;
|
|
37
|
+
const pid = childProcessInstance.pid;
|
|
38
|
+
if (!pid)
|
|
39
|
+
return false;
|
|
40
|
+
(0, kill_process_tree_1.killProcessTree)(pid);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
function processInstance() {
|
|
44
|
+
return {
|
|
45
|
+
state: () => processState,
|
|
46
|
+
stop: () => {
|
|
47
|
+
if (processState === 'stopped')
|
|
48
|
+
return; // Already stopped
|
|
49
|
+
processState = 'stopping';
|
|
50
|
+
childProcessKilled = terminateProcess(childProcess);
|
|
51
|
+
removeProcessExitListeners();
|
|
52
|
+
if (processOptions === null || processOptions === void 0 ? void 0 : processOptions.onStopping)
|
|
53
|
+
processOptions.onStopping(childProcessKilled);
|
|
54
|
+
processState = 'stopped';
|
|
55
|
+
if (processOptions === null || processOptions === void 0 ? void 0 : processOptions.onStopped)
|
|
56
|
+
processOptions.onStopped(childProcessKilled);
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
// Ensure the child process tree is killed when the parent exits.
|
|
61
|
+
const processExitListener = () => childProcessKilled || terminateProcess(childProcess);
|
|
62
|
+
const removeProcessExitListeners = () => {
|
|
63
|
+
process.off('exit', processExitListener);
|
|
64
|
+
process.off('SIGTERM', processExitListener);
|
|
65
|
+
process.off('SIGINT', processExitListener);
|
|
66
|
+
process.off('SIGHUP', processExitListener);
|
|
67
|
+
};
|
|
68
|
+
process.on('exit', processExitListener);
|
|
69
|
+
process.on('SIGTERM', processExitListener);
|
|
70
|
+
process.on('SIGINT', processExitListener);
|
|
71
|
+
process.on('SIGHUP', processExitListener);
|
|
72
|
+
(_a = childProcess.stdout) === null || _a === void 0 ? void 0 : _a.on('data', (data) => {
|
|
73
|
+
stdoutOutput = appendOutput(stdoutOutput, data);
|
|
74
|
+
if (!isSilent())
|
|
75
|
+
process.stdout.write(data);
|
|
76
|
+
const dataAsString = data.toString();
|
|
77
|
+
if ((processOptions === null || processOptions === void 0 ? void 0 : processOptions.readyWhen) && dataAsString.includes(processOptions === null || processOptions === void 0 ? void 0 : processOptions.readyWhen)) {
|
|
78
|
+
processState = 'ready';
|
|
79
|
+
if (processOptions.onReady)
|
|
80
|
+
processOptions.onReady(dataAsString);
|
|
81
|
+
resolve(processInstance()); // Resolve when readyWhen matches (has no effect on background processes since it is already resolved)
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
(_b = childProcess === null || childProcess === void 0 ? void 0 : childProcess.stderr) === null || _b === void 0 ? void 0 : _b.on('data', (data) => {
|
|
85
|
+
stderrOutput = appendOutput(stderrOutput, data);
|
|
86
|
+
if (!isSilent())
|
|
87
|
+
process.stderr.write(data);
|
|
88
|
+
});
|
|
89
|
+
const rejectConditionallyWithMessage = (err, exitCode = -1) => {
|
|
90
|
+
if (processState === 'stopped')
|
|
91
|
+
return; // do not reject when process is already stopped
|
|
92
|
+
if (exitCode === 0)
|
|
93
|
+
return; // do not reject when exit code is 0
|
|
94
|
+
if (!err) {
|
|
95
|
+
err = new Error(`Command failed: ${command}\nParameters: ${paramsAsString}\nExit code: ${exitCode}`);
|
|
96
|
+
}
|
|
97
|
+
const messagePart2 = exitCode ? `with exit code ${exitCode}` : `and an error occurred: ${err.message}`;
|
|
98
|
+
console.error(`${nameOrCommand} was ${processState} ${messagePart2}`);
|
|
99
|
+
const processError = new Error(`Command failed: ${command}\nParameters: ${paramsAsString}\nExit code: ${exitCode}`);
|
|
100
|
+
const errorWithOutput = processError;
|
|
101
|
+
errorWithOutput.stdout = stdoutOutput;
|
|
102
|
+
errorWithOutput.stderr = stderrOutput;
|
|
103
|
+
errorWithOutput.cause = err;
|
|
104
|
+
reject(errorWithOutput);
|
|
105
|
+
};
|
|
106
|
+
childProcess.on('error', rejectConditionallyWithMessage);
|
|
107
|
+
childProcess.on('exit', (exitCode) => {
|
|
108
|
+
removeProcessExitListeners();
|
|
109
|
+
rejectConditionallyWithMessage(undefined, exitCode); // reject only if exit code is not zero
|
|
110
|
+
processState = 'stopped';
|
|
111
|
+
resolve(processInstance()); // finally we resolve here, when no background process was started or readyWhen did not match
|
|
112
|
+
});
|
|
113
|
+
// Resolve immediately on background process (after all listeners are registered)
|
|
114
|
+
if (processOptions === null || processOptions === void 0 ? void 0 : processOptions.background)
|
|
115
|
+
resolve(processInstance());
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=create-process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-process.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/create-process.ts"],"names":[],"mappings":";;AAgCA,sCAuGC;;AAvID,iDAAyD;AACzD,2DAAsD;AAsBtD,MAAM,WAAW,GAAG,MAAO,CAAC;AAE5B,SAAS,YAAY,CAAC,OAAe,EAAE,IAAa;IAClD,MAAM,YAAY,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC;IAC/E,IAAI,CAAC,YAAY;QAAE,OAAO,OAAO,CAAC;IAClC,MAAM,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IACtC,OAAO,MAAM,CAAC,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC;AAED,SAAsB,aAAa;iEACjC,OAAe,EACf,MAAgB,EAChB,iBAA6C,SAAS;QAEtD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;;YACrC,IAAI,YAA0B,CAAC;YAC/B,IAAI,kBAAkB,GAAG,KAAK,CAAC;YAC/B,IAAI,YAAY,GAAG,EAAE,CAAC;YACtB,IAAI,YAAY,GAAG,EAAE,CAAC;YAEtB,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,MAAM,KAAI,YAAY,KAAK,SAAS,CAAC,CAAC,2DAA2D;YAExI,MAAM,aAAa,GAAG,CAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,KAAI,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AAC,OAAO,EAAE,CAAC;gBACvG,OAAO,CAAC,KAAK,CAAC,GAAG,aAAa,QAAQ,YAAY,IAAI,YAAY,EAAE,CAAC,CAAC;gBACtE,MAAM,YAAY,GAAG,IAAI,KAAK,CAC5B,mBAAmB,OAAO,qBAAqB,cAAc,qBAAqB,QAAQ,EAAE,CAC7F,CAAC;gBACF,MAAM,eAAe,GAAG,YAA6E,CAAC;gBACtG,eAAe,CAAC,MAAM,GAAG,YAAY,CAAC;gBACtC,eAAe,CAAC,MAAM,GAAG,YAAY,CAAC;gBACtC,eAAe,CAAC,KAAK,GAAG,GAAG,CAAC;gBAC5B,MAAM,CAAC,eAAe,CAAC,CAAC;YAC1B,CAAC,CAAC;YAEF,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,8BAA8B,CAAC,CAAC;YACzD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE;gBACnC,0BAA0B,EAAE,CAAC;gBAC7B,8BAA8B,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,uCAAuC;gBAC5F,YAAY,GAAG,SAAS,CAAC;gBACzB,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,6FAA6F;YAC3H,CAAC,CAAC,CAAC;YAEH,iFAAiF;YACjF,IAAI,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,UAAU;gBAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toErrorWithMessage = toErrorWithMessage;
|
|
4
|
+
exports.errorToJson = errorToJson;
|
|
5
|
+
function isErrorWithMessage(error) {
|
|
6
|
+
return (typeof error === 'object' &&
|
|
7
|
+
error !== null &&
|
|
8
|
+
'message' in error &&
|
|
9
|
+
typeof error['message'] === 'string');
|
|
10
|
+
}
|
|
11
|
+
function toErrorWithMessage(maybeError) {
|
|
12
|
+
if (isErrorWithMessage(maybeError))
|
|
13
|
+
return maybeError;
|
|
14
|
+
try {
|
|
15
|
+
return new Error(typeof maybeError === 'string' ? maybeError : JSON.stringify(maybeError));
|
|
16
|
+
}
|
|
17
|
+
catch (_a) {
|
|
18
|
+
// fallback for stringify errors, like circular references for example.
|
|
19
|
+
return new Error(String(maybeError));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function errorToJson(error) {
|
|
23
|
+
return JSON.parse(JSON.stringify(error, Object.getOwnPropertyNames(error)));
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=error-message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-message.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/error-message.ts"],"names":[],"mappings":";;AAcA,gDASC;AAED,kCAEC;AAtBD,SAAS,kBAAkB,CAAC,KAAc;IACxC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,SAAS,IAAI,KAAK;QAClB,OAAQ,KAAiC,CAAC,SAAS,CAAC,KAAK,QAAQ,CAClE,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,UAAmB;IACpD,IAAI,kBAAkB,CAAC,UAAU,CAAC;QAAE,OAAO,UAAU,CAAC;IAEtD,IAAI,CAAC;QACH,OAAO,IAAI,KAAK,CAAC,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAE,UAAqB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC;IACzG,CAAC;IAAC,WAAM,CAAC;QACP,uEAAuE;QACvE,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;IACvC,CAAC;AACH,CAAC;AAED,SAAgB,WAAW,CAAC,KAAY;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getPackageVersion(packageName: string): any;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageVersion = getPackageVersion;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const root_directory_1 = require("./root-directory");
|
|
7
|
+
function getPackageVersion(packageName) {
|
|
8
|
+
try {
|
|
9
|
+
const packageFile = (0, path_1.join)((0, root_directory_1.rootDirectory)(), 'node_modules', packageName, 'package.json');
|
|
10
|
+
return (0, fs_1.existsSync)(packageFile) ? JSON.parse((0, fs_1.readFileSync)(packageFile).toString()).version : undefined;
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
console.error(err);
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=get-package-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-package-version.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/get-package-version.ts"],"names":[],"mappings":";;AAIA,8CAQC;AAZD,2BAA8C;AAC9C,+BAA4B;AAC5B,qDAAiD;AAEjD,SAAgB,iBAAiB,CAAC,WAAmB;IACnD,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,IAAA,8BAAa,GAAE,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QACvF,OAAO,IAAA,eAAU,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,WAAW,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;IACxG,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnB,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.killProcessTree = killProcessTree;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
/**
|
|
6
|
+
* Kills a process and all its children.
|
|
7
|
+
* On Linux/macOS uses a negative PID to signal the whole process group.
|
|
8
|
+
* On Windows uses `taskkill /F /T` because negative PIDs are not supported.
|
|
9
|
+
*/
|
|
10
|
+
function killProcessTree(pid) {
|
|
11
|
+
try {
|
|
12
|
+
if (process.platform === 'win32') {
|
|
13
|
+
(0, child_process_1.spawnSync)('taskkill', ['/pid', `${pid}`, '/T', '/F'], { stdio: 'ignore', timeout: 10000 });
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
process.kill(-pid, 'SIGTERM');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch (_a) {
|
|
20
|
+
try {
|
|
21
|
+
process.kill(pid, 'SIGTERM');
|
|
22
|
+
}
|
|
23
|
+
catch (_b) {
|
|
24
|
+
// ignore — process may have already exited
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=kill-process-tree.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kill-process-tree.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/kill-process-tree.ts"],"names":[],"mappings":";;AAOA,0CAcC;AArBD,iDAA0C;AAE1C;;;;GAIG;AACH,SAAgB,eAAe,CAAC,GAAW;IACzC,IAAI,CAAC;QACH,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACjC,IAAA,yBAAS,EAAC,UAAU,EAAE,CAAC,MAAM,EAAE,GAAG,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QAC7F,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAChC,CAAC;IACH,CAAC;IAAC,WAAM,CAAC;QACP,IAAI,CAAC;YACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;QAC/B,CAAC;QAAC,WAAM,CAAC;YACP,2CAA2C;QAC7C,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function replaceInFile(file: string, search: RegExp, replace: string): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.replaceInFile = replaceInFile;
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
function replaceInFile(file, search, replace) {
|
|
6
|
+
const content = (0, fs_1.readFileSync)(file, 'utf8');
|
|
7
|
+
const replacedContent = content.replace(search, replace);
|
|
8
|
+
const tmpfile = `${file}.jstmpreplace`;
|
|
9
|
+
(0, fs_1.writeFileSync)(tmpfile, replacedContent, 'utf8');
|
|
10
|
+
(0, fs_1.renameSync)(tmpfile, file);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=replace-in-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replace-in-file.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/replace-in-file.ts"],"names":[],"mappings":";;AAEA,sCAMC;AARD,2BAA6D;AAE7D,SAAgB,aAAa,CAAC,IAAY,EAAE,MAAc,EAAE,OAAe;IACzE,MAAM,OAAO,GAAG,IAAA,iBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC3C,MAAM,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,GAAG,IAAI,eAAe,CAAC;IACvC,IAAA,kBAAa,EAAC,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;IAChD,IAAA,eAAU,EAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function rootDirectory(pathToAnalyze?: string): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rootDirectory = rootDirectory;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("path"));
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
function rootDirectory(pathToAnalyze = '') {
|
|
8
|
+
const nodeModules = /[/\\]node_modules/;
|
|
9
|
+
const usedPath = pathToAnalyze || __dirname;
|
|
10
|
+
if (nodeModules.test(usedPath))
|
|
11
|
+
return usedPath.split(nodeModules)[0];
|
|
12
|
+
// Source libraries and internal files in the built product have different
|
|
13
|
+
// depths. Locate their Nx workspace rather than depending on that depth.
|
|
14
|
+
if (!pathToAnalyze) {
|
|
15
|
+
let directory = usedPath;
|
|
16
|
+
while (directory !== path.dirname(directory)) {
|
|
17
|
+
if ((0, node_fs_1.existsSync)(path.join(directory, 'nx.json')))
|
|
18
|
+
return directory;
|
|
19
|
+
directory = path.dirname(directory);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return path.resolve(path.join(usedPath, '..', '..', '..', '..'));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=root-directory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-directory.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/root-directory.ts"],"names":[],"mappings":";;AAGA,sCAcC;;AAjBD,mDAA6B;AAC7B,qCAAqC;AAErC,SAAgB,aAAa,CAAC,aAAa,GAAG,EAAE;IAC9C,MAAM,WAAW,GAAG,mBAAmB,CAAC;IACxC,MAAM,QAAQ,GAAG,aAAa,IAAI,SAAS,CAAC;IAC5C,IAAI,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,0EAA0E;IAC1E,yEAAyE;IACzE,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,IAAI,SAAS,GAAG,QAAQ,CAAC;QACzB,OAAO,SAAS,KAAK,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YAC7C,IAAI,IAAA,oBAAU,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBAAE,OAAO,SAAS,CAAC;YAClE,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function waitForUrl(url: string, timeout?: number | undefined): Promise<void>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.waitForUrl = waitForUrl;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
6
|
+
const waitOn = require('wait-on');
|
|
7
|
+
function waitForUrl(url_1) {
|
|
8
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* (url, timeout = undefined) {
|
|
9
|
+
if (timeout && (timeout < 1000 || timeout >= 3600))
|
|
10
|
+
throw new Error('Invalid timeout');
|
|
11
|
+
const usedTimeout = timeout || 5 * 60 * 1000;
|
|
12
|
+
console.log(`waiting for URL ${url} | timeout: ${new Date(usedTimeout).toISOString().slice(14, -5)}`);
|
|
13
|
+
const opts = {
|
|
14
|
+
resources: [url],
|
|
15
|
+
interval: usedTimeout > 4000 ? 2000 : 125,
|
|
16
|
+
window: 1000,
|
|
17
|
+
timeout: usedTimeout,
|
|
18
|
+
strictSSL: false,
|
|
19
|
+
headers: {
|
|
20
|
+
Accept: 'text/html, application/json, text/plain, */*',
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
yield waitOn(opts);
|
|
24
|
+
console.log(`URL ready: ${url}`);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=wait-for-url.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-for-url.js","sourceRoot":"","sources":["../../../../../libs/shared-util/src/lib/wait-for-url.ts"],"names":[],"mappings":";;AAGA,gCAgBC;;AAnBD,8DAA8D;AAC9D,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;AAElC,SAAsB,UAAU;iEAAC,GAAW,EAAE,UAA8B,SAAS;QACnF,IAAI,OAAO,IAAI,CAAC,OAAO,GAAG,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACvF,MAAM,WAAW,GAAG,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,mBAAmB,GAAG,eAAe,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACtG,MAAM,IAAI,GAAG;YACX,SAAS,EAAE,CAAC,GAAG,CAAC;YAChB,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG;YACzC,MAAM,EAAE,IAAI;YACZ,OAAO,EAAE,WAAW;YACpB,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE;gBACP,MAAM,EAAE,8CAA8C;aACvD;SACF,CAAC;QACF,MAAM,MAAM,CAAC,IAAI,CAAC,CAAC;QACnB,OAAO,CAAC,GAAG,CAAC,cAAc,GAAG,EAAE,CAAC,CAAC;IACnC,CAAC;CAAA"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnuechtel/nx-cucumber",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.3.0-17590857434",
|
|
4
4
|
"description": "Plugin to use Cucumber within Nx workspaces",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://gitlab.com/gnuechtel/
|
|
8
|
+
"url": "https://gitlab.com/gnuechtel/nx-cucumber.git",
|
|
9
9
|
"directory": "libs/nx-cucumber"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@nx/devkit": ">=24 <25",
|
|
13
13
|
"minimatch": "^10.0.0",
|
|
14
14
|
"tslib": "^2.8.1",
|
|
15
|
-
"
|
|
16
|
-
"@gnuechtel/shared-util": "24.2.0"
|
|
15
|
+
"wait-on": "^9.5.1"
|
|
17
16
|
},
|
|
18
17
|
"peerDependencies": {
|
|
19
18
|
"@cucumber/cucumber": ">=13 <14",
|
|
@@ -23,7 +22,10 @@
|
|
|
23
22
|
"playwright": ">=1.64 <2",
|
|
24
23
|
"@playwright/test": ">=1.64 <2",
|
|
25
24
|
"nx": ">=24 <25",
|
|
26
|
-
"typescript": ">=5.8 <7"
|
|
25
|
+
"typescript": ">=5.8 <7",
|
|
26
|
+
"nyc": "^18.0.0",
|
|
27
|
+
"@jridgewell/trace-mapping": ">=0.3.0",
|
|
28
|
+
"@jridgewell/gen-mapping": ">=0.3.0"
|
|
27
29
|
},
|
|
28
30
|
"type": "commonjs",
|
|
29
31
|
"main": "./src/index.js",
|
|
@@ -34,12 +36,20 @@
|
|
|
34
36
|
"executors": "./executors.json",
|
|
35
37
|
"typings": "./src/index.d.ts",
|
|
36
38
|
"engines": {
|
|
37
|
-
"node": "
|
|
39
|
+
"node": "^24.0.0 || ^26.0.0"
|
|
38
40
|
},
|
|
39
41
|
"peerDependenciesMeta": {
|
|
40
42
|
"typescript": {
|
|
41
43
|
"optional": true
|
|
44
|
+
},
|
|
45
|
+
"nyc": {
|
|
46
|
+
"optional": true
|
|
47
|
+
},
|
|
48
|
+
"@jridgewell/trace-mapping": {
|
|
49
|
+
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@jridgewell/gen-mapping": {
|
|
52
|
+
"optional": true
|
|
42
53
|
}
|
|
43
|
-
}
|
|
44
|
-
"types": "./src/index.d.ts"
|
|
54
|
+
}
|
|
45
55
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOutputDirectories = getOutputDirectories;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const shared_util_1 = require("
|
|
5
|
+
const shared_util_1 = require("../../internal/shared-util/src/index.js");
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
7
|
function getOutputDirectories(outputDirectory) {
|
|
8
8
|
const fullOutputDirectory = path.join((0, shared_util_1.rootDirectory)(), outputDirectory);
|
|
@@ -4,10 +4,10 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const cucumber_1 = require("@cucumber/cucumber");
|
|
5
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
6
|
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const shared_coverage_1 = require("
|
|
7
|
+
const shared_coverage_1 = require("../../internal/shared-coverage/src/index.js");
|
|
8
8
|
const playwright_world_1 = require("./playwright-world");
|
|
9
|
-
const shared_coverage_2 = require("
|
|
10
|
-
const shared_util_1 = require("
|
|
9
|
+
const shared_coverage_2 = require("../../internal/shared-coverage/src/index.js");
|
|
10
|
+
const shared_util_1 = require("../../internal/shared-util/src/index.js");
|
|
11
11
|
const playwright_browser_1 = require("../core/playwright-browser");
|
|
12
12
|
const playwright_browser_2 = require("./playwright-browser");
|
|
13
13
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.scenarioName = exports.PlaywrightWorld = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cucumber_1 = require("@cucumber/cucumber");
|
|
6
|
-
const shared_coverage_1 = require("
|
|
6
|
+
const shared_coverage_1 = require("../../internal/shared-coverage/src/index.js");
|
|
7
7
|
const output_directories_1 = require("../core/output-directories");
|
|
8
8
|
const fs = tslib_1.__importStar(require("fs"));
|
|
9
9
|
const path = tslib_1.__importStar(require("path"));
|