electron-forge-maker-innosetup 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +360 -0
- package/dist/MakerInnosetup.d.ts +63 -0
- package/dist/MakerInnosetup.js +424 -0
- package/dist/generator.d.ts +82 -0
- package/dist/generator.js +495 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +29 -0
- package/dist/parser.d.ts +83 -0
- package/dist/parser.js +494 -0
- package/dist/types.d.ts +607 -0
- package/dist/types.js +5 -0
- package/package.json +50 -0
- package/vendor/.gitkeep +2 -0
- package/vendor/innosetup/Default.isl +384 -0
- package/vendor/innosetup/ISCC.exe +0 -0
- package/vendor/innosetup/ISCmplr.dll +0 -0
- package/vendor/innosetup/ISPPBuiltins.iss +323 -0
- package/vendor/innosetup/Languages/Armenian.isl +376 -0
- package/vendor/innosetup/Languages/BrazilianPortuguese.isl +384 -0
- package/vendor/innosetup/Languages/Bulgarian.isl +382 -0
- package/vendor/innosetup/Languages/Catalan.isl +371 -0
- package/vendor/innosetup/Languages/ChineseSimplified.isl +420 -0
- package/vendor/innosetup/Languages/Corsican.isl +399 -0
- package/vendor/innosetup/Languages/Czech.isl +378 -0
- package/vendor/innosetup/Languages/Danish.isl +379 -0
- package/vendor/innosetup/Languages/Dutch.isl +359 -0
- package/vendor/innosetup/Languages/Finnish.isl +359 -0
- package/vendor/innosetup/Languages/French.isl +404 -0
- package/vendor/innosetup/Languages/German.isl +406 -0
- package/vendor/innosetup/Languages/Hebrew.isl +377 -0
- package/vendor/innosetup/Languages/Icelandic.isl +361 -0
- package/vendor/innosetup/Languages/Italian.isl +390 -0
- package/vendor/innosetup/Languages/Japanese.isl +367 -0
- package/vendor/innosetup/Languages/Norwegian.isl +378 -0
- package/vendor/innosetup/Languages/Polish.isl +377 -0
- package/vendor/innosetup/Languages/Portuguese.isl +366 -0
- package/vendor/innosetup/Languages/Russian.isl +370 -0
- package/vendor/innosetup/Languages/Slovak.isl +385 -0
- package/vendor/innosetup/Languages/Slovenian.isl +370 -0
- package/vendor/innosetup/Languages/Spanish.isl +383 -0
- package/vendor/innosetup/Languages/Turkish.isl +384 -0
- package/vendor/innosetup/Languages/Ukrainian.isl +385 -0
- package/vendor/innosetup/WizClassicImage-IS.bmp +0 -0
- package/vendor/innosetup/WizClassicImage.bmp +0 -0
- package/vendor/innosetup/WizClassicSmallImage-IS.bmp +0 -0
- package/vendor/innosetup/WizClassicSmallImage.bmp +0 -0
- package/vendor/innosetup/isbunzip.dll +0 -0
- package/vendor/innosetup/isbzip.dll +0 -0
- package/vendor/innosetup/islzma.dll +0 -0
- package/vendor/innosetup/islzma32.exe +0 -0
- package/vendor/innosetup/islzma64.exe +0 -0
- package/vendor/innosetup/isscint.dll +0 -0
- package/vendor/innosetup/isunzlib.dll +0 -0
- package/vendor/innosetup/iszlib.dll +0 -0
|
@@ -0,0 +1,424 @@
|
|
|
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 () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.InnoScriptParser = exports.InnoScriptGenerator = void 0;
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const child_process_1 = require("child_process");
|
|
46
|
+
const maker_base_1 = __importDefault(require("@electron-forge/maker-base"));
|
|
47
|
+
const generator_1 = require("./generator");
|
|
48
|
+
const parser_1 = require("./parser");
|
|
49
|
+
/**
|
|
50
|
+
* Electron Forge Maker for Innosetup
|
|
51
|
+
*/
|
|
52
|
+
class MakerInnosetup extends maker_base_1.default {
|
|
53
|
+
constructor(config = {}, platforms) {
|
|
54
|
+
super(config, platforms);
|
|
55
|
+
this.name = "innosetup";
|
|
56
|
+
this.defaultPlatforms = ["win32"];
|
|
57
|
+
this.scriptGenerator = new generator_1.InnoScriptGenerator();
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* 从 ISS 文件解析配置
|
|
61
|
+
* @param issFilePath ISS 文件路径
|
|
62
|
+
* @returns MakerInnosetupConfig 配置对象
|
|
63
|
+
*/
|
|
64
|
+
static fromIssFile(issFilePath) {
|
|
65
|
+
const config = parser_1.InnoScriptParser.parseFile(issFilePath);
|
|
66
|
+
return {
|
|
67
|
+
config: config,
|
|
68
|
+
scriptPath: issFilePath,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 从 ISS 脚本内容解析配置
|
|
73
|
+
* @param issContent ISS 脚本内容
|
|
74
|
+
* @returns MakerInnosetupConfig 配置对象
|
|
75
|
+
*/
|
|
76
|
+
static fromIssContent(issContent) {
|
|
77
|
+
const config = parser_1.InnoScriptParser.parse(issContent);
|
|
78
|
+
return {
|
|
79
|
+
config: config,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 检查是否支持当前平台
|
|
84
|
+
*/
|
|
85
|
+
isSupportedOnCurrentPlatform() {
|
|
86
|
+
return process.platform === "win32";
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 查找 Innosetup 编译器路径
|
|
90
|
+
*/
|
|
91
|
+
findInnosetupCompiler() {
|
|
92
|
+
if (this.config.innosetupPath) {
|
|
93
|
+
return this.config.innosetupPath;
|
|
94
|
+
}
|
|
95
|
+
// 1. 优先查找内置的便携版(相对于包的位置)
|
|
96
|
+
const builtinPaths = [
|
|
97
|
+
// 相对于 dist 目录
|
|
98
|
+
path.join(__dirname, "..", "vendor", "innosetup", "ISCC.exe"),
|
|
99
|
+
path.join(__dirname, "..", "vendor", "ISCC.exe"),
|
|
100
|
+
// 相对于 src 目录
|
|
101
|
+
path.join(__dirname, "..", "..", "vendor", "innosetup", "ISCC.exe"),
|
|
102
|
+
path.join(__dirname, "..", "..", "vendor", "ISCC.exe"),
|
|
103
|
+
];
|
|
104
|
+
for (const builtinPath of builtinPaths) {
|
|
105
|
+
if (fs.existsSync(builtinPath)) {
|
|
106
|
+
console.log(`Using bundled Innosetup: ${builtinPath}`);
|
|
107
|
+
return builtinPath;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// 2. 尝试从环境变量中查找
|
|
111
|
+
if (process.env.INNOSETUP_PATH &&
|
|
112
|
+
fs.existsSync(process.env.INNOSETUP_PATH)) {
|
|
113
|
+
return process.env.INNOSETUP_PATH;
|
|
114
|
+
}
|
|
115
|
+
// 3. 查找系统安装的 Innosetup
|
|
116
|
+
const systemPaths = [
|
|
117
|
+
"C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe",
|
|
118
|
+
"C:\\Program Files\\Inno Setup 6\\ISCC.exe",
|
|
119
|
+
"C:\\Program Files (x86)\\Inno Setup 5\\ISCC.exe",
|
|
120
|
+
"C:\\Program Files\\Inno Setup 5\\ISCC.exe",
|
|
121
|
+
];
|
|
122
|
+
for (const systemPath of systemPaths) {
|
|
123
|
+
if (fs.existsSync(systemPath)) {
|
|
124
|
+
return systemPath;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
throw new Error("Innosetup compiler not found. Please:\n" +
|
|
128
|
+
"1. Place Innosetup portable in vendor/innosetup/ directory, or\n" +
|
|
129
|
+
"2. Install Innosetup to system, or\n" +
|
|
130
|
+
"3. Set INNOSETUP_PATH environment variable, or\n" +
|
|
131
|
+
"4. Set innosetupPath in config.");
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 根据架构获取架构标识符
|
|
135
|
+
*/
|
|
136
|
+
getArchIdentifier(arch) {
|
|
137
|
+
switch (arch) {
|
|
138
|
+
case "x64":
|
|
139
|
+
return "x64";
|
|
140
|
+
case "ia32":
|
|
141
|
+
case "x86":
|
|
142
|
+
return "x86";
|
|
143
|
+
case "arm64":
|
|
144
|
+
return "arm64";
|
|
145
|
+
default:
|
|
146
|
+
return arch;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 根据架构获取 ArchitecturesAllowed 配置
|
|
151
|
+
*/
|
|
152
|
+
getArchitecturesAllowed(arch) {
|
|
153
|
+
switch (arch) {
|
|
154
|
+
case "x64":
|
|
155
|
+
return "x64compatible";
|
|
156
|
+
case "ia32":
|
|
157
|
+
case "x86":
|
|
158
|
+
return "x86compatible";
|
|
159
|
+
case "arm64":
|
|
160
|
+
return "arm64";
|
|
161
|
+
default:
|
|
162
|
+
return arch;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* 生成默认配置
|
|
167
|
+
*/
|
|
168
|
+
generateDefaultConfig(appDir, appName, appVersion, arch, outputDir) {
|
|
169
|
+
const exeName = `${appName}.exe`;
|
|
170
|
+
const archId = this.getArchIdentifier(arch);
|
|
171
|
+
const outputName = `${appName}-${appVersion}-${archId}-setup`;
|
|
172
|
+
return {
|
|
173
|
+
Setup: {
|
|
174
|
+
AppName: this.config.appName || appName,
|
|
175
|
+
AppVersion: this.config.appVersion || appVersion,
|
|
176
|
+
AppPublisher: this.config.appPublisher || "",
|
|
177
|
+
AppId: this.config.appId || `{{${appName}}`,
|
|
178
|
+
DefaultDirName: `{autopf}\\${appName}`,
|
|
179
|
+
DefaultGroupName: appName,
|
|
180
|
+
OutputDir: outputDir,
|
|
181
|
+
OutputBaseFilename: outputName,
|
|
182
|
+
Compression: "lzma2",
|
|
183
|
+
SolidCompression: true,
|
|
184
|
+
ArchitecturesAllowed: this.getArchitecturesAllowed(arch),
|
|
185
|
+
ArchitecturesInstallIn64BitMode: arch === "x64" ? "x64compatible" : "",
|
|
186
|
+
SetupIconFile: this.config.setupIconFile || "",
|
|
187
|
+
UninstallDisplayIcon: `{app}\\${exeName}`,
|
|
188
|
+
LicenseFile: this.config.licenseFile || "",
|
|
189
|
+
PrivilegesRequired: "admin",
|
|
190
|
+
WizardStyle: "modern",
|
|
191
|
+
},
|
|
192
|
+
Languages: [
|
|
193
|
+
{
|
|
194
|
+
Name: "english",
|
|
195
|
+
MessagesFile: "compiler:Default.isl",
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
Name: "chinesesimplified",
|
|
199
|
+
MessagesFile: "compiler:Languages\\ChineseSimplified.isl",
|
|
200
|
+
},
|
|
201
|
+
],
|
|
202
|
+
Tasks: [],
|
|
203
|
+
Files: [
|
|
204
|
+
{
|
|
205
|
+
Source: path.join(appDir, "*"),
|
|
206
|
+
DestDir: "{app}",
|
|
207
|
+
Flags: "ignoreversion recursesubdirs createallsubdirs",
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
Icons: [
|
|
211
|
+
{
|
|
212
|
+
Name: `{group}\\${appName}`,
|
|
213
|
+
Filename: `{app}\\${exeName}`,
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
Name: `{group}\\Uninstall ${appName}`,
|
|
217
|
+
Filename: "{uninstallexe}",
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
Run: [
|
|
221
|
+
{
|
|
222
|
+
Filename: `{app}\\${exeName}`,
|
|
223
|
+
Description: `Launch ${appName}`,
|
|
224
|
+
Flags: "nowait postinstall skipifsilent",
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* 合并用户配置和默认配置
|
|
231
|
+
*/
|
|
232
|
+
mergeConfig(defaultConfig, userConfig) {
|
|
233
|
+
if (!userConfig) {
|
|
234
|
+
return defaultConfig;
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
Setup: { ...defaultConfig.Setup, ...userConfig.Setup },
|
|
238
|
+
Languages: userConfig.Languages || defaultConfig.Languages,
|
|
239
|
+
Tasks: userConfig.Tasks || defaultConfig.Tasks,
|
|
240
|
+
Types: userConfig.Types || defaultConfig.Types,
|
|
241
|
+
Components: userConfig.Components || defaultConfig.Components,
|
|
242
|
+
Files: userConfig.Files || defaultConfig.Files,
|
|
243
|
+
Dirs: userConfig.Dirs || defaultConfig.Dirs,
|
|
244
|
+
Icons: userConfig.Icons || defaultConfig.Icons,
|
|
245
|
+
INI: userConfig.INI || defaultConfig.INI,
|
|
246
|
+
InstallDelete: userConfig.InstallDelete || defaultConfig.InstallDelete,
|
|
247
|
+
UninstallDelete: userConfig.UninstallDelete || defaultConfig.UninstallDelete,
|
|
248
|
+
Registry: userConfig.Registry || defaultConfig.Registry,
|
|
249
|
+
Run: userConfig.Run || defaultConfig.Run,
|
|
250
|
+
UninstallRun: userConfig.UninstallRun || defaultConfig.UninstallRun,
|
|
251
|
+
Messages: userConfig.Messages || defaultConfig.Messages,
|
|
252
|
+
CustomMessages: userConfig.CustomMessages || defaultConfig.CustomMessages,
|
|
253
|
+
Code: userConfig.Code || defaultConfig.Code,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* 添加任务(桌面图标、快速启动等)
|
|
258
|
+
*/
|
|
259
|
+
addTasks(config, appName) {
|
|
260
|
+
if (!config.Tasks) {
|
|
261
|
+
config.Tasks = [];
|
|
262
|
+
}
|
|
263
|
+
if (this.config.createDesktopIcon !== false) {
|
|
264
|
+
config.Tasks.push({
|
|
265
|
+
Name: "desktopicon",
|
|
266
|
+
Description: "Create a &desktop icon",
|
|
267
|
+
GroupDescription: "Additional icons:",
|
|
268
|
+
Flags: "unchecked",
|
|
269
|
+
});
|
|
270
|
+
if (config.Icons) {
|
|
271
|
+
config.Icons.push({
|
|
272
|
+
Name: "{autodesktop}\\" + appName,
|
|
273
|
+
Filename: `{app}\\${appName}.exe`,
|
|
274
|
+
Tasks: "desktopicon",
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
if (this.config.createQuickLaunchIcon) {
|
|
279
|
+
config.Tasks.push({
|
|
280
|
+
Name: "quicklaunchicon",
|
|
281
|
+
Description: "Create a &Quick Launch icon",
|
|
282
|
+
GroupDescription: "Additional icons:",
|
|
283
|
+
Flags: "unchecked",
|
|
284
|
+
});
|
|
285
|
+
if (config.Icons) {
|
|
286
|
+
config.Icons.push({
|
|
287
|
+
Name: "{userappdata}\\Microsoft\\Internet Explorer\\Quick Launch\\" +
|
|
288
|
+
appName,
|
|
289
|
+
Filename: `{app}\\${appName}.exe`,
|
|
290
|
+
Tasks: "quicklaunchicon",
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* 执行 Innosetup 编译
|
|
297
|
+
*/
|
|
298
|
+
async compileScript(scriptPath, compilerPath) {
|
|
299
|
+
return new Promise((resolve, reject) => {
|
|
300
|
+
const args = [scriptPath];
|
|
301
|
+
if (this.config.isccOptions) {
|
|
302
|
+
args.push(...this.config.isccOptions);
|
|
303
|
+
}
|
|
304
|
+
const iscc = (0, child_process_1.spawn)(compilerPath, args, {
|
|
305
|
+
stdio: "pipe",
|
|
306
|
+
});
|
|
307
|
+
let output = "";
|
|
308
|
+
let errorOutput = "";
|
|
309
|
+
iscc.stdout.on("data", (data) => {
|
|
310
|
+
const text = data.toString();
|
|
311
|
+
output += text;
|
|
312
|
+
console.log(text);
|
|
313
|
+
});
|
|
314
|
+
iscc.stderr.on("data", (data) => {
|
|
315
|
+
const text = data.toString();
|
|
316
|
+
errorOutput += text;
|
|
317
|
+
console.error(text);
|
|
318
|
+
});
|
|
319
|
+
iscc.on("close", (code) => {
|
|
320
|
+
if (code === 0) {
|
|
321
|
+
resolve(output);
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
reject(new Error(`Innosetup compilation failed with code ${code}\n${errorOutput}`));
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
iscc.on("error", (err) => {
|
|
328
|
+
reject(new Error(`Failed to start Innosetup compiler: ${err.message}`));
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* 制作安装包
|
|
334
|
+
*/
|
|
335
|
+
async make(options) {
|
|
336
|
+
const { appName, dir, makeDir, targetArch, packageJSON } = options;
|
|
337
|
+
const appVersion = packageJSON.version || "1.0.0";
|
|
338
|
+
const archId = this.getArchIdentifier(targetArch);
|
|
339
|
+
console.log(`Creating Innosetup installer for ${appName} ${appVersion} (${targetArch})...`);
|
|
340
|
+
// 查找编译器
|
|
341
|
+
const compilerPath = this.findInnosetupCompiler();
|
|
342
|
+
console.log(`Using Innosetup compiler: ${compilerPath}`);
|
|
343
|
+
// 确定输出目录:根据架构生成子目录
|
|
344
|
+
// 格式: makeDir/innosetup.windows/x64 或 makeDir/innosetup.windows/arm64
|
|
345
|
+
const baseOutputDir = this.config.outputDir || path.join(makeDir, "innosetup.windows");
|
|
346
|
+
const outputDir = path.join(baseOutputDir, archId);
|
|
347
|
+
// 确保输出目录存在
|
|
348
|
+
if (!fs.existsSync(outputDir)) {
|
|
349
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
350
|
+
}
|
|
351
|
+
console.log(`Output directory: ${outputDir}`);
|
|
352
|
+
// 生成或使用脚本
|
|
353
|
+
let scriptPath;
|
|
354
|
+
let finalConfig;
|
|
355
|
+
let actualOutputDir = outputDir; // 实际的输出目录
|
|
356
|
+
if (this.config.scriptPath) {
|
|
357
|
+
// 使用用户提供的脚本
|
|
358
|
+
scriptPath = this.config.scriptPath;
|
|
359
|
+
console.log(`Using custom script: ${scriptPath}`);
|
|
360
|
+
// 解析脚本以获取实际的输出目录
|
|
361
|
+
try {
|
|
362
|
+
const parsedConfig = parser_1.InnoScriptParser.parseFile(scriptPath);
|
|
363
|
+
if (parsedConfig.Setup?.OutputDir) {
|
|
364
|
+
// 如果脚本中定义了输出目录,使用绝对路径
|
|
365
|
+
const scriptOutputDir = parsedConfig.Setup.OutputDir;
|
|
366
|
+
actualOutputDir = path.isAbsolute(scriptOutputDir)
|
|
367
|
+
? scriptOutputDir
|
|
368
|
+
: path.resolve(path.dirname(scriptPath), scriptOutputDir);
|
|
369
|
+
console.log(`Script defines OutputDir: ${actualOutputDir}`);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
catch (err) {
|
|
373
|
+
console.warn(`Failed to parse script for OutputDir: ${err}`);
|
|
374
|
+
// 继续使用默认的 outputDir
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
else {
|
|
378
|
+
// 生成脚本
|
|
379
|
+
const defaultConfig = this.generateDefaultConfig(dir, appName, appVersion, targetArch, outputDir);
|
|
380
|
+
finalConfig = this.mergeConfig(defaultConfig, this.config.config);
|
|
381
|
+
// 添加任务
|
|
382
|
+
this.addTasks(finalConfig, appName);
|
|
383
|
+
// 生成脚本内容
|
|
384
|
+
const scriptContent = this.scriptGenerator.generate(finalConfig);
|
|
385
|
+
// 保存脚本
|
|
386
|
+
scriptPath = path.join(makeDir, `${appName}-setup.iss`);
|
|
387
|
+
this.scriptGenerator.saveToFile(scriptContent, scriptPath);
|
|
388
|
+
console.log(`Generated Innosetup script: ${scriptPath}`);
|
|
389
|
+
}
|
|
390
|
+
// 编译安装包
|
|
391
|
+
console.log("Compiling installer...");
|
|
392
|
+
await this.compileScript(scriptPath, compilerPath);
|
|
393
|
+
// 查找生成的安装包
|
|
394
|
+
// 如果使用自定义脚本,在实际输出目录中查找
|
|
395
|
+
const searchDir = actualOutputDir;
|
|
396
|
+
console.log(`Searching for installer in: ${searchDir}`);
|
|
397
|
+
// 尝试匹配输出文件名模式
|
|
398
|
+
const outputPattern = `${appName}-${appVersion}-${archId}-setup.exe`;
|
|
399
|
+
const outputPath = path.join(searchDir, outputPattern);
|
|
400
|
+
if (fs.existsSync(outputPath)) {
|
|
401
|
+
console.log(`Installer created successfully: ${outputPath}`);
|
|
402
|
+
return [outputPath];
|
|
403
|
+
}
|
|
404
|
+
// 如果没找到,尝试查找所有 exe 文件
|
|
405
|
+
if (fs.existsSync(searchDir)) {
|
|
406
|
+
const files = fs.readdirSync(searchDir);
|
|
407
|
+
const exeFiles = files
|
|
408
|
+
.filter((f) => f.endsWith(".exe"))
|
|
409
|
+
.map((f) => path.join(searchDir, f));
|
|
410
|
+
if (exeFiles.length > 0) {
|
|
411
|
+
console.log(`Installer created: ${exeFiles[0]}`);
|
|
412
|
+
return exeFiles;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
throw new Error(`Failed to find generated installer in ${searchDir}`);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
exports.default = MakerInnosetup;
|
|
419
|
+
// 导出类型
|
|
420
|
+
__exportStar(require("./types"), exports);
|
|
421
|
+
var generator_2 = require("./generator");
|
|
422
|
+
Object.defineProperty(exports, "InnoScriptGenerator", { enumerable: true, get: function () { return generator_2.InnoScriptGenerator; } });
|
|
423
|
+
var parser_2 = require("./parser");
|
|
424
|
+
Object.defineProperty(exports, "InnoScriptParser", { enumerable: true, get: function () { return parser_2.InnoScriptParser; } });
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { InnoSetupConfig } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* 生成 Innosetup 脚本文件内容
|
|
4
|
+
*/
|
|
5
|
+
export declare class InnoScriptGenerator {
|
|
6
|
+
/**
|
|
7
|
+
* 生成脚本内容
|
|
8
|
+
*/
|
|
9
|
+
generate(config: InnoSetupConfig): string;
|
|
10
|
+
/**
|
|
11
|
+
* 生成 Setup 部分
|
|
12
|
+
*/
|
|
13
|
+
private generateSetupSection;
|
|
14
|
+
/**
|
|
15
|
+
* 生成 Languages 部分
|
|
16
|
+
*/
|
|
17
|
+
private generateLanguagesSection;
|
|
18
|
+
/**
|
|
19
|
+
* 生成 Types 部分
|
|
20
|
+
*/
|
|
21
|
+
private generateTypesSection;
|
|
22
|
+
/**
|
|
23
|
+
* 生成 Components 部分
|
|
24
|
+
*/
|
|
25
|
+
private generateComponentsSection;
|
|
26
|
+
/**
|
|
27
|
+
* 生成 Tasks 部分
|
|
28
|
+
*/
|
|
29
|
+
private generateTasksSection;
|
|
30
|
+
/**
|
|
31
|
+
* 生成 Files 部分
|
|
32
|
+
*/
|
|
33
|
+
private generateFilesSection;
|
|
34
|
+
/**
|
|
35
|
+
* 生成 Dirs 部分
|
|
36
|
+
*/
|
|
37
|
+
private generateDirsSection;
|
|
38
|
+
/**
|
|
39
|
+
* 生成 Icons 部分
|
|
40
|
+
*/
|
|
41
|
+
private generateIconsSection;
|
|
42
|
+
/**
|
|
43
|
+
* 生成 INI 部分
|
|
44
|
+
*/
|
|
45
|
+
private generateINISection;
|
|
46
|
+
/**
|
|
47
|
+
* 生成 InstallDelete 部分
|
|
48
|
+
*/
|
|
49
|
+
private generateInstallDeleteSection;
|
|
50
|
+
/**
|
|
51
|
+
* 生成 UninstallDelete 部分
|
|
52
|
+
*/
|
|
53
|
+
private generateUninstallDeleteSection;
|
|
54
|
+
/**
|
|
55
|
+
* 生成 Registry 部分
|
|
56
|
+
*/
|
|
57
|
+
private generateRegistrySection;
|
|
58
|
+
/**
|
|
59
|
+
* 生成 Run 部分
|
|
60
|
+
*/
|
|
61
|
+
private generateRunSection;
|
|
62
|
+
/**
|
|
63
|
+
* 生成 UninstallRun 部分
|
|
64
|
+
*/
|
|
65
|
+
private generateUninstallRunSection;
|
|
66
|
+
/**
|
|
67
|
+
* 生成 Messages 部分
|
|
68
|
+
*/
|
|
69
|
+
private generateMessagesSection;
|
|
70
|
+
/**
|
|
71
|
+
* 生成 CustomMessages 部分
|
|
72
|
+
*/
|
|
73
|
+
private generateCustomMessagesSection;
|
|
74
|
+
/**
|
|
75
|
+
* 生成 Code 部分
|
|
76
|
+
*/
|
|
77
|
+
private generateCodeSection;
|
|
78
|
+
/**
|
|
79
|
+
* 将脚本保存到文件
|
|
80
|
+
*/
|
|
81
|
+
saveToFile(scriptContent: string, filePath: string): void;
|
|
82
|
+
}
|