dmgLicense.js
2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addLicenseToDmg = addLicenseToDmg;
function _builderUtil() {
const data = require("builder-util");
_builderUtil = function () {
return data;
};
return data;
}
function _jsYaml() {
const data = require("js-yaml");
_jsYaml = function () {
return data;
};
return data;
}
function _license() {
const data = require("app-builder-lib/out/util/license");
_license = function () {
return data;
};
return data;
}
function _fsExtra() {
const data = require("fs-extra");
_fsExtra = function () {
return data;
};
return data;
}
function _licenseButtons() {
const data = require("./licenseButtons");
_licenseButtons = function () {
return data;
};
return data;
}
function _dmgLicense() {
const data = require("dmg-license");
_dmgLicense = function () {
return data;
};
return data;
}
async function addLicenseToDmg(packager, dmgPath) {
const licenseFiles = await (0, _license().getLicenseFiles)(packager);
if (licenseFiles.length === 0) {
return null;
}
const licenseButtonFiles = await (0, _licenseButtons().getLicenseButtonsFile)(packager);
packager.debugLogger.add("dmg.licenseFiles", licenseFiles);
packager.debugLogger.add("dmg.licenseButtons", licenseButtonFiles);
const jsonFile = {
"$schema": "https://github.com/argv-minus-one/dmg-license/raw/master/schema.json",
// defaultLang: '',
body: [],
labels: []
};
for (const file of licenseFiles) {
jsonFile.body.push({
file: file.file,
lang: file.langWithRegion.replace('_', '-')
});
}
for (const button of licenseButtonFiles) {
const filepath = button.file;
const label = filepath.endsWith(".yml") ? (0, _jsYaml().load)(await (0, _fsExtra().readFile)(filepath, "utf-8")) : await (0, _fsExtra().readJson)(filepath);
if (label.description) {
// to support original button file format
label.message = label.description;
delete label.description;
}
jsonFile.labels.push(Object.assign({
lang: button.langWithRegion.replace('_', '-')
}, label));
}
await (0, _dmgLicense().dmgLicenseFromJSON)(dmgPath, jsonFile, {
onNonFatalError: _builderUtil().log.warn.bind(_builderUtil().log)
});
return jsonFile;
}
// __ts-babel@6.0.4
//# sourceMappingURL=dmgLicense.js.map