Skip to content

Commit 3ae7999

Browse files
authored
chore: clean up dependencies and eslint rules (#145)
* chore: remove regenerator runtime * chore: move to eslint-config-universe * chore: upgrade semantic release and plugins * chore: clean up jest and use default runner * chore: clean up typescript and updated types * chore: upgrade actions cache
1 parent 3007741 commit 3ae7999

12 files changed

Lines changed: 1457 additions & 767 deletions

File tree

.eslintrc.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
module.exports = {
2-
ignorePatterns: ['/build/**', 'node_modules/**'],
3-
parser: '@typescript-eslint/parser',
4-
plugins: ['@typescript-eslint', 'jest', 'prettier'],
5-
env: {
6-
es6: true,
7-
'jest/globals': true,
8-
node: true,
9-
},
10-
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
11-
rules: {
12-
'@typescript-eslint/explicit-member-accessibility': ['error', { accessibility: 'no-public' }],
13-
'@typescript-eslint/no-var-requires': 'off',
14-
'prettier/prettier': 'error',
15-
},
2+
ignorePatterns: ['build/**', 'node_modules/**'],
3+
extends: ['universe/node'],
164
};

build/setup/index.js

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function restoreCache(paths, primaryKey, restoreKeys, options) {
9797
if (core.isDebug()) {
9898
yield tar_1.listTar(archivePath, compressionMethod);
9999
}
100-
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
100+
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
101101
core.info(`Cache Size: ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B)`);
102102
yield tar_1.extractTar(archivePath, compressionMethod);
103103
core.info('Cache restored successfully');
@@ -142,18 +142,29 @@ function saveCache(paths, key, options) {
142142
const archiveFolder = yield utils.createTempDirectory();
143143
const archivePath = path.join(archiveFolder, utils.getCacheFileName(compressionMethod));
144144
core.debug(`Archive Path: ${archivePath}`);
145-
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
146-
if (core.isDebug()) {
147-
yield tar_1.listTar(archivePath, compressionMethod);
145+
try {
146+
yield tar_1.createTar(archiveFolder, cachePaths, compressionMethod);
147+
if (core.isDebug()) {
148+
yield tar_1.listTar(archivePath, compressionMethod);
149+
}
150+
const fileSizeLimit = 10 * 1024 * 1024 * 1024; // 10GB per repo limit
151+
const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath);
152+
core.debug(`File Size: ${archiveFileSize}`);
153+
if (archiveFileSize > fileSizeLimit) {
154+
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 10GB limit, not saving cache.`);
155+
}
156+
core.debug(`Saving Cache (ID: ${cacheId})`);
157+
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
148158
}
149-
const fileSizeLimit = 5 * 1024 * 1024 * 1024; // 5GB per repo limit
150-
const archiveFileSize = utils.getArchiveFileSizeIsBytes(archivePath);
151-
core.debug(`File Size: ${archiveFileSize}`);
152-
if (archiveFileSize > fileSizeLimit) {
153-
throw new Error(`Cache size of ~${Math.round(archiveFileSize / (1024 * 1024))} MB (${archiveFileSize} B) is over the 5GB limit, not saving cache.`);
159+
finally {
160+
// Try to delete the archive to save space
161+
try {
162+
yield utils.unlinkFile(archivePath);
163+
}
164+
catch (error) {
165+
core.debug(`Failed to delete archive: ${error}`);
166+
}
154167
}
155-
core.debug(`Saving Cache (ID: ${cacheId})`);
156-
yield cacheHttpClient.saveCache(cacheId, archivePath, options);
157168
return cacheId;
158169
});
159170
}
@@ -321,7 +332,7 @@ function uploadChunk(httpClient, resourceUrl, openStream, start, end) {
321332
function uploadFile(httpClient, cacheId, archivePath, options) {
322333
return __awaiter(this, void 0, void 0, function* () {
323334
// Upload Chunks
324-
const fileSize = fs.statSync(archivePath).size;
335+
const fileSize = utils.getArchiveFileSizeInBytes(archivePath);
325336
const resourceUrl = getCacheApiUrl(`caches/${cacheId.toString()}`);
326337
const fd = fs.openSync(archivePath, 'r');
327338
const uploadOptions = options_1.getUploadOptions(options);
@@ -371,7 +382,7 @@ function saveCache(cacheId, archivePath, options) {
371382
yield uploadFile(httpClient, cacheId, archivePath, options);
372383
// Commit Cache
373384
core.debug('Commiting cache');
374-
const cacheSize = utils.getArchiveFileSizeIsBytes(archivePath);
385+
const cacheSize = utils.getArchiveFileSizeInBytes(archivePath);
375386
core.info(`Cache Size: ~${Math.round(cacheSize / (1024 * 1024))} MB (${cacheSize} B)`);
376387
const commitCacheResponse = yield commitCache(httpClient, cacheId, cacheSize);
377388
if (!requestUtils_1.isSuccessStatusCode(commitCacheResponse.statusCode)) {
@@ -451,10 +462,10 @@ function createTempDirectory() {
451462
});
452463
}
453464
exports.createTempDirectory = createTempDirectory;
454-
function getArchiveFileSizeIsBytes(filePath) {
465+
function getArchiveFileSizeInBytes(filePath) {
455466
return fs.statSync(filePath).size;
456467
}
457-
exports.getArchiveFileSizeIsBytes = getArchiveFileSizeIsBytes;
468+
exports.getArchiveFileSizeInBytes = getArchiveFileSizeInBytes;
458469
function resolvePaths(patterns) {
459470
var e_1, _a;
460471
var _b;
@@ -759,7 +770,7 @@ function downloadCacheHttpClient(archiveLocation, archivePath) {
759770
const contentLengthHeader = downloadResponse.message.headers['content-length'];
760771
if (contentLengthHeader) {
761772
const expectedLength = parseInt(contentLengthHeader);
762-
const actualLength = utils.getArchiveFileSizeIsBytes(archivePath);
773+
const actualLength = utils.getArchiveFileSizeInBytes(archivePath);
763774
if (actualLength !== expectedLength) {
764775
throw new Error(`Incomplete download. Expected file size: ${expectedLength}, actual file size: ${actualLength}`);
765776
}
@@ -67770,8 +67781,8 @@ exports.toRemoteCache = exports.fromRemoteCache = exports.toLocalCache = exports
6777067781
const cache_1 = __nccwpck_require__(7799);
6777167782
const core = __importStar(__nccwpck_require__(2186));
6777267783
const toolCache = __importStar(__nccwpck_require__(7784));
67773-
const path_1 = __importDefault(__nccwpck_require__(1017));
6777467784
const os_1 = __importDefault(__nccwpck_require__(2037));
67785+
const path_1 = __importDefault(__nccwpck_require__(1017));
6777567786
/**
6777667787
* Get the path to the `expo-cli` from cache, if any.
6777767788
* Note, this cache is **NOT** shared between jobs.

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ module.exports = {
55
moduleFileExtensions: ['js', 'ts'],
66
testEnvironment: 'node',
77
testMatch: ['**/*.test.ts'],
8-
testRunner: 'jest-circus/runner',
98
transform: {
109
'^.+\\.ts$': 'ts-jest',
1110
},

ncc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
const ncc = require('@vercel/ncc');
12
const fs = require('fs');
23
const path = require('path');
3-
const ncc = require('@vercel/ncc');
44

55
build();
66

package.json

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,36 @@
1616
"homepage": "https://github.com/expo/expo-github-action#readme",
1717
"scripts": {
1818
"test": "jest",
19-
"lint": "tsc --noEmit && eslint .",
19+
"lint": "eslint .",
2020
"build": "node ncc.js",
2121
"clean": "rimraf build"
2222
},
2323
"dependencies": {
24-
"@actions/cache": "^1.0.7",
24+
"@actions/cache": "^1.0.8",
2525
"@actions/core": "^1.6.0",
2626
"@actions/exec": "^1.1.0",
2727
"@actions/io": "^1.1.1",
2828
"@actions/tool-cache": "^1.7.1",
2929
"semver": "^7.3.5"
3030
},
3131
"devDependencies": {
32-
"@semantic-release/changelog": "^5.0.1",
33-
"@semantic-release/git": "^9.0.0",
32+
"@semantic-release/changelog": "^6.0.1",
33+
"@semantic-release/git": "^10.0.1",
3434
"@tsconfig/node16": "^1.0.2",
35-
"@types/jest": "^27.0.2",
35+
"@types/jest": "^27.4.0",
3636
"@types/node": "^16.11.19",
37-
"@types/semver": "^7.3.6",
38-
"@typescript-eslint/eslint-plugin": "^5.4.0",
39-
"@typescript-eslint/parser": "^5.4.0",
37+
"@types/semver": "^7.3.9",
38+
"@typescript-eslint/eslint-plugin": "^5.9.1",
39+
"@typescript-eslint/parser": "^5.9.1",
4040
"@vercel/ncc": "^0.33.1",
41-
"conventional-changelog-conventionalcommits": "^4.6.0",
42-
"eslint": "^8.2.0",
43-
"eslint-plugin-jest": "^25.2.4",
44-
"eslint-plugin-prettier": "^4.0.0",
45-
"jest": "^27.3.1",
46-
"jest-circus": "^27.3.1",
47-
"prettier": "^2.4.1",
48-
"regenerator-runtime": "^0.13.9",
41+
"conventional-changelog-conventionalcommits": "^4.6.3",
42+
"eslint": "^8.6.0",
43+
"eslint-config-universe": "^10.0.0",
44+
"jest": "^27.4.7",
45+
"prettier": "^2.5.1",
4946
"rimraf": "^3.0.2",
50-
"semantic-release": "^17.4.4",
51-
"ts-jest": "^27.0.7",
52-
"typescript": "^4.4.4"
47+
"semantic-release": "^18.0.1",
48+
"ts-jest": "^27.1.2",
49+
"typescript": "^4.5.4"
5350
}
5451
}

src/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { ReserveCacheError, restoreCache, saveCache } from '@actions/cache';
22
import * as core from '@actions/core';
33
import * as toolCache from '@actions/tool-cache';
4-
import path from 'path';
54
import os from 'os';
5+
import path from 'path';
66

77
import type { InstallConfig } from './install';
88

tests/actions/setup.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/order,import/first */
12
import { getToolsMock, mockInput } from '../utils';
23

34
jest.mock('../../src/tools', () => getToolsMock());

tests/cache.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import os from 'os';
2-
import { join } from 'path';
31
import * as remoteCache from '@actions/cache';
42
import * as core from '@actions/core';
53
import * as toolCache from '@actions/tool-cache';
4+
import os from 'os';
5+
import { join } from 'path';
66

77
import * as cache from '../src/cache';
88
import * as utils from './utils';

tests/install.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/order,import/first */
12
const cli = { exec: jest.fn() };
23
const io = { mkdirP: jest.fn(), which: jest.fn() };
34
const cache = {

tests/packager.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { valid as validVersion } from 'semver';
2+
23
import { resolveVersion } from '../src/packager';
34

45
describe(resolveVersion, () => {

0 commit comments

Comments
 (0)