Skip to content

Commit

Permalink
refactor: update all dev dependencies to latest version (#71)
Browse files Browse the repository at this point in the history
* refactor: use node 14 as primary version to build from

* refactor: add explicit return types to all files

* refactor: update all dev dependencies to latest version

* refactor: update strict typings in test utils
  • Loading branch information
byCedric authored Dec 4, 2020
1 parent 13d7820 commit ed7f67d
Show file tree
Hide file tree
Showing 10 changed files with 658 additions and 497 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- ubuntu-latest
- windows-latest
include:
- node: 12
- node: 14
os: macos-latest
checkUpToDate: true
- node: 12
- node: 14
os: ubuntu-latest
checkUpToDate: true
steps:
Expand Down
15 changes: 9 additions & 6 deletions build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8880,9 +8880,12 @@ function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
'Content-Type': 'application/octet-stream',
'Content-Range': getContentRange(start, end)
};
yield requestUtils_1.retryHttpClientResponse(`uploadChunk (start: ${start}, end: ${end})`, () => __awaiter(this, void 0, void 0, function* () {
const uploadChunkResponse = yield requestUtils_1.retryHttpClientResponse(`uploadChunk (start: ${start}, end: ${end})`, () => __awaiter(this, void 0, void 0, function* () {
return httpClient.sendStream('PATCH', resourceUrl, openStream(), additionalHeaders);
}));
if (!requestUtils_1.isSuccessStatusCode(uploadChunkResponse.message.statusCode)) {
throw new Error(`Cache service responded with ${uploadChunkResponse.message.statusCode} during upload chunk.`);
}
});
}
function uploadFile(httpClient, cacheId, archivePath, options) {
Expand Down Expand Up @@ -22772,7 +22775,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -28992,7 +28995,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -86609,7 +86612,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -92258,7 +92261,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down Expand Up @@ -107561,7 +107564,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Expand Down
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,27 @@
"clean": "rimraf build"
},
"dependencies": {
"@actions/cache": "^1.0.3",
"@actions/cache": "^1.0.4",
"@actions/core": "^1.2.6",
"@actions/exec": "^1.0.4",
"@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.5.5",
"@actions/tool-cache": "^1.6.1",
"libnpm": "^3.0.1"
},
"devDependencies": {
"@types/jest": "^26.0.4",
"@types/node": "^12.12.49",
"@typescript-eslint/eslint-plugin": "^3.6.1",
"@typescript-eslint/parser": "^3.6.1",
"@types/jest": "^26.0.16",
"@types/node": "^14.14.10",
"@typescript-eslint/eslint-plugin": "^4.9.0",
"@typescript-eslint/parser": "^4.9.0",
"@zeit/ncc": "^0.22.3",
"eslint": "^7.4.0",
"eslint-plugin-jest": "^23.18.0",
"husky": "^4.2.5",
"jest": "^26.0.1",
"jest-circus": "^26.1.0",
"eslint": "^7.14.0",
"eslint-plugin-jest": "^24.1.3",
"husky": "^4.3.0",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"rimraf": "^3.0.2",
"ts-jest": "^26.1.2",
"typescript": "^3.9.6"
"ts-jest": "^26.4.4",
"typescript": "^4.1.2"
},
"husky": {
"hooks": {
Expand Down
10 changes: 5 additions & 5 deletions src/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import os from 'os';
*
* @see https://github.com/actions/toolkit/issues/47
*/
export async function fromLocalCache(version: string) {
export async function fromLocalCache(version: string): Promise<string | undefined> {
return toolCache.find('expo-cli', version);
}

Expand All @@ -20,15 +20,15 @@ export async function fromLocalCache(version: string) {
*
* @see https://github.com/actions/toolkit/issues/47
*/
export async function toLocalCache(root: string, version: string) {
export async function toLocalCache(root: string, version: string): Promise<string> {
return toolCache.cacheDir(root, 'expo-cli', version);
}

/**
* Download the remotely stored `expo-cli` from cache, if any.
* Note, this cache is shared between jobs.
*/
export async function fromRemoteCache(version: string, packager: string, customCacheKey?: string) {
export async function fromRemoteCache(version: string, packager: string, customCacheKey?: string): Promise<string | undefined> {
// see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
const target = path.join(process.env['RUNNER_TOOL_CACHE'] || '', 'expo-cli', version, os.arch());
const cacheKey = customCacheKey || getRemoteKey(version, packager);
Expand All @@ -43,7 +43,7 @@ export async function fromRemoteCache(version: string, packager: string, customC
* Store the root of `expo-cli` in the remote cache, for future reuse.
* Note, this cache is shared between jobs.
*/
export async function toRemoteCache(source: string, version: string, packager: string, customCacheKey?: string) {
export async function toRemoteCache(source: string, version: string, packager: string, customCacheKey?: string): Promise<void> {
const cacheKey = customCacheKey || getRemoteKey(version, packager);

try {
Expand All @@ -61,6 +61,6 @@ export async function toRemoteCache(source: string, version: string, packager: s
/**
* Get the cache key to use when (re)storing the Expo CLI from remote cache.
*/
function getRemoteKey(version: string, packager: string) {
function getRemoteKey(version: string, packager: string): string {
return `expo-cli-${process.platform}-${os.arch()}-${packager}-${version}`;
}
6 changes: 3 additions & 3 deletions src/expo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AuthOptions = {
* This step is required for publishing and building new apps.
* It uses the `EXPO_CLI_PASSWORD` environment variable for improved security.
*/
export async function authWithCredentials(username?: string, password?: string) {
export async function authWithCredentials(username?: string, password?: string): Promise<void> {
if (!username || !password) {
return core.info('Skipping authentication: `expo-username` and/or `expo-password` not set...');
}
Expand All @@ -35,7 +35,7 @@ export async function authWithCredentials(username?: string, password?: string)
*
* @see https://github.com/actions/toolkit/blob/905b2c7b0681b11056141a60055f1ba77358b7e9/packages/core/src/core.ts#L39
*/
export async function authWithToken(token?: string) {
export async function authWithToken(token?: string): Promise<void> {
if (!token) {
return core.info('Skipping authentication: `expo-token` not set...');
}
Expand All @@ -57,7 +57,7 @@ export async function authWithToken(token?: string) {
* Authenticate with Expo using either the token or username/password method.
* If both of them are set, token has priority.
*/
export function authenticate(options: AuthOptions) {
export function authenticate(options: AuthOptions): Promise<void> {
if (options.token) {
return authWithToken(options.token);
}
Expand Down
6 changes: 3 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type InstallConfig = {
* This uses the npm registry and accepts latest, dist-tags or version ranges.
* It's used to determine the cached version of `expo-cli`.
*/
export async function resolve(version: string) {
export async function resolve(version: string): Promise<string> {
return (await registry.manifest(`expo-cli@${version}`)).version;
}

Expand All @@ -28,7 +28,7 @@ export async function resolve(version: string) {
* Here you can provide any semver range or dist tag used in the registry.
* It returns the path where Expo is installed.
*/
export async function install(config: InstallConfig) {
export async function install(config: InstallConfig): Promise<string> {
const exact = await resolve(config.version);
let root: string | undefined = await fromLocalCache(exact);

Expand All @@ -54,7 +54,7 @@ export async function install(config: InstallConfig) {
* Install `expo-cli`, by version, using npm or yarn.
* It creates a temporary directory to store all required files.
*/
export async function fromPackager(version: string, packager: string) {
export async function fromPackager(version: string, packager: string): Promise<string> {
const root = process.env['RUNNER_TEMP'] || '';
const tool = await io.which(packager);

Expand Down
2 changes: 1 addition & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { authenticate } from './expo';
import { install, InstallConfig } from './install';
import { patchWatchers } from './system';

export async function run() {
export async function run(): Promise<void> {
const config: InstallConfig = {
version: getInput('expo-version') || 'latest',
packager: getInput('expo-packager') || 'yarn',
Expand Down
2 changes: 1 addition & 1 deletion src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as cli from '@actions/exec';
*
* @see https://github.com/expo/expo-github-action/issues/20
*/
export async function patchWatchers() {
export async function patchWatchers(): Promise<void> {
if (process.platform !== 'linux') {
return core.info('Skipping patch for watchers, not running on Linux...');
}
Expand Down
8 changes: 4 additions & 4 deletions tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ const originalPlatform = process.platform;
* Change the node platform for testing purposes.
* With this you can fake the `process.platform`.
*/
export function setPlatform(platform: NodeJS.Platform) {
export function setPlatform(platform: NodeJS.Platform): void {
Object.defineProperty(process, 'platform', { value: platform });
}

/**
* Revert the platform to the original one.
*/
export function restorePlatform() {
export function restorePlatform(): void {
setPlatform(originalPlatform);
}

Expand All @@ -22,13 +22,13 @@ const originalEnv = { ...process.env };
/**
* Change the environment variable for testing purposes.
*/
export function setEnv(name: string, value: string) {
export function setEnv(name: string, value: string): void {
process.env[name] = value;
}

/**
* Revert the environment variable changes.
*/
export function restoreEnv() {
export function restoreEnv(): void {
process.env = originalEnv;
}
Loading

0 comments on commit ed7f67d

Please sign in to comment.