-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
54 lines (43 loc) · 1.58 KB
/
index.js
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
import {defaultTo} from 'lodash-es';
import AggregateError from 'aggregate-error';
import verifyPluginConfig from './lib/verify-config.js';
import verifyPodAuth from './lib/verify-auth.js';
import verifyCliInstalled from './lib/verify-cli-installed.js';
import verifyPodLint from './lib/verify-pod-lint.js';
import preparePod from './lib/prepare.js';
import publishPod from './lib/publish.js';
// Let verified;
let prepared;
export async function verifyConditions(pluginConfig, context) {
// Set default values for config
pluginConfig.podLint = defaultTo(pluginConfig.podLint, true);
pluginConfig.podLintArgs = defaultTo(pluginConfig.podLintArgs, '');
pluginConfig.podPushArgs = defaultTo(pluginConfig.podPushArgs, '');
const errors = []
errors.push(...await verifyPluginConfig(pluginConfig, context));
try {
// 1. Verify `pod` command exists
await verifyCliInstalled(pluginConfig, context);
// 2. Verify `COCOAPODS_TRUNK_TOKEN` environment variable exists
// 3. Verify `pod trunk me` is successful.
await verifyPodAuth(pluginConfig, context);
// 4. Verify `pod lib lint` is successful
await verifyPodLint(pluginConfig, context);
} catch (error) {
errors.push(error);
}
if (errors.length > 0) {
throw new AggregateError(errors);
}
// Verified = true;
}
export async function prepare(pluginConfig, context) {
await preparePod(pluginConfig, context);
prepared = true;
}
export async function publish(pluginConfig, context) {
if (!prepared) {
await preparePod(pluginConfig, context);
}
return publishPod(pluginConfig, context);
}