Skip to content

Commit

Permalink
Merge pull request #37975 from kubabutkiewicz/ts-migration/G18
Browse files Browse the repository at this point in the history
[TS migration] Migrate 'sanitizeStringForJSONParse.js', 'promiseWhile.js',  'CONST.js', 'versionUpdater.js',  'ActionUtils.js'  .github file to TypeScript
  • Loading branch information
flodnv authored Apr 3, 2024
2 parents 7177173 + 25318df commit aaddfed
Show file tree
Hide file tree
Showing 29 changed files with 1,104 additions and 7,856 deletions.
11 changes: 6 additions & 5 deletions .github/actions/javascript/authorChecklist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16846,9 +16846,12 @@ exports["default"] = newComponentCategory;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
const CONST = {
const GIT_CONST = {
GITHUB_OWNER: 'Expensify',
APP_REPO: 'App',
};
const CONST = {
...GIT_CONST,
APPLAUSE_BOT: 'applausebot',
OS_BOTIFY: 'OSBotify',
LABELS: {
Expand All @@ -16857,11 +16860,9 @@ const CONST = {
INTERNAL_QA: 'InternalQA',
},
DATE_FORMAT_STRING: 'yyyy-MM-dd',
APP_REPO_URL: '',
APP_REPO_GIT_URL: '',
APP_REPO_URL: `https://github.com/${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}`,
APP_REPO_GIT_URL: `git@github.com:${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}.git`,
};
CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`;
CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`;
exports["default"] = CONST;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/naming-convention */
import lodashThrottle from 'lodash/throttle';
import ActionUtils from '@github/libs/ActionUtils';
import {getStringInput} from '@github/libs/ActionUtils';
import CONST from '@github/libs/CONST';
import GitHubUtils, {POLL_RATE} from '@github/libs/GithubUtils';
import {promiseDoWhile} from '@github/libs/promiseWhile';
Expand All @@ -9,11 +9,11 @@ type CurrentStagingDeploys = Awaited<ReturnType<typeof GitHubUtils.octokit.actio

function run() {
console.info('[awaitStagingDeploys] run()');
console.info('[awaitStagingDeploys] ActionUtils', ActionUtils);
console.info('[awaitStagingDeploys] getStringInput', getStringInput);
console.info('[awaitStagingDeploys] GitHubUtils', GitHubUtils);
console.info('[awaitStagingDeploys] promiseDoWhile', promiseDoWhile);

const tag = ActionUtils.getStringInput('TAG', {required: false});
const tag = getStringInput('TAG', {required: false});
console.info('[awaitStagingDeploys] run() tag', tag);

let currentStagingDeploys: CurrentStagingDeploys = [];
Expand Down
230 changes: 119 additions & 111 deletions .github/actions/javascript/awaitStagingDeploys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,108 +4,6 @@
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({

/***/ 970:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

const core = __nccwpck_require__(2186);

/**
* Safely parse a JSON input to a GitHub Action.
*
* @param {String} name - The name of the input.
* @param {Object} options - Options to pass to core.getInput
* @param {*} [defaultValue] - A default value to provide for the input.
* Not required if the {required: true} option is given in the second arg to this function.
* @returns {any}
*/
function getJSONInput(name, options, defaultValue = undefined) {
const input = core.getInput(name, options);
if (input) {
return JSON.parse(input);
}
return defaultValue;
}

/**
* Safely access a string input to a GitHub Action, or fall back on a default if the string is empty.
*
* @param {String} name
* @param {Object} options
* @param {*} [defaultValue]
* @returns {string|undefined}
*/
function getStringInput(name, options, defaultValue = undefined) {
const input = core.getInput(name, options);
if (!input) {
return defaultValue;
}
return input;
}

module.exports = {
getJSONInput,
getStringInput,
};


/***/ }),

/***/ 4502:
/***/ ((module) => {

/**
* Simulates a while loop where the condition is determined by the result of a Promise.
*
* @param {Function} condition
* @param {Function} action
* @returns {Promise}
*/
function promiseWhile(condition, action) {
console.info('[promiseWhile] promiseWhile()');

return new Promise((resolve, reject) => {
const loop = function () {
if (!condition()) {
resolve();
} else {
const actionResult = action();
console.info('[promiseWhile] promiseWhile() actionResult', actionResult);
Promise.resolve(actionResult).then(loop).catch(reject);
}
};
loop();
});
}

/**
* Simulates a do-while loop where the condition is determined by the result of a Promise.
*
* @param {Function} condition
* @param {Function} action
* @returns {Promise}
*/
function promiseDoWhile(condition, action) {
console.info('[promiseWhile] promiseDoWhile()');

return new Promise((resolve, reject) => {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
actionResult
.then(() => promiseWhile(condition, action))
.then(() => resolve())
.catch(reject);
});
}

module.exports = {
promiseWhile,
promiseDoWhile,
};


/***/ }),

/***/ 7351:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

Expand Down Expand Up @@ -12251,16 +12149,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
Object.defineProperty(exports, "__esModule", ({ value: true }));
/* eslint-disable @typescript-eslint/naming-convention */
const throttle_1 = __importDefault(__nccwpck_require__(2891));
const ActionUtils_1 = __importDefault(__nccwpck_require__(970));
const ActionUtils_1 = __nccwpck_require__(6981);
const CONST_1 = __importDefault(__nccwpck_require__(9873));
const GithubUtils_1 = __importStar(__nccwpck_require__(9296));
const promiseWhile_1 = __nccwpck_require__(4502);
const promiseWhile_1 = __nccwpck_require__(9438);
function run() {
console.info('[awaitStagingDeploys] run()');
console.info('[awaitStagingDeploys] ActionUtils', ActionUtils_1.default);
console.info('[awaitStagingDeploys] getStringInput', ActionUtils_1.getStringInput);
console.info('[awaitStagingDeploys] GitHubUtils', GithubUtils_1.default);
console.info('[awaitStagingDeploys] promiseDoWhile', promiseWhile_1.promiseDoWhile);
const tag = ActionUtils_1.default.getStringInput('TAG', { required: false });
const tag = (0, ActionUtils_1.getStringInput)('TAG', { required: false });
console.info('[awaitStagingDeploys] run() tag', tag);
let currentStagingDeploys = [];
console.info('[awaitStagingDeploys] run() _.throttle', throttle_1.default);
Expand Down Expand Up @@ -12304,6 +12202,68 @@ if (require.main === require.cache[eval('__filename')]) {
exports["default"] = run;


/***/ }),

/***/ 6981:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {

"use strict";

var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.getStringInput = exports.getJSONInput = void 0;
const core = __importStar(__nccwpck_require__(2186));
/**
* Safely parse a JSON input to a GitHub Action.
*
* @param name - The name of the input.
* @param options - Options to pass to core.getInput
* @param [defaultValue] - A default value to provide for the input.
* Not required if the {required: true} option is given in the second arg to this function.
*/
function getJSONInput(name, options, defaultValue) {
const input = core.getInput(name, options);
if (input) {
return JSON.parse(input);
}
return defaultValue;
}
exports.getJSONInput = getJSONInput;
/**
* Safely access a string input to a GitHub Action, or fall back on a default if the string is empty.
*/
function getStringInput(name, options, defaultValue) {
const input = core.getInput(name, options);
if (!input) {
return defaultValue;
}
return input;
}
exports.getStringInput = getStringInput;


/***/ }),

/***/ 9873:
Expand All @@ -12312,9 +12272,12 @@ exports["default"] = run;
"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
const CONST = {
const GIT_CONST = {
GITHUB_OWNER: 'Expensify',
APP_REPO: 'App',
};
const CONST = {
...GIT_CONST,
APPLAUSE_BOT: 'applausebot',
OS_BOTIFY: 'OSBotify',
LABELS: {
Expand All @@ -12323,11 +12286,9 @@ const CONST = {
INTERNAL_QA: 'InternalQA',
},
DATE_FORMAT_STRING: 'yyyy-MM-dd',
APP_REPO_URL: '',
APP_REPO_GIT_URL: '',
APP_REPO_URL: `https://github.com/${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}`,
APP_REPO_GIT_URL: `git@github.com:${GIT_CONST.GITHUB_OWNER}/${GIT_CONST.APP_REPO}.git`,
};
CONST.APP_REPO_URL = `https://github.com/${CONST.GITHUB_OWNER}/${CONST.APP_REPO}`;
CONST.APP_REPO_GIT_URL = `git@github.com:${CONST.GITHUB_OWNER}/${CONST.APP_REPO}.git`;
exports["default"] = CONST;


Expand Down Expand Up @@ -12784,6 +12745,53 @@ exports["default"] = GithubUtils;
module.exports = GithubUtils;


/***/ }),

/***/ 9438:
/***/ ((__unused_webpack_module, exports) => {

"use strict";

Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.promiseDoWhile = exports.promiseWhile = void 0;
/**
* Simulates a while loop where the condition is determined by the result of a Promise.
*/
function promiseWhile(condition, action) {
console.info('[promiseWhile] promiseWhile()');
return new Promise((resolve, reject) => {
const loop = function () {
if (!condition()) {
resolve();
}
else {
const actionResult = action?.();
console.info('[promiseWhile] promiseWhile() actionResult', actionResult);
Promise.resolve(actionResult).then(loop).catch(reject);
}
};
loop();
});
}
exports.promiseWhile = promiseWhile;
/**
* Simulates a do-while loop where the condition is determined by the result of a Promise.
*/
function promiseDoWhile(condition, action) {
console.info('[promiseWhile] promiseDoWhile()');
return new Promise((resolve, reject) => {
console.info('[promiseWhile] promiseDoWhile() condition', condition);
const actionResult = action?.();
console.info('[promiseWhile] promiseDoWhile() actionResult', actionResult);
actionResult
?.then(() => promiseWhile(condition, action))
.then(() => resolve())
.catch(reject);
});
}
exports.promiseDoWhile = promiseDoWhile;


/***/ }),

/***/ 8227:
Expand Down
Loading

0 comments on commit aaddfed

Please sign in to comment.