@balena/compose-parser 0.0.2-build-setup-compose-go-1206dd03ac7e912df0da255a5bbf3d40cb932da1-1

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.
@@ -0,0 +1,289 @@
1
+ export type Dict<T> = Record<string, T>;
2
+ export type Value = string | number | null;
3
+ export type ByteValue = string;
4
+ export type DurationValue = string;
5
+ export type ListOrDict<T> = T[] | Dict<T>;
6
+ export type StringOrList = string | string[];
7
+ export type NonEmpty<T> = keyof T extends never ? never : T;
8
+ interface BlkioLimit {
9
+ path?: string;
10
+ rate?: number | ByteValue;
11
+ }
12
+ interface BlkioWeight {
13
+ path?: string;
14
+ weight?: number;
15
+ }
16
+ interface ConfigMount {
17
+ source: string;
18
+ target?: string;
19
+ uid?: string;
20
+ gid?: string;
21
+ mode?: number;
22
+ }
23
+ type Config = ConfigMount;
24
+ type Secret = ConfigMount;
25
+ interface DependsOnConfig {
26
+ condition: string;
27
+ restart?: boolean;
28
+ required?: boolean;
29
+ }
30
+ export interface DevicesConfig {
31
+ source: string;
32
+ target: string;
33
+ permissions: string;
34
+ }
35
+ interface EnvFileConfig {
36
+ path: string;
37
+ required?: boolean;
38
+ format?: string;
39
+ }
40
+ interface GPUConfig {
41
+ driver?: string;
42
+ count?: number;
43
+ device_ids?: string[];
44
+ options?: Dict<string>;
45
+ }
46
+ interface LifecycleHook {
47
+ command: string[];
48
+ user?: string;
49
+ privileged?: boolean;
50
+ working_dir?: string;
51
+ environment?: Dict<string>;
52
+ }
53
+ interface PortConfig {
54
+ name?: string;
55
+ target?: number;
56
+ host_ip?: string;
57
+ published?: string;
58
+ protocol?: string;
59
+ app_protocol?: string;
60
+ mode?: string;
61
+ }
62
+ interface Ulimit {
63
+ soft: number;
64
+ hard: number;
65
+ }
66
+ interface ServiceVolumeBase {
67
+ type: string;
68
+ source?: string;
69
+ target?: string;
70
+ read_only?: boolean;
71
+ consistency?: string;
72
+ }
73
+ interface ServiceBindMount extends ServiceVolumeBase {
74
+ type: 'bind';
75
+ bind: {
76
+ propagation?: string;
77
+ create_host_path?: boolean;
78
+ selinux?: string;
79
+ };
80
+ }
81
+ interface ServiceVolumeMount extends ServiceVolumeBase {
82
+ type: 'volume';
83
+ volume: {
84
+ nocopy?: boolean;
85
+ subpath?: boolean;
86
+ };
87
+ }
88
+ interface ServiceTmpfsMount extends ServiceVolumeBase {
89
+ type: 'tmpfs';
90
+ tmpfs: {
91
+ size?: number | ByteValue;
92
+ mode?: number;
93
+ };
94
+ }
95
+ interface ServiceImageMount extends ServiceVolumeBase {
96
+ type: 'image';
97
+ image: {
98
+ subpath?: string;
99
+ };
100
+ }
101
+ export type ServiceVolumeConfig = ServiceBindMount | ServiceVolumeMount | ServiceTmpfsMount | ServiceImageMount;
102
+ export interface BuildConfig {
103
+ additional_contexts?: Dict<string>;
104
+ args?: Dict<string>;
105
+ context?: string;
106
+ cache_from?: string[];
107
+ cache_to?: string[];
108
+ dockerfile?: string;
109
+ dockerfile_inline?: string;
110
+ entitlements?: string[];
111
+ extra_hosts?: string[];
112
+ isolation?: string;
113
+ labels?: Dict<string>;
114
+ network?: string;
115
+ no_cache?: boolean;
116
+ platforms?: string[];
117
+ privileged?: boolean;
118
+ pull?: boolean;
119
+ secrets?: Secret[];
120
+ ssh?: string[];
121
+ shm_size?: number | string;
122
+ tags?: string[];
123
+ target?: string;
124
+ ulimits?: Dict<number | Ulimit>;
125
+ }
126
+ export interface Service {
127
+ annotations?: Dict<string>;
128
+ attach?: boolean;
129
+ build?: BuildConfig;
130
+ blkio_config?: {
131
+ weight?: number;
132
+ weight_device?: BlkioWeight[];
133
+ device_read_bps?: BlkioLimit[];
134
+ device_write_bps?: BlkioLimit[];
135
+ device_read_iops?: BlkioLimit[];
136
+ device_write_iops?: BlkioLimit[];
137
+ };
138
+ cpu_count?: number;
139
+ cpu_percent?: number;
140
+ cpu_shares?: number | string;
141
+ cpu_period?: number | string;
142
+ cpu_quota?: number | string;
143
+ cpu_rt_runtime?: number | string;
144
+ cpu_rt_period?: number | string;
145
+ cap_add?: string[];
146
+ cap_drop?: string[];
147
+ cpus?: string;
148
+ cpuset?: string;
149
+ cgroup?: string;
150
+ cgroup_parent?: string;
151
+ command?: string[];
152
+ configs?: Config[];
153
+ container_name?: string;
154
+ credential_spec?: Dict<string>;
155
+ depends_on?: string[] | Dict<DependsOnConfig>;
156
+ deploy?: Dict<any>;
157
+ develop?: Array<{
158
+ watch: any;
159
+ }>;
160
+ device_cgroup_rules?: string[];
161
+ devices?: string[] | DevicesConfig[];
162
+ dns?: string[];
163
+ dns_opt?: string[];
164
+ dns_search?: string[];
165
+ domainname?: string;
166
+ entrypoint?: string[];
167
+ env_file?: Array<string | EnvFileConfig>;
168
+ environment?: Dict<string>;
169
+ expose?: string[];
170
+ external_links?: string[];
171
+ extra_hosts?: string[];
172
+ gpus?: Array<NonEmpty<GPUConfig>>;
173
+ group_add?: string[];
174
+ healthcheck?: NonEmpty<{
175
+ test?: string[];
176
+ disable?: boolean;
177
+ retries?: number;
178
+ interval?: DurationValue;
179
+ start_period?: DurationValue;
180
+ start_interval?: DurationValue;
181
+ timeout?: DurationValue;
182
+ }>;
183
+ hostname?: string;
184
+ image?: string;
185
+ init?: boolean;
186
+ ipc?: string;
187
+ isolation?: string;
188
+ labels?: Dict<string>;
189
+ label_file?: string[];
190
+ links?: string[];
191
+ logging?: {
192
+ driver?: string;
193
+ options?: Dict<string>;
194
+ };
195
+ mac_address?: string;
196
+ mem_limit?: number | ByteValue;
197
+ mem_reservation?: number | ByteValue;
198
+ mem_swappiness?: number;
199
+ memswap_limit?: number | ByteValue;
200
+ network_mode?: string;
201
+ networks?: Dict<null | {
202
+ aliases?: string[];
203
+ driver_opts?: Dict<string>;
204
+ interface_name?: string;
205
+ ipv4_address?: string;
206
+ ipv6_address?: string;
207
+ link_local_ips?: string[];
208
+ mac_address?: string;
209
+ gw_priority?: number;
210
+ priority?: number;
211
+ }>;
212
+ oom_kill_disable?: boolean;
213
+ oom_score_adj?: number;
214
+ pid?: string;
215
+ pids_limit?: number;
216
+ platform?: string;
217
+ ports?: Array<string | PortConfig>;
218
+ post_start?: LifecycleHook[];
219
+ pre_stop?: LifecycleHook[];
220
+ privileged?: boolean;
221
+ pull_policy?: string;
222
+ read_only?: boolean;
223
+ restart?: string;
224
+ runtime?: string;
225
+ scale?: number;
226
+ secrets?: Secret[];
227
+ security_opt?: string[];
228
+ shm_size?: number | ByteValue;
229
+ stdin_open?: boolean;
230
+ stop_grace_period?: DurationValue;
231
+ stop_signal?: string;
232
+ storage_opt?: Dict<string>;
233
+ sysctls?: Dict<string>;
234
+ tmpfs?: string[];
235
+ tty?: boolean;
236
+ ulimits?: Dict<number | Ulimit>;
237
+ user?: string;
238
+ userns_mode?: string;
239
+ uts?: string;
240
+ volumes?: string[] | ServiceVolumeConfig[];
241
+ volumes_from?: string[];
242
+ working_dir?: string;
243
+ }
244
+ export interface Network {
245
+ driver?: string;
246
+ driver_opts?: Dict<string>;
247
+ attachable?: boolean;
248
+ enable_ipv4?: boolean;
249
+ enable_ipv6?: boolean;
250
+ external?: boolean;
251
+ ipam?: {
252
+ driver?: string;
253
+ config?: Array<{
254
+ subnet?: string;
255
+ ip_range?: string;
256
+ gateway?: string;
257
+ aux_addresses?: Dict<string>;
258
+ }>;
259
+ options?: Dict<string>;
260
+ };
261
+ internal?: boolean;
262
+ labels?: Dict<string>;
263
+ name?: string;
264
+ }
265
+ export interface Volume {
266
+ driver?: string;
267
+ driver_opts?: Dict<string>;
268
+ external?: boolean;
269
+ labels?: Dict<string>;
270
+ name?: string;
271
+ }
272
+ export interface Composition {
273
+ name?: string;
274
+ version?: string;
275
+ services: Dict<Service>;
276
+ networks?: Dict<Network>;
277
+ volumes?: Dict<Volume>;
278
+ }
279
+ export type ContractObject = {
280
+ type: string;
281
+ } & {
282
+ [key: string]: any;
283
+ };
284
+ export interface ImageDescriptor {
285
+ serviceName: string;
286
+ image: string | BuildConfig;
287
+ contract?: ContractObject;
288
+ }
289
+ export {};
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../lib/types.ts"],"names":[],"mappings":""}
package/install.js ADDED
@@ -0,0 +1,42 @@
1
+ const { execSync } = require('child_process');
2
+ const fs = require('fs');
3
+
4
+ // If the SKIP_BIN is true, use the default install
5
+ // This is because we don't support Go in Flowzone, so running
6
+ // npm i there would fail outside of the Docker tests.
7
+ if (process.env.SKIP_BIN === 'true') {
8
+ console.log('Skipping binary installation');
9
+ process.exit(0);
10
+ }
11
+
12
+ // Try to fetch prebuilt binary first
13
+ try {
14
+ console.log('Attempting to fetch prebuilt binary...');
15
+ execSync('node-pre-gyp install --fallback-to-build=false', { stdio: 'inherit' });
16
+ console.log('Prebuilt binary fetched successfully');
17
+ renameBinary();
18
+ process.exit(0);
19
+ } catch (error) {
20
+ console.log('Failed to fetch prebuilt binary');
21
+ }
22
+
23
+ try {
24
+ console.log('Attempting to build from source...');
25
+ execSync('npm run build:go', { stdio: 'inherit' });
26
+ console.log('Binary built successfully');
27
+ process.exit(0);
28
+ } catch (error) {
29
+ console.log('Failed to build from source');
30
+ console.warn('All binary installation attempts have failed, please make sure Go is installed then build from source');
31
+ }
32
+
33
+ // If node-pre-gyp fetches a binary, it will be named `balena-compose-go-<platform>-<arch>`
34
+ // with platform and arch being variables. Rename it to `balena-compose-go` for consistency across platforms.
35
+ function renameBinary() {
36
+ // Find binary which starts with `balena-compose-go-`
37
+ const binaryName = fs.readdirSync('./dist/bin').find(file => file.startsWith('balena-compose-go-'));
38
+ if (binaryName) {
39
+ console.log(`Renaming binary from ${binaryName} to balena-compose-go`);
40
+ fs.renameSync(`./dist/bin/${binaryName}`, './dist/bin/balena-compose-go');
41
+ }
42
+ }