@capacitor/cli 9.0.0-alpha.7 → 9.0.0-beta.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/assets/android-template.tar.gz +0 -0
- package/assets/capacitor-cordova-android-plugins.tar.gz +0 -0
- package/assets/capacitor-cordova-ios-plugins.tar.gz +0 -0
- package/assets/ios-pods-template.tar.gz +0 -0
- package/assets/ios-spm-template.tar.gz +0 -0
- package/dist/android/network-security-config.js +230 -0
- package/dist/android/update.js +5 -1
- package/dist/common.js +1 -1
- package/dist/config.js +4 -3
- package/dist/cordova.js +8 -17
- package/dist/declarations.d.ts +8 -41
- package/dist/index.js +4 -14
- package/dist/ios/common.js +1 -1
- package/dist/ios/update.js +9 -17
- package/dist/ipc.js +51 -11
- package/dist/plugin.js +1 -1
- package/dist/run-context/declared.js +54 -0
- package/dist/run-context/index.js +111 -0
- package/dist/run-context/registry.js +45 -0
- package/dist/run-context/signals.js +115 -0
- package/dist/run-context/types.js +2 -0
- package/dist/run-context/unknown.js +46 -0
- package/dist/run-context/version.js +74 -0
- package/dist/tasks/copy.js +3 -1
- package/dist/tasks/doctor.js +4 -1
- package/dist/tasks/list.js +1 -1
- package/dist/tasks/migrate-debug-xcconfig.js +60 -0
- package/dist/tasks/migrate-spm.js +0 -1
- package/dist/tasks/migrate-swiftui.js +344 -54
- package/dist/tasks/migrate-to-modern-project.js +27 -0
- package/dist/tasks/migrate.js +41 -4
- package/dist/tasks/run.js +8 -3
- package/dist/tasks/telemetry.js +8 -1
- package/dist/telemetry.js +303 -57
- package/dist/util/capacitor-package.js +95 -146
- package/dist/util/cordova-ios.js +13 -8
- package/dist/util/js.js +1 -1
- package/dist/util/monorepotools.js +2 -2
- package/dist/util/node.js +3 -3
- package/dist/util/npm.js +120 -0
- package/dist/util/spm.js +35 -25
- package/dist/util/subprocess.js +2 -2
- package/dist/util/xcode.js +193 -2
- package/dist/util/xml.js +1 -1
- package/package.json +3 -2
package/dist/util/xcode.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.findGroupUuidByComment = exports.addSwiftFileToAppTarget = void 0;
|
|
3
|
+
exports.removeBaseConfigurationFile = exports.findGroupUuidByComment = exports.addMultipleBuildSettings = exports.removeStoryboardFromAppTarget = exports.removeSwiftFileFromAppTarget = exports.addSwiftFileToAppTarget = void 0;
|
|
4
4
|
const fs_extra_1 = require("fs-extra");
|
|
5
|
+
const path_1 = require("path");
|
|
5
6
|
const xcode_1 = require("xcode");
|
|
7
|
+
const COMMENT_SUFFIX = '_comment';
|
|
6
8
|
/**
|
|
7
9
|
* Register a Swift source file with the first native target of an Xcode project.
|
|
8
10
|
*
|
|
@@ -32,10 +34,140 @@ function addSwiftFileToAppTarget(pbxprojPath, groupName, fileRelPath) {
|
|
|
32
34
|
return { added: true };
|
|
33
35
|
}
|
|
34
36
|
exports.addSwiftFileToAppTarget = addSwiftFileToAppTarget;
|
|
37
|
+
/**
|
|
38
|
+
* Unregister a Swift source file from an Xcode project.
|
|
39
|
+
*
|
|
40
|
+
* Clears the file's PBXBuildFile, its entry in every Sources build phase, its listing in
|
|
41
|
+
* any PBXGroup, and its PBXFileReference. Matching is by resolved file reference UUID, so
|
|
42
|
+
* nothing else that happens to share the name is touched. Idempotent: a second call is a
|
|
43
|
+
* no-op and leaves the file untouched.
|
|
44
|
+
*
|
|
45
|
+
* @param pbxprojPath Absolute path to project.pbxproj
|
|
46
|
+
* @param fileName Basename of the Swift file to unregister (e.g. 'SceneDelegate.swift')
|
|
47
|
+
*/
|
|
48
|
+
function removeSwiftFileFromAppTarget(pbxprojPath, fileName) {
|
|
49
|
+
const project = (0, xcode_1.project)(pbxprojPath);
|
|
50
|
+
project.parseSync();
|
|
51
|
+
const objects = project.hash.project.objects;
|
|
52
|
+
const fileRefUuids = findSwiftFileUuidsByFileName(objects.PBXFileReference, fileName);
|
|
53
|
+
if (fileRefUuids.length === 0) {
|
|
54
|
+
return { removed: false };
|
|
55
|
+
}
|
|
56
|
+
const buildFileUuids = removeFromBuildFileSection(objects.PBXBuildFile, fileRefUuids);
|
|
57
|
+
removeFromBuildPhaseFiles(objects.PBXSourcesBuildPhase, buildFileUuids);
|
|
58
|
+
removeFromGroupChildren(objects.PBXGroup, fileRefUuids);
|
|
59
|
+
for (const uuid of fileRefUuids) {
|
|
60
|
+
deleteWithComment(objects.PBXFileReference, uuid);
|
|
61
|
+
}
|
|
62
|
+
(0, fs_extra_1.writeFileSync)(pbxprojPath, project.writeSync(), 'utf-8');
|
|
63
|
+
return { removed: true };
|
|
64
|
+
}
|
|
65
|
+
exports.removeSwiftFileFromAppTarget = removeSwiftFileFromAppTarget;
|
|
66
|
+
/**
|
|
67
|
+
* Unregister a storyboard from an Xcode project.
|
|
68
|
+
*
|
|
69
|
+
* A localized storyboard is a PBXVariantGroup whose children are the per-language
|
|
70
|
+
* PBXFileReferences, and it is the variant group — not the file reference — that the
|
|
71
|
+
* PBXBuildFile and the owning PBXGroup point at. Both levels are removed here, along with
|
|
72
|
+
* the Resources build phase entry. Falls back to a bare PBXFileReference for a project
|
|
73
|
+
* whose storyboard was moved out of Base.lproj. Idempotent: a second call is a no-op.
|
|
74
|
+
*
|
|
75
|
+
* @param pbxprojPath Absolute path to project.pbxproj
|
|
76
|
+
* @param storyboardName Basename of the storyboard to unregister (e.g. 'Main.storyboard')
|
|
77
|
+
*/
|
|
78
|
+
function removeStoryboardFromAppTarget(pbxprojPath, storyboardName) {
|
|
79
|
+
const project = (0, xcode_1.project)(pbxprojPath);
|
|
80
|
+
project.parseSync();
|
|
81
|
+
const objects = project.hash.project.objects;
|
|
82
|
+
const variantGroupUuids = findVariantGroupUuidsByName(objects.PBXVariantGroup, storyboardName);
|
|
83
|
+
const fileRefUuids = findStoryboardFileRefUuids(objects.PBXFileReference, storyboardName);
|
|
84
|
+
const uuids = [...variantGroupUuids, ...fileRefUuids];
|
|
85
|
+
if (uuids.length === 0) {
|
|
86
|
+
return { removed: false };
|
|
87
|
+
}
|
|
88
|
+
const buildFileUuids = removeFromBuildFileSection(objects.PBXBuildFile, uuids);
|
|
89
|
+
removeFromBuildPhaseFiles(objects.PBXResourcesBuildPhase, buildFileUuids);
|
|
90
|
+
removeFromGroupChildren(objects.PBXGroup, uuids);
|
|
91
|
+
for (const uuid of variantGroupUuids) {
|
|
92
|
+
deleteWithComment(objects.PBXVariantGroup, uuid);
|
|
93
|
+
}
|
|
94
|
+
for (const uuid of fileRefUuids) {
|
|
95
|
+
deleteWithComment(objects.PBXFileReference, uuid);
|
|
96
|
+
}
|
|
97
|
+
(0, fs_extra_1.writeFileSync)(pbxprojPath, project.writeSync(), 'utf-8');
|
|
98
|
+
return { removed: true };
|
|
99
|
+
}
|
|
100
|
+
exports.removeStoryboardFromAppTarget = removeStoryboardFromAppTarget;
|
|
101
|
+
function addMultipleBuildSettings(pbxprojPath, settings) {
|
|
102
|
+
const project = (0, xcode_1.project)(pbxprojPath);
|
|
103
|
+
project.parseSync();
|
|
104
|
+
for (const key in settings) {
|
|
105
|
+
const value = settings[key];
|
|
106
|
+
project.addToBuildSettings(key, value);
|
|
107
|
+
}
|
|
108
|
+
(0, fs_extra_1.writeFileSync)(pbxprojPath, project.writeSync(), 'utf-8');
|
|
109
|
+
}
|
|
110
|
+
exports.addMultipleBuildSettings = addMultipleBuildSettings;
|
|
111
|
+
function findSwiftFileUuidsByFileName(section, fileName) {
|
|
112
|
+
return sectionEntries(section)
|
|
113
|
+
.filter(([, fileReference]) => unquote(fileReference['lastKnownFileType']) === 'sourcecode.swift' &&
|
|
114
|
+
(0, path_1.basename)(unquote(fileReference['path'])) === fileName)
|
|
115
|
+
.map(([uuid]) => uuid);
|
|
116
|
+
}
|
|
117
|
+
function findVariantGroupUuidsByName(section, storyboardName) {
|
|
118
|
+
if (!section)
|
|
119
|
+
return [];
|
|
120
|
+
return sectionEntries(section)
|
|
121
|
+
.filter(([, group]) => unquote(group['name']) === storyboardName)
|
|
122
|
+
.map(([uuid]) => uuid);
|
|
123
|
+
}
|
|
124
|
+
function findStoryboardFileRefUuids(section, storyboardName) {
|
|
125
|
+
return sectionEntries(section)
|
|
126
|
+
.filter(([, fileReference]) => (0, path_1.basename)(unquote(fileReference['path'])) === storyboardName)
|
|
127
|
+
.map(([uuid]) => uuid);
|
|
128
|
+
}
|
|
129
|
+
/** Deletes every PBXBuildFile pointing at one of `fileRefUuids` and returns their UUIDs. */
|
|
130
|
+
function removeFromBuildFileSection(section, fileRefUuids) {
|
|
131
|
+
const removed = [];
|
|
132
|
+
for (const [uuid, buildFile] of sectionEntries(section)) {
|
|
133
|
+
if (!fileRefUuids.includes(buildFile['fileRef']))
|
|
134
|
+
continue;
|
|
135
|
+
removed.push(uuid);
|
|
136
|
+
deleteWithComment(section, uuid);
|
|
137
|
+
}
|
|
138
|
+
return removed;
|
|
139
|
+
}
|
|
140
|
+
function removeFromBuildPhaseFiles(section, buildFileUuids) {
|
|
141
|
+
if (!section)
|
|
142
|
+
return;
|
|
143
|
+
for (const [, buildPhase] of sectionEntries(section)) {
|
|
144
|
+
const files = buildPhase['files'];
|
|
145
|
+
if (!Array.isArray(files))
|
|
146
|
+
continue;
|
|
147
|
+
buildPhase['files'] = files.filter((file) => !buildFileUuids.includes(file.value));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function removeFromGroupChildren(section, uuids) {
|
|
151
|
+
for (const [, group] of sectionEntries(section)) {
|
|
152
|
+
const children = group['children'];
|
|
153
|
+
if (!Array.isArray(children))
|
|
154
|
+
continue;
|
|
155
|
+
group['children'] = children.filter((child) => !uuids.includes(child.value));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
function sectionEntries(section) {
|
|
159
|
+
return Object.entries(section).filter((entry) => !entry[0].endsWith(COMMENT_SUFFIX) && typeof entry[1] !== 'string');
|
|
160
|
+
}
|
|
161
|
+
function deleteWithComment(section, uuid) {
|
|
162
|
+
delete section[uuid];
|
|
163
|
+
delete section[`${uuid}${COMMENT_SUFFIX}`];
|
|
164
|
+
}
|
|
165
|
+
function unquote(value) {
|
|
166
|
+
return typeof value === 'string' ? value.replace(/^"(.*)"$/, '$1') : '';
|
|
167
|
+
}
|
|
35
168
|
// Exported for tests.
|
|
36
169
|
function findGroupUuidByComment(project, comment) {
|
|
37
170
|
const groups = project.hash.project.objects.PBXGroup;
|
|
38
|
-
const COMMENT_SUFFIX = '_comment';
|
|
39
171
|
for (const key of Object.keys(groups)) {
|
|
40
172
|
if (!key.endsWith(COMMENT_SUFFIX))
|
|
41
173
|
continue;
|
|
@@ -46,3 +178,62 @@ function findGroupUuidByComment(project, comment) {
|
|
|
46
178
|
return null;
|
|
47
179
|
}
|
|
48
180
|
exports.findGroupUuidByComment = findGroupUuidByComment;
|
|
181
|
+
/**
|
|
182
|
+
* Unregister an .xcconfig file from an Xcode project.
|
|
183
|
+
*
|
|
184
|
+
* Clears the baseConfigurationReference of every build configuration using it, drops it
|
|
185
|
+
* from any group it is listed under, and deletes its PBXFileReference. Matches on the
|
|
186
|
+
* resolved file reference rather than on text, so a CocoaPods project's
|
|
187
|
+
* Pods-App.debug.xcconfig is left alone. Idempotent: a second call is a no-op.
|
|
188
|
+
*
|
|
189
|
+
* @param pbxprojPath Absolute path to project.pbxproj
|
|
190
|
+
* @param fileName Basename of the .xcconfig to unregister (e.g. 'debug.xcconfig')
|
|
191
|
+
*/
|
|
192
|
+
function removeBaseConfigurationFile(pbxprojPath, fileName) {
|
|
193
|
+
const project = (0, xcode_1.project)(pbxprojPath);
|
|
194
|
+
project.parseSync();
|
|
195
|
+
const objects = project.hash.project.objects;
|
|
196
|
+
const uuids = findXCConfigUuidsByFileName(objects.PBXFileReference, fileName);
|
|
197
|
+
if (uuids.length === 0) {
|
|
198
|
+
return { removed: false };
|
|
199
|
+
}
|
|
200
|
+
clearBaseConfigurationReferences(objects.XCBuildConfiguration, uuids);
|
|
201
|
+
removeFromGroupChildren(objects.PBXGroup, uuids);
|
|
202
|
+
for (const uuid of uuids) {
|
|
203
|
+
delete objects.PBXFileReference[uuid];
|
|
204
|
+
delete objects.PBXFileReference[`${uuid}${COMMENT_SUFFIX}`];
|
|
205
|
+
}
|
|
206
|
+
(0, fs_extra_1.writeFileSync)(pbxprojPath, project.writeSync(), 'utf-8');
|
|
207
|
+
return { removed: true };
|
|
208
|
+
}
|
|
209
|
+
exports.removeBaseConfigurationFile = removeBaseConfigurationFile;
|
|
210
|
+
function findXCConfigUuidsByFileName(section, fileName) {
|
|
211
|
+
const uuids = [];
|
|
212
|
+
for (const key of Object.keys(section)) {
|
|
213
|
+
if (key.endsWith(COMMENT_SUFFIX))
|
|
214
|
+
continue;
|
|
215
|
+
const fileReference = section[key];
|
|
216
|
+
if (typeof fileReference === 'string')
|
|
217
|
+
continue;
|
|
218
|
+
if (unquote(fileReference['lastKnownFileType']) !== 'text.xcconfig')
|
|
219
|
+
continue;
|
|
220
|
+
if ((0, path_1.basename)(unquote(fileReference['path'])) !== fileName)
|
|
221
|
+
continue;
|
|
222
|
+
uuids.push(key);
|
|
223
|
+
}
|
|
224
|
+
return uuids;
|
|
225
|
+
}
|
|
226
|
+
function clearBaseConfigurationReferences(section, uuids) {
|
|
227
|
+
for (const key of Object.keys(section)) {
|
|
228
|
+
if (key.endsWith(COMMENT_SUFFIX))
|
|
229
|
+
continue;
|
|
230
|
+
const buildConfiguration = section[key];
|
|
231
|
+
if (typeof buildConfiguration === 'string')
|
|
232
|
+
continue;
|
|
233
|
+
const reference = buildConfiguration['baseConfigurationReference'];
|
|
234
|
+
if (typeof reference !== 'string' || !uuids.includes(reference))
|
|
235
|
+
continue;
|
|
236
|
+
delete buildConfiguration['baseConfigurationReference'];
|
|
237
|
+
delete buildConfiguration[`baseConfigurationReference${COMMENT_SUFFIX}`];
|
|
238
|
+
}
|
|
239
|
+
}
|
package/dist/util/xml.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capacitor/cli",
|
|
3
|
-
"version": "9.0.0-
|
|
3
|
+
"version": "9.0.0-beta.0",
|
|
4
4
|
"description": "Capacitor: Cross-platform apps with JavaScript and the web",
|
|
5
5
|
"homepage": "https://capacitorjs.com",
|
|
6
6
|
"author": "Ionic Team <hi@ionic.io> (https://ionic.io)",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@ionic/cli-framework-output": "^2.2.8",
|
|
48
48
|
"@ionic/utils-subprocess": "^3.0.1",
|
|
49
49
|
"@ionic/utils-terminal": "^2.3.5",
|
|
50
|
+
"agent-cli-detector": "^0.1.7",
|
|
50
51
|
"commander": "^12.1.0",
|
|
51
52
|
"debug": "^4.4.0",
|
|
52
53
|
"env-paths": "^2.2.0",
|
|
@@ -60,7 +61,7 @@
|
|
|
60
61
|
"semver": "^7.6.3",
|
|
61
62
|
"tar": "^7.5.3",
|
|
62
63
|
"tslib": "^2.8.1",
|
|
63
|
-
"xcode": "^
|
|
64
|
+
"xcode": "^4.0.0",
|
|
64
65
|
"xml2js": "^0.6.2"
|
|
65
66
|
},
|
|
66
67
|
"devDependencies": {
|