Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: group output by steps for readability #70

Merged
merged 1 commit into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ module.exports = {
'@typescript-eslint/indent': ['error', 'tab'],
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-use-before-define': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
};
14 changes: 9 additions & 5 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14098,21 +14098,24 @@ const install_1 = __webpack_require__(655);
const system_1 = __webpack_require__(913);
function run() {
return __awaiter(this, void 0, void 0, function* () {
const path = yield install_1.install({
const config = {
version: core_1.getInput('expo-version') || 'latest',
packager: core_1.getInput('expo-packager') || 'yarn',
cache: (core_1.getInput('expo-cache') || 'false') === 'true',
cacheKey: core_1.getInput('expo-cache-key') || undefined,
});
};
const path = yield core_1.group(config.cache
? `Installing Expo CLI from cache or with ${config.packager}`
: `Installing Expo CLI with ${config.packager}`, () => install_1.install(config));
core_1.addPath(path);
yield expo_1.authenticate({
yield core_1.group('Checking current authenticated account', () => expo_1.authenticate({
token: core_1.getInput('expo-token') || undefined,
username: core_1.getInput('expo-username') || undefined,
password: core_1.getInput('expo-password') || undefined,
});
}));
const shouldPatchWatchers = core_1.getInput('expo-patch-watchers') || 'true';
if (shouldPatchWatchers !== 'false') {
yield system_1.patchWatchers();
yield core_1.group('Patching system watchers for the `ENOSPC` error', () => system_1.patchWatchers());
}
});
}
Expand Down Expand Up @@ -22837,6 +22840,7 @@ function authenticate(options) {
return authWithCredentials(options.username, options.password);
}
core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
return Promise.resolve();
}
exports.authenticate = authenticate;

Expand Down
1 change: 1 addition & 0 deletions src/expo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,5 @@ export function authenticate(options: AuthOptions) {
}

core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
return Promise.resolve();
}
2 changes: 1 addition & 1 deletion src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { fromLocalCache, fromRemoteCache, toLocalCache, toRemoteCache } from './
// eslint-disable-next-line @typescript-eslint/no-var-requires
const registry = require('libnpm');

type InstallConfig = {
export type InstallConfig = {
version: string;
packager: string;
cache?: boolean;
Expand Down
33 changes: 23 additions & 10 deletions src/run.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
import { addPath, getInput } from '@actions/core';
import { addPath, getInput, group } from '@actions/core';
import { authenticate } from './expo';
import { install } from './install';
import { install, InstallConfig } from './install';
import { patchWatchers } from './system';

export async function run() {
const path = await install({
const config: InstallConfig = {
version: getInput('expo-version') || 'latest',
packager: getInput('expo-packager') || 'yarn',
cache: (getInput('expo-cache') || 'false') === 'true',
cacheKey: getInput('expo-cache-key') || undefined,
});
};

const path = await group(
config.cache
? `Installing Expo CLI from cache or with ${config.packager}`
: `Installing Expo CLI with ${config.packager}`,
() => install(config),
);

addPath(path);

await authenticate({
token: getInput('expo-token') || undefined,
username: getInput('expo-username') || undefined,
password: getInput('expo-password') || undefined,
});
await group(
'Checking current authenticated account',
() => authenticate({
token: getInput('expo-token') || undefined,
username: getInput('expo-username') || undefined,
password: getInput('expo-password') || undefined,
}),
);

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

if (shouldPatchWatchers !== 'false') {
await patchWatchers();
await group(
'Patching system watchers for the `ENOSPC` error',
() => patchWatchers(),
);
}
}
6 changes: 5 additions & 1 deletion tests/run.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
const core = { addPath: jest.fn(), getInput: jest.fn() };
const core = {
addPath: jest.fn(),
getInput: jest.fn(),
group: (message: string, action: () => Promise<any>) => action()
};
const exec = { exec: jest.fn() };
const expo = { authenticate: jest.fn() };
const install = { install: jest.fn() };
Expand Down