@sentry/wizard 3.40.0 → 3.41.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/CHANGELOG.md +8 -1
- package/README.md +19 -19
- package/bin.ts +5 -0
- package/codecov.yml +15 -0
- package/dist/bin.js +4 -0
- package/dist/bin.js.map +1 -1
- package/dist/e2e-tests/jest.config.d.ts +1 -0
- package/dist/e2e-tests/jest.config.js +1 -0
- package/dist/e2e-tests/jest.config.js.map +1 -1
- package/dist/package.json +3 -2
- package/dist/src/apple/apple-wizard.js +1 -2
- package/dist/src/apple/apple-wizard.js.map +1 -1
- package/dist/src/apple/code-tools.d.ts +10 -0
- package/dist/src/apple/code-tools.js +16 -12
- package/dist/src/apple/code-tools.js.map +1 -1
- package/dist/src/apple/fastlane.d.ts +23 -0
- package/dist/src/apple/fastlane.js +11 -7
- package/dist/src/apple/fastlane.js.map +1 -1
- package/dist/src/apple/templates.d.ts +1 -1
- package/dist/src/apple/templates.js +0 -2
- package/dist/src/apple/templates.js.map +1 -1
- package/dist/src/apple/xcode-manager.d.ts +10 -6
- package/dist/src/apple/xcode-manager.js +146 -61
- package/dist/src/apple/xcode-manager.js.map +1 -1
- package/dist/src/nextjs/nextjs-wizard.js +5 -3
- package/dist/src/nextjs/nextjs-wizard.js.map +1 -1
- package/dist/src/nuxt/nuxt-wizard.js +6 -4
- package/dist/src/nuxt/nuxt-wizard.js.map +1 -1
- package/dist/src/nuxt/sdk-setup.d.ts +1 -1
- package/dist/src/nuxt/sdk-setup.js +2 -1
- package/dist/src/nuxt/sdk-setup.js.map +1 -1
- package/dist/src/react-native/react-native-wizard.js +5 -3
- package/dist/src/react-native/react-native-wizard.js.map +1 -1
- package/dist/src/remix/remix-wizard.js +5 -3
- package/dist/src/remix/remix-wizard.js.map +1 -1
- package/dist/src/run.d.ts +1 -0
- package/dist/src/run.js +1 -0
- package/dist/src/run.js.map +1 -1
- package/dist/src/sveltekit/sveltekit-wizard.js +5 -3
- package/dist/src/sveltekit/sveltekit-wizard.js.map +1 -1
- package/dist/src/utils/clack-utils.d.ts +3 -1
- package/dist/src/utils/clack-utils.js +18 -12
- package/dist/src/utils/clack-utils.js.map +1 -1
- package/dist/src/utils/package-manager.d.ts +1 -0
- package/dist/src/utils/package-manager.js +5 -0
- package/dist/src/utils/package-manager.js.map +1 -1
- package/dist/src/utils/types.d.ts +9 -0
- package/dist/src/utils/types.js.map +1 -1
- package/dist/test/apple/cocoapod.test.d.ts +1 -0
- package/dist/test/apple/cocoapod.test.js +409 -0
- package/dist/test/apple/cocoapod.test.js.map +1 -0
- package/dist/test/apple/code-tools.test.d.ts +1 -0
- package/dist/test/apple/code-tools.test.js +673 -0
- package/dist/test/apple/code-tools.test.js.map +1 -0
- package/dist/test/apple/fastfile.test.d.ts +1 -0
- package/dist/test/apple/fastfile.test.js +431 -0
- package/dist/test/apple/fastfile.test.js.map +1 -0
- package/dist/test/apple/templates.test.d.ts +1 -0
- package/dist/test/apple/templates.test.js +73 -0
- package/dist/test/apple/templates.test.js.map +1 -0
- package/dist/test/apple/xcode-manager.test.d.ts +1 -0
- package/dist/test/apple/xcode-manager.test.js +834 -0
- package/dist/test/apple/xcode-manager.test.js.map +1 -0
- package/dist/test/utils/clack-utils.test.js +89 -0
- package/dist/test/utils/clack-utils.test.js.map +1 -1
- package/e2e-tests/jest.config.ts +1 -0
- package/e2e-tests/test-applications/apple/damaged-missing-configuration-list/Project.xcodeproj/project.pbxproj +52 -0
- package/e2e-tests/test-applications/apple/damaged-missing-configuration-list/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +78 -0
- package/e2e-tests/test-applications/apple/no-targets/Project.xcodeproj/project.pbxproj +62 -0
- package/e2e-tests/test-applications/apple/no-targets/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +78 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project.xcodeproj/project.pbxproj +470 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project.xcodeproj/xcshareddata/xcschemes/Project1.xcscheme +78 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project1/ContentView.swift +7 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project1/Project1App.swift +10 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project2/ContentView.swift +7 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-multi-targets/Project2/Project2App.swift +10 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/project.pbxproj +382 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Project.xcodeproj/xcshareddata/xcschemes/Project.xcscheme +78 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Sources/ContentView.swift +7 -0
- package/e2e-tests/test-applications/apple/spm-swiftui-single-target/Sources/MainApp.swift +10 -0
- package/package.json +3 -2
- package/src/apple/apple-wizard.ts +1 -2
- package/src/apple/code-tools.ts +21 -6
- package/src/apple/fastlane.ts +18 -2
- package/src/apple/templates.ts +2 -2
- package/src/apple/xcode-manager.ts +181 -94
- package/src/nextjs/nextjs-wizard.ts +5 -2
- package/src/nuxt/nuxt-wizard.ts +6 -3
- package/src/nuxt/sdk-setup.ts +2 -0
- package/src/react-native/react-native-wizard.ts +5 -2
- package/src/remix/remix-wizard.ts +5 -2
- package/src/run.ts +2 -0
- package/src/sveltekit/sveltekit-wizard.ts +5 -2
- package/src/utils/clack-utils.ts +12 -2
- package/src/utils/package-manager.ts +6 -0
- package/src/utils/types.ts +10 -0
- package/test/apple/cocoapod.test.ts +306 -0
- package/test/apple/code-tools.test.ts +1042 -0
- package/test/apple/fastfile.test.ts +550 -0
- package/test/apple/templates.test.ts +191 -0
- package/test/apple/xcode-manager.test.ts +1066 -0
- package/test/utils/clack-utils.test.ts +92 -0
- package/types/xcode.d.ts +526 -0
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
var fs = __importStar(require("fs"));
|
|
27
|
+
var os = __importStar(require("os"));
|
|
28
|
+
var path = __importStar(require("path"));
|
|
29
|
+
var templates_1 = require("../../src/apple/templates");
|
|
30
|
+
var xcode_manager_1 = require("../../src/apple/xcode-manager");
|
|
31
|
+
jest.mock('@clack/prompts', function () { return ({
|
|
32
|
+
default: {
|
|
33
|
+
log: {
|
|
34
|
+
info: jest.fn(),
|
|
35
|
+
success: jest.fn(),
|
|
36
|
+
step: jest.fn(),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}); });
|
|
40
|
+
var appleProjectsPath = path.resolve(__dirname, '../../e2e-tests/test-applications/apple');
|
|
41
|
+
var damagedProjectPath = path.join(appleProjectsPath, 'damaged-missing-configuration-list/Project.xcodeproj/project.pbxproj');
|
|
42
|
+
var noTargetsProjectPath = path.join(appleProjectsPath, 'no-targets/Project.xcodeproj/project.pbxproj');
|
|
43
|
+
var singleTargetProjectPath = path.join(appleProjectsPath, 'spm-swiftui-single-target/Project.xcodeproj/project.pbxproj');
|
|
44
|
+
var multiTargetProjectPath = path.join(appleProjectsPath, 'spm-swiftui-multi-targets/Project.xcodeproj/project.pbxproj');
|
|
45
|
+
var projectData = {
|
|
46
|
+
id: '1234567890',
|
|
47
|
+
slug: 'project',
|
|
48
|
+
organization: {
|
|
49
|
+
id: '1234567890',
|
|
50
|
+
name: 'Sentry',
|
|
51
|
+
slug: 'sentry',
|
|
52
|
+
},
|
|
53
|
+
keys: [{ dsn: { public: 'https://sentry.io/1234567890' } }],
|
|
54
|
+
};
|
|
55
|
+
describe('XcodeManager', function () {
|
|
56
|
+
afterEach(function () {
|
|
57
|
+
jest.clearAllMocks();
|
|
58
|
+
});
|
|
59
|
+
describe('XcodeProject', function () {
|
|
60
|
+
describe('getAllTargets', function () {
|
|
61
|
+
describe('single target', function () {
|
|
62
|
+
it('should return all targets', function () {
|
|
63
|
+
// -- Arrange --
|
|
64
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
65
|
+
// -- Act --
|
|
66
|
+
var targets = xcodeProject.getAllTargets();
|
|
67
|
+
// -- Assert --
|
|
68
|
+
expect(targets).toEqual(['Project']);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe('multiple targets', function () {
|
|
72
|
+
it('should return all targets', function () {
|
|
73
|
+
// -- Arrange --
|
|
74
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(multiTargetProjectPath);
|
|
75
|
+
// -- Act --
|
|
76
|
+
var targets = xcodeProject.getAllTargets();
|
|
77
|
+
// -- Assert --
|
|
78
|
+
expect(targets).toEqual(['Project1', 'Project2']);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('no targets', function () {
|
|
82
|
+
it('should return an empty array', function () {
|
|
83
|
+
// -- Arrange --
|
|
84
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(noTargetsProjectPath);
|
|
85
|
+
// -- Act --
|
|
86
|
+
var targets = xcodeProject.getAllTargets();
|
|
87
|
+
// -- Assert --
|
|
88
|
+
expect(targets).toEqual([]);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe('project with missing configuration list', function () {
|
|
92
|
+
it('should return an empty array', function () {
|
|
93
|
+
// -- Arrange --
|
|
94
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(damagedProjectPath);
|
|
95
|
+
// -- Act --
|
|
96
|
+
var targets = xcodeProject.getAllTargets();
|
|
97
|
+
// -- Assert --
|
|
98
|
+
expect(targets).toEqual([]);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
describe('updateXcodeProject', function () {
|
|
103
|
+
var sourceProjectPath;
|
|
104
|
+
var tempProjectPath;
|
|
105
|
+
var xcodeProject;
|
|
106
|
+
beforeEach(function () {
|
|
107
|
+
var tempDir = path.join(os.tmpdir(), fs.mkdtempSync('update-xcode-project'));
|
|
108
|
+
fs.mkdirSync(tempDir);
|
|
109
|
+
sourceProjectPath = singleTargetProjectPath;
|
|
110
|
+
tempProjectPath = path.resolve(tempDir, 'project.pbxproj');
|
|
111
|
+
fs.copyFileSync(sourceProjectPath, tempProjectPath);
|
|
112
|
+
xcodeProject = new xcode_manager_1.XcodeProject(tempProjectPath);
|
|
113
|
+
});
|
|
114
|
+
describe('upload symbols script', function () {
|
|
115
|
+
var _a;
|
|
116
|
+
var scriptVariants = [
|
|
117
|
+
{
|
|
118
|
+
uploadSource: true,
|
|
119
|
+
includeHomebrewPath: true,
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
uploadSource: true,
|
|
123
|
+
includeHomebrewPath: false,
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
uploadSource: false,
|
|
127
|
+
includeHomebrewPath: true,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
uploadSource: false,
|
|
131
|
+
includeHomebrewPath: false,
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
var _loop_1 = function (variant) {
|
|
135
|
+
describe("upload source = ".concat((_a = variant.uploadSource) === null || _a === void 0 ? void 0 : _a.toString(), " and include homebrew path = ").concat(variant.includeHomebrewPath.toString()), function () {
|
|
136
|
+
beforeEach(function () {
|
|
137
|
+
jest
|
|
138
|
+
.spyOn(fs, 'existsSync')
|
|
139
|
+
.mockReturnValue(variant.includeHomebrewPath);
|
|
140
|
+
});
|
|
141
|
+
afterEach(function () {
|
|
142
|
+
jest.restoreAllMocks();
|
|
143
|
+
});
|
|
144
|
+
it('should add the upload symbols script to the target', function () {
|
|
145
|
+
// -- Arrange --
|
|
146
|
+
var generatedShellScript = (0, templates_1.getRunScriptTemplate)(projectData.organization.slug, projectData.slug, variant.uploadSource, variant.includeHomebrewPath);
|
|
147
|
+
var expectedShellScript = "\"".concat(generatedShellScript.replace(/"/g, '\\"'), "\"");
|
|
148
|
+
// -- Act --
|
|
149
|
+
xcodeProject.updateXcodeProject(projectData, 'Project', false, // Ignore SPM reference
|
|
150
|
+
variant.uploadSource);
|
|
151
|
+
// -- Assert --
|
|
152
|
+
var updatedXcodeProject = new xcode_manager_1.XcodeProject(tempProjectPath);
|
|
153
|
+
// Expect the upload symbols script to be added
|
|
154
|
+
var scriptObjects = updatedXcodeProject.objects.PBXShellScriptBuildPhase;
|
|
155
|
+
expect(scriptObjects).toBeDefined();
|
|
156
|
+
if (!scriptObjects) {
|
|
157
|
+
throw new Error('Script objects not found');
|
|
158
|
+
}
|
|
159
|
+
var scriptKeys = Object.keys(scriptObjects);
|
|
160
|
+
expect(scriptKeys).toHaveLength(2);
|
|
161
|
+
// Find the script ID
|
|
162
|
+
var scriptId = scriptKeys.find(function (key) { return !key.endsWith('_comment'); });
|
|
163
|
+
expect(scriptId).toBeDefined();
|
|
164
|
+
if (!scriptId) {
|
|
165
|
+
throw new Error('Script ID not found');
|
|
166
|
+
}
|
|
167
|
+
expect(scriptId).toMatch(/^[A-F0-9]{24}$/i);
|
|
168
|
+
// Expect the script to be added
|
|
169
|
+
var script = scriptObjects[scriptId];
|
|
170
|
+
expect(script).toBeDefined();
|
|
171
|
+
expect(typeof script).not.toBe('string');
|
|
172
|
+
expect(script.inputPaths).toEqual([
|
|
173
|
+
'"${DWARF_DSYM_FOLDER_PATH}/${DWARF_DSYM_FILE_NAME}/Contents/Resources/DWARF/${TARGET_NAME}"',
|
|
174
|
+
]);
|
|
175
|
+
expect(script.outputPaths).toEqual([]);
|
|
176
|
+
expect(script.shellPath).toBe('/bin/sh');
|
|
177
|
+
expect(script.shellScript).toEqual(expectedShellScript);
|
|
178
|
+
var commentKey = "".concat(scriptId, "_comment");
|
|
179
|
+
expect(scriptKeys).toContain(commentKey);
|
|
180
|
+
expect(scriptObjects[commentKey]).toBe('Upload Debug Symbols to Sentry');
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
};
|
|
184
|
+
for (var _i = 0, scriptVariants_1 = scriptVariants; _i < scriptVariants_1.length; _i++) {
|
|
185
|
+
var variant = scriptVariants_1[_i];
|
|
186
|
+
_loop_1(variant);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
describe('debug information format and sandbox', function () {
|
|
190
|
+
describe('upload source is false', function () {
|
|
191
|
+
it('should not update the Xcode project', function () {
|
|
192
|
+
// -- Act --
|
|
193
|
+
xcodeProject.updateXcodeProject(projectData, 'Project', false, // Ignore SPM reference
|
|
194
|
+
false);
|
|
195
|
+
// -- Assert --
|
|
196
|
+
var expectedXcodeProject = new xcode_manager_1.XcodeProject(sourceProjectPath);
|
|
197
|
+
expect(xcodeProject.objects.XCBuildConfiguration).toEqual(expectedXcodeProject.objects.XCBuildConfiguration);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
200
|
+
describe('upload source is true', function () {
|
|
201
|
+
var uploadSource = true;
|
|
202
|
+
describe('named target not found', function () {
|
|
203
|
+
it('should not update the flags in the Xcode project', function () {
|
|
204
|
+
// -- Act --
|
|
205
|
+
xcodeProject.updateXcodeProject(projectData, 'Invalid Target Name', false, // Ignore SPM reference
|
|
206
|
+
uploadSource);
|
|
207
|
+
// -- Assert --
|
|
208
|
+
var originalXcodeProject = new xcode_manager_1.XcodeProject(sourceProjectPath);
|
|
209
|
+
expect(xcodeProject.objects.XCBuildConfiguration).toEqual(originalXcodeProject.objects.XCBuildConfiguration);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
describe('named target found', function () {
|
|
213
|
+
describe('build configurations is undefined', function () {
|
|
214
|
+
it('should not update the Xcode project', function () {
|
|
215
|
+
// -- Act --
|
|
216
|
+
xcodeProject.updateXcodeProject(projectData, 'Invalid Target Name', false, // Ignore SPM reference
|
|
217
|
+
uploadSource);
|
|
218
|
+
// -- Assert --
|
|
219
|
+
var originalXcodeProject = new xcode_manager_1.XcodeProject(sourceProjectPath);
|
|
220
|
+
expect(xcodeProject.objects.XCBuildConfiguration).toEqual(originalXcodeProject.objects.XCBuildConfiguration);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
describe('no build configurations found', function () {
|
|
224
|
+
it('should not update the Xcode project', function () {
|
|
225
|
+
// -- Arrange --
|
|
226
|
+
xcodeProject.objects.XCBuildConfiguration = {};
|
|
227
|
+
// -- Act --
|
|
228
|
+
xcodeProject.updateXcodeProject(projectData, 'Invalid Target Name', false, // Ignore SPM reference
|
|
229
|
+
uploadSource);
|
|
230
|
+
// -- Assert --
|
|
231
|
+
expect(xcodeProject.objects.XCBuildConfiguration).toEqual({});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
describe('build configurations found', function () {
|
|
235
|
+
var debugProjectBuildConfigurationListId = 'D4E604DA2D50CEEE00CAB00F';
|
|
236
|
+
var releaseProjectBuildConfigurationListId = 'D4E604DB2D50CEEE00CAB00F';
|
|
237
|
+
var debugTargetBuildConfigurationListId = 'D4E604DD2D50CEEE00CAB00F';
|
|
238
|
+
var releaseTargetBuildConfigurationListId = 'D4E604DE2D50CEEE00CAB00F';
|
|
239
|
+
it('should update the target configuration lists', function () {
|
|
240
|
+
var _a, _b;
|
|
241
|
+
// -- Act --
|
|
242
|
+
xcodeProject.updateXcodeProject(projectData, 'Project', false, // Ignore SPM reference
|
|
243
|
+
uploadSource);
|
|
244
|
+
// -- Assert --
|
|
245
|
+
expect(xcodeProject.objects.XCBuildConfiguration).toBeDefined();
|
|
246
|
+
// Both Debug and Release are configured equally
|
|
247
|
+
var expectedConfigKeys = [
|
|
248
|
+
debugTargetBuildConfigurationListId,
|
|
249
|
+
releaseTargetBuildConfigurationListId, // Release
|
|
250
|
+
];
|
|
251
|
+
for (var _i = 0, expectedConfigKeys_1 = expectedConfigKeys; _i < expectedConfigKeys_1.length; _i++) {
|
|
252
|
+
var key = expectedConfigKeys_1[_i];
|
|
253
|
+
var buildConfiguration = (_a = xcodeProject.objects
|
|
254
|
+
.XCBuildConfiguration) === null || _a === void 0 ? void 0 : _a[key];
|
|
255
|
+
expect(buildConfiguration).toBeDefined();
|
|
256
|
+
expect(typeof buildConfiguration).not.toBe('string');
|
|
257
|
+
var buildSettings = (_b = buildConfiguration.buildSettings) !== null && _b !== void 0 ? _b : {};
|
|
258
|
+
expect(buildSettings.DEBUG_INFORMATION_FORMAT).toBe('"dwarf-with-dsym"');
|
|
259
|
+
expect(buildSettings.ENABLE_USER_SCRIPT_SANDBOXING).toBe('"NO"');
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
it('should not update the project configuration lists', function () {
|
|
263
|
+
var _a, _b, _c, _d, _e, _f;
|
|
264
|
+
// -- Act --
|
|
265
|
+
xcodeProject.updateXcodeProject(projectData, 'Project', false, // Ignore SPM reference
|
|
266
|
+
uploadSource);
|
|
267
|
+
// -- Assert --
|
|
268
|
+
expect(xcodeProject.objects.XCBuildConfiguration).toBeDefined();
|
|
269
|
+
// Check project build configurations 'Debug'
|
|
270
|
+
var debugBuildConfiguration = (_a = xcodeProject.objects
|
|
271
|
+
.XCBuildConfiguration) === null || _a === void 0 ? void 0 : _a[debugProjectBuildConfigurationListId];
|
|
272
|
+
expect(debugBuildConfiguration).toBeDefined();
|
|
273
|
+
expect(typeof debugBuildConfiguration).not.toBe('string');
|
|
274
|
+
expect((_b = debugBuildConfiguration.buildSettings) === null || _b === void 0 ? void 0 : _b.DEBUG_INFORMATION_FORMAT).toBe('dwarf');
|
|
275
|
+
expect((_c = debugBuildConfiguration.buildSettings) === null || _c === void 0 ? void 0 : _c.ENABLE_USER_SCRIPT_SANDBOXING).toBe('YES');
|
|
276
|
+
// Check project build configurations 'Release'
|
|
277
|
+
var releaseBuildConfiguration = (_d = xcodeProject.objects
|
|
278
|
+
.XCBuildConfiguration) === null || _d === void 0 ? void 0 : _d[releaseProjectBuildConfigurationListId];
|
|
279
|
+
expect(releaseBuildConfiguration).toBeDefined();
|
|
280
|
+
expect(typeof releaseBuildConfiguration).not.toBe('string');
|
|
281
|
+
expect((_e = releaseBuildConfiguration.buildSettings) === null || _e === void 0 ? void 0 : _e.DEBUG_INFORMATION_FORMAT).toBe('"dwarf-with-dsym"');
|
|
282
|
+
expect((_f = releaseBuildConfiguration.buildSettings) === null || _f === void 0 ? void 0 : _f.ENABLE_USER_SCRIPT_SANDBOXING).toBe('YES');
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
describe('add SPM reference', function () {
|
|
289
|
+
var addSPMReference = true;
|
|
290
|
+
describe('framework build phase already contains Sentry', function () {
|
|
291
|
+
it('should not update the Xcode project', function () {
|
|
292
|
+
// -- Arrange --
|
|
293
|
+
xcodeProject.objects.PBXFrameworksBuildPhase = {
|
|
294
|
+
'framework-id': {
|
|
295
|
+
files: [
|
|
296
|
+
{
|
|
297
|
+
value: '123',
|
|
298
|
+
comment: 'Sentry in Frameworks',
|
|
299
|
+
},
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
};
|
|
303
|
+
// -- Act --
|
|
304
|
+
xcodeProject.updateXcodeProject(projectData, 'Project', addSPMReference);
|
|
305
|
+
// -- Assert --
|
|
306
|
+
var expectedXcodeProject = new xcode_manager_1.XcodeProject(sourceProjectPath);
|
|
307
|
+
expectedXcodeProject.objects.PBXFrameworksBuildPhase = {
|
|
308
|
+
'framework-id': {
|
|
309
|
+
files: [
|
|
310
|
+
{
|
|
311
|
+
value: '123',
|
|
312
|
+
comment: 'Sentry in Frameworks',
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
expect(xcodeProject.objects.PBXFrameworksBuildPhase).toEqual(expectedXcodeProject.objects.PBXFrameworksBuildPhase);
|
|
318
|
+
expect(xcodeProject.objects.XCRemoteSwiftPackageReference).toEqual(expectedXcodeProject.objects.XCRemoteSwiftPackageReference);
|
|
319
|
+
expect(xcodeProject.objects.XCSwiftPackageProductDependency).toEqual(expectedXcodeProject.objects.XCSwiftPackageProductDependency);
|
|
320
|
+
});
|
|
321
|
+
});
|
|
322
|
+
it('should add the SPM reference to the target', function () {
|
|
323
|
+
var _a;
|
|
324
|
+
// -- Act --
|
|
325
|
+
xcodeProject.updateXcodeProject(projectData, 'Project', addSPMReference);
|
|
326
|
+
// -- Assert --
|
|
327
|
+
// Get the target
|
|
328
|
+
var target = (_a = xcodeProject.objects.PBXNativeTarget) === null || _a === void 0 ? void 0 : _a['D4E604CC2D50CEEC00CAB00F'];
|
|
329
|
+
expect(target).toBeDefined();
|
|
330
|
+
if (!target) {
|
|
331
|
+
throw new Error('Target is undefined');
|
|
332
|
+
}
|
|
333
|
+
// Check the SPM dependency is added to the target
|
|
334
|
+
expect(target.packageProductDependencies).toEqual([
|
|
335
|
+
expect.objectContaining({
|
|
336
|
+
value: expect.any(String),
|
|
337
|
+
comment: 'Sentry',
|
|
338
|
+
}),
|
|
339
|
+
]);
|
|
340
|
+
// Check the SPM package reference object is added to the project
|
|
341
|
+
var remoteSwiftPackageReferences = xcodeProject.objects.XCRemoteSwiftPackageReference;
|
|
342
|
+
expect(remoteSwiftPackageReferences).toBeDefined();
|
|
343
|
+
if (!remoteSwiftPackageReferences) {
|
|
344
|
+
throw new Error('XCRemoteSwiftPackageReference is undefined');
|
|
345
|
+
}
|
|
346
|
+
var rspRefKeys = Object.keys(remoteSwiftPackageReferences);
|
|
347
|
+
expect(rspRefKeys).toHaveLength(2);
|
|
348
|
+
// First key is expected to be the UUID of the SPM package reference
|
|
349
|
+
expect(rspRefKeys[0]).toMatch(/^[A-F0-9]{24}$/i);
|
|
350
|
+
// Second key is expected to be the UUID of the SPM package reference with _comment suffix
|
|
351
|
+
expect(rspRefKeys[1]).toMatch(/^[A-F0-9]{24}_comment$/i);
|
|
352
|
+
expect(remoteSwiftPackageReferences === null || remoteSwiftPackageReferences === void 0 ? void 0 : remoteSwiftPackageReferences[rspRefKeys[0]]).toEqual({
|
|
353
|
+
isa: 'XCRemoteSwiftPackageReference',
|
|
354
|
+
repositoryURL: '"https://github.com/getsentry/sentry-cocoa/"',
|
|
355
|
+
requirement: {
|
|
356
|
+
kind: 'upToNextMajorVersion',
|
|
357
|
+
minimumVersion: '8.0.0',
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
expect(remoteSwiftPackageReferences === null || remoteSwiftPackageReferences === void 0 ? void 0 : remoteSwiftPackageReferences[rspRefKeys[1]]).toBe('XCRemoteSwiftPackageReference "sentry-cocoa"');
|
|
361
|
+
// Check the SPM package is a dependency of the target
|
|
362
|
+
var packageProductDependencies = xcodeProject.objects.XCSwiftPackageProductDependency;
|
|
363
|
+
expect(packageProductDependencies).toBeDefined();
|
|
364
|
+
if (!packageProductDependencies) {
|
|
365
|
+
throw new Error('XCSwiftPackageProductDependency is undefined');
|
|
366
|
+
}
|
|
367
|
+
var ppDepKeys = Object.keys(packageProductDependencies);
|
|
368
|
+
expect(ppDepKeys).toHaveLength(2);
|
|
369
|
+
// First key is expected to be the UUID of the SPM package dependency
|
|
370
|
+
expect(ppDepKeys[0]).toMatch(/^[A-F0-9]{24}$/i);
|
|
371
|
+
// Second key is expected to be the UUID of the SPM package dependency with _comment suffix
|
|
372
|
+
expect(ppDepKeys[1]).toMatch(/^[A-F0-9]{24}_comment$/i);
|
|
373
|
+
expect(packageProductDependencies === null || packageProductDependencies === void 0 ? void 0 : packageProductDependencies[ppDepKeys[0]]).toEqual({
|
|
374
|
+
isa: 'XCSwiftPackageProductDependency',
|
|
375
|
+
package: rspRefKeys[0],
|
|
376
|
+
package_comment: 'XCRemoteSwiftPackageReference "sentry-cocoa"',
|
|
377
|
+
productName: 'Sentry',
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
describe('filesForTarget', function () {
|
|
384
|
+
describe('targets are undefined', function () {
|
|
385
|
+
it('should return undefined', function () {
|
|
386
|
+
// -- Arrange --
|
|
387
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
388
|
+
xcodeProject.objects.PBXNativeTarget = undefined;
|
|
389
|
+
// -- Act --
|
|
390
|
+
var files = xcodeProject.filesForTarget('Project');
|
|
391
|
+
// -- Assert --
|
|
392
|
+
expect(files).toBeUndefined();
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
describe('target not found', function () {
|
|
396
|
+
it('should return undefined', function () {
|
|
397
|
+
// -- Arrange --
|
|
398
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
399
|
+
// -- Act --
|
|
400
|
+
var files = xcodeProject.filesForTarget('NonExistentTarget');
|
|
401
|
+
// -- Assert --
|
|
402
|
+
expect(files).toBeUndefined();
|
|
403
|
+
});
|
|
404
|
+
});
|
|
405
|
+
describe('target build phases are undefined', function () {
|
|
406
|
+
it('should return undefined', function () {
|
|
407
|
+
// -- Arrange --
|
|
408
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
409
|
+
xcodeProject.objects.PBXNativeTarget = {
|
|
410
|
+
Project: {
|
|
411
|
+
name: 'Project',
|
|
412
|
+
buildPhases: undefined,
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
// -- Act --
|
|
416
|
+
var files = xcodeProject.filesForTarget('Project');
|
|
417
|
+
// -- Assert --
|
|
418
|
+
expect(files).toBeUndefined();
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
describe('build phases are undefined', function () {
|
|
422
|
+
it('should return undefined', function () {
|
|
423
|
+
// -- Arrange --
|
|
424
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
425
|
+
xcodeProject.objects.PBXNativeTarget = {
|
|
426
|
+
Project: {
|
|
427
|
+
name: 'Project',
|
|
428
|
+
buildPhases: undefined,
|
|
429
|
+
},
|
|
430
|
+
};
|
|
431
|
+
xcodeProject.objects.PBXSourcesBuildPhase = undefined;
|
|
432
|
+
// -- Act --
|
|
433
|
+
var files = xcodeProject.filesForTarget('Project');
|
|
434
|
+
// -- Assert --
|
|
435
|
+
expect(files).toBeUndefined();
|
|
436
|
+
});
|
|
437
|
+
});
|
|
438
|
+
describe('referenced build phase is undefined', function () {
|
|
439
|
+
it('should return undefined', function () {
|
|
440
|
+
// -- Arrange --
|
|
441
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
442
|
+
xcodeProject.objects.PBXNativeTarget = {
|
|
443
|
+
Project: {
|
|
444
|
+
name: 'Project',
|
|
445
|
+
buildPhases: [
|
|
446
|
+
{
|
|
447
|
+
value: 'random-build-phase',
|
|
448
|
+
},
|
|
449
|
+
],
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
// -- Act --
|
|
453
|
+
var files = xcodeProject.filesForTarget('Project');
|
|
454
|
+
// -- Assert --
|
|
455
|
+
expect(files).toBeUndefined();
|
|
456
|
+
});
|
|
457
|
+
});
|
|
458
|
+
describe('build phase files are undefined', function () {
|
|
459
|
+
it('should return empty array', function () {
|
|
460
|
+
// -- Arrange --
|
|
461
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
462
|
+
xcodeProject.objects.PBXNativeTarget = {
|
|
463
|
+
Project: {
|
|
464
|
+
name: 'Project',
|
|
465
|
+
buildPhases: [
|
|
466
|
+
{
|
|
467
|
+
value: 'build-phase-key',
|
|
468
|
+
},
|
|
469
|
+
],
|
|
470
|
+
},
|
|
471
|
+
};
|
|
472
|
+
xcodeProject.objects.PBXSourcesBuildPhase = {
|
|
473
|
+
'build-phase-key': {
|
|
474
|
+
files: undefined,
|
|
475
|
+
},
|
|
476
|
+
};
|
|
477
|
+
// -- Act --
|
|
478
|
+
var files = xcodeProject.filesForTarget('Project');
|
|
479
|
+
// -- Assert --
|
|
480
|
+
expect(files).toEqual([]);
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
describe('build phase has no files', function () {
|
|
484
|
+
it('should return empty array', function () {
|
|
485
|
+
// -- Arrange --
|
|
486
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
487
|
+
// -- Act --
|
|
488
|
+
var files = xcodeProject.filesForTarget('Project');
|
|
489
|
+
// -- Assert --
|
|
490
|
+
expect(files).toEqual([]);
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
describe('build phase with files', function () {
|
|
494
|
+
var xcodeProject;
|
|
495
|
+
beforeEach(function () {
|
|
496
|
+
xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
497
|
+
xcodeProject.objects.PBXNativeTarget = {
|
|
498
|
+
'some-target': {
|
|
499
|
+
name: 'some-target',
|
|
500
|
+
buildPhases: [
|
|
501
|
+
{
|
|
502
|
+
value: 'build-phase-key',
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
},
|
|
506
|
+
};
|
|
507
|
+
xcodeProject.objects.PBXSourcesBuildPhase = {
|
|
508
|
+
'build-phase-key': {
|
|
509
|
+
files: [
|
|
510
|
+
{
|
|
511
|
+
value: 'file-key',
|
|
512
|
+
},
|
|
513
|
+
],
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
xcodeProject.objects.PBXBuildFile = {
|
|
517
|
+
'file-key': {
|
|
518
|
+
isa: 'PBXBuildFile',
|
|
519
|
+
fileRef: 'file-ref-key',
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
xcodeProject.files = [
|
|
523
|
+
{
|
|
524
|
+
key: 'file-ref-key',
|
|
525
|
+
path: 'file-path',
|
|
526
|
+
},
|
|
527
|
+
];
|
|
528
|
+
});
|
|
529
|
+
describe('build file objects are not defined', function () {
|
|
530
|
+
it('should return empty array', function () {
|
|
531
|
+
// -- Arrange --
|
|
532
|
+
xcodeProject.objects.PBXBuildFile = undefined;
|
|
533
|
+
// -- Act --
|
|
534
|
+
var files = xcodeProject.filesForTarget('some-target');
|
|
535
|
+
// -- Assert --
|
|
536
|
+
expect(files).toEqual([]);
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
describe('build file object is not found', function () {
|
|
540
|
+
it('should return empty array', function () {
|
|
541
|
+
// -- Arrange --
|
|
542
|
+
xcodeProject.objects.PBXBuildFile = {};
|
|
543
|
+
// -- Act --
|
|
544
|
+
var files = xcodeProject.filesForTarget('some-target');
|
|
545
|
+
// -- Assert --
|
|
546
|
+
expect(files).toEqual([]);
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
describe('build file object exists', function () {
|
|
550
|
+
describe('file reference is undefined', function () {
|
|
551
|
+
it('should ignore the file', function () {
|
|
552
|
+
// -- Arrange --
|
|
553
|
+
xcodeProject.files = [];
|
|
554
|
+
// -- Act --
|
|
555
|
+
var files = xcodeProject.filesForTarget('some-target');
|
|
556
|
+
// -- Assert --
|
|
557
|
+
expect(files).toEqual([]);
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
it('should return array of file paths', function () {
|
|
561
|
+
// -- Act --
|
|
562
|
+
var files = xcodeProject.filesForTarget('some-target');
|
|
563
|
+
// -- Assert --
|
|
564
|
+
expect(files).toEqual([
|
|
565
|
+
path.join(appleProjectsPath, 'spm-swiftui-single-target', 'file-path'),
|
|
566
|
+
]);
|
|
567
|
+
});
|
|
568
|
+
});
|
|
569
|
+
});
|
|
570
|
+
});
|
|
571
|
+
describe('projectFiles', function () {
|
|
572
|
+
describe('no groups in project', function () {
|
|
573
|
+
it('should return empty array', function () {
|
|
574
|
+
// -- Arrange --
|
|
575
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
576
|
+
xcodeProject.objects.PBXGroup = undefined;
|
|
577
|
+
// -- Act --
|
|
578
|
+
var files = xcodeProject.projectFiles();
|
|
579
|
+
// -- Assert --
|
|
580
|
+
expect(files).toEqual([]);
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
describe('main group not found', function () {
|
|
584
|
+
it('should return empty array', function () {
|
|
585
|
+
var _a;
|
|
586
|
+
// -- Arrange --
|
|
587
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
588
|
+
var project = (_a = xcodeProject.objects.PBXProject) === null || _a === void 0 ? void 0 : _a['D4E604C52D50CEEC00CAB00F'];
|
|
589
|
+
if (project) {
|
|
590
|
+
delete project.mainGroup;
|
|
591
|
+
}
|
|
592
|
+
// -- Act --
|
|
593
|
+
var files = xcodeProject.projectFiles();
|
|
594
|
+
// -- Assert --
|
|
595
|
+
expect(files).toEqual([]);
|
|
596
|
+
});
|
|
597
|
+
});
|
|
598
|
+
describe('main group found', function () {
|
|
599
|
+
it('should return array of file paths', function () {
|
|
600
|
+
// -- Arrange --
|
|
601
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
602
|
+
// -- Act --
|
|
603
|
+
var files = xcodeProject.projectFiles();
|
|
604
|
+
// -- Assert --
|
|
605
|
+
expect(files).toEqual([
|
|
606
|
+
{
|
|
607
|
+
key: 'D4E604CD2D50CEEC00CAB00F',
|
|
608
|
+
path: 'Project.app',
|
|
609
|
+
},
|
|
610
|
+
]);
|
|
611
|
+
});
|
|
612
|
+
it('should cache the result', function () {
|
|
613
|
+
// -- Arrange --
|
|
614
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
615
|
+
// Smoke test
|
|
616
|
+
expect(xcodeProject.files).toBeUndefined();
|
|
617
|
+
// -- Act --
|
|
618
|
+
var files = xcodeProject.projectFiles();
|
|
619
|
+
// -- Assert --
|
|
620
|
+
expect(xcodeProject.files).toBeDefined();
|
|
621
|
+
expect(xcodeProject.files).toEqual(files);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
describe('buildGroup', function () {
|
|
626
|
+
describe('group has undefined children', function () {
|
|
627
|
+
it('should return empty array', function () {
|
|
628
|
+
// -- Arrange --
|
|
629
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
630
|
+
var group = {
|
|
631
|
+
children: undefined,
|
|
632
|
+
path: '',
|
|
633
|
+
};
|
|
634
|
+
// -- Act --
|
|
635
|
+
var files = xcodeProject.buildGroup(group);
|
|
636
|
+
// -- Assert --
|
|
637
|
+
expect(files).toEqual([]);
|
|
638
|
+
});
|
|
639
|
+
});
|
|
640
|
+
describe('group has no children', function () {
|
|
641
|
+
it('should return empty array', function () {
|
|
642
|
+
// -- Arrange --
|
|
643
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
644
|
+
var group = {};
|
|
645
|
+
// -- Act --
|
|
646
|
+
var files = xcodeProject.buildGroup(group);
|
|
647
|
+
// -- Assert --
|
|
648
|
+
expect(files).toEqual([]);
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
describe('group child is file reference', function () {
|
|
652
|
+
var group = {
|
|
653
|
+
children: [
|
|
654
|
+
{
|
|
655
|
+
value: 'D4E604CD2D50CEEC00CAB00F',
|
|
656
|
+
},
|
|
657
|
+
],
|
|
658
|
+
path: '',
|
|
659
|
+
};
|
|
660
|
+
describe('file references are undefined', function () {
|
|
661
|
+
it('should return empty array', function () {
|
|
662
|
+
// -- Arrange --
|
|
663
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
664
|
+
xcodeProject.objects.PBXFileReference = undefined;
|
|
665
|
+
// -- Act --
|
|
666
|
+
var files = xcodeProject.buildGroup(group);
|
|
667
|
+
// -- Assert --
|
|
668
|
+
expect(files).toEqual([]);
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
describe('file reference is string', function () {
|
|
672
|
+
it('should be ignored', function () {
|
|
673
|
+
// -- Arrange --
|
|
674
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
675
|
+
var group = {
|
|
676
|
+
children: [
|
|
677
|
+
{
|
|
678
|
+
value: 'D4E604CD2D50CEEC00CAB00F_comment',
|
|
679
|
+
},
|
|
680
|
+
],
|
|
681
|
+
path: '',
|
|
682
|
+
};
|
|
683
|
+
// -- Act --
|
|
684
|
+
var files = xcodeProject.buildGroup(group);
|
|
685
|
+
// -- Assert --
|
|
686
|
+
expect(files).toEqual([]);
|
|
687
|
+
});
|
|
688
|
+
});
|
|
689
|
+
describe('file reference is valid', function () {
|
|
690
|
+
it('should return array of escaped paths', function () {
|
|
691
|
+
// -- Arrange --
|
|
692
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
693
|
+
xcodeProject.objects.PBXFileReference = {
|
|
694
|
+
D4E604CD2D50CEEC00CAB00F: {
|
|
695
|
+
path: '"some/path/to/file.swift"',
|
|
696
|
+
},
|
|
697
|
+
};
|
|
698
|
+
var group = {
|
|
699
|
+
children: [
|
|
700
|
+
{
|
|
701
|
+
value: 'D4E604CD2D50CEEC00CAB00F',
|
|
702
|
+
},
|
|
703
|
+
],
|
|
704
|
+
path: '',
|
|
705
|
+
};
|
|
706
|
+
// -- Act --
|
|
707
|
+
var files = xcodeProject.buildGroup(group);
|
|
708
|
+
// -- Assert --
|
|
709
|
+
expect(files).toEqual([
|
|
710
|
+
{
|
|
711
|
+
key: 'D4E604CD2D50CEEC00CAB00F',
|
|
712
|
+
path: 'some/path/to/file.swift',
|
|
713
|
+
},
|
|
714
|
+
]);
|
|
715
|
+
});
|
|
716
|
+
});
|
|
717
|
+
});
|
|
718
|
+
describe('group child is group reference', function () {
|
|
719
|
+
var group = {
|
|
720
|
+
children: [
|
|
721
|
+
{
|
|
722
|
+
value: 'D4E604C42D50CEEC00CAB00F',
|
|
723
|
+
},
|
|
724
|
+
],
|
|
725
|
+
path: '',
|
|
726
|
+
};
|
|
727
|
+
describe('groups are undefined', function () {
|
|
728
|
+
it('should return empty array', function () {
|
|
729
|
+
// -- Arrange --
|
|
730
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
731
|
+
xcodeProject.objects.PBXGroup = undefined;
|
|
732
|
+
// -- Act --
|
|
733
|
+
var files = xcodeProject.buildGroup(group);
|
|
734
|
+
// -- Assert --
|
|
735
|
+
expect(files).toEqual([]);
|
|
736
|
+
});
|
|
737
|
+
});
|
|
738
|
+
describe('group reference is string', function () {
|
|
739
|
+
it('should return array of file paths', function () {
|
|
740
|
+
// -- Arrange --
|
|
741
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
742
|
+
var group = {
|
|
743
|
+
children: [
|
|
744
|
+
{
|
|
745
|
+
value: 'D4E604CE2D50CEEC00CAB00F_comment',
|
|
746
|
+
},
|
|
747
|
+
],
|
|
748
|
+
path: '',
|
|
749
|
+
};
|
|
750
|
+
// -- Act --
|
|
751
|
+
var files = xcodeProject.buildGroup(group);
|
|
752
|
+
// -- Assert --
|
|
753
|
+
expect(files).toEqual([]);
|
|
754
|
+
});
|
|
755
|
+
});
|
|
756
|
+
describe('group reference is valid', function () {
|
|
757
|
+
it('should return array of file paths', function () {
|
|
758
|
+
// -- Arrange --
|
|
759
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
760
|
+
// -- Act --
|
|
761
|
+
var files = xcodeProject.buildGroup(group);
|
|
762
|
+
// -- Assert --
|
|
763
|
+
expect(files).toEqual([
|
|
764
|
+
{
|
|
765
|
+
key: 'D4E604CD2D50CEEC00CAB00F',
|
|
766
|
+
path: 'Project.app',
|
|
767
|
+
},
|
|
768
|
+
]);
|
|
769
|
+
});
|
|
770
|
+
});
|
|
771
|
+
describe('group reference has path', function () {
|
|
772
|
+
it('should append the path to the file paths', function () {
|
|
773
|
+
// -- Arrange --
|
|
774
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
775
|
+
var group = {
|
|
776
|
+
children: [
|
|
777
|
+
{
|
|
778
|
+
value: 'sub-group',
|
|
779
|
+
},
|
|
780
|
+
],
|
|
781
|
+
path: '"some/path/to/group"',
|
|
782
|
+
};
|
|
783
|
+
var subgroup = {
|
|
784
|
+
children: [
|
|
785
|
+
{
|
|
786
|
+
value: 'file-at-path',
|
|
787
|
+
},
|
|
788
|
+
],
|
|
789
|
+
};
|
|
790
|
+
var file = {
|
|
791
|
+
path: '"some/file/at/path.swift"',
|
|
792
|
+
};
|
|
793
|
+
xcodeProject.objects.PBXGroup = {
|
|
794
|
+
'main-group': group,
|
|
795
|
+
'sub-group': subgroup,
|
|
796
|
+
};
|
|
797
|
+
xcodeProject.objects.PBXFileReference = {
|
|
798
|
+
'file-at-path': file,
|
|
799
|
+
};
|
|
800
|
+
// -- Act --
|
|
801
|
+
var files = xcodeProject.buildGroup(group);
|
|
802
|
+
// -- Assert --
|
|
803
|
+
expect(files).toEqual([
|
|
804
|
+
{
|
|
805
|
+
key: 'file-at-path',
|
|
806
|
+
path: 'some/file/at/path.swift',
|
|
807
|
+
},
|
|
808
|
+
]);
|
|
809
|
+
});
|
|
810
|
+
});
|
|
811
|
+
});
|
|
812
|
+
describe('group child is not a file reference or group', function () {
|
|
813
|
+
it('should be ignored', function () {
|
|
814
|
+
// -- Arrange --
|
|
815
|
+
var xcodeProject = new xcode_manager_1.XcodeProject(singleTargetProjectPath);
|
|
816
|
+
xcodeProject.objects.PBXGroup = {};
|
|
817
|
+
xcodeProject.objects.PBXFileReference = {};
|
|
818
|
+
var group = {
|
|
819
|
+
children: [
|
|
820
|
+
{
|
|
821
|
+
value: 'random-key',
|
|
822
|
+
},
|
|
823
|
+
],
|
|
824
|
+
path: '',
|
|
825
|
+
};
|
|
826
|
+
// -- Act --
|
|
827
|
+
var files = xcodeProject.buildGroup(group);
|
|
828
|
+
// -- Assert --
|
|
829
|
+
expect(files).toEqual([]);
|
|
830
|
+
});
|
|
831
|
+
});
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
//# sourceMappingURL=xcode-manager.test.js.map
|