Skip to content

Commit c1d4db6

Browse files
committed
chore: typescript
1 parent 1488525 commit c1d4db6

8 files changed

Lines changed: 4823 additions & 111 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

.github/actions/determineNodeVersions/dist/index.js

Lines changed: 100 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -25545,6 +25545,93 @@ module.exports = {
2554525545
}
2554625546

2554725547

25548+
/***/ }),
25549+
25550+
/***/ 9407:
25551+
/***/ ((module, __unused_webpack___webpack_exports__, __nccwpck_require__) => {
25552+
25553+
__nccwpck_require__.a(module, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
25554+
/* harmony import */ var _main_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(1730);
25555+
// The entrypoint for the action
25556+
25557+
await (0,_main_js__WEBPACK_IMPORTED_MODULE_0__/* .run */ .e)();
25558+
25559+
__webpack_async_result__();
25560+
} catch(e) { __webpack_async_result__(e); } }, 1);
25561+
25562+
/***/ }),
25563+
25564+
/***/ 1730:
25565+
/***/ ((__unused_webpack_module, __webpack_exports__, __nccwpck_require__) => {
25566+
25567+
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
25568+
/* harmony export */ e: () => (/* binding */ run)
25569+
/* harmony export */ });
25570+
/* unused harmony export getVersions */
25571+
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(7484);
25572+
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nccwpck_require__.n(_actions_core__WEBPACK_IMPORTED_MODULE_0__);
25573+
/*
25574+
* Copyright (c) 2024, salesforce.com, inc.
25575+
* All rights reserved.
25576+
* Licensed under the BSD 3-Clause license.
25577+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
25578+
*/
25579+
25580+
const getVersions = async () => {
25581+
// Get the node release schedule json
25582+
const response = await fetch("https://raw.githubusercontent.com/nodejs/Release/main/schedule.json");
25583+
const json = await response.json();
25584+
// This version of node was installed in the composite action before this script runs
25585+
// This defaults to 'lts/*' but allows for the user to override it with an env var
25586+
// Below we will replace the matching major version with this more specific version
25587+
// This will ensure that the unit tests run on the same version that will be shipped
25588+
const installedNode = process.versions.node;
25589+
// Support disabling certain versions via an environment variable
25590+
// They will be named like `NODE_DISABLE_VERSION_18` and will be set to `true`
25591+
const disabledVersions = Object.keys(process.env).filter((env) => env.startsWith('NODE_DISABLE_VERSION_')).map((env) => env.replace('NODE_DISABLE_VERSION_', ''));
25592+
const today = new Date();
25593+
// Build an array of versions that the current date is between the start and end dates
25594+
const versions = Object.keys(json)
25595+
.filter((version) => {
25596+
const startDate = new Date(json[version].start);
25597+
const endDate = new Date(json[version].end);
25598+
return today >= startDate && today <= endDate;
25599+
})
25600+
.map((version) => version.replace('v', ''))
25601+
// Remove versions that are disabled via env vars
25602+
.filter((version) => {
25603+
if (disabledVersions.includes(version)) {
25604+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.notice)(`Node version ${version} is disabled via env var`);
25605+
return false;
25606+
}
25607+
return true;
25608+
})
25609+
// Override the matching major version with the installed version
25610+
// for example if the installed version is 18.15.1, replace 18 with 18.15.1
25611+
.map((version) => {
25612+
if (version === installedNode.split('.')[0]) {
25613+
console.log(`Node version ${version} is overridden to ${installedNode}`);
25614+
return installedNode;
25615+
}
25616+
return version;
25617+
});
25618+
if (versions.length === 0) {
25619+
throw new Error('No versions found');
25620+
}
25621+
console.log('Found versions: ', versions);
25622+
return versions;
25623+
};
25624+
const run = async () => {
25625+
try {
25626+
const versions = await getVersions();
25627+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput)('nodeVersions', versions);
25628+
}
25629+
catch (error) {
25630+
(0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed)(error.message);
25631+
}
25632+
};
25633+
25634+
2554825635
/***/ }),
2554925636

