@regressionproof/snapshotter 0.5.0 → 0.5.2
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/build/esm/git.js +15 -0
- package/build/esm/snapshot.js +6 -1
- package/build/git.js +13 -0
- package/build/snapshot.js +12 -1
- package/package.json +2 -2
package/build/esm/git.js
CHANGED
|
@@ -40,9 +40,24 @@ export function gitPush(mirrorPath, remote, log) {
|
|
|
40
40
|
catch (_a) {
|
|
41
41
|
yield execOrThrow(`git -C "${mirrorPath}" remote add origin "${authedUrl}"`);
|
|
42
42
|
}
|
|
43
|
+
yield execOrThrow(`git -C "${mirrorPath}" fetch origin`, log);
|
|
44
|
+
if (yield hasRemoteHead(mirrorPath)) {
|
|
45
|
+
yield execOrThrow(`git -C "${mirrorPath}" rebase origin/HEAD`, log);
|
|
46
|
+
}
|
|
43
47
|
yield execOrThrow(`git -C "${mirrorPath}" push -u origin HEAD`, log);
|
|
44
48
|
});
|
|
45
49
|
}
|
|
50
|
+
function hasRemoteHead(mirrorPath) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
try {
|
|
53
|
+
yield execAsync(`git -C "${mirrorPath}" symbolic-ref -q refs/remotes/origin/HEAD`);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
catch (_a) {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
46
61
|
function execOrThrow(command, log) {
|
|
47
62
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
63
|
var _a, _b;
|
package/build/esm/snapshot.js
CHANGED
|
@@ -27,7 +27,7 @@ class Snapshotter {
|
|
|
27
27
|
this.log.info('Files synced', mirrorPath);
|
|
28
28
|
const snapshotterDir = path.join(mirrorPath, '.snapshotter');
|
|
29
29
|
mkdirSync(snapshotterDir, { recursive: true });
|
|
30
|
-
writeFileSync(path.join(snapshotterDir, 'testResults.json'), JSON.stringify(testResults, null, 2));
|
|
30
|
+
writeFileSync(path.join(snapshotterDir, 'testResults.json'), JSON.stringify(sortTestResults(testResults), null, 2));
|
|
31
31
|
this.log.info('Test results saved', snapshotterDir);
|
|
32
32
|
const committed = yield gitCommit(mirrorPath, this.log);
|
|
33
33
|
if (!committed) {
|
|
@@ -52,3 +52,8 @@ export function snapshot(options) {
|
|
|
52
52
|
return new Snapshotter().snapshot(options);
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
|
+
function sortTestResults(testResults) {
|
|
56
|
+
const suites = [...testResults.suites].map((suite) => (Object.assign(Object.assign({}, suite), { tests: [...suite.tests].sort((left, right) => left.name.localeCompare(right.name)) })));
|
|
57
|
+
suites.sort((left, right) => left.path.localeCompare(right.path));
|
|
58
|
+
return Object.assign(Object.assign({}, testResults), { suites });
|
|
59
|
+
}
|
package/build/git.js
CHANGED
|
@@ -35,8 +35,21 @@ async function gitPush(mirrorPath, remote, log) {
|
|
|
35
35
|
catch {
|
|
36
36
|
await execOrThrow(`git -C "${mirrorPath}" remote add origin "${authedUrl}"`);
|
|
37
37
|
}
|
|
38
|
+
await execOrThrow(`git -C "${mirrorPath}" fetch origin`, log);
|
|
39
|
+
if (await hasRemoteHead(mirrorPath)) {
|
|
40
|
+
await execOrThrow(`git -C "${mirrorPath}" rebase origin/HEAD`, log);
|
|
41
|
+
}
|
|
38
42
|
await execOrThrow(`git -C "${mirrorPath}" push -u origin HEAD`, log);
|
|
39
43
|
}
|
|
44
|
+
async function hasRemoteHead(mirrorPath) {
|
|
45
|
+
try {
|
|
46
|
+
await execAsync(`git -C "${mirrorPath}" symbolic-ref -q refs/remotes/origin/HEAD`);
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
40
53
|
async function execOrThrow(command, log) {
|
|
41
54
|
try {
|
|
42
55
|
return await execAsync(command);
|
package/build/snapshot.js
CHANGED
|
@@ -22,7 +22,7 @@ class Snapshotter {
|
|
|
22
22
|
this.log.info('Files synced', mirrorPath);
|
|
23
23
|
const snapshotterDir = path_1.default.join(mirrorPath, '.snapshotter');
|
|
24
24
|
(0, fs_1.mkdirSync)(snapshotterDir, { recursive: true });
|
|
25
|
-
(0, fs_1.writeFileSync)(path_1.default.join(snapshotterDir, 'testResults.json'), JSON.stringify(testResults, null, 2));
|
|
25
|
+
(0, fs_1.writeFileSync)(path_1.default.join(snapshotterDir, 'testResults.json'), JSON.stringify(sortTestResults(testResults), null, 2));
|
|
26
26
|
this.log.info('Test results saved', snapshotterDir);
|
|
27
27
|
const committed = await (0, git_js_1.gitCommit)(mirrorPath, this.log);
|
|
28
28
|
if (!committed) {
|
|
@@ -44,3 +44,14 @@ class Snapshotter {
|
|
|
44
44
|
async function snapshot(options) {
|
|
45
45
|
return new Snapshotter().snapshot(options);
|
|
46
46
|
}
|
|
47
|
+
function sortTestResults(testResults) {
|
|
48
|
+
const suites = [...testResults.suites].map((suite) => ({
|
|
49
|
+
...suite,
|
|
50
|
+
tests: [...suite.tests].sort((left, right) => left.name.localeCompare(right.name)),
|
|
51
|
+
}));
|
|
52
|
+
suites.sort((left, right) => left.path.localeCompare(right.path));
|
|
53
|
+
return {
|
|
54
|
+
...testResults,
|
|
55
|
+
suites,
|
|
56
|
+
};
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regressionproof/snapshotter",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"@sprucelabs/spruce-core-schemas": "^42.1.3",
|
|
95
95
|
"@sprucelabs/spruce-skill-utils": "^34.0.3"
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "b227dba3baef857f884befca26a119b9cfc545b7"
|
|
98
98
|
}
|