@datadog/datadog-ci 1.1.0 → 1.2.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/LICENSE-3rdparty.csv +2 -0
- package/dist/commands/dsyms/__tests__/upload.test.js +219 -16
- package/dist/commands/dsyms/__tests__/utils.test.js +86 -46
- package/dist/commands/dsyms/interfaces.d.ts +14 -5
- package/dist/commands/dsyms/interfaces.js +15 -28
- package/dist/commands/dsyms/renderer.d.ts +7 -5
- package/dist/commands/dsyms/renderer.js +18 -6
- package/dist/commands/dsyms/upload.d.ts +31 -0
- package/dist/commands/dsyms/upload.js +127 -13
- package/dist/commands/dsyms/utils.d.ts +12 -6
- package/dist/commands/dsyms/utils.js +23 -51
- package/dist/commands/synthetics/__tests__/run-test.test.js +30 -24
- package/dist/commands/synthetics/__tests__/utils.test.js +19 -10
- package/dist/commands/synthetics/api.d.ts +3 -12
- package/dist/commands/synthetics/api.js +4 -1
- package/dist/commands/synthetics/command.js +4 -0
- package/dist/commands/synthetics/errors.d.ts +4 -4
- package/dist/commands/synthetics/errors.js +5 -4
- package/dist/commands/synthetics/interfaces.d.ts +1 -4
- package/dist/commands/synthetics/reporters/default.js +2 -2
- package/dist/commands/synthetics/run-test.d.ts +1 -11
- package/dist/commands/synthetics/run-test.js +5 -2
- package/dist/commands/synthetics/utils.d.ts +1 -0
- package/dist/commands/synthetics/utils.js +6 -5
- package/package.json +5 -3
package/LICENSE-3rdparty.csv
CHANGED
|
@@ -10,6 +10,7 @@ Component,Origin,Licence,Copyright
|
|
|
10
10
|
@types/inquirer,dev,MIT,Copyright Microsoft Corporation
|
|
11
11
|
@types/jest,dev,MIT,Copyright Microsoft Corporation
|
|
12
12
|
@types/node,dev,MIT,Copyright Microsoft Corporation
|
|
13
|
+
@types/rimraf,dev,MIT,Copyright Carlos Ballesteros Velasco <https://github.com/soywiz> and contributors
|
|
13
14
|
@types/ssh2,dev,MIT,Copyright Microsoft Corporation
|
|
14
15
|
@types/ssh2-streams,dev,MIT,Copyright Microsoft Corporation
|
|
15
16
|
@types/sshpk,dev,MIT,Copyright Microsoft Corporation
|
|
@@ -34,6 +35,7 @@ pkg,dev,MIT,Copyright (c) 2021 Vercel, Inc.
|
|
|
34
35
|
prettier,dev,MIT,Copyright © James Long and contributors
|
|
35
36
|
proxy,dev,MIT,Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
36
37
|
proxy-agent,import,MIT,Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
|
|
38
|
+
rimraf,import,ISC,Copyright (c) 2011-2022 Isaac Z. Schlueter and Contributors
|
|
37
39
|
simple-git,import,MIT,Copyright (c) 2015 Steve King
|
|
38
40
|
ssh2,import,MIT,Copyright (c) Brian White
|
|
39
41
|
ssh2-streams,import,MIT,Copyright (c) 2014 Brian White
|
|
@@ -8,15 +8,207 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
// tslint:disable: no-string-literal
|
|
13
|
-
// tslint:disable: no-var-requires
|
|
14
16
|
const advanced_1 = require("clipanion/lib/advanced");
|
|
17
|
+
const fs_1 = require("fs");
|
|
18
|
+
const glob_1 = __importDefault(require("glob"));
|
|
15
19
|
const os_1 = require("os");
|
|
20
|
+
const path_1 = __importDefault(require("path"));
|
|
21
|
+
const utils_1 = require("../../../helpers/utils");
|
|
16
22
|
const upload_1 = require("../upload");
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
const utils_2 = require("../utils");
|
|
24
|
+
/**
|
|
25
|
+
* `dwarfdump` and `lipo` are only available in macOS, so we mock their behaviour when running tests on other platforms.
|
|
26
|
+
*/
|
|
27
|
+
const mockDwarfdumpAndLipoIfNotMacOS = () => {
|
|
28
|
+
if (os_1.platform() !== 'darwin') {
|
|
29
|
+
// For `dwarfdump --uuid` mock, return the same output as the command would give on macOS:
|
|
30
|
+
require('../utils').executeDwarfdump = jest.fn().mockImplementation((dsymPath) => {
|
|
31
|
+
let fixture = dsymPath.includes('multiple-archs') ? fatDSYMFixture : undefined;
|
|
32
|
+
fixture = fixture !== null && fixture !== void 0 ? fixture : (dsymPath.includes('single-arch') ? slimDSYMFixture : undefined);
|
|
33
|
+
if (fixture !== undefined) {
|
|
34
|
+
const outputLines = fixture.slices.map((slice) => {
|
|
35
|
+
const objectPathInDsym = path_1.default.relative(fixture.bundlePath, slice.objectPath);
|
|
36
|
+
const objectPathInMockedDSYM = utils_1.buildPath(dsymPath, objectPathInDsym);
|
|
37
|
+
return `UUID: ${slice.uuid} (${slice.arch}) ${objectPathInMockedDSYM}`;
|
|
38
|
+
});
|
|
39
|
+
return { stderr: '', stdout: outputLines.join('\n') };
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new Error(`Cannot find mock dSYM fixture for dsymPath: ${dsymPath}`);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
// For `lipo -thin` mock, just copy the object to new location (without extracting the slice as macOS would do):
|
|
46
|
+
require('../utils').executeLipo = jest
|
|
47
|
+
.fn()
|
|
48
|
+
.mockImplementation((objectPath, arch, newObjectPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
yield fs_1.promises.copyFile(objectPath, newObjectPath);
|
|
50
|
+
return { stderr: '', stdout: '' };
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Fixture for dSYM containing two arch slices. This is the same dSYM information as can be
|
|
56
|
+
* read with `dwarfdump --uuid ./src/commands/dsyms/__tests__/fixtures/multiple-archs/DDTest.framework.dSYM` on macOS.
|
|
57
|
+
*/
|
|
58
|
+
const fatDSYMFixture = {
|
|
59
|
+
bundlePath: 'src/commands/dsyms/__tests__/fixtures/multiple-archs/DDTest.framework.dSYM',
|
|
60
|
+
slices: [
|
|
61
|
+
{
|
|
62
|
+
arch: 'armv7',
|
|
63
|
+
objectPath: 'src/commands/dsyms/__tests__/fixtures/multiple-archs/DDTest.framework.dSYM/Contents/Resources/DWARF/DDTest',
|
|
64
|
+
uuid: 'C8469F85-B060-3085-B69D-E46C645560EA',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
arch: 'arm64',
|
|
68
|
+
objectPath: 'src/commands/dsyms/__tests__/fixtures/multiple-archs/DDTest.framework.dSYM/Contents/Resources/DWARF/DDTest',
|
|
69
|
+
uuid: '06EE3D68-D605-3E92-B92D-2F48C02A505E',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Fixture for dSYM containing single arch slice. This is the same dSYM information as can be
|
|
75
|
+
* read with `dwarfdump --uuid ./src/commands/dsyms/__tests__/fixtures/single-archs/DDTest.framework.dSYM` on macOS.
|
|
76
|
+
*/
|
|
77
|
+
const slimDSYMFixture = {
|
|
78
|
+
bundlePath: 'src/commands/dsyms/__tests__/fixtures/single-arch/DDTest.framework.dSYM',
|
|
79
|
+
slices: [
|
|
80
|
+
{
|
|
81
|
+
arch: 'arm64',
|
|
82
|
+
objectPath: 'src/commands/dsyms/__tests__/fixtures/single-arch/DDTest.framework.dSYM/Contents/Resources/DWARF/DDTest',
|
|
83
|
+
uuid: '3BC12422-63CC-30E8-B916-E5006CE3286C',
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
};
|
|
87
|
+
describe('upload', () => {
|
|
88
|
+
beforeAll(() => {
|
|
89
|
+
mockDwarfdumpAndLipoIfNotMacOS();
|
|
90
|
+
});
|
|
91
|
+
describe('findDSYMsInDirectory', () => {
|
|
92
|
+
const command = new upload_1.UploadCommand();
|
|
93
|
+
test('Should find dSYMs recursively', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const expectedDSYMs = [fatDSYMFixture, slimDSYMFixture];
|
|
95
|
+
const actualDSYMs = yield command['findDSYMsInDirectory']('src/commands/dsyms/__tests__/fixtures');
|
|
96
|
+
expect(actualDSYMs.length).toEqual(2);
|
|
97
|
+
expect(actualDSYMs).toContainEqual(expectedDSYMs[0]);
|
|
98
|
+
expect(actualDSYMs).toContainEqual(expectedDSYMs[1]);
|
|
99
|
+
}));
|
|
100
|
+
});
|
|
101
|
+
describe('parseDwarfdumpOutput', () => {
|
|
102
|
+
const command = new upload_1.UploadCommand();
|
|
103
|
+
test('Should read arch slice from single-line output', () => {
|
|
104
|
+
const output = 'UUID: 00000000-1111-2222-3333-444444444444 (arm64) /folder/Foo.dSYM/Contents/Resources/DWARF/Foo';
|
|
105
|
+
const slices = command['parseDwarfdumpOutput'](output);
|
|
106
|
+
expect(slices).toEqual([
|
|
107
|
+
{
|
|
108
|
+
arch: 'arm64',
|
|
109
|
+
objectPath: '/folder/Foo.dSYM/Contents/Resources/DWARF/Foo',
|
|
110
|
+
uuid: '00000000-1111-2222-3333-444444444444',
|
|
111
|
+
},
|
|
112
|
+
]);
|
|
113
|
+
});
|
|
114
|
+
test('Should read arch slices from multi-line output', () => {
|
|
115
|
+
const output = 'UUID: 00000000-1111-2222-3333-444444444444 (arm64) /folder/Foo.dSYM/Contents/Resources/DWARF/Foo\n' +
|
|
116
|
+
'UUID: AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE (x86_64) /folder/Foo.dSYM/Contents/Resources/DWARF/Foo\n' +
|
|
117
|
+
'UUID: FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF (armv7) /folder/Foo.dSYM/Contents/Resources/DWARF/Foo\n';
|
|
118
|
+
const slices = command['parseDwarfdumpOutput'](output);
|
|
119
|
+
expect(slices).toEqual([
|
|
120
|
+
{
|
|
121
|
+
arch: 'arm64',
|
|
122
|
+
objectPath: '/folder/Foo.dSYM/Contents/Resources/DWARF/Foo',
|
|
123
|
+
uuid: '00000000-1111-2222-3333-444444444444',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
arch: 'x86_64',
|
|
127
|
+
objectPath: '/folder/Foo.dSYM/Contents/Resources/DWARF/Foo',
|
|
128
|
+
uuid: 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE',
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
arch: 'armv7',
|
|
132
|
+
objectPath: '/folder/Foo.dSYM/Contents/Resources/DWARF/Foo',
|
|
133
|
+
uuid: 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF',
|
|
134
|
+
},
|
|
135
|
+
]);
|
|
136
|
+
});
|
|
137
|
+
test('Should read arch slice if object path contains whitespaces', () => {
|
|
138
|
+
const output = 'UUID: 00000000-1111-2222-3333-444444444444 (arm64) /folder with whitespaces/Foo Bar.dSYM/Contents/Resources/DWARF/Foo Bar';
|
|
139
|
+
const slices = command['parseDwarfdumpOutput'](output);
|
|
140
|
+
expect(slices).toEqual([
|
|
141
|
+
{
|
|
142
|
+
arch: 'arm64',
|
|
143
|
+
objectPath: '/folder with whitespaces/Foo Bar.dSYM/Contents/Resources/DWARF/Foo Bar',
|
|
144
|
+
uuid: '00000000-1111-2222-3333-444444444444',
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
});
|
|
148
|
+
test('Should read no arch slices from invalid output', () => {
|
|
149
|
+
const slices = command['parseDwarfdumpOutput']('');
|
|
150
|
+
expect(slices).toEqual([]);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
describe('thinDSYMs', () => {
|
|
154
|
+
const command = new upload_1.UploadCommand();
|
|
155
|
+
test('Given fat dSYM, it should extract each arch slice to separate dSYM in target folder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
156
|
+
const tmpDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
157
|
+
// Given
|
|
158
|
+
const inputDSYM = fatDSYMFixture;
|
|
159
|
+
expect(inputDSYM.slices.length).toBeGreaterThan(1);
|
|
160
|
+
// When
|
|
161
|
+
const extractedDSYMs = yield command['thinDSYMs']([inputDSYM], tmpDirectory);
|
|
162
|
+
// Then
|
|
163
|
+
expect(extractedDSYMs.length).toEqual(inputDSYM.slices.length);
|
|
164
|
+
inputDSYM.slices.forEach((slice) => {
|
|
165
|
+
expect(extractedDSYMs).toContainEqual({
|
|
166
|
+
bundlePath: `${utils_1.buildPath(tmpDirectory, slice.uuid)}.dSYM`,
|
|
167
|
+
slices: [
|
|
168
|
+
{
|
|
169
|
+
arch: slice.arch,
|
|
170
|
+
objectPath: `${utils_1.buildPath(tmpDirectory, slice.uuid)}.dSYM/Contents/Resources/DWARF/DDTest`,
|
|
171
|
+
uuid: slice.uuid,
|
|
172
|
+
},
|
|
173
|
+
],
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
const objectFilesInTargetFolder = glob_1.default.sync(utils_1.buildPath(tmpDirectory, '**/Contents/Resources/DWARF/DDTest'));
|
|
177
|
+
expect(objectFilesInTargetFolder.length).toEqual(inputDSYM.slices.length);
|
|
178
|
+
yield utils_2.deleteDirectory(tmpDirectory);
|
|
179
|
+
}));
|
|
180
|
+
test('Given slim dSYM, it should leave it untouched and not extract anything into target folder', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
|
+
const tmpDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
182
|
+
// Given
|
|
183
|
+
const inputDSYM = slimDSYMFixture;
|
|
184
|
+
expect(inputDSYM.slices.length).toEqual(1);
|
|
185
|
+
// When
|
|
186
|
+
const extractedDSYMs = yield command['thinDSYMs']([inputDSYM], tmpDirectory);
|
|
187
|
+
// Then
|
|
188
|
+
expect(extractedDSYMs).toEqual([inputDSYM]);
|
|
189
|
+
const filesInTargetFolder = glob_1.default.sync(utils_1.buildPath(tmpDirectory, '*'));
|
|
190
|
+
expect(filesInTargetFolder.length).toEqual(0);
|
|
191
|
+
yield utils_2.deleteDirectory(tmpDirectory);
|
|
192
|
+
}));
|
|
193
|
+
});
|
|
194
|
+
describe('compressDSYMsToDirectory', () => {
|
|
195
|
+
const command = new upload_1.UploadCommand();
|
|
196
|
+
test('Should archive dSYMs to target directory and name archives by their UUIDs', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
197
|
+
const tmpDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
198
|
+
const dsymFixtures = [fatDSYMFixture, slimDSYMFixture];
|
|
199
|
+
// When
|
|
200
|
+
const compressedDSYMs = yield command['compressDSYMsToDirectory'](dsymFixtures, tmpDirectory);
|
|
201
|
+
// Then
|
|
202
|
+
expect(compressedDSYMs[0].dsym).toEqual(dsymFixtures[0]);
|
|
203
|
+
expect(compressedDSYMs[0].archivePath).toEqual(utils_1.buildPath(tmpDirectory, `${dsymFixtures[0].slices[0].uuid}.zip`));
|
|
204
|
+
expect(fs_1.existsSync(compressedDSYMs[0].archivePath)).toBeTruthy();
|
|
205
|
+
expect(compressedDSYMs[1].dsym).toEqual(dsymFixtures[1]);
|
|
206
|
+
expect(compressedDSYMs[1].archivePath).toEqual(utils_1.buildPath(tmpDirectory, `${dsymFixtures[1].slices[0].uuid}.zip`));
|
|
207
|
+
expect(fs_1.existsSync(compressedDSYMs[1].archivePath)).toBeTruthy();
|
|
208
|
+
yield utils_2.deleteDirectory(tmpDirectory);
|
|
209
|
+
}));
|
|
210
|
+
});
|
|
211
|
+
});
|
|
20
212
|
describe('execute', () => {
|
|
21
213
|
const makeCli = () => {
|
|
22
214
|
const cli = new advanced_1.Cli();
|
|
@@ -34,33 +226,44 @@ describe('execute', () => {
|
|
|
34
226
|
},
|
|
35
227
|
};
|
|
36
228
|
};
|
|
37
|
-
const runCLI = (
|
|
229
|
+
const runCLI = (dsymPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
230
|
const cli = makeCli();
|
|
39
231
|
const context = createMockContext();
|
|
40
232
|
process.env = { DATADOG_API_KEY: 'PLACEHOLDER' };
|
|
41
|
-
const code = yield cli.run(['dsyms', 'upload',
|
|
233
|
+
const code = yield cli.run(['dsyms', 'upload', dsymPath, '--dry-run'], context);
|
|
42
234
|
return { context, code };
|
|
43
235
|
});
|
|
44
|
-
|
|
45
|
-
|
|
236
|
+
beforeAll(() => {
|
|
237
|
+
mockDwarfdumpAndLipoIfNotMacOS();
|
|
238
|
+
});
|
|
239
|
+
test('Should succeed with folder input', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
240
|
+
const { context, code } = yield runCLI('src/commands/dsyms/__tests__/fixtures/');
|
|
46
241
|
const outputString = context.stdout.toString();
|
|
47
242
|
const output = outputString.split(os_1.EOL);
|
|
48
243
|
expect(outputString).not.toContain('Error');
|
|
49
244
|
expect(code).toBe(0);
|
|
50
245
|
expect(output[1]).toContain('Starting upload with concurrency 20. ');
|
|
51
|
-
expect(output[2]).toContain('Will look for dSYMs in src/commands/dsyms/__tests__/
|
|
52
|
-
expect(output[3]).toContain('
|
|
53
|
-
expect(output[
|
|
246
|
+
expect(output[2]).toContain('Will look for dSYMs in src/commands/dsyms/__tests__/fixtures/');
|
|
247
|
+
expect(output[3]).toContain('Will use temporary intermediate directory: ');
|
|
248
|
+
expect(output[4]).toContain('Will use temporary upload directory: ');
|
|
249
|
+
expect(output[5]).toContain('Uploading C8469F85-B060-3085-B69D-E46C645560EA.zip (DDTest, arch: armv7, UUID: C8469F85-B060-3085-B69D-E46C645560EA)');
|
|
250
|
+
expect(output[6]).toContain('Uploading 06EE3D68-D605-3E92-B92D-2F48C02A505E.zip (DDTest, arch: arm64, UUID: 06EE3D68-D605-3E92-B92D-2F48C02A505E)');
|
|
251
|
+
expect(output[7]).toContain('Uploading 3BC12422-63CC-30E8-B916-E5006CE3286C.zip (DDTest, arch: arm64, UUID: 3BC12422-63CC-30E8-B916-E5006CE3286C)');
|
|
252
|
+
expect(output[10]).toContain('Handled 3 dSYMs with success');
|
|
54
253
|
}));
|
|
55
|
-
test('
|
|
56
|
-
const { context, code } = yield runCLI('
|
|
254
|
+
test('Should succeed with zip file input', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
255
|
+
const { context, code } = yield runCLI('src/commands/dsyms/__tests__/fixtures/all.zip');
|
|
57
256
|
const outputString = context.stdout.toString();
|
|
58
257
|
const output = outputString.split(os_1.EOL);
|
|
59
258
|
expect(outputString).not.toContain('Error');
|
|
60
259
|
expect(code).toBe(0);
|
|
61
260
|
expect(output[1]).toContain('Starting upload with concurrency 20. ');
|
|
62
|
-
expect(output[2]).toContain('Will look for dSYMs in src/commands/dsyms/__tests__/
|
|
63
|
-
expect(output[3]).toContain('
|
|
64
|
-
expect(output[
|
|
261
|
+
expect(output[2]).toContain('Will look for dSYMs in src/commands/dsyms/__tests__/fixtures/all.zip');
|
|
262
|
+
expect(output[3]).toContain('Will use temporary intermediate directory: ');
|
|
263
|
+
expect(output[4]).toContain('Will use temporary upload directory: ');
|
|
264
|
+
expect(output[5]).toContain('Uploading C8469F85-B060-3085-B69D-E46C645560EA.zip (DDTest, arch: armv7, UUID: C8469F85-B060-3085-B69D-E46C645560EA)');
|
|
265
|
+
expect(output[6]).toContain('Uploading 06EE3D68-D605-3E92-B92D-2F48C02A505E.zip (DDTest, arch: arm64, UUID: 06EE3D68-D605-3E92-B92D-2F48C02A505E)');
|
|
266
|
+
expect(output[7]).toContain('Uploading 3BC12422-63CC-30E8-B916-E5006CE3286C.zip (DDTest, arch: arm64, UUID: 3BC12422-63CC-30E8-B916-E5006CE3286C)');
|
|
267
|
+
expect(output[10]).toContain('Handled 3 dSYMs with success');
|
|
65
268
|
}));
|
|
66
269
|
});
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
2
21
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
22
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
23
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -8,51 +27,72 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
27
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
28
|
});
|
|
10
29
|
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
11
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
describe('
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
describe('
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
const fs_1 = __importStar(require("fs"));
|
|
35
|
+
const glob_1 = __importDefault(require("glob"));
|
|
36
|
+
const utils_1 = require("../../../helpers/utils");
|
|
37
|
+
const utils_2 = require("../utils");
|
|
38
|
+
describe('utils', () => {
|
|
39
|
+
describe('createTmpDirectory', () => {
|
|
40
|
+
test('Create unique directory', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const tmpDirectory1 = yield utils_2.createUniqueTmpDirectory();
|
|
42
|
+
const tmpDirectory2 = yield utils_2.createUniqueTmpDirectory();
|
|
43
|
+
expect(fs_1.default.existsSync(tmpDirectory1)).toBeTruthy();
|
|
44
|
+
expect(fs_1.default.existsSync(tmpDirectory2)).toBeTruthy();
|
|
45
|
+
expect(tmpDirectory1).not.toEqual(tmpDirectory2);
|
|
46
|
+
yield utils_2.deleteDirectory(tmpDirectory1);
|
|
47
|
+
yield utils_2.deleteDirectory(tmpDirectory2);
|
|
48
|
+
}));
|
|
49
|
+
});
|
|
50
|
+
describe('deleteDirectory', () => {
|
|
51
|
+
test('Delete empty directory', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const tmpDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
53
|
+
yield utils_2.deleteDirectory(tmpDirectory);
|
|
54
|
+
expect(fs_1.default.existsSync(tmpDirectory)).toBeFalsy();
|
|
55
|
+
}));
|
|
56
|
+
test('Delete non-empty directory', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
const tmpDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
58
|
+
yield fs_1.promises.mkdir(utils_1.buildPath(tmpDirectory, 'foo'));
|
|
59
|
+
yield fs_1.promises.writeFile(utils_1.buildPath(tmpDirectory, 'foo', 'bar1'), 'mock1');
|
|
60
|
+
yield fs_1.promises.writeFile(utils_1.buildPath(tmpDirectory, 'foo', 'bar2'), 'mock2');
|
|
61
|
+
yield utils_2.deleteDirectory(tmpDirectory);
|
|
62
|
+
expect(fs_1.default.existsSync(tmpDirectory)).toBeFalsy();
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
describe('zipDirectoryToArchive', () => {
|
|
66
|
+
test('Compress folder to archive at given path', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
67
|
+
const archiveDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
68
|
+
const archivePath = utils_1.buildPath(archiveDirectory, 'archive.zip');
|
|
69
|
+
yield utils_2.zipDirectoryToArchive('./src/commands/dsyms/__tests__/fixtures', archivePath);
|
|
70
|
+
expect(fs_1.default.existsSync(archivePath)).toBeTruthy();
|
|
71
|
+
yield utils_2.deleteDirectory(archiveDirectory);
|
|
72
|
+
}));
|
|
73
|
+
});
|
|
74
|
+
describe('unzipArchiveToDirectory', () => {
|
|
75
|
+
test('Uncompress archive to given destination', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
76
|
+
const archiveDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
77
|
+
const destinationDirectory = yield utils_2.createUniqueTmpDirectory();
|
|
78
|
+
const archivePath = utils_1.buildPath(archiveDirectory, 'archive.zip');
|
|
79
|
+
yield utils_2.zipDirectoryToArchive('./src/commands/dsyms/__tests__/fixtures', archivePath);
|
|
80
|
+
yield utils_2.unzipArchiveToDirectory(archivePath, destinationDirectory);
|
|
81
|
+
const originalContentList = glob_1.default.sync(utils_1.buildPath('./src/commands/dsyms/__tests__/', 'fixtures/**/*'));
|
|
82
|
+
const unzippedContentList = glob_1.default.sync(utils_1.buildPath(destinationDirectory, 'fixtures/**/*'));
|
|
83
|
+
expect(originalContentList.length).toEqual(unzippedContentList.length);
|
|
84
|
+
yield utils_2.deleteDirectory(archiveDirectory);
|
|
85
|
+
yield utils_2.deleteDirectory(destinationDirectory);
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
describe('isZipFile', () => {
|
|
89
|
+
test('Zip file should return true', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
|
+
const file = './src/commands/dsyms/__tests__/fixtures/all.zip';
|
|
91
|
+
expect(yield utils_2.isZipFile(file)).toBeTruthy();
|
|
92
|
+
}));
|
|
93
|
+
test('Arbitrary file should return false', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const file = './src/commands/dsyms/__tests__/fixtures/multiple-archs/DDTest.framework.dSYM';
|
|
95
|
+
expect(yield utils_2.isZipFile(file)).toBeFalsy();
|
|
96
|
+
}));
|
|
97
|
+
});
|
|
58
98
|
});
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { MultipartPayload } from '../../helpers/upload';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
export interface Dsym {
|
|
3
|
+
bundlePath: string;
|
|
4
|
+
slices: ArchSlice[];
|
|
5
|
+
}
|
|
6
|
+
export interface ArchSlice {
|
|
7
|
+
arch: string;
|
|
8
|
+
objectPath: string;
|
|
9
|
+
uuid: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class CompressedDsym {
|
|
12
|
+
archivePath: string;
|
|
13
|
+
dsym: Dsym;
|
|
14
|
+
constructor(archivePath: string, dsym: Dsym);
|
|
15
|
+
asMultipartPayload(): MultipartPayload;
|
|
7
16
|
}
|
|
@@ -1,38 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
14
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
6
|
+
exports.CompressedDsym = void 0;
|
|
16
7
|
const fs_1 = __importDefault(require("fs"));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
-
this.uuids = uuids;
|
|
8
|
+
class CompressedDsym {
|
|
9
|
+
constructor(archivePath, dsym) {
|
|
10
|
+
this.archivePath = archivePath;
|
|
11
|
+
this.dsym = dsym;
|
|
22
12
|
}
|
|
23
13
|
asMultipartPayload() {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
content,
|
|
34
|
-
};
|
|
35
|
-
});
|
|
14
|
+
const concatUUIDs = this.dsym.slices.map((slice) => slice.uuid).join();
|
|
15
|
+
const content = new Map([
|
|
16
|
+
['symbols_archive', { value: fs_1.default.createReadStream(this.archivePath) }],
|
|
17
|
+
['type', { value: 'ios_symbols' }],
|
|
18
|
+
['uuids', { value: concatUUIDs }],
|
|
19
|
+
]);
|
|
20
|
+
return {
|
|
21
|
+
content,
|
|
22
|
+
};
|
|
36
23
|
}
|
|
37
24
|
}
|
|
38
|
-
exports.
|
|
25
|
+
exports.CompressedDsym = CompressedDsym;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { Dsym } from './interfaces';
|
|
2
1
|
import { UploadStatus } from '../../helpers/upload';
|
|
2
|
+
import { ArchSlice, CompressedDsym, Dsym } from './interfaces';
|
|
3
3
|
export declare const renderConfigurationError: (error: Error) => string;
|
|
4
|
-
export declare const renderInvalidDsymWarning: (
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
4
|
+
export declare const renderInvalidDsymWarning: (dSYMPath: string) => string;
|
|
5
|
+
export declare const renderDSYMSlimmingFailure: (dSYM: Dsym, slice: ArchSlice) => string;
|
|
6
|
+
export declare const renderFailedUpload: (dSYM: CompressedDsym, errorMessage: string) => string;
|
|
7
|
+
export declare const renderRetriedUpload: (dSYM: CompressedDsym, errorMessage: string, attempt: number) => string;
|
|
7
8
|
export declare const renderSuccessfulCommand: (statuses: UploadStatus[], duration: number, dryRun: boolean) => string;
|
|
8
9
|
export declare const renderCommandInfo: (basePath: string, poolLimit: number, dryRun: boolean) => string;
|
|
9
|
-
export declare const
|
|
10
|
+
export declare const renderCommandDetail: (intermediateDirectory: string, uploadDirectory: string) => string;
|
|
11
|
+
export declare const renderUpload: (dSYM: CompressedDsym) => string;
|
|
@@ -3,22 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.renderUpload = exports.renderCommandInfo = exports.renderSuccessfulCommand = exports.renderRetriedUpload = exports.renderFailedUpload = exports.renderInvalidDsymWarning = exports.renderConfigurationError = void 0;
|
|
6
|
+
exports.renderUpload = exports.renderCommandDetail = exports.renderCommandInfo = exports.renderSuccessfulCommand = exports.renderRetriedUpload = exports.renderFailedUpload = exports.renderDSYMSlimmingFailure = exports.renderInvalidDsymWarning = exports.renderConfigurationError = void 0;
|
|
7
7
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
-
const
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const formatting_1 = require("../../helpers/formatting");
|
|
10
10
|
const upload_1 = require("../../helpers/upload");
|
|
11
|
+
const utils_1 = require("./utils");
|
|
11
12
|
const renderConfigurationError = (error) => chalk_1.default.red(`${formatting_1.ICONS.FAILED} Configuration error: ${error}.\n`);
|
|
12
13
|
exports.renderConfigurationError = renderConfigurationError;
|
|
13
|
-
const renderInvalidDsymWarning = (
|
|
14
|
+
const renderInvalidDsymWarning = (dSYMPath) => chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} Invalid dSYM file, will be skipped: ${dSYMPath}\n`);
|
|
14
15
|
exports.renderInvalidDsymWarning = renderInvalidDsymWarning;
|
|
16
|
+
const renderDSYMSlimmingFailure = (dSYM, slice) => chalk_1.default.yellow(`${formatting_1.ICONS.WARNING} Failed to export '${slice.arch}' arch (${slice.uuid}) from ${dSYM.bundlePath}\n`);
|
|
17
|
+
exports.renderDSYMSlimmingFailure = renderDSYMSlimmingFailure;
|
|
15
18
|
const renderFailedUpload = (dSYM, errorMessage) => {
|
|
16
|
-
const dSYMPathBold = `[${chalk_1.default.bold.dim(dSYM.
|
|
19
|
+
const dSYMPathBold = `[${chalk_1.default.bold.dim(dSYM.dsym.bundlePath)}]`;
|
|
17
20
|
return chalk_1.default.red(`${formatting_1.ICONS.FAILED} Failed upload dSYM for ${dSYMPathBold}: ${errorMessage}\n`);
|
|
18
21
|
};
|
|
19
22
|
exports.renderFailedUpload = renderFailedUpload;
|
|
20
23
|
const renderRetriedUpload = (dSYM, errorMessage, attempt) => {
|
|
21
|
-
const dSYMPathBold = `[${chalk_1.default.bold.dim(dSYM.
|
|
24
|
+
const dSYMPathBold = `[${chalk_1.default.bold.dim(dSYM.dsym.bundlePath)}]`;
|
|
22
25
|
return chalk_1.default.yellow(`[attempt ${attempt}] Retrying dSYM upload ${dSYMPathBold}: ${errorMessage}\n`);
|
|
23
26
|
};
|
|
24
27
|
exports.renderRetriedUpload = renderRetriedUpload;
|
|
@@ -75,5 +78,14 @@ const renderCommandInfo = (basePath, poolLimit, dryRun) => {
|
|
|
75
78
|
return fullStr;
|
|
76
79
|
};
|
|
77
80
|
exports.renderCommandInfo = renderCommandInfo;
|
|
78
|
-
const
|
|
81
|
+
const renderCommandDetail = (intermediateDirectory, uploadDirectory) => `Will use temporary intermediate directory: ${intermediateDirectory}\n` +
|
|
82
|
+
`Will use temporary upload directory: ${uploadDirectory}\n`;
|
|
83
|
+
exports.renderCommandDetail = renderCommandDetail;
|
|
84
|
+
const renderUpload = (dSYM) => {
|
|
85
|
+
const archiveName = path_1.default.basename(dSYM.archivePath);
|
|
86
|
+
const objectName = dSYM.dsym.slices.map((slice) => path_1.default.basename(slice.objectPath))[0];
|
|
87
|
+
const archs = dSYM.dsym.slices.map((slice) => slice.arch).join();
|
|
88
|
+
const uuids = dSYM.dsym.slices.map((slice) => slice.uuid).join();
|
|
89
|
+
return `Uploading ${archiveName} (${objectName}, arch: ${archs}, UUID: ${uuids})\n`;
|
|
90
|
+
};
|
|
79
91
|
exports.renderUpload = renderUpload;
|
|
@@ -2,10 +2,41 @@ import { Command } from 'clipanion';
|
|
|
2
2
|
export declare class UploadCommand extends Command {
|
|
3
3
|
static usage: import("clipanion").Usage;
|
|
4
4
|
private basePath;
|
|
5
|
+
private cliVersion;
|
|
5
6
|
private config;
|
|
6
7
|
private dryRun;
|
|
7
8
|
private maxConcurrency;
|
|
9
|
+
constructor();
|
|
8
10
|
execute(): Promise<1 | 0>;
|
|
11
|
+
private compressDSYMsToDirectory;
|
|
12
|
+
private findDSYMsInDirectory;
|
|
9
13
|
private getRequestBuilder;
|
|
14
|
+
/**
|
|
15
|
+
* Parses the output of `dwarfdump --uuid` command (ref.: https://www.unix.com/man-page/osx/1/dwarfdump/).
|
|
16
|
+
* It returns one or many arch slices read from the output.
|
|
17
|
+
*
|
|
18
|
+
* Example `dwarfdump --uuid` output:
|
|
19
|
+
* ```
|
|
20
|
+
* $ dwarfdump --uuid DDTest.framework.dSYM
|
|
21
|
+
* UUID: C8469F85-B060-3085-B69D-E46C645560EA (armv7) DDTest.framework.dSYM/Contents/Resources/DWARF/DDTest
|
|
22
|
+
* UUID: 06EE3D68-D605-3E92-B92D-2F48C02A505E (arm64) DDTest.framework.dSYM/Contents/Resources/DWARF/DDTest
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
private parseDwarfdumpOutput;
|
|
26
|
+
/**
|
|
27
|
+
* It takes fat dSYM as input and returns multiple dSYMs by extracting **each arch**
|
|
28
|
+
* to separate dSYM file. New files are saved to `intermediatePath` and named by their object uuid (`<uuid>.dSYM`).
|
|
29
|
+
*
|
|
30
|
+
* For example, given `<source path>/Foo.dSYM/Contents/Resources/DWARF/Foo` dSYM with two arch slices: `arm64` (uuid1)
|
|
31
|
+
* and `x86_64` (uuid2), it will:
|
|
32
|
+
* - create `<intermediate path>/<uuid1>.dSYM/Contents/Resources/DWARF/Foo` for `arm64`,
|
|
33
|
+
* - create `<intermediate path>/<uuid2>.dSYM/Contents/Resources/DWARF/Foo` for `x86_64`.
|
|
34
|
+
*/
|
|
35
|
+
private thinDSYM;
|
|
36
|
+
/**
|
|
37
|
+
* It takes `N` dSYMs and returns `N` or more dSYMs. If a dSYM includes more than one arch slice,
|
|
38
|
+
* it will be thinned by extracting each arch to a new dSYM in `intermediatePath`.
|
|
39
|
+
*/
|
|
40
|
+
private thinDSYMs;
|
|
10
41
|
private uploadDSYM;
|
|
11
42
|
}
|