Skip to content

Commit 75b743c

Browse files
authored
refactor: group output by steps for readability (#70)
1 parent 187c4ad commit 75b743c

6 files changed

Lines changed: 40 additions & 17 deletions

File tree

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ module.exports = {
2222
'@typescript-eslint/indent': ['error', 'tab'],
2323
'@typescript-eslint/no-non-null-assertion': 'off',
2424
'@typescript-eslint/no-use-before-define': 'off',
25+
'@typescript-eslint/no-explicit-any': 'off',
2526
},
2627
};

build/index.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14098,21 +14098,24 @@ const install_1 = __webpack_require__(655);
1409814098
const system_1 = __webpack_require__(913);
1409914099
function run() {
1410014100
return __awaiter(this, void 0, void 0, function* () {
14101-
const path = yield install_1.install({
14101+
const config = {
1410214102
version: core_1.getInput('expo-version') || 'latest',
1410314103
packager: core_1.getInput('expo-packager') || 'yarn',
1410414104
cache: (core_1.getInput('expo-cache') || 'false') === 'true',
1410514105
cacheKey: core_1.getInput('expo-cache-key') || undefined,
14106-
});
14106+
};
14107+
const path = yield core_1.group(config.cache
14108+
? `Installing Expo CLI from cache or with ${config.packager}`
14109+
: `Installing Expo CLI with ${config.packager}`, () => install_1.install(config));
1410714110
core_1.addPath(path);
14108-
yield expo_1.authenticate({
14111+
yield core_1.group('Checking current authenticated account', () => expo_1.authenticate({
1410914112
token: core_1.getInput('expo-token') || undefined,
1411014113
username: core_1.getInput('expo-username') || undefined,
1411114114
password: core_1.getInput('expo-password') || undefined,
14112-
});
14115+
}));
1411314116
const shouldPatchWatchers = core_1.getInput('expo-patch-watchers') || 'true';
1411414117
if (shouldPatchWatchers !== 'false') {
14115-
yield system_1.patchWatchers();
14118+
yield core_1.group('Patching system watchers for the `ENOSPC` error', () => system_1.patchWatchers());
1411614119
}
1411714120
});
1411814121
}
@@ -22837,6 +22840,7 @@ function authenticate(options) {
2283722840
return authWithCredentials(options.username, options.password);
2283822841
}
2283922842
core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
22843+
return Promise.resolve();
2284022844
}
2284122845
exports.authenticate = authenticate;
2284222846

src/expo.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@ export function authenticate(options: AuthOptions) {
6767
}
6868

6969
core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
70+
return Promise.resolve();
7071
}

src/install.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { fromLocalCache, fromRemoteCache, toLocalCache, toRemoteCache } from './
77
// eslint-disable-next-line @typescript-eslint/no-var-requires
88
const registry = require('libnpm');
99

10-
type InstallConfig = {
10+
export type InstallConfig = {
1111
version: string;
1212
packager: string;
1313
cache?: boolean;

src/run.ts

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
1-
import { addPath, getInput } from '@actions/core';
1+
import { addPath, getInput, group } from '@actions/core';
22
import { authenticate } from './expo';
3-
import { install } from './install';
3+
import { install, InstallConfig } from './install';
44
import { patchWatchers } from './system';
55

66
export async function run() {
7-
const path = await install({
7+
const config: InstallConfig = {
88
version: getInput('expo-version') || 'latest',
99
packager: getInput('expo-packager') || 'yarn',
1010
cache: (getInput('expo-cache') || 'false') === 'true',
1111
cacheKey: getInput('expo-cache-key') || undefined,
12-
});
12+
};
13+
14+
const path = await group(
15+
config.cache
16+
? `Installing Expo CLI from cache or with ${config.packager}`
17+
: `Installing Expo CLI with ${config.packager}`,
18+
() => install(config),
19+
);
1320

1421
addPath(path);
1522

16-
await authenticate({
17-
token: getInput('expo-token') || undefined,
18-
username: getInput('expo-username') || undefined,
19-
password: getInput('expo-password') || undefined,
20-
});
23+
await group(
24+
'Checking current authenticated account',
25+
() => authenticate({
26+
token: getInput('expo-token') || undefined,
27+
username: getInput('expo-username') || undefined,
28+
password: getInput('expo-password') || undefined,
29+
}),
30+
);
2131

2232
const shouldPatchWatchers = getInput('expo-patch-watchers') || 'true';
2333

2434
if (shouldPatchWatchers !== 'false') {
25-
await patchWatchers();
35+
await group(
36+
'Patching system watchers for the `ENOSPC` error',
37+
() => patchWatchers(),
38+
);
2639
}
2740
}

tests/run.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
const core = { addPath: jest.fn(), getInput: jest.fn() };
1+
const core = {
2+
addPath: jest.fn(),
3+
getInput: jest.fn(),
4+
group: (message: string, action: () => Promise<any>) => action()
5+
};
26
const exec = { exec: jest.fn() };
37
const expo = { authenticate: jest.fn() };
48
const install = { install: jest.fn() };

0 commit comments

Comments
 (0)