2555025637
/***/ 2613:
@@ -27368,101 +27455,6 @@ function parseParams (str) {
2736827455
module.exports = parseParams
2736927456

2737027457

27371-
/***/ }),
27372-
27373-
/***/ 9722:
27374-
/***/ ((__webpack_module__, __unused_webpack___webpack_exports__, __nccwpck_require__) => {
27375-
27376-
__nccwpck_require__.a(__webpack_module__, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {
27377-
/* harmony import */ var _main_js__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(8525);
27378-
// The entrypoint for the action
27379-
27380-
27381-
await (0,_main_js__WEBPACK_IMPORTED_MODULE_0__/* .run */ .e)()
27382-
27383-
__webpack_async_result__();
27384-
} catch(e) { __webpack_async_result__(e); } }, 1);
27385-
27386-
/***/ }),
27387-
27388-
/***/ 8525:
27389-
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __nccwpck_require__) => {
27390-
27391-
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
27392-
/* harmony export */ e: () => (/* binding */ run)
27393-
/* harmony export */ });
27394-
/* unused harmony export getVersions */
27395-
/* harmony import */ var _actions_core__WEBPACK_IMPORTED_MODULE_0__ = __nccwpck_require__(7484);
27396-
/*
27397-
* Copyright (c) 2024, salesforce.com, inc.
27398-
* All rights reserved.
27399-
* Licensed under the BSD 3-Clause license.
27400-
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
27401-
*/
27402-
27403-
27404-
27405-
const getVersions = async () => {
27406-
// Get the node release schedule json
27407-
const json = await (await fetch("https://raw.githubusercontent.com/nodejs/Release/main/schedule.json")).json();
27408-
27409-
// This version of node was installed in the composite action before this script runs
27410-
// This defaults to 'lts/*' but allows for the user to override it with an env var
27411-
// Below we will replace the matching major version with this more specific version
27412-
// This will ensure that the unit tests run on the same version that will be shipped
27413-
const installedNode = process.versions.node;
27414-
27415-
// Support disabling certain versions via an environment variable
27416-
// They will be named like `NODE_DISABLE_VERSION_18` and will be set to `true`
27417-
const disabledVersions = Object.keys(process.env).filter((env) => env.startsWith('NODE_DISABLE_VERSION_')).map((env) => env.replace('NODE_DISABLE_VERSION_', ''));
27418-
27419-
const today = new Date();
27420-
27421-
// Build an array of versions that the current date is between the start and end dates
27422-
const versions = Object.keys(json)
27423-
.filter((version) => {
27424-
const startDate = new Date(json[version].start);
27425-
const endDate = new Date(json[version].end);
27426-
return today >= startDate && today <= endDate;
27427-
})
27428-
.map((version) => version.replace('v', ''))
27429-
// Remove versions that are disabled via env vars
27430-
.filter((version) => {
27431-
if (disabledVersions.includes(version)) {
27432-
_actions_core__WEBPACK_IMPORTED_MODULE_0__.notice(`Node version ${version} is disabled via env var`);
27433-
return false;
27434-
}
27435-
return true;
27436-
})
27437-
// Override the matching major version with the installed version
27438-
// for example if the installed version is 18.15.1, replace 18 with 18.15.1
27439-
.map((version) => {
27440-
if (version === installedNode.split('.')[0]) {
27441-
console.log(`Node version ${version} is overridden to ${installedNode}`);
27442-
return installedNode;
27443-
}
27444-
return version;
27445-
})
27446-
27447-
if (versions.length === 0) {
27448-
throw new Error('No versions found');
27449-
}
27450-
27451-
console.log('Found versions: ', versions);
27452-
return versions;
27453-
};
27454-
27455-
const run = async () => {
27456-
try {
27457-
const versions = await getVersions();
27458-
27459-
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput('nodeVersions', versions)
27460-
} catch (error) {
27461-
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(error.message);
27462-
}
27463-
};
27464-
27465-
2746627458
/***/ })
2746727459

