refactor: simplify typescript config with community config (#94)

This commit is contained in:
Cedric van Putten authored and GitHub committed 2021-06-17 13:05:01 +02:00
1 parent 6bc0bedbc7
commit da4e75428b
4 files changed
+130 -190

No files matched your search

+121 -181
View File
@@ -16618,44 +16618,33 @@ module.exports = ["389-exception","Autoconf-exception-2.0","Autoconf-exception-3
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.run = void 0;
const core_1 = __webpack_require__(470);
const install_1 = __webpack_require__(655);
const tools_1 = __webpack_require__(534);
function run() {
return __awaiter(this, void 0, void 0, function* () {
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,
};
// Resolve the exact requested Expo CLI version
config.version = yield tools_1.resolveVersion(config.version);
const path = yield core_1.group(config.cache
? `Installing Expo CLI (${config.version}) from cache or with ${config.packager}`
: `Installing Expo CLI (${config.version}) with ${config.packager}`, () => install_1.install(config));
core_1.addPath(path);
yield core_1.group('Checking current authenticated account', () => tools_1.maybeAuthenticate({
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 core_1.group('Patching system watchers for the `ENOSPC` error', () => tools_1.maybePatchWatchers());
}
});
async function run() {
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,
};
// Resolve the exact requested Expo CLI version
config.version = await tools_1.resolveVersion(config.version);
const path = await core_1.group(config.cache
? `Installing Expo CLI (${config.version}) from cache or with ${config.packager}`
: `Installing Expo CLI (${config.version}) with ${config.packager}`, () => install_1.install(config));
core_1.addPath(path);
await core_1.group('Checking current authenticated account', () => tools_1.maybeAuthenticate({
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') {
await core_1.group('Patching system watchers for the `ENOSPC` error', () => tools_1.maybePatchWatchers());
}
}
exports.run = run;
@@ -78228,15 +78217,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
@@ -78252,37 +78232,33 @@ const registry = __webpack_require__(52);
* This uses the npm registry and accepts latest, dist-tags or version ranges.
* It's used to determine the cached version of `expo-cli`.
*/
function resolveVersion(version) {
return __awaiter(this, void 0, void 0, function* () {
return (yield registry.manifest(`expo-cli@${version}`)).version;
});
async function resolveVersion(version) {
return (await registry.manifest(`expo-cli@${version}`)).version;
}
exports.resolveVersion = resolveVersion;
/**
* Authenticate with Expo using either the token or username/password method.
* If both of them are set, token has priority.
*/
function maybeAuthenticate(options = {}) {
return __awaiter(this, void 0, void 0, function* () {
// github actions toolkit will handle commands with `.cmd` on windows, we need that
const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo';
if (options.token) {
yield cli.exec(bin, ['whoami'], {
env: Object.assign(Object.assign({}, process.env), { EXPO_TOKEN: options.token }),
});
return core.exportVariable('EXPO_TOKEN', options.token);
async function maybeAuthenticate(options = {}) {
// github actions toolkit will handle commands with `.cmd` on windows, we need that
const bin = process.platform === 'win32' ? 'expo.cmd' : 'expo';
if (options.token) {
await cli.exec(bin, ['whoami'], {
env: { ...process.env, EXPO_TOKEN: options.token },
});
return core.exportVariable('EXPO_TOKEN', options.token);
}
if (options.username || options.password) {
if (!options.username || !options.password) {
return core.info('Skipping authentication: `expo-username` and/or `expo-password` not set...');
}
if (options.username || options.password) {
if (!options.username || !options.password) {
return core.info('Skipping authentication: `expo-username` and/or `expo-password` not set...');
}
yield cli.exec(bin, ['login', `--username=${options.username}`], {
env: Object.assign(Object.assign({}, process.env), { EXPO_CLI_PASSWORD: options.password }),
});
return;
}
core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
});
await cli.exec(bin, ['login', `--username=${options.username}`], {
env: { ...process.env, EXPO_CLI_PASSWORD: options.password },
});
return;
}
core.info('Skipping authentication: `expo-token`, `expo-username`, and/or `expo-password` not set...');
}
exports.maybeAuthenticate = maybeAuthenticate;
/**
@@ -78292,24 +78268,22 @@ exports.maybeAuthenticate = maybeAuthenticate;
*
* @see https://github.com/expo/expo-github-action/issues/20
*/
function maybePatchWatchers() {
return __awaiter(this, void 0, void 0, function* () {
if (process.platform !== 'linux') {
return core.info('Skipping patch for watchers, not running on Linux...');
}
core.info('Patching system watchers for the `ENOSPC` error...');
try {
// see https://github.com/expo/expo-cli/issues/277#issuecomment-452685177
yield cli.exec('sudo sysctl fs.inotify.max_user_instances=524288');
yield cli.exec('sudo sysctl fs.inotify.max_user_watches=524288');
yield cli.exec('sudo sysctl fs.inotify.max_queued_events=524288');
yield cli.exec('sudo sysctl -p');
}
catch (_a) {
core.warning("Looks like we can't patch watchers/inotify limits, you might encouter the `ENOSPC` error.");
core.warning('For more info, https://github.com/expo/expo-github-action/issues/20');
}
});
async function maybePatchWatchers() {
if (process.platform !== 'linux') {
return core.info('Skipping patch for watchers, not running on Linux...');
}
core.info('Patching system watchers for the `ENOSPC` error...');
try {
// see https://github.com/expo/expo-cli/issues/277#issuecomment-452685177
await cli.exec('sudo sysctl fs.inotify.max_user_instances=524288');
await cli.exec('sudo sysctl fs.inotify.max_user_watches=524288');
await cli.exec('sudo sysctl fs.inotify.max_queued_events=524288');
await cli.exec('sudo sysctl -p');
}
catch {
core.warning("Looks like we can't patch watchers/inotify limits, you might encouter the `ENOSPC` error.");
core.warning('For more info, https://github.com/expo/expo-github-action/issues/20');
}
}
exports.maybePatchWatchers = maybePatchWatchers;
/**
@@ -78317,31 +78291,27 @@ exports.maybePatchWatchers = maybePatchWatchers;
* If there is, create a warning for people to upgrade their workflow.
* Because this introduces additional requests, it should only be executed when necessary.
*/
function maybeWarnForUpdate() {
return __awaiter(this, void 0, void 0, function* () {
const latest = yield resolveVersion('latest');
const current = yield resolveVersion(core.getInput('expo-version') || 'latest');
if (semver_1.default.diff(latest, current) === 'major') {
core.warning(`There is a new major version available of the Expo CLI (${latest})`);
core.warning(`If you run into issues, try upgrading your workflow to "expo-version: ${semver_1.default.major(latest)}.x"`);
}
});
async function maybeWarnForUpdate() {
const latest = await resolveVersion('latest');
const current = await resolveVersion(core.getInput('expo-version') || 'latest');
if (semver_1.default.diff(latest, current) === 'major') {
core.warning(`There is a new major version available of the Expo CLI (${latest})`);
core.warning(`If you run into issues, try upgrading your workflow to "expo-version: ${semver_1.default.major(latest)}.x"`);
}
}
exports.maybeWarnForUpdate = maybeWarnForUpdate;
/**
* Handle errors when this action fails, providing useful next-steps for developers.
* This mostly checks if the installed version is the latest version.
*/
function handleError(error) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield maybeWarnForUpdate();
}
catch (_a) {
// If this fails, ignore it
}
core.setFailed(error);
});
async function handleError(error) {
try {
await maybeWarnForUpdate();
}
catch {
// If this fails, ignore it
}
core.setFailed(error);
}
exports.handleError = handleError;
@@ -93854,15 +93824,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fromPackager = exports.install = void 0;
const core = __importStar(__webpack_require__(470));
@@ -93875,38 +93836,34 @@ const cache_1 = __webpack_require__(722);
* Here you can provide any semver range or dist tag used in the registry.
* It returns the path where Expo is installed.
*/
function install(config) {
return __awaiter(this, void 0, void 0, function* () {
let root = yield cache_1.fromLocalCache(config.version);
if (!root && config.cache) {
root = yield cache_1.fromRemoteCache(config.version, config.packager, config.cacheKey);
async function install(config) {
let root = await cache_1.fromLocalCache(config.version);
if (!root && config.cache) {
root = await cache_1.fromRemoteCache(config.version, config.packager, config.cacheKey);
}
else {
core.info('Skipping remote cache, not enabled...');
}
if (!root) {
root = await fromPackager(config.version, config.packager);
root = await cache_1.toLocalCache(root, config.version);
if (config.cache) {
await cache_1.toRemoteCache(root, config.version, config.packager, config.cacheKey);
}
else {
core.info('Skipping remote cache, not enabled...');
}
if (!root) {
root = yield fromPackager(config.version, config.packager);
root = yield cache_1.toLocalCache(root, config.version);
if (config.cache) {
yield cache_1.toRemoteCache(root, config.version, config.packager, config.cacheKey);
}
}
return path.join(root, 'node_modules', '.bin');
});
}
return path.join(root, 'node_modules', '.bin');
}
exports.install = install;
/**
* Install `expo-cli`, by version, using npm or yarn.
* It creates a temporary directory to store all required files.
*/
function fromPackager(version, packager) {
return __awaiter(this, void 0, void 0, function* () {
const root = process.env['RUNNER_TEMP'] || '';
const tool = yield io.which(packager);
yield io.mkdirP(root);
yield cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root });
return root;
});
async function fromPackager(version, packager) {
const root = process.env['RUNNER_TEMP'] || '';
const tool = await io.which(packager);
await io.mkdirP(root);
await cli.exec(tool, ['add', `expo-cli@${version}`], { cwd: root });
return root;
}
exports.fromPackager = fromPackager;
@@ -101870,15 +101827,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
@@ -101895,10 +101843,8 @@ const os_1 = __importDefault(__webpack_require__(87));
*
* @see https://github.com/actions/toolkit/issues/47
*/
function fromLocalCache(version) {
return __awaiter(this, void 0, void 0, function* () {
return toolCache.find('expo-cli', version);
});
async function fromLocalCache(version) {
return toolCache.find('expo-cli', version);
}
exports.fromLocalCache = fromLocalCache;
/**
@@ -101907,52 +101853,46 @@ exports.fromLocalCache = fromLocalCache;
*
* @see https://github.com/actions/toolkit/issues/47
*/
function toLocalCache(root, version) {
return __awaiter(this, void 0, void 0, function* () {
return toolCache.cacheDir(root, 'expo-cli', version);
});
async function toLocalCache(root, version) {
return toolCache.cacheDir(root, 'expo-cli', version);
}
exports.toLocalCache = toLocalCache;
/**
* Download the remotely stored `expo-cli` from cache, if any.
* Note, this cache is shared between jobs.
*/
function fromRemoteCache(version, packager, customCacheKey) {
return __awaiter(this, void 0, void 0, function* () {
// see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
const target = path_1.default.join(process.env['RUNNER_TOOL_CACHE'] || '', 'expo-cli', version, os_1.default.arch());
const cacheKey = customCacheKey || getRemoteKey(version, packager);
try {
// When running with nektos/act, or other custom environments, the cache might not be set up.
const hit = yield cache_1.restoreCache([target], cacheKey);
if (hit) {
return target;
}
async function fromRemoteCache(version, packager, customCacheKey) {
// see: https://github.com/actions/toolkit/blob/8a4134761f09d0d97fb15f297705fd8644fef920/packages/tool-cache/src/tool-cache.ts#L401
const target = path_1.default.join(process.env['RUNNER_TOOL_CACHE'] || '', 'expo-cli', version, os_1.default.arch());
const cacheKey = customCacheKey || getRemoteKey(version, packager);
try {
// When running with nektos/act, or other custom environments, the cache might not be set up.
const hit = await cache_1.restoreCache([target], cacheKey);
if (hit) {
return target;
}
catch (error) {
if (!handleRemoteCacheError(error)) {
throw error;
}
}
catch (error) {
if (!handleRemoteCacheError(error)) {
throw error;
}
});
}
}
exports.fromRemoteCache = fromRemoteCache;
/**
* Store the root of `expo-cli` in the remote cache, for future reuse.
* Note, this cache is shared between jobs.
*/
function toRemoteCache(source, version, packager, customCacheKey) {
return __awaiter(this, void 0, void 0, function* () {
const cacheKey = customCacheKey || getRemoteKey(version, packager);
try {
yield cache_1.saveCache([source], cacheKey);
async function toRemoteCache(source, version, packager, customCacheKey) {
const cacheKey = customCacheKey || getRemoteKey(version, packager);
try {
await cache_1.saveCache([source], cacheKey);
}
catch (error) {
if (!handleRemoteCacheError(error)) {
throw error;
}
catch (error) {
if (!handleRemoteCacheError(error)) {
throw error;
}
}
});
}
}
exports.toRemoteCache = toRemoteCache;
/**
+1
View File
@@ -31,6 +31,7 @@
"semver": "^7.3.5"
},
"devDependencies": {
"@tsconfig/node14": "^1.0.1",
"@types/jest": "^26.0.23",
"@types/node": "^14.17.3",
"@types/semver": "^7.3.6",
+3 -9
View File
@@ -1,18 +1,12 @@
{
"extends": "./node_modules/@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": [
"es6"
],
"outDir": "./build",
"rootDir": "./src",
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"skipLibCheck": true
"noImplicitAny": false
},
"exclude": [
"build",
"node_modules",
"tests/**"
]
+5
View File
@@ -742,6 +742,11 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
"@tsconfig/node14@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2"
integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==
"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.14":
version "7.1.14"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.14.tgz#faaeefc4185ec71c389f4501ee5ec84b170cc402"