@balena/compose 0.1.0-import-modules-d457c16709fa5260df6ff68da79c0f0e92f7aaa5
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/CHANGELOG.md +15 -0
- package/LICENSE +201 -0
- package/README.md +200 -0
- package/dist/build/builder.d.ts +18 -0
- package/dist/build/builder.js +127 -0
- package/dist/build/builder.js.map +1 -0
- package/dist/build/index.d.ts +4 -0
- package/dist/build/index.js +7 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/plugin.d.ts +11 -0
- package/dist/build/plugin.js +3 -0
- package/dist/build/plugin.js.map +1 -0
- package/dist/build/utils.d.ts +8 -0
- package/dist/build/utils.js +60 -0
- package/dist/build/utils.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/multibuild/build-metadata.d.ts +24 -0
- package/dist/multibuild/build-metadata.js +166 -0
- package/dist/multibuild/build-metadata.js.map +1 -0
- package/dist/multibuild/build-secrets/Dockerfile +3 -0
- package/dist/multibuild/build-secrets/Dockerfile.remove +3 -0
- package/dist/multibuild/build-secrets/index.d.ts +43 -0
- package/dist/multibuild/build-secrets/index.js +140 -0
- package/dist/multibuild/build-secrets/index.js.map +1 -0
- package/dist/multibuild/build-task.d.ts +36 -0
- package/dist/multibuild/build-task.js +3 -0
- package/dist/multibuild/build-task.js.map +1 -0
- package/dist/multibuild/build.d.ts +6 -0
- package/dist/multibuild/build.js +167 -0
- package/dist/multibuild/build.js.map +1 -0
- package/dist/multibuild/constants.d.ts +1 -0
- package/dist/multibuild/constants.js +5 -0
- package/dist/multibuild/constants.js.map +1 -0
- package/dist/multibuild/contracts.d.ts +6 -0
- package/dist/multibuild/contracts.js +55 -0
- package/dist/multibuild/contracts.js.map +1 -0
- package/dist/multibuild/errors.d.ts +43 -0
- package/dist/multibuild/errors.js +71 -0
- package/dist/multibuild/errors.js.map +1 -0
- package/dist/multibuild/external.d.ts +5 -0
- package/dist/multibuild/external.js +62 -0
- package/dist/multibuild/external.js.map +1 -0
- package/dist/multibuild/index.d.ts +33 -0
- package/dist/multibuild/index.js +187 -0
- package/dist/multibuild/index.js.map +1 -0
- package/dist/multibuild/local-image.d.ts +25 -0
- package/dist/multibuild/local-image.js +29 -0
- package/dist/multibuild/local-image.js.map +1 -0
- package/dist/multibuild/manifests.d.ts +19 -0
- package/dist/multibuild/manifests.js +27 -0
- package/dist/multibuild/manifests.js.map +1 -0
- package/dist/multibuild/path-utils.d.ts +4 -0
- package/dist/multibuild/path-utils.js +28 -0
- package/dist/multibuild/path-utils.js.map +1 -0
- package/dist/multibuild/registry-secrets.d.ts +16 -0
- package/dist/multibuild/registry-secrets.js +75 -0
- package/dist/multibuild/registry-secrets.js.map +1 -0
- package/dist/multibuild/resolve.d.ts +5 -0
- package/dist/multibuild/resolve.js +63 -0
- package/dist/multibuild/resolve.js.map +1 -0
- package/dist/multibuild/utils.d.ts +10 -0
- package/dist/multibuild/utils.js +61 -0
- package/dist/multibuild/utils.js.map +1 -0
- package/dist/multibuild/validation-types/varlist.d.ts +7 -0
- package/dist/multibuild/validation-types/varlist.js +52 -0
- package/dist/multibuild/validation-types/varlist.js.map +1 -0
- package/package.json +91 -0
|
@@ -0,0 +1,187 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.performSingleBuild = exports.initializeBuildMetadata = exports.performBuilds = exports.performSingleResolution = exports.performResolution = exports.buildHasSecrets = exports.fromImageDescriptors = exports.splitBuildStream = exports.CANONICAL_HUB_URL = exports.PathUtils = exports.getRegistryAndName = exports.resolveDockerPlatform = exports.QEMU_BIN_NAME = void 0;
|
|
18
|
+
const Bluebird = require("bluebird");
|
|
19
|
+
const _ = require("lodash");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const Compose = require("@balena/compose-parse");
|
|
22
|
+
const tar = require("tar-stream");
|
|
23
|
+
const TarUtils = require("tar-utils");
|
|
24
|
+
const build_1 = require("./build");
|
|
25
|
+
const build_metadata_1 = require("./build-metadata");
|
|
26
|
+
const build_secrets_1 = require("./build-secrets");
|
|
27
|
+
const contracts = require("./contracts");
|
|
28
|
+
const errors_1 = require("./errors");
|
|
29
|
+
const PathUtils = require("./path-utils");
|
|
30
|
+
exports.PathUtils = PathUtils;
|
|
31
|
+
const path_utils_1 = require("./path-utils");
|
|
32
|
+
const resolve_1 = require("./resolve");
|
|
33
|
+
const Utils = require("./utils");
|
|
34
|
+
var build_metadata_2 = require("./build-metadata");
|
|
35
|
+
Object.defineProperty(exports, "QEMU_BIN_NAME", { enumerable: true, get: function () { return build_metadata_2.QEMU_BIN_NAME; } });
|
|
36
|
+
__exportStar(require("./build-task"), exports);
|
|
37
|
+
__exportStar(require("./errors"), exports);
|
|
38
|
+
__exportStar(require("./local-image"), exports);
|
|
39
|
+
__exportStar(require("./registry-secrets"), exports);
|
|
40
|
+
var resolve_2 = require("./resolve");
|
|
41
|
+
Object.defineProperty(exports, "resolveDockerPlatform", { enumerable: true, get: function () { return resolve_2.resolveDockerPlatform; } });
|
|
42
|
+
var utils_1 = require("./utils");
|
|
43
|
+
Object.defineProperty(exports, "getRegistryAndName", { enumerable: true, get: function () { return utils_1.getRegistryAndName; } });
|
|
44
|
+
var constants_1 = require("./constants");
|
|
45
|
+
Object.defineProperty(exports, "CANONICAL_HUB_URL", { enumerable: true, get: function () { return constants_1.CANONICAL_HUB_URL; } });
|
|
46
|
+
function splitBuildStream(composition, buildStream) {
|
|
47
|
+
const images = Compose.parse(composition);
|
|
48
|
+
return fromImageDescriptors(images, buildStream);
|
|
49
|
+
}
|
|
50
|
+
exports.splitBuildStream = splitBuildStream;
|
|
51
|
+
async function fromImageDescriptors(images, buildStream, metadataDirectories = ['.balena/', '.resin/']) {
|
|
52
|
+
const buildMetadata = new build_metadata_1.default(metadataDirectories);
|
|
53
|
+
const newStream = await buildMetadata.extractMetadata(buildStream);
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
const tasks = Utils.generateBuildTasks(images, buildMetadata);
|
|
56
|
+
const extract = tar.extract();
|
|
57
|
+
const entryFn = (header, stream, next) => {
|
|
58
|
+
const matchingTasks = _.filter(tasks, (task) => {
|
|
59
|
+
if (task.external) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
return (0, path_utils_1.posixContains)(task.context, header.name);
|
|
63
|
+
});
|
|
64
|
+
if (matchingTasks.length > 0) {
|
|
65
|
+
TarUtils.streamToBuffer(stream)
|
|
66
|
+
.then((buf) => {
|
|
67
|
+
matchingTasks.forEach((task) => {
|
|
68
|
+
const relative = path.posix.relative(task.context, header.name);
|
|
69
|
+
if (contracts.isContractFile(relative)) {
|
|
70
|
+
if (task.contract != null) {
|
|
71
|
+
throw new errors_1.MultipleContractsForService(task.serviceName);
|
|
72
|
+
}
|
|
73
|
+
task.contract = contracts.processContract(buf);
|
|
74
|
+
}
|
|
75
|
+
const newHeader = _.cloneDeep(header);
|
|
76
|
+
newHeader.name = relative;
|
|
77
|
+
task.buildStream.entry(newHeader, buf);
|
|
78
|
+
});
|
|
79
|
+
})
|
|
80
|
+
.then(() => {
|
|
81
|
+
next();
|
|
82
|
+
return null;
|
|
83
|
+
})
|
|
84
|
+
.catch(errors_1.ContractError, reject)
|
|
85
|
+
.catch((e) => reject(new errors_1.TarError(e)));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
TarUtils.drainStream(stream)
|
|
89
|
+
.then(() => {
|
|
90
|
+
next();
|
|
91
|
+
return null;
|
|
92
|
+
})
|
|
93
|
+
.catch((e) => reject(new errors_1.TarError(e)));
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
extract.on('entry', entryFn);
|
|
97
|
+
extract.on('finish', () => {
|
|
98
|
+
_.each(tasks, (task) => {
|
|
99
|
+
if (!task.external) {
|
|
100
|
+
task.buildStream.finalize();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
resolve(tasks);
|
|
104
|
+
});
|
|
105
|
+
extract.on('error', (e) => {
|
|
106
|
+
reject(new errors_1.TarError(e));
|
|
107
|
+
});
|
|
108
|
+
newStream.pipe(extract);
|
|
109
|
+
}).then((tasks) => {
|
|
110
|
+
contracts.checkContractNamesUnique(tasks);
|
|
111
|
+
return tasks;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
exports.fromImageDescriptors = fromImageDescriptors;
|
|
115
|
+
function buildHasSecrets(tasks) {
|
|
116
|
+
if (tasks.length === 0) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
return !_.isEmpty((0, build_secrets_1.generateSecretPopulationMap)(_.map(tasks, 'serviceName'), tasks[0].buildMetadata, '/tmp'));
|
|
120
|
+
}
|
|
121
|
+
exports.buildHasSecrets = buildHasSecrets;
|
|
122
|
+
function performResolution(tasks, architecture, deviceType, resolveListeners, additionalTemplateVars, dockerfilePreprocessHook) {
|
|
123
|
+
return tasks.map((task) => {
|
|
124
|
+
task.architecture = architecture;
|
|
125
|
+
return (0, resolve_1.resolveTask)(task, architecture, deviceType, resolveListeners, additionalTemplateVars, dockerfilePreprocessHook);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
exports.performResolution = performResolution;
|
|
129
|
+
function performSingleResolution(task, architecture, deviceType, resolveListeners, additionalTemplateVars, dockerfilePreprocessHook) {
|
|
130
|
+
task.architecture = architecture;
|
|
131
|
+
return (0, resolve_1.resolveTask)(task, architecture, deviceType, resolveListeners, additionalTemplateVars, dockerfilePreprocessHook);
|
|
132
|
+
}
|
|
133
|
+
exports.performSingleResolution = performSingleResolution;
|
|
134
|
+
async function performBuilds(tasks, docker, tmpDir) {
|
|
135
|
+
if (tasks.length === 0) {
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
const buildMetadata = tasks[0].buildMetadata;
|
|
139
|
+
const { secrets: secretMap, regSecrets: registrySecrets, architecture, } = await initializeBuildMetadata(tasks, docker, tmpDir);
|
|
140
|
+
const images = await Bluebird.map(tasks, (task) => {
|
|
141
|
+
return performSingleBuild(task, docker, registrySecrets, secretMap, buildMetadata.getBuildVarsForService(task.serviceName));
|
|
142
|
+
});
|
|
143
|
+
if (!_.isEmpty(secretMap)) {
|
|
144
|
+
try {
|
|
145
|
+
await (0, build_secrets_1.removeSecrets)(docker, secretMap, architecture, tmpDir);
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
throw new errors_1.SecretRemovalError(e);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return images;
|
|
152
|
+
}
|
|
153
|
+
exports.performBuilds = performBuilds;
|
|
154
|
+
async function initializeBuildMetadata(tasks, docker, tmpDir) {
|
|
155
|
+
if (tasks.length === 0) {
|
|
156
|
+
return {
|
|
157
|
+
secrets: {},
|
|
158
|
+
regSecrets: {},
|
|
159
|
+
architecture: '',
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const buildMetadata = tasks[0].buildMetadata;
|
|
163
|
+
const architecture = (await docker.version()).Arch;
|
|
164
|
+
buildMetadata.parseMetadata();
|
|
165
|
+
const registrySecrets = buildMetadata.registrySecrets;
|
|
166
|
+
const secretMap = (0, build_secrets_1.generateSecretPopulationMap)(_.map(tasks, 'serviceName'), buildMetadata, tmpDir);
|
|
167
|
+
const hasSecrets = !_.isEmpty(secretMap);
|
|
168
|
+
if (hasSecrets) {
|
|
169
|
+
await (0, build_secrets_1.populateSecrets)(docker, secretMap, architecture, tmpDir);
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
secrets: secretMap,
|
|
173
|
+
regSecrets: registrySecrets,
|
|
174
|
+
architecture,
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
exports.initializeBuildMetadata = initializeBuildMetadata;
|
|
178
|
+
async function performSingleBuild(task, docker, registrySecrets, secretMap, buildArgs) {
|
|
179
|
+
try {
|
|
180
|
+
return await (0, build_1.runBuildTask)(task, docker, registrySecrets, secretMap, buildArgs);
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
throw new errors_1.BuildProcessError(e);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.performSingleBuild = performSingleBuild;
|
|
187
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../lib/multibuild/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAiBA,qCAAqC;AAErC,4BAA4B;AAC5B,6BAA6B;AAC7B,iDAAiD;AAEjD,kCAAkC;AAClC,sCAAsC;AAEtC,mCAAuC;AACvC,qDAA6C;AAC7C,mDAOyB;AAEzB,yCAAyC;AACzC,qCAMkB;AAElB,0CAA0C;AAcjC,8BAAS;AAblB,6CAA6C;AAE7C,uCAA0D;AAC1D,iCAAiC;AAEjC,mDAAiD;AAAxC,+GAAA,aAAa,OAAA;AACtB,+CAA6B;AAC7B,2CAAyB;AACzB,gDAA8B;AAC9B,qDAAmC;AACnC,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA;AAC9B,iCAA6C;AAApC,2GAAA,kB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C,CAAC,CAAC,CAAC;KAC/B;AACF,CAAC;AAlBD,gDAkBC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type * as Dockerode from 'dockerode';
|
|
2
|
+
export interface ImageInfo {
|
|
3
|
+
external: boolean;
|
|
4
|
+
successful: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare class LocalImage {
|
|
7
|
+
dockerfile?: string;
|
|
8
|
+
external: boolean;
|
|
9
|
+
name?: string;
|
|
10
|
+
serviceName: string;
|
|
11
|
+
daemon: Dockerode;
|
|
12
|
+
layers?: string[];
|
|
13
|
+
baseImageTags?: Array<{
|
|
14
|
+
repo: string;
|
|
15
|
+
tag: string;
|
|
16
|
+
}>;
|
|
17
|
+
successful: boolean;
|
|
18
|
+
error?: Error;
|
|
19
|
+
startTime?: number;
|
|
20
|
+
endTime?: number;
|
|
21
|
+
projectType?: string;
|
|
22
|
+
constructor(daemon: Dockerode, name: string | null, serviceName: string, info: ImageInfo);
|
|
23
|
+
getImage(): Dockerode.Image;
|
|
24
|
+
deleteImage(): Promise<void>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LocalImage = void 0;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
class LocalImage {
|
|
6
|
+
constructor(daemon, name, serviceName, info) {
|
|
7
|
+
this.daemon = daemon;
|
|
8
|
+
this.external = info.external;
|
|
9
|
+
this.successful = info.successful;
|
|
10
|
+
this.serviceName = serviceName;
|
|
11
|
+
if (name != null) {
|
|
12
|
+
this.name = name;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
getImage() {
|
|
16
|
+
if (this.name == null) {
|
|
17
|
+
throw new Error('Attempting to get image without name');
|
|
18
|
+
}
|
|
19
|
+
return this.daemon.getImage(this.name);
|
|
20
|
+
}
|
|
21
|
+
deleteImage() {
|
|
22
|
+
const image = this.getImage();
|
|
23
|
+
return image.remove().catch((e) => {
|
|
24
|
+
throw new errors_1.ImageRemovalError(e);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.LocalImage = LocalImage;
|
|
29
|
+
//# sourceMappingURL=local-image.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-image.js","sourceRoot":"","sources":["../../lib/multibuild/local-image.ts"],"names":[],"mappings":";;;AAmBA,qCAA6C;AAa7C,MAAa,UAAU;IA0EtB,YACC,MAAiB,EACjB,IAAmB,EACnB,WAAmB,EACnB,IAAe;QAEf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,IAAI,IAAI,IAAI,EAAE;YACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;SACjB;IACF,CAAC;IAKM,QAAQ;QACd,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,EAAE;YACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;SACxD;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAOM,WAAW;QACjB,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;YACjC,MAAM,IAAI,0BAAiB,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC,CAAC,CAAC;IACJ,CAAC;CACD;AA9GD,gCA8GC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type * as Dockermodem from 'docker-modem';
|
|
2
|
+
export declare const MEDIATYPE_MANIFEST_V1 = "application/vnd.docker.distribution.manifest.v1+prettyjws";
|
|
3
|
+
export declare const MEDIATYPE_MANIFEST_V2 = "application/vnd.docker.distribution.manifest.v2+json";
|
|
4
|
+
export declare const MEDIATYPE_MANIFEST_LIST_V2 = "application/vnd.docker.distribution.manifest.list.v2+json";
|
|
5
|
+
export declare type DockerImageManifestPlatform = {
|
|
6
|
+
architecture?: string;
|
|
7
|
+
os?: string;
|
|
8
|
+
variant?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare type DockerImageManifestDescriptor = {
|
|
11
|
+
mediaType: string;
|
|
12
|
+
digest: string;
|
|
13
|
+
platform?: DockerImageManifestPlatform;
|
|
14
|
+
};
|
|
15
|
+
export declare type DockerImageManifest = {
|
|
16
|
+
Descriptor: DockerImageManifestDescriptor;
|
|
17
|
+
Platforms: DockerImageManifestPlatform[];
|
|
18
|
+
};
|
|
19
|
+
export declare function getManifest(modem: Dockermodem, repository: string): Promise<DockerImageManifest>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getManifest = exports.MEDIATYPE_MANIFEST_LIST_V2 = exports.MEDIATYPE_MANIFEST_V2 = exports.MEDIATYPE_MANIFEST_V1 = void 0;
|
|
4
|
+
exports.MEDIATYPE_MANIFEST_V1 = 'application/vnd.docker.distribution.manifest.v1+prettyjws';
|
|
5
|
+
exports.MEDIATYPE_MANIFEST_V2 = 'application/vnd.docker.distribution.manifest.v2+json';
|
|
6
|
+
exports.MEDIATYPE_MANIFEST_LIST_V2 = 'application/vnd.docker.distribution.manifest.list.v2+json';
|
|
7
|
+
function getManifest(modem, repository) {
|
|
8
|
+
const optsf = {
|
|
9
|
+
path: `/distribution/${repository}/json?`,
|
|
10
|
+
method: 'GET',
|
|
11
|
+
statusCodes: {
|
|
12
|
+
200: true,
|
|
13
|
+
403: 'not found or not authorized',
|
|
14
|
+
500: 'server error',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
modem.dial(optsf, (err, data) => {
|
|
19
|
+
if (err) {
|
|
20
|
+
return reject(err);
|
|
21
|
+
}
|
|
22
|
+
resolve(data);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.getManifest = getManifest;
|
|
27
|
+
//# sourceMappingURL=manifests.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifests.js","sourceRoot":"","sources":["../../lib/multibuild/manifests.ts"],"names":[],"mappings":";;;AAoBa,QAAA,qBAAqB,GACjC,2DAA2D,CAAC;AAChD,QAAA,qBAAqB,GACjC,sDAAsD,CAAC;AAC3C,QAAA,0BAA0B,GACtC,2DAA2D,CAAC;AAmB7D,SAAgB,WAAW,CAC1B,KAAkB,EAClB,UAAkB;IAElB,MAAM,KAAK,GAAG;QACb,IAAI,EAAE,iBAAiB,UAAU,QAAQ;QACzC,MAAM,EAAE,KAAK;QACb,WAAW,EAAE;YACZ,GAAG,EAAE,IAAI;YACT,GAAG,EAAE,6BAA6B;YAClC,GAAG,EAAE,cAAc;SACnB;KACD,CAAC;IAEF,OAAO,IAAI,OAAO,CAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC3D,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,GAAY,EAAE,IAAyB,EAAE,EAAE;YAC7D,IAAI,GAAG,EAAE;gBACR,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC;aACnB;YACD,OAAO,CAAC,IAAI,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC;AAtBD,kCAsBC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toNativePath = exports.toPosixPath = exports.posixContains = exports.contains = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const nativeSepRE = new RegExp(_.escapeRegExp(path.sep), 'g');
|
|
7
|
+
const nativeDotDotRE = new RegExp('^\\.\\.$|\\.\\.' + _.escapeRegExp(path.sep));
|
|
8
|
+
const contains = (path1, path2) => {
|
|
9
|
+
path1 = path.normalize(path1);
|
|
10
|
+
path2 = path.normalize(path2);
|
|
11
|
+
return !nativeDotDotRE.test(path.relative(path1, path2));
|
|
12
|
+
};
|
|
13
|
+
exports.contains = contains;
|
|
14
|
+
const posixContains = (path1, path2) => {
|
|
15
|
+
path1 = path.posix.normalize(path1);
|
|
16
|
+
path2 = path.posix.normalize(path2);
|
|
17
|
+
return !/^\.\.$|\.\.\//.test(path.posix.relative(path1, path2));
|
|
18
|
+
};
|
|
19
|
+
exports.posixContains = posixContains;
|
|
20
|
+
function toPosixPath(p) {
|
|
21
|
+
return p.replace(nativeSepRE, '/');
|
|
22
|
+
}
|
|
23
|
+
exports.toPosixPath = toPosixPath;
|
|
24
|
+
function toNativePath(p) {
|
|
25
|
+
return p.replace(/\//g, path.sep);
|
|
26
|
+
}
|
|
27
|
+
exports.toNativePath = toNativePath;
|
|
28
|
+
//# sourceMappingURL=path-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../../lib/multibuild/path-utils.ts"],"names":[],"mappings":";;;AAgBA,4BAA4B;AAC5B,6BAA6B;AAE7B,MAAM,WAAW,GAAG,IAAI,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC;AAC9D,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AASzE,MAAM,QAAQ,GAAG,CAAC,KAAa,EAAE,KAAa,EAAW,EAAE;IAEjE,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAI9B,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAC1D,CAAC,CAAC;AARW,QAAA,QAAQ,YAQnB;AAQK,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,KAAa,EAAW,EAAE;IAEtE,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACpC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAIpC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AACjE,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB;AASF,SAAgB,WAAW,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;AACpC,CAAC;AAFD,kCAEC;AAED,SAAgB,YAAY,CAAC,CAAS;IACrC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;AACnC,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { RegistrySecretValidationError } from './errors';
|
|
2
|
+
export interface RegistrySecrets {
|
|
3
|
+
[registryAddress: string]: {
|
|
4
|
+
username: string;
|
|
5
|
+
password: string;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
export declare class RegistrySecretValidator {
|
|
9
|
+
private registrySecretJsonSchema;
|
|
10
|
+
private validator;
|
|
11
|
+
private validateFunction;
|
|
12
|
+
validateRegistrySecrets(parsedJson: unknown): RegistrySecrets;
|
|
13
|
+
parseRegistrySecrets(json: string): RegistrySecrets;
|
|
14
|
+
}
|
|
15
|
+
export declare function addCanonicalDockerHubEntry(registryconfig: RegistrySecrets): void;
|
|
16
|
+
export declare function getAuthConfigObj(imageName: string, registryconfig: RegistrySecrets): Promise<RegistrySecrets | {}>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAuthConfigObj = exports.addCanonicalDockerHubEntry = exports.RegistrySecretValidator = exports.RegistrySecretValidationError = void 0;
|
|
4
|
+
const ajv = require("ajv");
|
|
5
|
+
const errors_1 = require("./errors");
|
|
6
|
+
var errors_2 = require("./errors");
|
|
7
|
+
Object.defineProperty(exports, "RegistrySecretValidationError", { enumerable: true, get: function () { return errors_2.RegistrySecretValidationError; } });
|
|
8
|
+
const constants_1 = require("./constants");
|
|
9
|
+
class RegistrySecretValidator {
|
|
10
|
+
constructor() {
|
|
11
|
+
this.registrySecretJsonSchema = {
|
|
12
|
+
type: 'object',
|
|
13
|
+
patternProperties: {
|
|
14
|
+
'^\\S*$': {
|
|
15
|
+
type: 'object',
|
|
16
|
+
properties: {
|
|
17
|
+
username: { type: 'string' },
|
|
18
|
+
password: { type: 'string' },
|
|
19
|
+
},
|
|
20
|
+
additionalProperties: false,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
additionalProperties: false,
|
|
24
|
+
};
|
|
25
|
+
this.validator = new ajv();
|
|
26
|
+
this.validateFunction = this.validator.compile(this.registrySecretJsonSchema);
|
|
27
|
+
}
|
|
28
|
+
validateRegistrySecrets(parsedJson) {
|
|
29
|
+
const valid = this.validateFunction(parsedJson);
|
|
30
|
+
if (!valid) {
|
|
31
|
+
throw new errors_1.RegistrySecretValidationError(this.validator.errorsText(this.validateFunction.errors));
|
|
32
|
+
}
|
|
33
|
+
return parsedJson;
|
|
34
|
+
}
|
|
35
|
+
parseRegistrySecrets(json) {
|
|
36
|
+
const secrets = JSON.parse(json);
|
|
37
|
+
return this.validateRegistrySecrets(secrets);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.RegistrySecretValidator = RegistrySecretValidator;
|
|
41
|
+
function addCanonicalDockerHubEntry(registryconfig) {
|
|
42
|
+
if (constants_1.CANONICAL_HUB_URL in registryconfig) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const hubDomains = [
|
|
46
|
+
'index.docker.io',
|
|
47
|
+
'idx.docker.io',
|
|
48
|
+
'docker.io',
|
|
49
|
+
'cloud.docker.com',
|
|
50
|
+
'hub.docker.com',
|
|
51
|
+
'docker.com',
|
|
52
|
+
];
|
|
53
|
+
outer: for (const hubDomain of hubDomains) {
|
|
54
|
+
for (const registryDomain of Object.keys(registryconfig)) {
|
|
55
|
+
if (registryDomain === '' ||
|
|
56
|
+
registryDomain.match(new RegExp(`(^|https?://)${hubDomain}($|/.*)`))) {
|
|
57
|
+
registryconfig[constants_1.CANONICAL_HUB_URL] = registryconfig[registryDomain];
|
|
58
|
+
break outer;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.addCanonicalDockerHubEntry = addCanonicalDockerHubEntry;
|
|
64
|
+
async function getAuthConfigObj(imageName, registryconfig) {
|
|
65
|
+
const { getRegistryAndName } = await Promise.resolve().then(() => require('./utils'));
|
|
66
|
+
const { registry } = getRegistryAndName(imageName);
|
|
67
|
+
if (registry) {
|
|
68
|
+
return registryconfig[registry] || {};
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
return registryconfig[constants_1.CANONICAL_HUB_URL] || {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.getAuthConfigObj = getAuthConfigObj;
|
|
75
|
+
//# sourceMappingURL=registry-secrets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-secrets.js","sourceRoot":"","sources":["../../lib/multibuild/registry-secrets.ts"],"names":[],"mappings":";;;AAuBA,2BAA2B;A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,CAAC;IACF,KAAK,EAAE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAC1C,KAAK,MAAM,cAAc,IAAI,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,EAAE;YAEzD,IACC,cAAc,KAAK,EAAE;gBACrB,cAAc,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,gBAAgB,SAAS,SAAS,CAAC,CAAC,EACnE;gBACD,cAAc,CAAC,6BAAiB,CAAC,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;gBACnE,MAAM,KAAK,CAAC;aACZ;SACD;KACD;AACF,CAAC;AA5BD,gEA4BC;AAaM,KAAK,UAAU,gBAAgB,CACrC,SAAiB,EACjB,cAA+B;IAE/B,MAAM,EAAE,kBAAkB,EAAE,GAAG,2CAAa,SAAS,EAAC,CAAC;IACvD,MAAM,EAAE,QAAQ,EAAE,GAAG,kBAAkB,CAAC,SAAS,CAAC,CAAC;IAGnD,IAAI,QAAQ,EAAE;QACb,OAAO,cAAc,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;KACtC;SAAM;QAGN,OAAO,cAAc,CAAC,6BAAiB,CAAC,IAAI,EAAE,CAAC;KAC/C;AACF,CAAC;AAfD,4CAeC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BuildTask } from './build-task';
|
|
2
|
+
import { ResolveListeners } from 'resin-bundle-resolve';
|
|
3
|
+
export { ResolveListeners };
|
|
4
|
+
export declare function resolveTask(task: BuildTask, architecture: string, deviceType: string, resolveListeners: ResolveListeners, additionalVars?: Dictionary<string>, dockerfilePreprocessHook?: (content: string) => string): BuildTask;
|
|
5
|
+
export declare function resolveDockerPlatform(balenaArchitecture: string): string;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveDockerPlatform = exports.resolveTask = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const Resolve = require("resin-bundle-resolve");
|
|
6
|
+
function resolveTask(task, architecture, deviceType, resolveListeners, additionalVars = {}, dockerfilePreprocessHook) {
|
|
7
|
+
const platform = resolveDockerPlatform(architecture);
|
|
8
|
+
if (platform) {
|
|
9
|
+
task.dockerPlatform = platform;
|
|
10
|
+
}
|
|
11
|
+
if (task.external) {
|
|
12
|
+
return task;
|
|
13
|
+
}
|
|
14
|
+
let resolveTaskPromise;
|
|
15
|
+
task.resolvedPromise = new Promise((resolve) => {
|
|
16
|
+
resolveTaskPromise = resolve;
|
|
17
|
+
});
|
|
18
|
+
const dockerfileHook = (content) => {
|
|
19
|
+
if (dockerfilePreprocessHook) {
|
|
20
|
+
task.dockerfile = dockerfilePreprocessHook(content);
|
|
21
|
+
return task.dockerfile;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
task.dockerfile = content;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const bundle = new Resolve.Bundle(task.buildStream, deviceType, architecture, dockerfileHook);
|
|
28
|
+
const resolvers = Resolve.getDefaultResolvers();
|
|
29
|
+
const listeners = _.cloneDeep(resolveListeners);
|
|
30
|
+
(listeners['resolver'] = listeners['resolver'] || []).push((resolverName) => {
|
|
31
|
+
task.projectType = resolverName;
|
|
32
|
+
task.resolved = true;
|
|
33
|
+
resolveTaskPromise();
|
|
34
|
+
});
|
|
35
|
+
(listeners['resolved-name'] = listeners['resolved-name'] || []).push((resolvedName) => {
|
|
36
|
+
task.dockerfilePath = resolvedName;
|
|
37
|
+
});
|
|
38
|
+
const templateVars = {
|
|
39
|
+
BALENA_SERVICE_NAME: task.serviceName,
|
|
40
|
+
...additionalVars,
|
|
41
|
+
};
|
|
42
|
+
task.buildStream = Resolve.resolveInput(bundle, resolvers, listeners, task.dockerfilePath, templateVars);
|
|
43
|
+
return task;
|
|
44
|
+
}
|
|
45
|
+
exports.resolveTask = resolveTask;
|
|
46
|
+
function resolveDockerPlatform(balenaArchitecture) {
|
|
47
|
+
switch (balenaArchitecture) {
|
|
48
|
+
case 'amd64':
|
|
49
|
+
return 'linux/amd64';
|
|
50
|
+
case 'i386-nlp':
|
|
51
|
+
case 'i386':
|
|
52
|
+
return 'linux/386';
|
|
53
|
+
case 'aarch64':
|
|
54
|
+
return 'linux/arm64/v8';
|
|
55
|
+
case 'armv7hf':
|
|
56
|
+
return 'linux/arm/v7';
|
|
57
|
+
case 'rpi':
|
|
58
|
+
return 'linux/arm/v6';
|
|
59
|
+
}
|
|
60
|
+
return '';
|
|
61
|
+
}
|
|
62
|
+
exports.resolveDockerPlatform = resolveDockerPlatform;
|
|
63
|
+
//# sourceMappingURL=resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../lib/multibuild/resolve.ts"],"names":[],"mappings":";;;AAgBA,4BAA4B;AAC5B,gDAAgD;AAsBhD,SAAgB,WAAW,CAC1B,IAAe,EACf,YAAoB,EACpB,UAAkB,EAClB,gBAAkC,EAClC,iBAAqC,EAAE,EACvC,wBAAsD;IAGtD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IACrD,IAAI,QAAQ,EAAE;QACb,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;KAC/B;IAED,IAAI,IAAI,CAAC,QAAQ,EAAE;QAElB,OAAO,IAAI,CAAC;KACZ;IAID,IAAI,kBAA8B,CAAC;IACnC,IAAI,CAAC,eAAe,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9C,kBAAkB,GAAG,OAAO,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,CAAC,OAAe,EAAE,EAAE;QAC1C,IAAI,wBAAwB,EAAE;YAC7B,IAAI,CAAC,UAAU,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAC;YACpD,OAAO,IAAI,CAAC,UAAU,CAAC;SACvB;aAAM;YACN,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC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,OAAO,cAAc,CAAC;QACvB,KAAK,KAAK;YACT,OAAO,cAAc,CAAC;KACvB;IACD,OAAO,EAAE,CAAC;AACX,CAAC;AAfD,sDAeC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ImageDescriptor } from '@balena/compose-parse';
|
|
2
|
+
import type BuildMetadata from './build-metadata';
|
|
3
|
+
import type { BuildTask } from './build-task';
|
|
4
|
+
export declare function generateBuildTasks(images: ImageDescriptor[], buildMetadata: BuildMetadata): BuildTask[];
|
|
5
|
+
export declare function getRegistryAndName(image: string): {
|
|
6
|
+
registry: string;
|
|
7
|
+
imageName: string;
|
|
8
|
+
tagName: string;
|
|
9
|
+
digest: string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRegistryAndName = exports.generateBuildTasks = void 0;
|
|
4
|
+
const _ = require("lodash");
|
|
5
|
+
const tar = require("tar-stream");
|
|
6
|
+
function generateBuildTasks(images, buildMetadata) {
|
|
7
|
+
return _.map(images, (img) => {
|
|
8
|
+
if (_.isString(img.image)) {
|
|
9
|
+
return {
|
|
10
|
+
external: true,
|
|
11
|
+
imageName: img.image,
|
|
12
|
+
serviceName: img.serviceName,
|
|
13
|
+
resolved: false,
|
|
14
|
+
buildMetadata,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (img.image.context == null) {
|
|
19
|
+
throw new Error('Must have a context specified with a Dockerfile');
|
|
20
|
+
}
|
|
21
|
+
const { network, cache_from: cachefrom, extra_hosts: extrahosts, shm_size: shmsize, target, ...imageProps } = img.image;
|
|
22
|
+
return _.merge({
|
|
23
|
+
external: false,
|
|
24
|
+
serviceName: img.serviceName,
|
|
25
|
+
buildStream: tar.pack(),
|
|
26
|
+
resolved: false,
|
|
27
|
+
buildMetadata,
|
|
28
|
+
}, img.image.dockerfile != null
|
|
29
|
+
? { dockerfilePath: img.image.dockerfile }
|
|
30
|
+
: {}, imageProps, {
|
|
31
|
+
dockerOpts: {
|
|
32
|
+
...(cachefrom ? { cachefrom } : {}),
|
|
33
|
+
...(shmsize ? { shmsize } : {}),
|
|
34
|
+
...(target ? { target } : {}),
|
|
35
|
+
...(extrahosts ? { extrahosts } : {}),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
exports.generateBuildTasks = generateBuildTasks;
|
|
42
|
+
function getRegistryAndName(image) {
|
|
43
|
+
const match = image.match(/^(?:(localhost|.*?[.:].*?)\/)?(.+?)(?::(.*?))?(?:@(.*?))?$/);
|
|
44
|
+
if (!match) {
|
|
45
|
+
throw new Error(`Could not parse image "${image}"`);
|
|
46
|
+
}
|
|
47
|
+
const [, registry, imageName, tag, digest] = match;
|
|
48
|
+
const tagName = !digest && !tag ? 'latest' : tag;
|
|
49
|
+
const digestMatch = digest === null || digest === void 0 ? void 0 : digest.match(/^[A-Za-z][A-Za-z0-9]*(?:[-_+.][A-Za-z][A-Za-z0-9]*)*:[0-9a-f-A-F]{32,}$/);
|
|
50
|
+
if (!imageName || (digest && !digestMatch)) {
|
|
51
|
+
throw new Error('Invalid image name, expected [domain.tld/]repo/image[:tag][@digest] format');
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
registry,
|
|
55
|
+
imageName,
|
|
56
|
+
tagName,
|
|
57
|
+
digest,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
exports.getRegistryAndName = getRegistryAndName;
|
|
61
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../lib/multibuild/utils.ts"],"names":[],"mappings":";;;AAgBA,4BAA4B;AAC5B,kCAAkC;AAclC,SAAgB,kBAAkB,CACjC,MAAyB,EACzB,aAA4B;IAE5B,OAAO,CAAC,CAAC,GAAG,C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