2746827460
/******/ });
@@ -27567,6 +27559,18 @@ const run = async () => {
2756727559
/******/ };
2756827560
/******/ })();
2756927561
/******/
27562+
/******/ /* webpack/runtime/compat get default export */
27563+
/******/ (() => {
27564+
/******/ // getDefaultExport function for compatibility with non-harmony modules
27565+
/******/ __nccwpck_require__.n = (module) => {
27566+
/******/ var getter = module && module.__esModule ?
27567+
/******/ () => (module['default']) :
27568+
/******/ () => (module);
27569+
/******/ __nccwpck_require__.d(getter, { a: getter });
27570+
/******/ return getter;
27571+
/******/ };
27572+
/******/ })();
27573+
/******/
2757027574
/******/ /* webpack/runtime/define property getters */
2757127575
/******/ (() => {
2757227576
/******/ // define getter functions for harmony exports
@@ -27593,6 +27597,6 @@ const run = async () => {
2759327597
/******/ // startup
2759427598
/******/ // Load entry module and return exports
2759527599
/******/ // This entry module used 'module' so it can't be inlined
27596-
/******/ var __webpack_exports__ = __nccwpck_require__(9722);
27600+
/******/ var __webpack_exports__ = __nccwpck_require__(9407);
2759727601
/******/ __webpack_exports__ = await __webpack_exports__;
2759827602
/******/
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export declare const getVersions: () => Promise<string[]>;
2+
export declare const run: () => Promise<void>;

.github/actions/determineNodeVersions/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Determine the active Node versions to test against",
55
"main": "index.js",
66
"scripts": {
7-
"build": "ncc build src/index.js -o dist",
7+
"build": "ncc build src/index.ts -o dist",
88
"test": "echo \"Error: no test specified\" && exit 1"
99
},
1010
"type": "module",
@@ -14,6 +14,8 @@
1414
"@actions/core": "^1.11.1"
1515
},
1616
"devDependencies": {
17-
"@vercel/ncc": "^0.38.2"
17+
"@salesforce/dev-scripts": "^10.2.10",
18+
"@vercel/ncc": "^0.38.2",
19+
"typescript": "^5.6.3"
1820
}
1921
}
File renamed without changes.

.github/actions/determineNodeVersions/src/main.js renamed to .github/actions/determineNodeVersions/src/main.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,24 @@
55
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66
*/
77

8-
import core from '@actions/core';
8+
import { setFailed, setOutput, notice } from '@actions/core';
9+
10+
type VersionData = {
11+
start: string;
12+
end: string;
13+
lts?: string;
14+
maintenance?: string;
15+
codename?: string;
16+
};
17+
18+
type VersionsJson = {
19+
[key: string]: VersionData;
20+
};
921

1022
export const getVersions = async () => {
1123
// Get the node release schedule json
12-
const json = await (await fetch("https://raw.githubusercontent.com/nodejs/Release/main/schedule.json")).json();
24+
const response = await fetch("https://raw.githubusercontent.com/nodejs/Release/main/schedule.json");
25+
const json = await response.json() as VersionsJson;
1326

1427
// This version of node was installed in the composite action before this script runs
1528
// This defaults to 'lts/*' but allows for the user to override it with an env var
@@ -34,7 +47,7 @@ export const getVersions = async () => {
3447
// Remove versions that are disabled via env vars
3548
.filter((version) => {
3649
if (disabledVersions.includes(version)) {
37-
core.notice(`Node version ${version} is disabled via env var`);
50+
notice(`Node version ${version} is disabled via env var`);
3851
return false;
3952
}
4053
return true;
@@ -60,9 +73,8 @@ export const getVersions = async () => {
6073
export const run = async () => {
6174
try {
6275
const versions = await getVersions();
63-
64-
core.setOutput('nodeVersions', versions)
65-
} catch (error) {
66-
core.setFailed(error.message);
76+
setOutput('nodeVersions', versions)
77+
} catch (error: any) {
78+
setFailed(error.message);
6779
}
6880
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "@salesforce/dev-config/tsconfig-strict-esm",
3+
"compilerOptions": {
4+
"outDir": "dist",
5+
"rootDir": "src",
6+
"baseUrl": "."
7+
},
8+
"include": ["./src/**/*.ts"]
9+
}

0 commit comments

Comments
 (0)