1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.filterCFBundleIdentifier = filterCFBundleIdentifier;
|
7 | exports.AppInfo = void 0;
|
8 |
|
9 | function _bluebirdLst() {
|
10 | const data = require("bluebird-lst");
|
11 |
|
12 | _bluebirdLst = function () {
|
13 | return data;
|
14 | };
|
15 |
|
16 | return data;
|
17 | }
|
18 |
|
19 | function _builderUtil() {
|
20 | const data = require("builder-util");
|
21 |
|
22 | _builderUtil = function () {
|
23 | return data;
|
24 | };
|
25 |
|
26 | return data;
|
27 | }
|
28 |
|
29 | function _sanitizeFilename() {
|
30 | const data = _interopRequireDefault(require("sanitize-filename"));
|
31 |
|
32 | _sanitizeFilename = function () {
|
33 | return data;
|
34 | };
|
35 |
|
36 | return data;
|
37 | }
|
38 |
|
39 | function _semver() {
|
40 | const data = require("semver");
|
41 |
|
42 | _semver = function () {
|
43 | return data;
|
44 | };
|
45 |
|
46 | return data;
|
47 | }
|
48 |
|
49 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
50 |
|
51 | class AppInfo {
|
52 | constructor(info, buildVersion) {
|
53 | this.info = info;
|
54 | this.description = (0, _builderUtil().smarten)(this.info.metadata.description || "");
|
55 | this.version = info.metadata.version;
|
56 |
|
57 | if (buildVersion == null) {
|
58 | buildVersion = info.config.buildVersion;
|
59 | }
|
60 |
|
61 | this.buildNumber = process.env.BUILD_NUMBER || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_BUILDNUMBER;
|
62 |
|
63 | if (buildVersion == null) {
|
64 | buildVersion = this.version;
|
65 |
|
66 | if (!(0, _builderUtil().isEmptyOrSpaces)(this.buildNumber)) {
|
67 | buildVersion += `.${this.buildNumber}`;
|
68 | }
|
69 | }
|
70 |
|
71 | this.buildVersion = buildVersion;
|
72 | this.productName = info.config.productName || info.metadata.productName || info.metadata.name;
|
73 | this.productFilename = (0, _sanitizeFilename().default)(this.productName);
|
74 | }
|
75 |
|
76 | get channel() {
|
77 | const prereleaseInfo = (0, _semver().prerelease)(this.version);
|
78 |
|
79 | if (prereleaseInfo != null && prereleaseInfo.length > 0) {
|
80 | return prereleaseInfo[0];
|
81 | }
|
82 |
|
83 | return null;
|
84 | }
|
85 |
|
86 | get versionInWeirdWindowsForm() {
|
87 | const parsedVersion = new (_semver().SemVer)(this.version);
|
88 |
|
89 | let buildNumber = this.buildNumber;
|
90 |
|
91 | if (buildNumber == null || !/^\d+$/.test(buildNumber)) {
|
92 | buildNumber = "0";
|
93 | }
|
94 |
|
95 | return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}.${buildNumber}`;
|
96 | }
|
97 |
|
98 | get notNullDevMetadata() {
|
99 | return this.info.devMetadata || {};
|
100 | }
|
101 |
|
102 | get companyName() {
|
103 | const author = this.info.metadata.author || this.notNullDevMetadata.author;
|
104 | return author == null ? null : author.name;
|
105 | }
|
106 |
|
107 | get id() {
|
108 | let appId;
|
109 |
|
110 | if (this.info.config.appId != null) {
|
111 | appId = this.info.config.appId;
|
112 | }
|
113 |
|
114 | const generateDefaultAppId = () => {
|
115 | const info = this.info;
|
116 | return `${info.framework.defaultAppIdPrefix}${info.metadata.name.toLowerCase()}`;
|
117 | };
|
118 |
|
119 | if (appId != null && (appId === "your.id" || (0, _builderUtil().isEmptyOrSpaces)(appId))) {
|
120 | const incorrectAppId = appId;
|
121 | appId = generateDefaultAppId();
|
122 |
|
123 | _builderUtil().log.warn(`do not use "${incorrectAppId}" as appId, "${appId}" will be used instead`);
|
124 | }
|
125 |
|
126 | return appId == null ? generateDefaultAppId() : appId;
|
127 | }
|
128 |
|
129 | get macBundleIdentifier() {
|
130 | return filterCFBundleIdentifier(this.id);
|
131 | }
|
132 |
|
133 | get name() {
|
134 | return this.info.metadata.name;
|
135 | }
|
136 |
|
137 | get sanitizedName() {
|
138 | return (0, _sanitizeFilename().default)(this.name);
|
139 | }
|
140 |
|
141 | get copyright() {
|
142 | const copyright = this.info.config.copyright;
|
143 |
|
144 | if (copyright != null) {
|
145 | return copyright;
|
146 | }
|
147 |
|
148 | return `Copyright © ${new Date().getFullYear()} ${this.companyName || this.productName}`;
|
149 | }
|
150 |
|
151 | computePackageUrl() {
|
152 | var _this = this;
|
153 |
|
154 | return (0, _bluebirdLst().coroutine)(function* () {
|
155 | const url = _this.info.metadata.homepage || _this.notNullDevMetadata.homepage;
|
156 |
|
157 | if (url != null) {
|
158 | return url;
|
159 | }
|
160 |
|
161 | const info = yield _this.info.repositoryInfo;
|
162 | return info == null || info.type !== "github" ? null : `https://${info.domain}/${info.user}/${info.project}`;
|
163 | })();
|
164 | }
|
165 |
|
166 | }
|
167 |
|
168 |
|
169 |
|
170 | exports.AppInfo = AppInfo;
|
171 |
|
172 | function filterCFBundleIdentifier(identifier) {
|
173 |
|
174 |
|
175 | return identifier.replace(/ /g, "-").replace(/[^a-zA-Z0-9.-]/g, "");
|
176 | }
|
177 |
|
\ | No newline at end of file |