nativescript 9.1.1-dev.1 → 9.1.2-dev.2026-09-24-36031892256
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -8
- package/config/test-deps-versions-generated.json +1 -1
- package/docs/man_pages/project/testing/build-windows.md +64 -0
- package/docs/man_pages/project/testing/build.md +4 -2
- package/docs/man_pages/project/testing/debug-windows.md +69 -0
- package/docs/man_pages/project/testing/debug.md +5 -2
- package/docs/man_pages/project/testing/run-windows.md +63 -0
- package/docs/man_pages/project/testing/run.md +5 -2
- package/lib/bootstrap.js +5 -0
- package/lib/commands/build.d.ts +10 -0
- package/lib/commands/build.js +41 -1
- package/lib/commands/debug.d.ts +12 -0
- package/lib/commands/debug.js +28 -1
- package/lib/commands/run.d.ts +14 -0
- package/lib/commands/run.js +35 -1
- package/lib/commands/typings.d.ts +1 -0
- package/lib/commands/typings.js +55 -0
- package/lib/common/bootstrap.js +1 -0
- package/lib/common/commands/doctor.d.ts +7 -0
- package/lib/common/commands/doctor.js +18 -1
- package/lib/common/definitions/mobile.d.ts +9 -0
- package/lib/common/file-system.js +34 -6
- package/lib/common/http-client.js +9 -2
- package/lib/common/mobile/device-platforms-constants.d.ts +2 -0
- package/lib/common/mobile/device-platforms-constants.js +4 -0
- package/lib/common/mobile/mobile-core/devices-service.d.ts +2 -1
- package/lib/common/mobile/mobile-core/devices-service.js +7 -1
- package/lib/common/mobile/mobile-helper.d.ts +1 -0
- package/lib/common/mobile/mobile-helper.js +9 -0
- package/lib/common/mobile/windows/windows-application-manager.d.ts +25 -0
- package/lib/common/mobile/windows/windows-application-manager.js +237 -0
- package/lib/common/mobile/windows/windows-device-discovery.d.ts +9 -0
- package/lib/common/mobile/windows/windows-device-discovery.js +27 -0
- package/lib/common/mobile/windows/windows-device-file-system.d.ts +15 -0
- package/lib/common/mobile/windows/windows-device-file-system.js +74 -0
- package/lib/common/mobile/windows/windows-device.d.ts +13 -0
- package/lib/common/mobile/windows/windows-device.js +110 -0
- package/lib/constants.d.ts +12 -2
- package/lib/constants.js +15 -4
- package/lib/controllers/prepare-controller.js +3 -0
- package/lib/controllers/run-controller.js +1 -0
- package/lib/data/build-data.d.ts +11 -0
- package/lib/data/build-data.js +18 -1
- package/lib/data/prepare-data.d.ts +4 -0
- package/lib/data/prepare-data.js +8 -1
- package/lib/declarations.d.ts +9 -0
- package/lib/definitions/livesync.d.ts +3 -0
- package/lib/definitions/project.d.ts +10 -0
- package/lib/device-path-provider.d.ts +3 -1
- package/lib/device-path-provider.js +13 -1
- package/lib/options.js +19 -0
- package/lib/project-data.js +5 -0
- package/lib/resolvers/livesync-service-resolver.js +3 -0
- package/lib/services/apple-portal/apple-portal-session-service.d.ts +1 -0
- package/lib/services/apple-portal/apple-portal-session-service.js +34 -0
- package/lib/services/build-data-service.d.ts +2 -2
- package/lib/services/build-data-service.js +3 -0
- package/lib/services/build-info-file-service.js +1 -0
- package/lib/services/bundler/bundler-compiler-service.js +1 -0
- package/lib/services/livesync/windows-device-livesync-service.d.ts +14 -0
- package/lib/services/livesync/windows-device-livesync-service.js +47 -0
- package/lib/services/livesync/windows-livesync-service.d.ts +13 -0
- package/lib/services/livesync/windows-livesync-service.js +19 -0
- package/lib/services/platform/add-platform-service.js +9 -1
- package/lib/services/platforms-data-service.d.ts +1 -1
- package/lib/services/platforms-data-service.js +2 -1
- package/lib/services/prepare-data-service.d.ts +2 -2
- package/lib/services/prepare-data-service.js +4 -1
- package/lib/services/project-cleanup-service.d.ts +1 -0
- package/lib/services/project-cleanup-service.js +30 -1
- package/lib/services/project-data-service.js +18 -0
- package/lib/services/windows-project-service.d.ts +42 -0
- package/lib/services/windows-project-service.js +907 -0
- package/package.json +3 -3
|
@@ -0,0 +1,907 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WindowsProjectService = void 0;
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const shell = require("shelljs");
|
|
6
|
+
const constants = require("../constants");
|
|
7
|
+
const constants_1 = require("../common/constants");
|
|
8
|
+
const projectServiceBaseLib = require("./platform-project-service-base");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const yok_1 = require("../common/yok");
|
|
11
|
+
function isGuid(s) {
|
|
12
|
+
return /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(s);
|
|
13
|
+
}
|
|
14
|
+
function generateGuid() {
|
|
15
|
+
try {
|
|
16
|
+
const crypto = require("crypto");
|
|
17
|
+
if (typeof crypto.randomUUID === "function")
|
|
18
|
+
return crypto.randomUUID();
|
|
19
|
+
const b = crypto.randomBytes(16);
|
|
20
|
+
b[6] = (b[6] & 0x0f) | 0x40;
|
|
21
|
+
b[8] = (b[8] & 0x3f) | 0x80;
|
|
22
|
+
const hex = Array.from(b).map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
23
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
24
|
+
}
|
|
25
|
+
catch (e) {
|
|
26
|
+
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
|
27
|
+
return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4() + s4() + s4()}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function generateDeterministicGuidFromString(s) {
|
|
31
|
+
try {
|
|
32
|
+
const crypto = require("crypto");
|
|
33
|
+
const hash = crypto.createHash("sha1").update(s).digest();
|
|
34
|
+
const b = Buffer.from(hash.slice(0, 16));
|
|
35
|
+
b[6] = (b[6] & 0x0f) | 0x50;
|
|
36
|
+
b[8] = (b[8] & 0x3f) | 0x80;
|
|
37
|
+
const hex = Array.from(b).map((n) => n.toString(16).padStart(2, "0")).join("");
|
|
38
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
return generateGuid();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class WindowsProjectService extends projectServiceBaseLib.PlatformProjectServiceBase {
|
|
45
|
+
constructor($fs, $projectDataService, $options, $logger, $childProcess, $platformEnvironmentRequirements) {
|
|
46
|
+
super($fs, $projectDataService);
|
|
47
|
+
this.$options = $options;
|
|
48
|
+
this.$logger = $logger;
|
|
49
|
+
this.$childProcess = $childProcess;
|
|
50
|
+
this.$platformEnvironmentRequirements = $platformEnvironmentRequirements;
|
|
51
|
+
this._platformData = null;
|
|
52
|
+
}
|
|
53
|
+
getPlatformData(projectData) {
|
|
54
|
+
if (!projectData && !this._platformData) {
|
|
55
|
+
throw new Error("First call of getPlatformData without providing projectData.");
|
|
56
|
+
}
|
|
57
|
+
if (projectData && projectData.platformsDir) {
|
|
58
|
+
const projectRoot = this.$options.hostProjectPath
|
|
59
|
+
? this.$options.hostProjectPath
|
|
60
|
+
: path.join(projectData.platformsDir, WindowsProjectService.WINDOWS_PLATFORM_NAME);
|
|
61
|
+
const runtimePackage = this.$projectDataService.getRuntimePackage(projectData.projectDir, constants.PlatformTypes.windows);
|
|
62
|
+
this._platformData = {
|
|
63
|
+
frameworkPackageName: runtimePackage.name,
|
|
64
|
+
normalizedPlatformName: "Windows",
|
|
65
|
+
platformNameLowerCase: "windows",
|
|
66
|
+
appDestinationDirectoryPath: path.join(projectRoot, projectData.projectName),
|
|
67
|
+
platformProjectService: this,
|
|
68
|
+
projectRoot: projectRoot,
|
|
69
|
+
getBuildOutputPath: (options) => {
|
|
70
|
+
if (options === null || options === void 0 ? void 0 : options.release) {
|
|
71
|
+
return path.join(projectRoot, projectData.projectName, "AppPackages");
|
|
72
|
+
}
|
|
73
|
+
return path.join(projectRoot, projectData.projectName, "bin");
|
|
74
|
+
},
|
|
75
|
+
getValidBuildOutputData: (options) => {
|
|
76
|
+
if (options === null || options === void 0 ? void 0 : options.release) {
|
|
77
|
+
return {
|
|
78
|
+
packageNames: [
|
|
79
|
+
`${projectData.projectName}.msixupload`,
|
|
80
|
+
`${projectData.projectName}.msix`,
|
|
81
|
+
],
|
|
82
|
+
regexes: [
|
|
83
|
+
/\.(msixupload|appxupload|msixbundle|appxbundle|msix|appx)$/i,
|
|
84
|
+
],
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
packageNames: ["AppxManifest.xml"],
|
|
89
|
+
};
|
|
90
|
+
},
|
|
91
|
+
configurationFileName: "Package.appxmanifest",
|
|
92
|
+
frameworkDirectoriesExtensions: [],
|
|
93
|
+
frameworkDirectoriesNames: ["metadata", "NativeScript", "internal"],
|
|
94
|
+
targetedOS: ["win32"],
|
|
95
|
+
relativeToFrameworkConfigurationFilePath: "app.config",
|
|
96
|
+
fastLivesyncFileExtensions: [".jpg", ".jpeg", ".png", ".gif", ".bmp"],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return this._platformData;
|
|
100
|
+
}
|
|
101
|
+
async validateOptions(_projectId, _provision, _teamId) {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
getAppResourcesDestinationDirectoryPath(projectData) {
|
|
105
|
+
return path.join(this.getPlatformData(projectData).projectRoot, projectData.projectName, "Assets");
|
|
106
|
+
}
|
|
107
|
+
async validate(projectData, options, notConfiguredEnvOptions) {
|
|
108
|
+
const checkEnvironmentRequirementsOutput = await this.$platformEnvironmentRequirements.checkEnvironmentRequirements({
|
|
109
|
+
platform: this.getPlatformData(projectData).normalizedPlatformName,
|
|
110
|
+
projectDir: projectData.projectDir,
|
|
111
|
+
options,
|
|
112
|
+
notConfiguredEnvOptions,
|
|
113
|
+
});
|
|
114
|
+
return { checkEnvironmentRequirementsOutput };
|
|
115
|
+
}
|
|
116
|
+
async createProject(frameworkDir, _frameworkVersion, projectData) {
|
|
117
|
+
const projectRoot = this.getPlatformData(projectData).projectRoot;
|
|
118
|
+
this.$fs.ensureDirectoryExists(projectRoot);
|
|
119
|
+
const name = projectData.projectName;
|
|
120
|
+
const entries = fs.readdirSync(frameworkDir, { withFileTypes: true });
|
|
121
|
+
for (const entry of entries) {
|
|
122
|
+
const srcPath = path.join(frameworkDir, entry.name);
|
|
123
|
+
if (entry.name === "__PROJECT_NAME__") {
|
|
124
|
+
const destPath = path.join(projectRoot, name);
|
|
125
|
+
shell.cp("-R", srcPath, destPath);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
const destPath = path.join(projectRoot, entry.name);
|
|
129
|
+
shell.cp("-R", srcPath, destPath);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async interpolateData(projectData) {
|
|
134
|
+
var _a, _b;
|
|
135
|
+
const projectRoot = this.getPlatformData(projectData).projectRoot;
|
|
136
|
+
const placeholder = "__PROJECT_NAME__";
|
|
137
|
+
const name = projectData.projectName;
|
|
138
|
+
const appId = (_b = (_a = projectData.projectIdentifiers) === null || _a === void 0 ? void 0 : _a["windows"]) !== null && _b !== void 0 ? _b : projectData.projectId;
|
|
139
|
+
const projectDir = path.join(projectRoot, name);
|
|
140
|
+
const clearReadOnlyRecursive = (dir) => {
|
|
141
|
+
try {
|
|
142
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
143
|
+
for (const entry of entries) {
|
|
144
|
+
const fullPath = path.join(dir, entry.name);
|
|
145
|
+
fs.chmodSync(fullPath, 0o666);
|
|
146
|
+
if (entry.isDirectory()) {
|
|
147
|
+
clearReadOnlyRecursive(fullPath);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
fs.chmodSync(dir, 0o666);
|
|
151
|
+
}
|
|
152
|
+
catch (e) {
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
if (process.platform === "win32" && this.$fs.exists(projectDir)) {
|
|
156
|
+
clearReadOnlyRecursive(projectDir);
|
|
157
|
+
}
|
|
158
|
+
const renameWithRetry = async (from, to) => {
|
|
159
|
+
let retries = 30;
|
|
160
|
+
while (retries > 0) {
|
|
161
|
+
try {
|
|
162
|
+
fs.renameSync(from, to);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
catch (err) {
|
|
166
|
+
if ((err.code === "EPERM" || err.code === "EBUSY") && retries > 1) {
|
|
167
|
+
retries--;
|
|
168
|
+
console.warn(`Rename failed, retrying... (${retries} retries left): ${err.message}`);
|
|
169
|
+
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
throw err;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
if (!this.$fs.exists(projectDir)) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const csprojPlaceholder = path.join(projectDir, `${placeholder}.csproj`);
|
|
181
|
+
const csprojDest = path.join(projectDir, `${name}.csproj`);
|
|
182
|
+
if (this.$fs.exists(csprojPlaceholder)) {
|
|
183
|
+
await renameWithRetry(csprojPlaceholder, csprojDest);
|
|
184
|
+
}
|
|
185
|
+
this._replaceInFiles(projectDir, placeholder, name);
|
|
186
|
+
if (appId) {
|
|
187
|
+
this._replaceInFiles(projectDir, "__APP_IDENTIFIER__", appId);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
_replaceInFiles(dir, from, to) {
|
|
191
|
+
const textExtensions = new Set([
|
|
192
|
+
".cs",
|
|
193
|
+
".csproj",
|
|
194
|
+
".xaml",
|
|
195
|
+
".xml",
|
|
196
|
+
".json",
|
|
197
|
+
".appxmanifest",
|
|
198
|
+
]);
|
|
199
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
200
|
+
for (const entry of entries) {
|
|
201
|
+
const fullPath = path.join(dir, entry.name);
|
|
202
|
+
if (entry.isDirectory()) {
|
|
203
|
+
this._replaceInFiles(fullPath, from, to);
|
|
204
|
+
}
|
|
205
|
+
else if (textExtensions.has(path.extname(entry.name).toLowerCase())) {
|
|
206
|
+
const content = fs.readFileSync(fullPath, "utf8");
|
|
207
|
+
if (content.includes(from)) {
|
|
208
|
+
fs.writeFileSync(fullPath, content.split(from).join(to), "utf8");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
interpolateConfigurationFile(projectData) {
|
|
214
|
+
var _a, _b;
|
|
215
|
+
const platformData = this.getPlatformData(projectData);
|
|
216
|
+
const manifestPath = path.join(platformData.projectRoot, projectData.projectName, "Package.appxmanifest");
|
|
217
|
+
if (!this.$fs.exists(manifestPath)) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
let content = fs.readFileSync(manifestPath, "utf8");
|
|
221
|
+
const appId = (_b = (_a = projectData.projectIdentifiers) === null || _a === void 0 ? void 0 : _a["windows"]) !== null && _b !== void 0 ? _b : projectData.projectId;
|
|
222
|
+
if (appId) {
|
|
223
|
+
content = content.split("__APP_IDENTIFIER__").join(appId);
|
|
224
|
+
}
|
|
225
|
+
content = content.split("__PROJECT_NAME__").join(projectData.projectName);
|
|
226
|
+
this.$fs.writeFile(manifestPath, content);
|
|
227
|
+
}
|
|
228
|
+
afterCreateProject(_projectRoot, _projectData) {
|
|
229
|
+
}
|
|
230
|
+
async buildProject(projectRoot, projectData, buildConfig) {
|
|
231
|
+
var _a, _b, _c, _d;
|
|
232
|
+
const isRelease = !!(buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.release);
|
|
233
|
+
const config = isRelease ? constants_1.Configurations.Release : constants_1.Configurations.Debug;
|
|
234
|
+
const arch = (_b = (_a = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.architectures) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : "x64";
|
|
235
|
+
const csproj = path.join(projectRoot, projectData.projectName, `${projectData.projectName}.csproj`);
|
|
236
|
+
const outputPath = path.join(projectRoot, projectData.projectName, "bin");
|
|
237
|
+
const appPackagesDir = path.join(projectRoot, projectData.projectName, "AppPackages");
|
|
238
|
+
this.$logger.info(`Building Windows project: ${csproj} [${config}|${arch}]${isRelease ? " (release package)" : ""}`);
|
|
239
|
+
const appManifestCandidates = [];
|
|
240
|
+
appManifestCandidates.push(path.join(projectRoot, projectData.projectName, "Package.appxmanifest"));
|
|
241
|
+
const cfgAppResources = (_d = (_c = projectData === null || projectData === void 0 ? void 0 : projectData.nsConfig) === null || _c === void 0 ? void 0 : _c.appResourcesPath) !== null && _d !== void 0 ? _d : null;
|
|
242
|
+
if (cfgAppResources) {
|
|
243
|
+
const resolved = path.isAbsolute(cfgAppResources)
|
|
244
|
+
? cfgAppResources
|
|
245
|
+
: path.join(projectData.projectDir, cfgAppResources);
|
|
246
|
+
appManifestCandidates.push(path.join(resolved, "Windows", "Package.appxmanifest"));
|
|
247
|
+
appManifestCandidates.push(path.join(resolved, "windows", "Package.appxmanifest"));
|
|
248
|
+
}
|
|
249
|
+
appManifestCandidates.push(path.join(projectData.projectDir, "App_Resources", "Windows", "Package.appxmanifest"));
|
|
250
|
+
appManifestCandidates.push(path.join(projectData.projectDir, "App_Resources", "windows", "Package.appxmanifest"));
|
|
251
|
+
appManifestCandidates.push(path.join(projectData.projectDir, "app", "App_Resources", "Windows", "Package.appxmanifest"));
|
|
252
|
+
appManifestCandidates.push(path.join(projectData.projectDir, "app", "App_Resources", "windows", "Package.appxmanifest"));
|
|
253
|
+
let appResourcesManifestArg = null;
|
|
254
|
+
for (const candidate of appManifestCandidates) {
|
|
255
|
+
if (this.$fs.exists(candidate)) {
|
|
256
|
+
appResourcesManifestArg = `-p:AppResourcesManifestPath=\"${candidate}\"`;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
const dotnetArgs = ["build", csproj, "-c", config, `-p:Platform=${arch}`];
|
|
261
|
+
if (isRelease) {
|
|
262
|
+
const storeUpload = !!(buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.storeUpload);
|
|
263
|
+
const bundle = !!(buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.msixBundle) || storeUpload;
|
|
264
|
+
const certificate = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.certificate;
|
|
265
|
+
const certificatePassword = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.certificatePassword;
|
|
266
|
+
const certificateThumbprint = buildConfig === null || buildConfig === void 0 ? void 0 : buildConfig.certificateThumbprint;
|
|
267
|
+
dotnetArgs.push("-p:GenerateAppxPackageOnBuild=true", `-p:AppxPackageDir=${appPackagesDir}${path.sep}`, `-p:UapAppxPackageBuildMode=${storeUpload ? "StoreUpload" : "SideloadOnly"}`, `-p:AppxBundle=${bundle ? "Always" : "Never"}`);
|
|
268
|
+
if (bundle) {
|
|
269
|
+
dotnetArgs.push(`-p:AppxBundlePlatforms=${arch}`);
|
|
270
|
+
}
|
|
271
|
+
if (storeUpload) {
|
|
272
|
+
dotnetArgs.push("-p:AppxPackageSigningEnabled=false");
|
|
273
|
+
}
|
|
274
|
+
else if (certificateThumbprint) {
|
|
275
|
+
dotnetArgs.push("-p:AppxPackageSigningEnabled=true", `-p:PackageCertificateThumbprint=${certificateThumbprint}`);
|
|
276
|
+
}
|
|
277
|
+
else if (certificate) {
|
|
278
|
+
const certPath = path.isAbsolute(certificate)
|
|
279
|
+
? certificate
|
|
280
|
+
: path.join(projectData.projectDir, certificate);
|
|
281
|
+
dotnetArgs.push("-p:AppxPackageSigningEnabled=true", `-p:PackageCertificateKeyFile=\"${certPath}\"`);
|
|
282
|
+
if (certificatePassword) {
|
|
283
|
+
dotnetArgs.push(`-p:PackageCertificatePassword=${certificatePassword}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
dotnetArgs.push("-p:AppxPackageSigningEnabled=false");
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
dotnetArgs.push("--output", outputPath);
|
|
292
|
+
}
|
|
293
|
+
if (appResourcesManifestArg) {
|
|
294
|
+
dotnetArgs.push(appResourcesManifestArg);
|
|
295
|
+
}
|
|
296
|
+
const result = await this.$childProcess.spawnFromEvent("dotnet", dotnetArgs, "close", { cwd: path.join(projectRoot, projectData.projectName) }, { throwError: false });
|
|
297
|
+
if (result.stdout) {
|
|
298
|
+
this.$logger.info(result.stdout);
|
|
299
|
+
}
|
|
300
|
+
if (result.exitCode !== 0) {
|
|
301
|
+
throw new Error(`dotnet build failed (exit ${result.exitCode}):\n${result.stdout || result.stderr}`);
|
|
302
|
+
}
|
|
303
|
+
const manifestSrc = path.join(projectRoot, projectData.projectName, "Package.appxmanifest");
|
|
304
|
+
const manifestDest = path.join(outputPath, "AppxManifest.xml");
|
|
305
|
+
if (!isRelease && this.$fs.exists(manifestSrc)) {
|
|
306
|
+
const raw = fs.readFileSync(manifestSrc, "utf8");
|
|
307
|
+
const expanded = raw.split("$targetnametoken$").join(projectData.projectName);
|
|
308
|
+
fs.writeFileSync(manifestDest, expanded, "utf8");
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
async prepareProject(_projectData, _prepareData) {
|
|
312
|
+
var _a, _b, _c, _d;
|
|
313
|
+
const projectData = _projectData;
|
|
314
|
+
const pluginsService = yok_1.injector.resolve("pluginsService");
|
|
315
|
+
const platformData = this.getPlatformData(projectData);
|
|
316
|
+
const appProjectDir = path.join(platformData.projectRoot, projectData.projectName);
|
|
317
|
+
try {
|
|
318
|
+
const marker = path.join(appProjectDir, "dotnet-bridge", "publish", ".dotnet_tool_done");
|
|
319
|
+
if (fs.existsSync(marker)) {
|
|
320
|
+
this.$logger.info("DotNetBridge publish marker found; skipping dotnet-tool");
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
const arch = process.arch === "arm64" ? "arm64" : "x64";
|
|
324
|
+
const exeCandidates = [
|
|
325
|
+
process.env.DOTNET_TOOL_PATH,
|
|
326
|
+
path.join(platformData.projectRoot, "tools", `dotnet-tool-${arch}.exe`),
|
|
327
|
+
path.join(platformData.projectRoot, "tools", "dotnet-tool.exe"),
|
|
328
|
+
].filter(Boolean);
|
|
329
|
+
let exePath = null;
|
|
330
|
+
for (const p of exeCandidates) {
|
|
331
|
+
if (p && fs.existsSync(p)) {
|
|
332
|
+
exePath = p;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (exePath) {
|
|
337
|
+
this.$logger.info(`Running dotnet-tool: ${exePath}`);
|
|
338
|
+
try {
|
|
339
|
+
const result = await this.$childProcess.spawnFromEvent(exePath, ["--app-root", platformData.projectRoot, "--dir", "app", "--force"], "close", { cwd: platformData.projectRoot }, { throwError: false });
|
|
340
|
+
if (result && result.stdout) {
|
|
341
|
+
this.$logger.info(result.stdout);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
catch (err) {
|
|
345
|
+
this.$logger.warn(`dotnet-tool execution failed: ${err}`);
|
|
346
|
+
}
|
|
347
|
+
try {
|
|
348
|
+
const markerPath = path.join(appProjectDir, "dotnet-bridge", "publish", ".dotnet_tool_done");
|
|
349
|
+
if (!fs.existsSync(markerPath)) {
|
|
350
|
+
const publishDir = path.join(appProjectDir, "dotnet-bridge", "publish");
|
|
351
|
+
if (fs.existsSync(publishDir)) {
|
|
352
|
+
const files = fs.readdirSync(publishDir);
|
|
353
|
+
if (files && files.length > 0) {
|
|
354
|
+
const bridgeDll = path.join(publishDir, "DotNetBridge.dll");
|
|
355
|
+
if (fs.existsSync(bridgeDll)) {
|
|
356
|
+
try {
|
|
357
|
+
fs.writeFileSync(markerPath, "done", "utf8");
|
|
358
|
+
this.$logger.info(`Created dotnet-tool marker at ${markerPath}`);
|
|
359
|
+
}
|
|
360
|
+
catch (werr) {
|
|
361
|
+
this.$logger.warn(`Failed creating dotnet-tool marker: ${werr}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
else {
|
|
365
|
+
this.$logger.info(`[NativeScript] publish directory exists but DotNetBridge.dll missing; files=${files.join(',')}`);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
this.$logger.info(`[NativeScript] publish directory not found at ${publishDir}`);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
catch (e) {
|
|
375
|
+
this.$logger.warn(`dotnet-tool sentinel check failed: ${e}`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
catch (err) {
|
|
381
|
+
this.$logger.warn(`dotnet-tool check failed: ${err}`);
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
const isRelease = !!(_prepareData === null || _prepareData === void 0 ? void 0 : _prepareData.release);
|
|
385
|
+
const wantsSourceProtect = (_d = (_a = this.$options.sourceProtect) !== null && _a !== void 0 ? _a : (_c = (_b = projectData === null || projectData === void 0 ? void 0 : projectData.nsConfig) === null || _b === void 0 ? void 0 : _b.windows) === null || _c === void 0 ? void 0 : _c.sourceProtect) !== null && _d !== void 0 ? _d : false;
|
|
386
|
+
const bundlePath = path.join(appProjectDir, "app.nsbundle");
|
|
387
|
+
if (!(isRelease && wantsSourceProtect) && fs.existsSync(bundlePath)) {
|
|
388
|
+
fs.unlinkSync(bundlePath);
|
|
389
|
+
this.$logger.info("Removed stale app.nsbundle from a previous source-protected build.");
|
|
390
|
+
}
|
|
391
|
+
if (isRelease && wantsSourceProtect) {
|
|
392
|
+
const arch = process.arch === "arm64" ? "arm64" : "x64";
|
|
393
|
+
const packCandidates = [
|
|
394
|
+
process.env.NSBUNDLE_PACK_PATH,
|
|
395
|
+
path.join(platformData.projectRoot, "tools", `nsbundle_pack-${arch}.exe`),
|
|
396
|
+
path.join(platformData.projectRoot, "tools", "nsbundle_pack.exe"),
|
|
397
|
+
].filter(Boolean);
|
|
398
|
+
let packExe = null;
|
|
399
|
+
for (const p of packCandidates) {
|
|
400
|
+
if (p && fs.existsSync(p)) {
|
|
401
|
+
packExe = p;
|
|
402
|
+
break;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
if (packExe) {
|
|
406
|
+
const keyHex = this.$options.sourceProtectKeyHex ||
|
|
407
|
+
process.env.NS_WINDOWS_BUNDLE_KEY;
|
|
408
|
+
const args = [
|
|
409
|
+
"--input", path.join(appProjectDir, "app"),
|
|
410
|
+
"--output", path.join(appProjectDir, "app.nsbundle"),
|
|
411
|
+
];
|
|
412
|
+
if (keyHex) {
|
|
413
|
+
args.push("--key-hex", keyHex);
|
|
414
|
+
}
|
|
415
|
+
this.$logger.info(`Running nsbundle_pack (source protection): ${packExe}`);
|
|
416
|
+
try {
|
|
417
|
+
const result = await this.$childProcess.spawnFromEvent(packExe, args, "close", { cwd: platformData.projectRoot }, { throwError: false });
|
|
418
|
+
if (result && result.stdout) {
|
|
419
|
+
this.$logger.info(result.stdout);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
catch (err) {
|
|
423
|
+
this.$logger.warn(`nsbundle_pack execution failed: ${err}`);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
this.$logger.info("Source protection requested but nsbundle_pack.exe was not found under tools/, skipping (plaintext app/ will be packaged).");
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
catch (err) {
|
|
432
|
+
this.$logger.warn(`Source protection check failed: ${err}`);
|
|
433
|
+
}
|
|
434
|
+
const pluginsDir = path.join(appProjectDir, "plugins");
|
|
435
|
+
if (!this.$fs.exists(pluginsDir)) {
|
|
436
|
+
this.$fs.ensureDirectoryExists(pluginsDir);
|
|
437
|
+
}
|
|
438
|
+
const installedPlugins = await pluginsService.getAllInstalledPlugins(projectData);
|
|
439
|
+
const manifest = {};
|
|
440
|
+
const stagedPlugins = [];
|
|
441
|
+
for (const pluginData of installedPlugins) {
|
|
442
|
+
try {
|
|
443
|
+
await this.preparePluginNativeCode(pluginData, projectData);
|
|
444
|
+
stagedPlugins.push({ name: pluginData.name });
|
|
445
|
+
const stagedPath = path.join(pluginsDir, pluginData.name);
|
|
446
|
+
const collect = (root) => {
|
|
447
|
+
const out = [];
|
|
448
|
+
if (!this.$fs.exists(root))
|
|
449
|
+
return out;
|
|
450
|
+
const walk = (dir) => {
|
|
451
|
+
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
452
|
+
const full = path.join(dir, e.name);
|
|
453
|
+
if (e.isDirectory())
|
|
454
|
+
walk(full);
|
|
455
|
+
else
|
|
456
|
+
out.push(path.relative(root, full).split(path.sep).join("\\"));
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
walk(root);
|
|
460
|
+
return out;
|
|
461
|
+
};
|
|
462
|
+
const stagedFiles = collect(stagedPath);
|
|
463
|
+
manifest[pluginData.name] = {
|
|
464
|
+
stagedFiles,
|
|
465
|
+
package: pluginData.nativescript || null,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
this.$logger.warn(`Failed to stage native files for plugin ${pluginData.name}: ${err}`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const aggregatePropsPath = path.join(pluginsDir, "Plugins.props");
|
|
473
|
+
const aggregateTargetsPath = path.join(pluginsDir, "Plugins.targets");
|
|
474
|
+
const propsLines = [
|
|
475
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
476
|
+
"<Project>",
|
|
477
|
+
];
|
|
478
|
+
const targetsLines = [
|
|
479
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
480
|
+
"<Project>",
|
|
481
|
+
];
|
|
482
|
+
for (const p of stagedPlugins) {
|
|
483
|
+
const pluginRelDir = p.name.split("/").join("\\");
|
|
484
|
+
const importPathProps = `$(MSBuildThisFileDirectory)${pluginRelDir}\\plugin.props`;
|
|
485
|
+
const importPathTargets = `$(MSBuildThisFileDirectory)${pluginRelDir}\\plugin.targets`;
|
|
486
|
+
propsLines.push(` <Import Project="${importPathProps}" Condition="Exists('${importPathProps}')" />`);
|
|
487
|
+
targetsLines.push(` <Import Project="${importPathTargets}" Condition="Exists('${importPathTargets}')" />`);
|
|
488
|
+
}
|
|
489
|
+
propsLines.push("</Project>");
|
|
490
|
+
targetsLines.push("</Project>");
|
|
491
|
+
this.$fs.writeFile(aggregatePropsPath, propsLines.join("\n"));
|
|
492
|
+
this.$fs.writeFile(aggregateTargetsPath, targetsLines.join("\n"));
|
|
493
|
+
const installedJsonPath = path.join(pluginsDir, "installed.json");
|
|
494
|
+
this.$fs.writeJson(installedJsonPath, manifest);
|
|
495
|
+
}
|
|
496
|
+
async checkForChanges(_changesInfo, _prepareData, _projectData) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
prepareAppResources(projectData) {
|
|
500
|
+
var _a, _b;
|
|
501
|
+
const projectRoot = projectData.projectDir;
|
|
502
|
+
const candidates = [];
|
|
503
|
+
const cfgAppResources = projectData && projectData.nsConfig && projectData.nsConfig.appResourcesPath ? projectData.nsConfig.appResourcesPath : null;
|
|
504
|
+
if (cfgAppResources) {
|
|
505
|
+
const resolved = path.isAbsolute(cfgAppResources)
|
|
506
|
+
? cfgAppResources
|
|
507
|
+
: path.join(projectData.projectDir, cfgAppResources);
|
|
508
|
+
candidates.push(path.join(resolved, "Windows"));
|
|
509
|
+
candidates.push(path.join(resolved, "windows"));
|
|
510
|
+
}
|
|
511
|
+
candidates.push(path.join(projectRoot, "App_Resources", "Windows"));
|
|
512
|
+
candidates.push(path.join(projectRoot, "App_Resources", "windows"));
|
|
513
|
+
candidates.push(path.join(projectRoot, "app", "App_Resources", "Windows"));
|
|
514
|
+
candidates.push(path.join(projectRoot, "app", "App_Resources", "windows"));
|
|
515
|
+
let srcRoot = null;
|
|
516
|
+
for (const c of candidates) {
|
|
517
|
+
if (this.$fs.exists(c)) {
|
|
518
|
+
srcRoot = c;
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (!srcRoot)
|
|
523
|
+
return;
|
|
524
|
+
const platformData = this.getPlatformData(projectData);
|
|
525
|
+
const platformAppDir = path.join(platformData.projectRoot, projectData.projectName);
|
|
526
|
+
const destAppResourcesWindows = path.join(platformAppDir, "App_Resources", "Windows");
|
|
527
|
+
this.$fs.ensureDirectoryExists(destAppResourcesWindows);
|
|
528
|
+
const copyRecursive = (srcDir, destDir) => {
|
|
529
|
+
const entries = fs.readdirSync(srcDir, { withFileTypes: true });
|
|
530
|
+
for (const e of entries) {
|
|
531
|
+
const srcPath = path.join(srcDir, e.name);
|
|
532
|
+
const destPath = path.join(destDir, e.name);
|
|
533
|
+
if (e.isDirectory()) {
|
|
534
|
+
this.$fs.ensureDirectoryExists(destPath);
|
|
535
|
+
copyRecursive(srcPath, destPath);
|
|
536
|
+
}
|
|
537
|
+
else if (e.isFile()) {
|
|
538
|
+
this.$fs.copyFile(srcPath, destPath);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
copyRecursive(srcRoot, destAppResourcesWindows);
|
|
543
|
+
const srcAssets = path.join(srcRoot, "Assets");
|
|
544
|
+
if (this.$fs.exists(srcAssets)) {
|
|
545
|
+
const destAssets = path.join(platformAppDir, "Assets");
|
|
546
|
+
this.$fs.ensureDirectoryExists(destAssets);
|
|
547
|
+
copyRecursive(srcAssets, destAssets);
|
|
548
|
+
}
|
|
549
|
+
const manifestInSrc = path.join(srcRoot, "Package.appxmanifest");
|
|
550
|
+
if (this.$fs.exists(manifestInSrc)) {
|
|
551
|
+
const destManifest = path.join(platformAppDir, "Package.appxmanifest");
|
|
552
|
+
let manifestContent = fs.readFileSync(manifestInSrc, "utf8");
|
|
553
|
+
const windowsCfg = (_b = (_a = projectData === null || projectData === void 0 ? void 0 : projectData.nsConfig) === null || _a === void 0 ? void 0 : _a.windows) !== null && _b !== void 0 ? _b : null;
|
|
554
|
+
const phoneProductIdArg = (this.$options && this.$options.phoneProductId) || (windowsCfg && (windowsCfg.PhoneProductId || windowsCfg.phoneProductId)) || null;
|
|
555
|
+
const phonePublisherIdArg = (this.$options && this.$options.phonePublisherId) || (windowsCfg && (windowsCfg.PhonePublisherId || windowsCfg.phonePublisherId)) || null;
|
|
556
|
+
const regenGuid = !!(this.$options && this.$options.regenGuid);
|
|
557
|
+
const noAutoGuid = !!(this.$options && this.$options.noAutoGuid);
|
|
558
|
+
const allowZeroGuid = !!(this.$options && this.$options.allowZeroGuid);
|
|
559
|
+
const zeroGuid = "00000000-0000-0000-0000-000000000000";
|
|
560
|
+
let modified = manifestContent;
|
|
561
|
+
const phoneIdentityRegex = /<mp:PhoneIdentity\b([^>]*)\/>/i;
|
|
562
|
+
if (phoneIdentityRegex.test(modified)) {
|
|
563
|
+
if (phoneProductIdArg) {
|
|
564
|
+
if (/(PhoneProductId\s*=\s*")[^"]*(")/i.test(modified)) {
|
|
565
|
+
modified = modified.replace(/(PhoneProductId\s*=\s*")([^\"]*)(\")/i, `$1${phoneProductIdArg}$3`);
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
modified = modified.replace(phoneIdentityRegex, `<mp:PhoneIdentity$1 PhoneProductId="${phoneProductIdArg}" />`);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
const prodMatch = modified.match(/PhoneProductId\s*=\s*"([^\"]*)"/i);
|
|
573
|
+
const prodValue = prodMatch ? prodMatch[1] : null;
|
|
574
|
+
const prodIsZero = prodValue === zeroGuid;
|
|
575
|
+
let appIdentifier = projectData && projectData.projectIdentifiers && projectData.projectIdentifiers["windows"] ? projectData.projectIdentifiers["windows"] : projectData.projectId;
|
|
576
|
+
if (!appIdentifier) {
|
|
577
|
+
try {
|
|
578
|
+
const cfgCandidates = [
|
|
579
|
+
path.join(projectData.projectDir, "nativescript.config.ts"),
|
|
580
|
+
path.join(projectData.projectDir, "nativescript.config.js"),
|
|
581
|
+
path.join(projectData.projectDir, "app", "nativescript.config.ts"),
|
|
582
|
+
path.join(projectData.projectDir, "app", "nativescript.config.js"),
|
|
583
|
+
];
|
|
584
|
+
for (const c of cfgCandidates) {
|
|
585
|
+
if (this.$fs.exists(c)) {
|
|
586
|
+
try {
|
|
587
|
+
const raw = fs.readFileSync(c, "utf8");
|
|
588
|
+
const m = raw.match(/id\s*:\s*['\"]([^'\"]+)['\"]/i);
|
|
589
|
+
if (m && m[1]) {
|
|
590
|
+
appIdentifier = m[1];
|
|
591
|
+
break;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
catch (e) { }
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
catch (e) { }
|
|
599
|
+
}
|
|
600
|
+
if (allowZeroGuid) {
|
|
601
|
+
if (prodMatch) {
|
|
602
|
+
modified = modified.replace(/(PhoneProductId\s*=\s*")([^\"]*)(\")/i, `$1${zeroGuid}$3`);
|
|
603
|
+
}
|
|
604
|
+
else {
|
|
605
|
+
modified = modified.replace(phoneIdentityRegex, `<mp:PhoneIdentity$1 PhoneProductId="${zeroGuid}" />`);
|
|
606
|
+
}
|
|
607
|
+
if (this.$logger && typeof (this.$logger.warn) === "function") {
|
|
608
|
+
this.$logger.warn("Using zero PhoneProductId because --allow-zero-guid was provided.");
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
else if (regenGuid) {
|
|
612
|
+
const newGuid = generateGuid();
|
|
613
|
+
if (prodMatch) {
|
|
614
|
+
modified = modified.replace(/(PhoneProductId\s*=\s*")([^\"]*)(\")/i, `$1${newGuid}$3`);
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
modified = modified.replace(phoneIdentityRegex, `<mp:PhoneIdentity$1 PhoneProductId="${newGuid}" />`);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
else if (!prodValue || !isGuid(prodValue) || prodIsZero) {
|
|
621
|
+
if (!noAutoGuid) {
|
|
622
|
+
let newGuid;
|
|
623
|
+
if (appIdentifier) {
|
|
624
|
+
newGuid = generateDeterministicGuidFromString(appIdentifier);
|
|
625
|
+
}
|
|
626
|
+
else {
|
|
627
|
+
newGuid = generateGuid();
|
|
628
|
+
}
|
|
629
|
+
if (prodMatch) {
|
|
630
|
+
modified = modified.replace(/(PhoneProductId\s*=\s*")([^\"]*)(\")/i, `$1${newGuid}$3`);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
modified = modified.replace(phoneIdentityRegex, `<mp:PhoneIdentity$1 PhoneProductId="${newGuid}" />`);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (phonePublisherIdArg) {
|
|
639
|
+
if (/(PhonePublisherId\s*=\s*")[^"]*(")/i.test(modified)) {
|
|
640
|
+
modified = modified.replace(/(PhonePublisherId\s*=\s*")([^\"]*)(\")/i, `$1${phonePublisherIdArg}$3`);
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
modified = modified.replace(phoneIdentityRegex, `<mp:PhoneIdentity$1 PhonePublisherId="${phonePublisherIdArg}" />`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
if (noAutoGuid && !phoneProductIdArg && !phonePublisherIdArg && !allowZeroGuid) {
|
|
649
|
+
fs.writeFileSync(destManifest, manifestContent, "utf8");
|
|
650
|
+
this.interpolateConfigurationFile(projectData);
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
const appIdentifier = projectData && projectData.projectIdentifiers && projectData.projectIdentifiers["windows"] ? projectData.projectIdentifiers["windows"] : projectData.projectId;
|
|
654
|
+
const chosenProd = phoneProductIdArg || (allowZeroGuid ? zeroGuid : (noAutoGuid ? null : (appIdentifier ? generateDeterministicGuidFromString(appIdentifier) : generateGuid())));
|
|
655
|
+
const chosenPub = phonePublisherIdArg || "00000000-0000-0000-0000-000000000000";
|
|
656
|
+
if (chosenProd) {
|
|
657
|
+
if (allowZeroGuid && !phoneProductIdArg && this.$logger && typeof (this.$logger.warn) === "function") {
|
|
658
|
+
this.$logger.warn("Using zero PhoneProductId because --allow-zero-guid was provided.");
|
|
659
|
+
}
|
|
660
|
+
const identityTag = ` <mp:PhoneIdentity PhoneProductId="${chosenProd}" PhonePublisherId="${chosenPub}" />\n\n`;
|
|
661
|
+
modified = manifestContent.replace(/<\/Package>/i, `${identityTag}</Package>`);
|
|
662
|
+
}
|
|
663
|
+
else if (phonePublisherIdArg) {
|
|
664
|
+
const identityTag = ` <mp:PhoneIdentity PhonePublisherId="${phonePublisherIdArg}" />\n\n`;
|
|
665
|
+
modified = manifestContent.replace(/<\/Package>/i, `${identityTag}</Package>`);
|
|
666
|
+
}
|
|
667
|
+
else {
|
|
668
|
+
fs.writeFileSync(destManifest, manifestContent, "utf8");
|
|
669
|
+
this.interpolateConfigurationFile(projectData);
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
try {
|
|
674
|
+
const identityRegex = /<Identity\b([^>]*)\/>/i;
|
|
675
|
+
const idMatch = modified.match(identityRegex);
|
|
676
|
+
if (idMatch) {
|
|
677
|
+
const attrs = idMatch[1] || "";
|
|
678
|
+
let newAttrs = attrs;
|
|
679
|
+
if (!/Name\s*=\s*\"/i.test(attrs)) {
|
|
680
|
+
newAttrs = ` Name="${projectData.projectId}"` + newAttrs;
|
|
681
|
+
}
|
|
682
|
+
if (!/Publisher\s*=\s*\"/i.test(attrs)) {
|
|
683
|
+
const publisherVal = phonePublisherIdArg && typeof phonePublisherIdArg === "string" ? phonePublisherIdArg : "CN=ui";
|
|
684
|
+
newAttrs = newAttrs + ` Publisher="${publisherVal}"`;
|
|
685
|
+
}
|
|
686
|
+
modified = modified.replace(identityRegex, `<Identity${newAttrs} />`);
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
catch (e) {
|
|
690
|
+
}
|
|
691
|
+
try {
|
|
692
|
+
const propsRegex = /<Properties\b[^>]*>([\s\S]*?)<\/Properties>/i;
|
|
693
|
+
const propsMatch = modified.match(propsRegex);
|
|
694
|
+
if (propsMatch) {
|
|
695
|
+
let inner = propsMatch[1];
|
|
696
|
+
if (!/\<DisplayName\b/i.test(inner)) {
|
|
697
|
+
inner = `\n <DisplayName>${projectData.projectName}<\/DisplayName>` + inner;
|
|
698
|
+
}
|
|
699
|
+
if (!/\<PublisherDisplayName\b/i.test(inner)) {
|
|
700
|
+
inner = `\n <PublisherDisplayName>${projectData.projectName}<\/PublisherDisplayName>` + inner;
|
|
701
|
+
}
|
|
702
|
+
modified = modified.replace(propsRegex, `<Properties>${inner}\n <\/Properties>`);
|
|
703
|
+
}
|
|
704
|
+
else {
|
|
705
|
+
const propsTag = ` <Properties>\n <DisplayName>${projectData.projectName}<\/DisplayName>\n <PublisherDisplayName>${projectData.projectName}<\/PublisherDisplayName>\n <Logo>Assets\\StoreLogo.png<\/Logo>\n <\/Properties>\n\n`;
|
|
706
|
+
if (/\<Dependencies\s*\>/i.test(modified)) {
|
|
707
|
+
modified = modified.replace(/\<Dependencies\s*\>/i, `${propsTag}<Dependencies>`);
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
710
|
+
modified = modified.replace(/<\/Identity>/i, `</Identity>\n\n${propsTag}`);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
catch (e) {
|
|
715
|
+
}
|
|
716
|
+
try {
|
|
717
|
+
const appRegex = /<Application\b([^>]*)>/i;
|
|
718
|
+
const appMatch = modified.match(appRegex);
|
|
719
|
+
if (appMatch) {
|
|
720
|
+
const attrs = appMatch[1] || "";
|
|
721
|
+
let newAttrs = attrs;
|
|
722
|
+
if (!/\bId\s*=\s*\"/i.test(attrs)) {
|
|
723
|
+
newAttrs = ` Id=\"App\"` + newAttrs;
|
|
724
|
+
}
|
|
725
|
+
if (!/\bExecutable\s*=\s*\"/i.test(attrs)) {
|
|
726
|
+
newAttrs = newAttrs + ` Executable=\"$targetnametoken$.exe\"`;
|
|
727
|
+
}
|
|
728
|
+
if (!/\bEntryPoint\s*=\s*\"/i.test(attrs)) {
|
|
729
|
+
newAttrs = newAttrs + ` EntryPoint=\"${projectData.projectName}.App\"`;
|
|
730
|
+
}
|
|
731
|
+
modified = modified.replace(appRegex, `<Application${newAttrs}>`);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
catch (e) {
|
|
735
|
+
}
|
|
736
|
+
try {
|
|
737
|
+
const visRegex = /<uap:VisualElements\b([^>]*)>/i;
|
|
738
|
+
const visMatch = modified.match(visRegex);
|
|
739
|
+
if (visMatch) {
|
|
740
|
+
const visAttrs = visMatch[1] || "";
|
|
741
|
+
if (!/\bDisplayName\s*=\s*\"/i.test(visAttrs)) {
|
|
742
|
+
const newVisAttrs = ` DisplayName=\"${projectData.projectName}\"` + visAttrs;
|
|
743
|
+
modified = modified.replace(visRegex, `<uap:VisualElements${newVisAttrs}>`);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
catch (e) {
|
|
748
|
+
}
|
|
749
|
+
fs.writeFileSync(destManifest, modified, "utf8");
|
|
750
|
+
this.interpolateConfigurationFile(projectData);
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
isPlatformPrepared(projectRoot, projectData) {
|
|
754
|
+
return this.$fs.exists(path.join(projectRoot, projectData.projectName));
|
|
755
|
+
}
|
|
756
|
+
async preparePluginNativeCode(pluginData, projectData) {
|
|
757
|
+
const platformFolder = path.join(pluginData.fullPath, "platforms", "windows");
|
|
758
|
+
const fallbackFolder = path.join(pluginData.fullPath, "windows");
|
|
759
|
+
const sourcesFolder = this.$fs.exists(platformFolder)
|
|
760
|
+
? platformFolder
|
|
761
|
+
: this.$fs.exists(fallbackFolder)
|
|
762
|
+
? fallbackFolder
|
|
763
|
+
: null;
|
|
764
|
+
if (!sourcesFolder) {
|
|
765
|
+
return;
|
|
766
|
+
}
|
|
767
|
+
if (!projectData) {
|
|
768
|
+
return;
|
|
769
|
+
}
|
|
770
|
+
const platformData = this.getPlatformData(projectData);
|
|
771
|
+
const appProjectDir = path.join(platformData.projectRoot, projectData.projectName);
|
|
772
|
+
const pluginStageDir = path.join(appProjectDir, "plugins", pluginData.name);
|
|
773
|
+
this.$fs.ensureDirectoryExists(pluginStageDir);
|
|
774
|
+
const walk = (dir) => {
|
|
775
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
776
|
+
for (const e of entries) {
|
|
777
|
+
const src = path.join(dir, e.name);
|
|
778
|
+
const rel = path.relative(sourcesFolder, src);
|
|
779
|
+
const dest = path.join(pluginStageDir, rel);
|
|
780
|
+
if (e.isDirectory()) {
|
|
781
|
+
this.$fs.ensureDirectoryExists(dest);
|
|
782
|
+
walk(src);
|
|
783
|
+
}
|
|
784
|
+
else if (e.isFile()) {
|
|
785
|
+
const ext = path.extname(e.name).toLowerCase();
|
|
786
|
+
if (ext === ".js" ||
|
|
787
|
+
ext === ".ts" ||
|
|
788
|
+
ext === ".json" ||
|
|
789
|
+
ext === ".map" ||
|
|
790
|
+
ext === ".md")
|
|
791
|
+
continue;
|
|
792
|
+
this.$fs.ensureDirectoryExists(path.dirname(dest));
|
|
793
|
+
fs.copyFileSync(src, dest);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
walk(sourcesFolder);
|
|
798
|
+
const providedProps = path.join(pluginData.fullPath, "plugin.props");
|
|
799
|
+
const providedTargets = path.join(pluginData.fullPath, "plugin.targets");
|
|
800
|
+
if (this.$fs.exists(providedProps)) {
|
|
801
|
+
this.$fs.copyFile(providedProps, path.join(pluginStageDir, "plugin.props"));
|
|
802
|
+
}
|
|
803
|
+
if (this.$fs.exists(providedTargets)) {
|
|
804
|
+
this.$fs.copyFile(providedTargets, path.join(pluginStageDir, "plugin.targets"));
|
|
805
|
+
}
|
|
806
|
+
const collectStagedFiles = (root) => {
|
|
807
|
+
const out = [];
|
|
808
|
+
if (!this.$fs.exists(root))
|
|
809
|
+
return out;
|
|
810
|
+
const walk = (dir) => {
|
|
811
|
+
for (const e of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
812
|
+
const full = path.join(dir, e.name);
|
|
813
|
+
if (e.isDirectory())
|
|
814
|
+
walk(full);
|
|
815
|
+
else
|
|
816
|
+
out.push(path.relative(root, full).split(path.sep).join("\\"));
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
walk(root);
|
|
820
|
+
return out;
|
|
821
|
+
};
|
|
822
|
+
if (!this.$fs.exists(path.join(pluginStageDir, "plugin.props"))) {
|
|
823
|
+
const stagedFiles = collectStagedFiles(pluginStageDir);
|
|
824
|
+
const lines = [
|
|
825
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
826
|
+
"<Project>",
|
|
827
|
+
" <ItemGroup>",
|
|
828
|
+
];
|
|
829
|
+
for (const f of stagedFiles) {
|
|
830
|
+
const rel = f.split(path.sep).join("\\");
|
|
831
|
+
const link = `plugins\\${pluginData.name}\\${rel}`;
|
|
832
|
+
lines.push(` <Content Include="$(MSBuildThisFileDirectory)${rel}">`);
|
|
833
|
+
lines.push(` <Link>${link}</Link>`);
|
|
834
|
+
lines.push(" <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>");
|
|
835
|
+
lines.push(" </Content>");
|
|
836
|
+
}
|
|
837
|
+
lines.push(" </ItemGroup>");
|
|
838
|
+
lines.push("</Project>");
|
|
839
|
+
this.$fs.writeFile(path.join(pluginStageDir, "plugin.props"), lines.join("\n"));
|
|
840
|
+
}
|
|
841
|
+
if (!this.$fs.exists(path.join(pluginStageDir, "plugin.targets"))) {
|
|
842
|
+
const stagedFiles = collectStagedFiles(pluginStageDir);
|
|
843
|
+
if (stagedFiles.length > 0) {
|
|
844
|
+
const safeName = pluginData.name.replace(/[^a-zA-Z0-9]/g, "_");
|
|
845
|
+
const pluginOutDir = `plugins\\${pluginData.name.split("/").join("\\")}`;
|
|
846
|
+
const lines = [
|
|
847
|
+
'<?xml version="1.0" encoding="utf-8"?>',
|
|
848
|
+
"<Project>",
|
|
849
|
+
` <Target Name="CopyPlugin_${safeName}" AfterTargets="Build">`,
|
|
850
|
+
` <MakeDir Directories="$(OutDir)${pluginOutDir}" />`,
|
|
851
|
+
];
|
|
852
|
+
for (const f of stagedFiles) {
|
|
853
|
+
const rel = f.split(path.sep).join("\\");
|
|
854
|
+
lines.push(` <Copy SourceFiles="$(MSBuildThisFileDirectory)${rel}"`);
|
|
855
|
+
lines.push(` DestinationFiles="$(OutDir)${pluginOutDir}\\${rel}"`);
|
|
856
|
+
lines.push(` SkipUnchangedFiles="true" />`);
|
|
857
|
+
}
|
|
858
|
+
lines.push(" </Target>");
|
|
859
|
+
lines.push("</Project>");
|
|
860
|
+
this.$fs.writeFile(path.join(pluginStageDir, "plugin.targets"), lines.join("\n"));
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
async removePluginNativeCode(_pluginData, _projectData) {
|
|
865
|
+
}
|
|
866
|
+
async beforePrepareAllPlugins(_projectData, dependencies) {
|
|
867
|
+
return dependencies !== null && dependencies !== void 0 ? dependencies : [];
|
|
868
|
+
}
|
|
869
|
+
async handleNativeDependenciesChange(_projectData, _opts) {
|
|
870
|
+
}
|
|
871
|
+
async cleanDeviceTempFolder(_deviceIdentifier, _projectData) {
|
|
872
|
+
}
|
|
873
|
+
async processConfigurationFilesFromAppResources(_projectData, _opts) {
|
|
874
|
+
}
|
|
875
|
+
ensureConfigurationFileInAppResources(projectData) {
|
|
876
|
+
const projectRoot = projectData.projectDir;
|
|
877
|
+
const candidates = [
|
|
878
|
+
path.join(projectRoot, "App_Resources", "Windows", "Package.appxmanifest"),
|
|
879
|
+
path.join(projectRoot, "App_Resources", "windows", "Package.appxmanifest"),
|
|
880
|
+
path.join(projectRoot, "app", "App_Resources", "Windows", "Package.appxmanifest"),
|
|
881
|
+
path.join(projectRoot, "app", "App_Resources", "windows", "Package.appxmanifest"),
|
|
882
|
+
];
|
|
883
|
+
let src = null;
|
|
884
|
+
for (const c of candidates) {
|
|
885
|
+
if (this.$fs.exists(c)) {
|
|
886
|
+
src = c;
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (!src)
|
|
891
|
+
return;
|
|
892
|
+
const dest = path.join(this.getPlatformData(projectData).projectRoot, projectData.projectName, "Package.appxmanifest");
|
|
893
|
+
this.$fs.copyFile(src, dest);
|
|
894
|
+
}
|
|
895
|
+
async stopServices(_projectRoot) {
|
|
896
|
+
return { stderr: "", stdout: "", exitCode: 0 };
|
|
897
|
+
}
|
|
898
|
+
async cleanProject(projectRoot) {
|
|
899
|
+
const buildDir = path.join(projectRoot, constants.BUILD_DIR);
|
|
900
|
+
if (this.$fs.exists(buildDir)) {
|
|
901
|
+
this.$fs.deleteDirectory(buildDir);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
exports.WindowsProjectService = WindowsProjectService;
|
|
906
|
+
WindowsProjectService.WINDOWS_PLATFORM_NAME = "windows";
|
|
907
|
+
yok_1.injector.register("windowsProjectService", WindowsProjectService);
|