1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.computeArchToTargetNamesMap = computeArchToTargetNamesMap;
|
7 | exports.createTargets = createTargets;
|
8 | exports.createCommonTarget = createCommonTarget;
|
9 | exports.NoOpTarget = void 0;
|
10 |
|
11 | function _bluebirdLst() {
|
12 | const data = require("bluebird-lst");
|
13 |
|
14 | _bluebirdLst = function () {
|
15 | return data;
|
16 | };
|
17 |
|
18 | return data;
|
19 | }
|
20 |
|
21 | function _builderUtil() {
|
22 | const data = require("builder-util");
|
23 |
|
24 | _builderUtil = function () {
|
25 | return data;
|
26 | };
|
27 |
|
28 | return data;
|
29 | }
|
30 |
|
31 | function _index() {
|
32 | const data = require("../index");
|
33 |
|
34 | _index = function () {
|
35 | return data;
|
36 | };
|
37 |
|
38 | return data;
|
39 | }
|
40 |
|
41 | function _ArchiveTarget() {
|
42 | const data = require("./ArchiveTarget");
|
43 |
|
44 | _ArchiveTarget = function () {
|
45 | return data;
|
46 | };
|
47 |
|
48 | return data;
|
49 | }
|
50 |
|
51 | const archiveTargets = new Set(["zip", "7z", "tar.xz", "tar.lz", "tar.gz", "tar.bz2"]);
|
52 |
|
53 | function computeArchToTargetNamesMap(raw, options, platform) {
|
54 | for (const targetNames of raw.values()) {
|
55 | if (targetNames.length > 0) {
|
56 |
|
57 | return raw;
|
58 | }
|
59 | }
|
60 |
|
61 | const defaultArchs = raw.size === 0 ? [platform === _index().Platform.MAC ? "x64" : process.arch] : Array.from(raw.keys()).map(it => _builderUtil().Arch[it]);
|
62 | const result = new Map(raw);
|
63 |
|
64 | for (const target of (0, _builderUtil().asArray)(options.target).map(it => typeof it === "string" ? {
|
65 | target: it
|
66 | } : it)) {
|
67 | let name = target.target;
|
68 | let archs = target.arch;
|
69 | const suffixPos = name.lastIndexOf(":");
|
70 |
|
71 | if (suffixPos > 0) {
|
72 | name = target.target.substring(0, suffixPos);
|
73 |
|
74 | if (archs == null) {
|
75 | archs = target.target.substring(suffixPos + 1);
|
76 | }
|
77 | }
|
78 |
|
79 | for (const arch of archs == null ? defaultArchs : (0, _builderUtil().asArray)(archs)) {
|
80 | (0, _builderUtil().addValue)(result, (0, _builderUtil().archFromString)(arch), name);
|
81 | }
|
82 | }
|
83 |
|
84 | if (result.size === 0) {
|
85 | for (const arch of defaultArchs) {
|
86 | result.set((0, _builderUtil().archFromString)(arch), []);
|
87 | }
|
88 | }
|
89 |
|
90 | return result;
|
91 | }
|
92 |
|
93 | function createTargets(nameToTarget, rawList, outDir, packager) {
|
94 | const result = [];
|
95 |
|
96 | const mapper = (name, factory) => {
|
97 | let target = nameToTarget.get(name);
|
98 |
|
99 | if (target == null) {
|
100 | target = factory(outDir);
|
101 | nameToTarget.set(name, target);
|
102 | }
|
103 |
|
104 | result.push(target);
|
105 | };
|
106 |
|
107 | const targets = normalizeTargets(rawList, packager.defaultTarget);
|
108 | packager.createTargets(targets, mapper);
|
109 | return result;
|
110 | }
|
111 |
|
112 | function normalizeTargets(targets, defaultTarget) {
|
113 | const list = [];
|
114 |
|
115 | for (const t of targets) {
|
116 | const name = t.toLowerCase().trim();
|
117 |
|
118 | if (name === _index().DEFAULT_TARGET) {
|
119 | list.push(...defaultTarget);
|
120 | } else {
|
121 | list.push(name);
|
122 | }
|
123 | }
|
124 |
|
125 | return list;
|
126 | }
|
127 |
|
128 | function createCommonTarget(target, outDir, packager) {
|
129 | if (archiveTargets.has(target)) {
|
130 | return new (_ArchiveTarget().ArchiveTarget)(target, outDir, packager);
|
131 | } else if (target === _index().DIR_TARGET) {
|
132 | return new NoOpTarget(_index().DIR_TARGET);
|
133 | } else {
|
134 | throw new Error(`Unknown target: ${target}`);
|
135 | }
|
136 | }
|
137 |
|
138 | class NoOpTarget extends _index().Target {
|
139 | constructor(name) {
|
140 | super(name);
|
141 | this.options = null;
|
142 | }
|
143 |
|
144 | get outDir() {
|
145 | throw new Error("NoOpTarget");
|
146 | }
|
147 |
|
148 | build(appOutDir, arch) {
|
149 |
|
150 | return (0, _bluebirdLst().coroutine)(function* () {})();
|
151 | }
|
152 |
|
153 | } exports.NoOpTarget = NoOpTarget;
|
154 |
|
\ | No newline at end of file |