From 9201450c1af2201636039661d388ec51f069184e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:36:08 +0000 Subject: [PATCH 1/2] Bump @tiobe/http-client from 0.4.0 to 0.5.0 Bumps [@tiobe/http-client](https://github.com/tiobe/tics-npm-toolkit/tree/HEAD/packages/http-client) from 0.4.0 to 0.5.0. - [Commits](https://github.com/tiobe/tics-npm-toolkit/commits/HEAD/packages/http-client) --- updated-dependencies: - dependency-name: "@tiobe/http-client" dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- package-lock.json | 20 +++++--------------- package.json | 2 +- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index ccd788a8..fa637b09 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@octokit/plugin-paginate-graphql": "^4.0.1", "@octokit/plugin-retry": "^6.1.0", "@octokit/request-error": "^5.1.1", - "@tiobe/http-client": "^0.4.0", + "@tiobe/http-client": "^0.5.0", "@tiobe/install-tics": "^0.6.0", "canonical-path": "^1.0.0", "date-fns": "^4.1.0", @@ -3185,12 +3185,12 @@ } }, "node_modules/@tiobe/http-client": { - "version": "0.4.0", - "resolved": "https://artifacts.tiobe.com/repository/npm/@tiobe/http-client/-/http-client-0.4.0.tgz", - "integrity": "sha512-9xs4BiRjIyWKkhLWncQrBryAtJKt+aM6j1D/uF/qovLOb6Tm5HvNBYGkBDo+RFc8xwagv//n07whSm5uRpBNOw==", + "version": "0.5.0", + "resolved": "https://artifacts.tiobe.com/repository/npm/@tiobe/http-client/-/http-client-0.5.0.tgz", + "integrity": "sha512-TT9e4NFvPDumOMwHoXFAWx5haGWL5a3rjoezRSXwr27L/DQUJLGSGx9BoWu/xwVtmwr4ebc8DnLLNZ0U6jVehw==", "license": "MIT", "dependencies": { - "@types/node-fetch": "^2.6.2", + "@types/node-fetch": "^2.6.11", "node-fetch": "2.7.0" } }, @@ -3203,16 +3203,6 @@ "@tiobe/http-client": "^0.5.0" } }, - "node_modules/@tiobe/install-tics/node_modules/@tiobe/http-client": { - "version": "0.5.0", - "resolved": "https://artifacts.tiobe.com/repository/npm/@tiobe/http-client/-/http-client-0.5.0.tgz", - "integrity": "sha512-TT9e4NFvPDumOMwHoXFAWx5haGWL5a3rjoezRSXwr27L/DQUJLGSGx9BoWu/xwVtmwr4ebc8DnLLNZ0U6jVehw==", - "license": "MIT", - "dependencies": { - "@types/node-fetch": "^2.6.11", - "node-fetch": "2.7.0" - } - }, "node_modules/@tootallnate/quickjs-emscripten": { "version": "0.23.0", "resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz", diff --git a/package.json b/package.json index b80735cb..ef4a08e2 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "@octokit/plugin-paginate-graphql": "^4.0.1", "@octokit/plugin-retry": "^6.1.0", "@octokit/request-error": "^5.1.1", - "@tiobe/http-client": "^0.4.0", + "@tiobe/http-client": "^0.5.0", "@tiobe/install-tics": "^0.6.0", "canonical-path": "^1.0.0", "date-fns": "^4.1.0", From 6aa0251db983a8ef0c57e24b06e7f0d8bacc4794 Mon Sep 17 00:00:00 2001 From: janssen <118828444+janssen-tiobe@users.noreply.github.com> Date: Mon, 10 Nov 2025 17:10:06 +0100 Subject: [PATCH 2/2] Fixed issues with tests --- dist/index.js | 1322 +++++++++------------ package-lock.json | 12 + test/unit/action/decorate/summary.test.ts | 1 - test/unit/helper/response.test.ts | 4 +- 4 files changed, 579 insertions(+), 760 deletions(-) diff --git a/dist/index.js b/dist/index.js index e2a2ce58..c7b75df7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1944,28 +1944,28 @@ async function getChangedFilesOfPullRequestQL() { }; let response; try { - response = await octokit_1.octokit.graphql.paginate(`query changedFiles($owner: String!, $repo: String!, $pull_number: Int!, $per_page: Int!, $cursor: String) { - rateLimit { - remaining - } - repository(owner: $owner, name: $repo) { - pullRequest(number: $pull_number) { - files(first: $per_page, after: $cursor) { - totalCount - nodes { - path - changeType - additions - deletions - viewerViewedState - } - pageInfo { - hasNextPage - endCursor - } - } - } - } + response = await octokit_1.octokit.graphql.paginate(`query changedFiles($owner: String!, $repo: String!, $pull_number: Int!, $per_page: Int!, $cursor: String) { + rateLimit { + remaining + } + repository(owner: $owner, name: $repo) { + pullRequest(number: $pull_number) { + files(first: $per_page, after: $cursor) { + totalCount + nodes { + path + changeType + additions + deletions + viewerViewedState + } + pageInfo { + hasNextPage + endCursor + } + } + } + } }`, params); logger_1.logger.debug(JSON.stringify(response)); } @@ -2893,7 +2893,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { }; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.httpClient = void 0; -const http_client_1 = __importDefault(__nccwpck_require__(99957)); +const http_client_1 = __importDefault(__nccwpck_require__(22338)); const proxy_agent_1 = __nccwpck_require__(75273); const config_1 = __nccwpck_require__(34151); exports.httpClient = new http_client_1.default(true, { @@ -45972,7 +45972,7 @@ exports.ReflectionTypeCheck = ReflectionTypeCheck; /***/ }), -/***/ 99957: +/***/ 22338: /***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { "use strict"; @@ -46012,363 +46012,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge Object.defineProperty(exports, "__esModule", ({ value: true })); const node_fetch_1 = __importStar(__nccwpck_require__(26705)); const retry_1 = __importStar(__nccwpck_require__(72344)); -class HttpClient { - /** - * @param ci If this http client is used in a ci environment. - * @param options (Optional) options to use for the HttpClient. - * @param agent (Optional) agent to be set when using proxy. - */ - constructor(ci, options, agent) { - this.ci = ci; - this.agent = agent; - this.defaultHeaders = new node_fetch_1.Headers(); - if (options === null || options === void 0 ? void 0 : options.authToken) { - this.defaultHeaders.set('authorization', `Basic ${options.authToken}`); - } - if (options === null || options === void 0 ? void 0 : options.xRequestWithTics) { - this.defaultHeaders.set('x-requested-with', 'TICS'); - } - this.customFetch = (0, retry_1.default)(node_fetch_1.default, options === null || options === void 0 ? void 0 : options.retry); - } - /** - * Executes a GET request to the given url. - * @param url api url to perform a GET request for. - */ - get(url, headers) { - return __awaiter(this, void 0, void 0, function* () { - let fixedHeaders = this.defaultHeaders; - headers === null || headers === void 0 ? void 0 : headers.forEach((value, key) => { - fixedHeaders.append(key, value); - }); - const requestInit = { - agent: this.agent, - headers: fixedHeaders - }; - const response = yield this.customFetch(url, requestInit); - switch (response.status) { - case 200: - const text = yield response.text(); - try { - const result = { - status: response.status, - retryCount: response.retryCount, - data: JSON.parse(text) - }; - return result; - } - catch (error) { - throw new retry_1.RequestError(`${error}: ${text}`, response.retryCount); - } - case 302: - throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Please check if the given ticsConfiguration is correct.`, response.retryCount); - case 400: - throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. ${(yield response.json()).alertMessages[0].header}`, response.retryCount); - case 401: - let authUrl = url.split('/api/')[0]; - authUrl += this.ci ? '/Administration.html#page=authToken' : '/UserSettings.html#page=authToken'; - throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Please provide a valid TICS authentication token. See ${authUrl}`, response.retryCount); - case 403: - throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Forbidden call: ${url}`, response.retryCount); - case 404: - throw new retry_1.RequestError(`HTTP request failed with status ${response.status}. Please check if the given ticsConfiguration is correct.`, response.retryCount); - default: - throw new retry_1.RequestError(`HTTP request failed with status ${response.status}: ${response.statusText}`, response.retryCount); - } - }); - } -} -exports["default"] = HttpClient; -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 72344: -/***/ ((__unused_webpack_module, exports) => { - -"use strict"; - -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.fetchBuilder = exports.RequestError = void 0; -class RequestError extends Error { - constructor(message, retryCount) { - super(message); - this.name = 'RequestError'; - this.retryCount = retryCount; - } -} -exports.RequestError = RequestError; -function sanitize(params, defaults) { - const result = Object.assign(Object.assign({}, defaults), params); - if (typeof result.retries === 'undefined') { - result.retries = defaults.retries; - } - if (typeof result.retryDelay === 'undefined') { - result.retryDelay = defaults.retryDelay; - } - if (typeof result.retryOn === 'undefined') { - result.retryOn = defaults.retryOn; - } - return result; -} -// eslint-disable-next-line @typescript-eslint/no-explicit-any -function fetchBuilder(fetchFunc, params = {}) { - const defaults = sanitize(params, { retries: 3, retryDelay: 500, retryOn: [419, 503, 504] }); - return function (input, init) { - const frp = sanitize({ - // TICS -no-unsafe-assignment - retries: init === null || init === void 0 ? void 0 : init.retries, - retryDelay: init === null || init === void 0 ? void 0 : init.retryDelay, - retryOn: init === null || init === void 0 ? void 0 : init.retryOn - // TICS +no-unsafe-assignment - }, defaults); - const retryDelayFn = typeof frp.retryDelay === 'function' ? frp.retryDelay : () => frp.retryDelay; - const retryOnFn = typeof frp.retryOn === 'function' - ? frp.retryOn - : (attempt, retries, error, response) => (!!error || !response || frp.retryOn.indexOf(response.status) !== -1) && attempt < retries; - return new Promise(function (resolve, reject) { - const extendedFetch = function (attempt) { - fetchFunc(input, init) - .then(function (response) { - if (retryOnFn(attempt, frp.retries, null, response)) { - // eslint-disable-next-line @typescript-eslint/no-use-before-define - retry(attempt, null, response); - } - else { - const responseWithRetryCount = response; - responseWithRetryCount.retryCount = attempt; - resolve(responseWithRetryCount); - } - }) - .catch(function (error) { - if (retryOnFn(attempt, frp.retries, error, null)) { - // eslint-disable-next-line @typescript-eslint/no-use-before-define - retry(attempt, error, null); - } - else { - reject(new RequestError(error.message, attempt)); - } - }); - }; - function retry(attempt, error, response) { - setTimeout(function () { - extendedFetch(++attempt); - }, retryDelayFn(attempt, error, response)); - } - extendedFetch(0); - }); - }; -} -exports.fetchBuilder = fetchBuilder; -exports["default"] = fetchBuilder; -//# sourceMappingURL=retry.js.map - -/***/ }), - -/***/ 36381: -/***/ (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; -}; -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 }; -}; -Object.defineProperty(exports, "__esModule", ({ value: true })); -exports.InstallTics = void 0; -exports.getBaseUrl = getBaseUrl; -const os = __importStar(__nccwpck_require__(70857)); -const http_client_1 = __importDefault(__nccwpck_require__(87507)); -var Platform; -(function (Platform) { - Platform["aix"] = "aix"; - Platform["android"] = "android"; - Platform["cygwin"] = "cygwin"; - Platform["darwin"] = "macos"; - Platform["freebsd"] = "freebsd"; - Platform["haiku"] = "haiku"; - Platform["linux"] = "linux"; - Platform["netbsd"] = "netbsd"; - Platform["openbsd"] = "openbsd"; - Platform["sunos"] = "sunos"; - Platform["win32"] = "windows"; -})(Platform || (Platform = {})); -/** - * Parse url from the given configuration url. - * @param url TICS Viewer configuration url. - */ -function getBaseUrl(url) { - const apiMarker = '/api/'; - if (url instanceof URL) { - url = url.href; - } - if (url.includes(apiMarker)) { - try { - return new URL(url.split(apiMarker)[0]); - } - catch (error) { - throw Error('URL could not be parsed.'); - } - } - throw Error('Incorrect TICS Viewer url was given.'); -} -class InstallTics { - /** - * @param ci If this http client is used in a ci environment. - * @param httpClient (Optional) Give your own HttpClient to use. - * @param options (Optional) Options to use for the HttpClient. Won't be used when setting httpClient. - */ - constructor(ci, httpClient, options) { - if (httpClient) { - this.httpClient = httpClient; - } - else { - this.httpClient = new http_client_1.default(ci, options === null || options === void 0 ? void 0 : options.httpClientOptions, options === null || options === void 0 ? void 0 : options.agent); - } - } - /** - * Retrieves the install command from the configured TICS Viewer. Uses environment variable TICSTRUSTSTRATEGY. - * @param url TICS configuration url. - */ - getInstallCommand(url) { - return __awaiter(this, void 0, void 0, function* () { - const platform = Platform[os.platform()]; - const installTicsUrl = yield this.getInstallTicsUrl(url, platform); - switch (platform) { - case Platform.linux: - return this.linuxInstall(installTicsUrl); - case Platform.win32: - return this.windowsInstall(installTicsUrl); - default: - throw Error(`No install command found for platform: ${platform}.`); - } - }); - } - /** - * Returns the TIOBE web base url. - * @param url TICS configuration url. - * @param platform os to retrieve the install url for. - */ - getInstallTicsUrl(url, platform) { - return __awaiter(this, void 0, void 0, function* () { - const baseUrl = getBaseUrl(url).toString(); - const installTicsUrl = new URL(url); - installTicsUrl.searchParams.append('platform', platform); - installTicsUrl.searchParams.append('url', baseUrl); - try { - const response = yield this.httpClient.get(installTicsUrl.href); - if (response.data.links.installTics) { - return baseUrl + response.data.links.installTics; - } - throw Error(`Install url could not be retrieved from ${installTicsUrl.href}.`); - } - catch (err) { - let message; - if (err instanceof Error) { - message = err.message; - } - throw Error(message); - } - }); - } - /** - * Returns the install command for Linux. - * @param installTicsUrl TICS installation url. - */ - linuxInstall(installTicsUrl) { - let trustStrategy = ''; - if (process.env.TICSTRUSTSTRATEGY === 'all' || process.env.TICSTRUSTSTRATEGY === 'self-signed') { - trustStrategy = '--insecure'; - } - return `source <(curl --silent ${trustStrategy} '${installTicsUrl}')`; - } - /** - * Returns the install command for Windows. - * @param installTicsUrl TICS installation url. - */ - windowsInstall(installTicsUrl) { - let trustStrategy = ''; - if (process.env.TICSTRUSTSTRATEGY === 'all' || process.env.TICSTRUSTSTRATEGY === 'self-signed') { - trustStrategy = '[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};'; - } - return `[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ${trustStrategy} iex ((New-Object System.Net.WebClient).DownloadString('${installTicsUrl}'))`; - } -} -exports.InstallTics = InstallTics; -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ 87507: -/***/ (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; -}; -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 })); -const node_fetch_1 = __importStar(__nccwpck_require__(26705)); -const retry_1 = __importStar(__nccwpck_require__(9277)); class HttpClient { /** * @param ci If this http client is used in a ci environment. @@ -46439,7 +46082,7 @@ exports["default"] = HttpClient; /***/ }), -/***/ 9277: +/***/ 72344: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -46522,6 +46165,171 @@ exports["default"] = fetchBuilder; /***/ }), +/***/ 36381: +/***/ (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; +}; +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 }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.InstallTics = void 0; +exports.getBaseUrl = getBaseUrl; +const os = __importStar(__nccwpck_require__(70857)); +const http_client_1 = __importDefault(__nccwpck_require__(22338)); +var Platform; +(function (Platform) { + Platform["aix"] = "aix"; + Platform["android"] = "android"; + Platform["cygwin"] = "cygwin"; + Platform["darwin"] = "macos"; + Platform["freebsd"] = "freebsd"; + Platform["haiku"] = "haiku"; + Platform["linux"] = "linux"; + Platform["netbsd"] = "netbsd"; + Platform["openbsd"] = "openbsd"; + Platform["sunos"] = "sunos"; + Platform["win32"] = "windows"; +})(Platform || (Platform = {})); +/** + * Parse url from the given configuration url. + * @param url TICS Viewer configuration url. + */ +function getBaseUrl(url) { + const apiMarker = '/api/'; + if (url instanceof URL) { + url = url.href; + } + if (url.includes(apiMarker)) { + try { + return new URL(url.split(apiMarker)[0]); + } + catch (error) { + throw Error('URL could not be parsed.'); + } + } + throw Error('Incorrect TICS Viewer url was given.'); +} +class InstallTics { + /** + * @param ci If this http client is used in a ci environment. + * @param httpClient (Optional) Give your own HttpClient to use. + * @param options (Optional) Options to use for the HttpClient. Won't be used when setting httpClient. + */ + constructor(ci, httpClient, options) { + if (httpClient) { + this.httpClient = httpClient; + } + else { + this.httpClient = new http_client_1.default(ci, options === null || options === void 0 ? void 0 : options.httpClientOptions, options === null || options === void 0 ? void 0 : options.agent); + } + } + /** + * Retrieves the install command from the configured TICS Viewer. Uses environment variable TICSTRUSTSTRATEGY. + * @param url TICS configuration url. + */ + getInstallCommand(url) { + return __awaiter(this, void 0, void 0, function* () { + const platform = Platform[os.platform()]; + const installTicsUrl = yield this.getInstallTicsUrl(url, platform); + switch (platform) { + case Platform.linux: + return this.linuxInstall(installTicsUrl); + case Platform.win32: + return this.windowsInstall(installTicsUrl); + default: + throw Error(`No install command found for platform: ${platform}.`); + } + }); + } + /** + * Returns the TIOBE web base url. + * @param url TICS configuration url. + * @param platform os to retrieve the install url for. + */ + getInstallTicsUrl(url, platform) { + return __awaiter(this, void 0, void 0, function* () { + const baseUrl = getBaseUrl(url).toString(); + const installTicsUrl = new URL(url); + installTicsUrl.searchParams.append('platform', platform); + installTicsUrl.searchParams.append('url', baseUrl); + try { + const response = yield this.httpClient.get(installTicsUrl.href); + if (response.data.links.installTics) { + return baseUrl + response.data.links.installTics; + } + throw Error(`Install url could not be retrieved from ${installTicsUrl.href}.`); + } + catch (err) { + let message; + if (err instanceof Error) { + message = err.message; + } + throw Error(message); + } + }); + } + /** + * Returns the install command for Linux. + * @param installTicsUrl TICS installation url. + */ + linuxInstall(installTicsUrl) { + let trustStrategy = ''; + if (process.env.TICSTRUSTSTRATEGY === 'all' || process.env.TICSTRUSTSTRATEGY === 'self-signed') { + trustStrategy = '--insecure'; + } + return `source <(curl --silent ${trustStrategy} '${installTicsUrl}')`; + } + /** + * Returns the install command for Windows. + * @param installTicsUrl TICS installation url. + */ + windowsInstall(installTicsUrl) { + let trustStrategy = ''; + if (process.env.TICSTRUSTSTRATEGY === 'all' || process.env.TICSTRUSTSTRATEGY === 'self-signed') { + trustStrategy = '[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true};'; + } + return `[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; ${trustStrategy} iex ((New-Object System.Net.WebClient).DownloadString('${installTicsUrl}'))`; + } +} +exports.InstallTics = InstallTics; +//# sourceMappingURL=index.js.map + +/***/ }), + /***/ 75926: /***/ ((__unused_webpack_module, exports) => { @@ -169911,7 +169719,7 @@ exports.DEFAULT_RETRY_POLICY_COUNT = 3; Object.defineProperty(exports, "__esModule", ({ value: true })); exports.createPipelineFromOptions = createPipelineFromOptions; const logPolicy_js_1 = __nccwpck_require__(47129); -const pipeline_js_1 = __nccwpck_require__(22338); +const pipeline_js_1 = __nccwpck_require__(99957); const redirectPolicy_js_1 = __nccwpck_require__(92187); const userAgentPolicy_js_1 = __nccwpck_require__(91691); const decompressResponsePolicy_js_1 = __nccwpck_require__(35035); @@ -170099,7 +169907,7 @@ tslib_1.__exportStar(__nccwpck_require__(92097), exports); tslib_1.__exportStar(__nccwpck_require__(43097), exports); var pipelineRequest_js_1 = __nccwpck_require__(72305); Object.defineProperty(exports, "createPipelineRequest", ({ enumerable: true, get: function () { return pipelineRequest_js_1.createPipelineRequest; } })); -var pipeline_js_1 = __nccwpck_require__(22338); +var pipeline_js_1 = __nccwpck_require__(99957); Object.defineProperty(exports, "createEmptyPipeline", ({ enumerable: true, get: function () { return pipeline_js_1.createEmptyPipeline; } })); var restError_js_1 = __nccwpck_require__(9758); Object.defineProperty(exports, "RestError", ({ enumerable: true, get: function () { return restError_js_1.RestError; } })); @@ -170764,7 +170572,7 @@ function createNodeHttpClient() { /***/ }), -/***/ 22338: +/***/ 99957: /***/ ((__unused_webpack_module, exports) => { "use strict"; @@ -198585,6 +198393,378 @@ function cleanEscapedString(input) { } +/***/ }), + +/***/ 27633: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.parseISO = parseISO; +var _index = __nccwpck_require__(46104); + +var _index2 = __nccwpck_require__(25848); +var _index3 = __nccwpck_require__(44826); + +/** + * The {@link parseISO} function options. + */ + +/** + * @name parseISO + * @category Common Helpers + * @summary Parse ISO string + * + * @description + * Parse the given string in ISO 8601 format and return an instance of Date. + * + * Function accepts complete ISO 8601 formats as well as partial implementations. + * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601 + * + * If the argument isn't a string, the function cannot parse the string or + * the values are invalid, it returns Invalid Date. + * + * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param argument - The value to convert + * @param options - An object with options + * + * @returns The parsed date in the local time zone + * + * @example + * // Convert string '2014-02-11T11:30:30' to date: + * const result = parseISO('2014-02-11T11:30:30') + * //=> Tue Feb 11 2014 11:30:30 + * + * @example + * // Convert string '+02014101' to date, + * // if the additional number of digits in the extended year format is 1: + * const result = parseISO('+02014101', { additionalDigits: 1 }) + * //=> Fri Apr 11 2014 00:00:00 + */ +function parseISO(argument, options) { + const invalidDate = () => (0, _index2.constructFrom)(options?.in, NaN); + + const additionalDigits = options?.additionalDigits ?? 2; + const dateStrings = splitDateString(argument); + + let date; + if (dateStrings.date) { + const parseYearResult = parseYear(dateStrings.date, additionalDigits); + date = parseDate(parseYearResult.restDateString, parseYearResult.year); + } + + if (!date || isNaN(+date)) return invalidDate(); + + const timestamp = +date; + let time = 0; + let offset; + + if (dateStrings.time) { + time = parseTime(dateStrings.time); + if (isNaN(time)) return invalidDate(); + } + + if (dateStrings.timezone) { + offset = parseTimezone(dateStrings.timezone); + if (isNaN(offset)) return invalidDate(); + } else { + const tmpDate = new Date(timestamp + time); + const result = (0, _index3.toDate)(0, options?.in); + result.setFullYear( + tmpDate.getUTCFullYear(), + tmpDate.getUTCMonth(), + tmpDate.getUTCDate(), + ); + result.setHours( + tmpDate.getUTCHours(), + tmpDate.getUTCMinutes(), + tmpDate.getUTCSeconds(), + tmpDate.getUTCMilliseconds(), + ); + return result; + } + + return (0, _index3.toDate)(timestamp + time + offset, options?.in); +} + +const patterns = { + dateTimeDelimiter: /[T ]/, + timeZoneDelimiter: /[Z ]/i, + timezone: /([Z+-].*)$/, +}; + +const dateRegex = + /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/; +const timeRegex = + /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/; +const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/; + +function splitDateString(dateString) { + const dateStrings = {}; + const array = dateString.split(patterns.dateTimeDelimiter); + let timeString; + + // The regex match should only return at maximum two array elements. + // [date], [time], or [date, time]. + if (array.length > 2) { + return dateStrings; + } + + if (/:/.test(array[0])) { + timeString = array[0]; + } else { + dateStrings.date = array[0]; + timeString = array[1]; + if (patterns.timeZoneDelimiter.test(dateStrings.date)) { + dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0]; + timeString = dateString.substr( + dateStrings.date.length, + dateString.length, + ); + } + } + + if (timeString) { + const token = patterns.timezone.exec(timeString); + if (token) { + dateStrings.time = timeString.replace(token[1], ""); + dateStrings.timezone = token[1]; + } else { + dateStrings.time = timeString; + } + } + + return dateStrings; +} + +function parseYear(dateString, additionalDigits) { + const regex = new RegExp( + "^(?:(\\d{4}|[+-]\\d{" + + (4 + additionalDigits) + + "})|(\\d{2}|[+-]\\d{" + + (2 + additionalDigits) + + "})$)", + ); + + const captures = dateString.match(regex); + // Invalid ISO-formatted year + if (!captures) return { year: NaN, restDateString: "" }; + + const year = captures[1] ? parseInt(captures[1]) : null; + const century = captures[2] ? parseInt(captures[2]) : null; + + // either year or century is null, not both + return { + year: century === null ? year : century * 100, + restDateString: dateString.slice((captures[1] || captures[2]).length), + }; +} + +function parseDate(dateString, year) { + // Invalid ISO-formatted year + if (year === null) return new Date(NaN); + + const captures = dateString.match(dateRegex); + // Invalid ISO-formatted string + if (!captures) return new Date(NaN); + + const isWeekDate = !!captures[4]; + const dayOfYear = parseDateUnit(captures[1]); + const month = parseDateUnit(captures[2]) - 1; + const day = parseDateUnit(captures[3]); + const week = parseDateUnit(captures[4]); + const dayOfWeek = parseDateUnit(captures[5]) - 1; + + if (isWeekDate) { + if (!validateWeekDate(year, week, dayOfWeek)) { + return new Date(NaN); + } + return dayOfISOWeekYear(year, week, dayOfWeek); + } else { + const date = new Date(0); + if ( + !validateDate(year, month, day) || + !validateDayOfYearDate(year, dayOfYear) + ) { + return new Date(NaN); + } + date.setUTCFullYear(year, month, Math.max(dayOfYear, day)); + return date; + } +} + +function parseDateUnit(value) { + return value ? parseInt(value) : 1; +} + +function parseTime(timeString) { + const captures = timeString.match(timeRegex); + if (!captures) return NaN; // Invalid ISO-formatted time + + const hours = parseTimeUnit(captures[1]); + const minutes = parseTimeUnit(captures[2]); + const seconds = parseTimeUnit(captures[3]); + + if (!validateTime(hours, minutes, seconds)) { + return NaN; + } + + return ( + hours * _index.millisecondsInHour + + minutes * _index.millisecondsInMinute + + seconds * 1000 + ); +} + +function parseTimeUnit(value) { + return (value && parseFloat(value.replace(",", "."))) || 0; +} + +function parseTimezone(timezoneString) { + if (timezoneString === "Z") return 0; + + const captures = timezoneString.match(timezoneRegex); + if (!captures) return 0; + + const sign = captures[1] === "+" ? -1 : 1; + const hours = parseInt(captures[2]); + const minutes = (captures[3] && parseInt(captures[3])) || 0; + + if (!validateTimezone(hours, minutes)) { + return NaN; + } + + return ( + sign * + (hours * _index.millisecondsInHour + minutes * _index.millisecondsInMinute) + ); +} + +function dayOfISOWeekYear(isoWeekYear, week, day) { + const date = new Date(0); + date.setUTCFullYear(isoWeekYear, 0, 4); + const fourthOfJanuaryDay = date.getUTCDay() || 7; + const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay; + date.setUTCDate(date.getUTCDate() + diff); + return date; +} + +// Validation functions + +// February is null to handle the leap year (using ||) +const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + +function isLeapYearIndex(year) { + return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); +} + +function validateDate(year, month, date) { + return ( + month >= 0 && + month <= 11 && + date >= 1 && + date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28)) + ); +} + +function validateDayOfYearDate(year, dayOfYear) { + return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365); +} + +function validateWeekDate(_year, week, day) { + return week >= 1 && week <= 53 && day >= 0 && day <= 6; +} + +function validateTime(hours, minutes, seconds) { + if (hours === 24) { + return minutes === 0 && seconds === 0; + } + + return ( + seconds >= 0 && + seconds < 60 && + minutes >= 0 && + minutes < 60 && + hours >= 0 && + hours < 25 + ); +} + +function validateTimezone(_hours, minutes) { + return minutes >= 0 && minutes <= 59; +} + + +/***/ }), + +/***/ 26380: +/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { + +"use strict"; + +exports.parseJSON = parseJSON; +var _index = __nccwpck_require__(44826); + +/** + * The {@link parseJSON} function options. + */ + +/** + * Converts a complete ISO date string in UTC time, the typical format for transmitting + * a date in JSON, to a JavaScript `Date` instance. + * + * This is a minimal implementation for converting dates retrieved from a JSON API to + * a `Date` instance which can be used with other functions in the `date-fns` library. + * The following formats are supported: + * + * - `2000-03-15T05:20:10.123Z`: The output of `.toISOString()` and `JSON.stringify(new Date())` + * - `2000-03-15T05:20:10Z`: Without milliseconds + * - `2000-03-15T05:20:10+00:00`: With a zero offset, the default JSON encoded format in some other languages + * - `2000-03-15T05:20:10+05:45`: With a positive or negative offset, the default JSON encoded format in some other languages + * - `2000-03-15T05:20:10+0000`: With a zero offset without a colon + * - `2000-03-15T05:20:10`: Without a trailing 'Z' symbol + * - `2000-03-15T05:20:10.1234567`: Up to 7 digits in milliseconds field. Only first 3 are taken into account since JS does not allow fractional milliseconds + * - `2000-03-15 05:20:10`: With a space instead of a 'T' separator for APIs returning a SQL date without reformatting + * + * For convenience and ease of use these other input types are also supported + * via [toDate](https://date-fns.org/docs/toDate): + * + * - A `Date` instance will be cloned + * - A `number` will be treated as a timestamp + * + * Any other input type or invalid date strings will return an `Invalid Date`. + * + * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. + * + * @param dateStr - A fully formed ISO8601 date string to convert + * @param options - An object with options + * + * @returns The parsed date in the local time zone + */ +function parseJSON(dateStr, options) { + const parts = dateStr.match( + /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/, + ); + + if (!parts) return (0, _index.toDate)(NaN, options?.in); + + return (0, _index.toDate)( + Date.UTC( + +parts[1], + +parts[2] - 1, + +parts[3], + +parts[4] - (+parts[9] || 0) * (parts[8] == "-" ? -1 : 1), + +parts[5] - (+parts[10] || 0) * (parts[8] == "-" ? -1 : 1), + +parts[6], + +((parts[7] || "0") + "00").substring(0, 3), + ), + options?.in, + ); +} + + /***/ }), /***/ 29861: @@ -201117,378 +201297,6 @@ function isLeapYearIndex(year) { } -/***/ }), - -/***/ 27633: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -exports.parseISO = parseISO; -var _index = __nccwpck_require__(46104); - -var _index2 = __nccwpck_require__(25848); -var _index3 = __nccwpck_require__(44826); - -/** - * The {@link parseISO} function options. - */ - -/** - * @name parseISO - * @category Common Helpers - * @summary Parse ISO string - * - * @description - * Parse the given string in ISO 8601 format and return an instance of Date. - * - * Function accepts complete ISO 8601 formats as well as partial implementations. - * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601 - * - * If the argument isn't a string, the function cannot parse the string or - * the values are invalid, it returns Invalid Date. - * - * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc). - * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. - * - * @param argument - The value to convert - * @param options - An object with options - * - * @returns The parsed date in the local time zone - * - * @example - * // Convert string '2014-02-11T11:30:30' to date: - * const result = parseISO('2014-02-11T11:30:30') - * //=> Tue Feb 11 2014 11:30:30 - * - * @example - * // Convert string '+02014101' to date, - * // if the additional number of digits in the extended year format is 1: - * const result = parseISO('+02014101', { additionalDigits: 1 }) - * //=> Fri Apr 11 2014 00:00:00 - */ -function parseISO(argument, options) { - const invalidDate = () => (0, _index2.constructFrom)(options?.in, NaN); - - const additionalDigits = options?.additionalDigits ?? 2; - const dateStrings = splitDateString(argument); - - let date; - if (dateStrings.date) { - const parseYearResult = parseYear(dateStrings.date, additionalDigits); - date = parseDate(parseYearResult.restDateString, parseYearResult.year); - } - - if (!date || isNaN(+date)) return invalidDate(); - - const timestamp = +date; - let time = 0; - let offset; - - if (dateStrings.time) { - time = parseTime(dateStrings.time); - if (isNaN(time)) return invalidDate(); - } - - if (dateStrings.timezone) { - offset = parseTimezone(dateStrings.timezone); - if (isNaN(offset)) return invalidDate(); - } else { - const tmpDate = new Date(timestamp + time); - const result = (0, _index3.toDate)(0, options?.in); - result.setFullYear( - tmpDate.getUTCFullYear(), - tmpDate.getUTCMonth(), - tmpDate.getUTCDate(), - ); - result.setHours( - tmpDate.getUTCHours(), - tmpDate.getUTCMinutes(), - tmpDate.getUTCSeconds(), - tmpDate.getUTCMilliseconds(), - ); - return result; - } - - return (0, _index3.toDate)(timestamp + time + offset, options?.in); -} - -const patterns = { - dateTimeDelimiter: /[T ]/, - timeZoneDelimiter: /[Z ]/i, - timezone: /([Z+-].*)$/, -}; - -const dateRegex = - /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/; -const timeRegex = - /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/; -const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/; - -function splitDateString(dateString) { - const dateStrings = {}; - const array = dateString.split(patterns.dateTimeDelimiter); - let timeString; - - // The regex match should only return at maximum two array elements. - // [date], [time], or [date, time]. - if (array.length > 2) { - return dateStrings; - } - - if (/:/.test(array[0])) { - timeString = array[0]; - } else { - dateStrings.date = array[0]; - timeString = array[1]; - if (patterns.timeZoneDelimiter.test(dateStrings.date)) { - dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0]; - timeString = dateString.substr( - dateStrings.date.length, - dateString.length, - ); - } - } - - if (timeString) { - const token = patterns.timezone.exec(timeString); - if (token) { - dateStrings.time = timeString.replace(token[1], ""); - dateStrings.timezone = token[1]; - } else { - dateStrings.time = timeString; - } - } - - return dateStrings; -} - -function parseYear(dateString, additionalDigits) { - const regex = new RegExp( - "^(?:(\\d{4}|[+-]\\d{" + - (4 + additionalDigits) + - "})|(\\d{2}|[+-]\\d{" + - (2 + additionalDigits) + - "})$)", - ); - - const captures = dateString.match(regex); - // Invalid ISO-formatted year - if (!captures) return { year: NaN, restDateString: "" }; - - const year = captures[1] ? parseInt(captures[1]) : null; - const century = captures[2] ? parseInt(captures[2]) : null; - - // either year or century is null, not both - return { - year: century === null ? year : century * 100, - restDateString: dateString.slice((captures[1] || captures[2]).length), - }; -} - -function parseDate(dateString, year) { - // Invalid ISO-formatted year - if (year === null) return new Date(NaN); - - const captures = dateString.match(dateRegex); - // Invalid ISO-formatted string - if (!captures) return new Date(NaN); - - const isWeekDate = !!captures[4]; - const dayOfYear = parseDateUnit(captures[1]); - const month = parseDateUnit(captures[2]) - 1; - const day = parseDateUnit(captures[3]); - const week = parseDateUnit(captures[4]); - const dayOfWeek = parseDateUnit(captures[5]) - 1; - - if (isWeekDate) { - if (!validateWeekDate(year, week, dayOfWeek)) { - return new Date(NaN); - } - return dayOfISOWeekYear(year, week, dayOfWeek); - } else { - const date = new Date(0); - if ( - !validateDate(year, month, day) || - !validateDayOfYearDate(year, dayOfYear) - ) { - return new Date(NaN); - } - date.setUTCFullYear(year, month, Math.max(dayOfYear, day)); - return date; - } -} - -function parseDateUnit(value) { - return value ? parseInt(value) : 1; -} - -function parseTime(timeString) { - const captures = timeString.match(timeRegex); - if (!captures) return NaN; // Invalid ISO-formatted time - - const hours = parseTimeUnit(captures[1]); - const minutes = parseTimeUnit(captures[2]); - const seconds = parseTimeUnit(captures[3]); - - if (!validateTime(hours, minutes, seconds)) { - return NaN; - } - - return ( - hours * _index.millisecondsInHour + - minutes * _index.millisecondsInMinute + - seconds * 1000 - ); -} - -function parseTimeUnit(value) { - return (value && parseFloat(value.replace(",", "."))) || 0; -} - -function parseTimezone(timezoneString) { - if (timezoneString === "Z") return 0; - - const captures = timezoneString.match(timezoneRegex); - if (!captures) return 0; - - const sign = captures[1] === "+" ? -1 : 1; - const hours = parseInt(captures[2]); - const minutes = (captures[3] && parseInt(captures[3])) || 0; - - if (!validateTimezone(hours, minutes)) { - return NaN; - } - - return ( - sign * - (hours * _index.millisecondsInHour + minutes * _index.millisecondsInMinute) - ); -} - -function dayOfISOWeekYear(isoWeekYear, week, day) { - const date = new Date(0); - date.setUTCFullYear(isoWeekYear, 0, 4); - const fourthOfJanuaryDay = date.getUTCDay() || 7; - const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay; - date.setUTCDate(date.getUTCDate() + diff); - return date; -} - -// Validation functions - -// February is null to handle the leap year (using ||) -const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; - -function isLeapYearIndex(year) { - return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0); -} - -function validateDate(year, month, date) { - return ( - month >= 0 && - month <= 11 && - date >= 1 && - date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28)) - ); -} - -function validateDayOfYearDate(year, dayOfYear) { - return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365); -} - -function validateWeekDate(_year, week, day) { - return week >= 1 && week <= 53 && day >= 0 && day <= 6; -} - -function validateTime(hours, minutes, seconds) { - if (hours === 24) { - return minutes === 0 && seconds === 0; - } - - return ( - seconds >= 0 && - seconds < 60 && - minutes >= 0 && - minutes < 60 && - hours >= 0 && - hours < 25 - ); -} - -function validateTimezone(_hours, minutes) { - return minutes >= 0 && minutes <= 59; -} - - -/***/ }), - -/***/ 26380: -/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => { - -"use strict"; - -exports.parseJSON = parseJSON; -var _index = __nccwpck_require__(44826); - -/** - * The {@link parseJSON} function options. - */ - -/** - * Converts a complete ISO date string in UTC time, the typical format for transmitting - * a date in JSON, to a JavaScript `Date` instance. - * - * This is a minimal implementation for converting dates retrieved from a JSON API to - * a `Date` instance which can be used with other functions in the `date-fns` library. - * The following formats are supported: - * - * - `2000-03-15T05:20:10.123Z`: The output of `.toISOString()` and `JSON.stringify(new Date())` - * - `2000-03-15T05:20:10Z`: Without milliseconds - * - `2000-03-15T05:20:10+00:00`: With a zero offset, the default JSON encoded format in some other languages - * - `2000-03-15T05:20:10+05:45`: With a positive or negative offset, the default JSON encoded format in some other languages - * - `2000-03-15T05:20:10+0000`: With a zero offset without a colon - * - `2000-03-15T05:20:10`: Without a trailing 'Z' symbol - * - `2000-03-15T05:20:10.1234567`: Up to 7 digits in milliseconds field. Only first 3 are taken into account since JS does not allow fractional milliseconds - * - `2000-03-15 05:20:10`: With a space instead of a 'T' separator for APIs returning a SQL date without reformatting - * - * For convenience and ease of use these other input types are also supported - * via [toDate](https://date-fns.org/docs/toDate): - * - * - A `Date` instance will be cloned - * - A `number` will be treated as a timestamp - * - * Any other input type or invalid date strings will return an `Invalid Date`. - * - * @typeParam ResultDate - The result `Date` type, it is the type returned from the context function if it is passed, or inferred from the arguments. - * - * @param dateStr - A fully formed ISO8601 date string to convert - * @param options - An object with options - * - * @returns The parsed date in the local time zone - */ -function parseJSON(dateStr, options) { - const parts = dateStr.match( - /(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?/, - ); - - if (!parts) return (0, _index.toDate)(NaN, options?.in); - - return (0, _index.toDate)( - Date.UTC( - +parts[1], - +parts[2] - 1, - +parts[3], - +parts[4] - (+parts[9] || 0) * (parts[8] == "-" ? -1 : 1), - +parts[5] - (+parts[10] || 0) * (parts[8] == "-" ? -1 : 1), - +parts[6], - +((parts[7] || "0") + "00").substring(0, 3), - ), - options?.in, - ); -} - - /***/ }), /***/ 80144: diff --git a/package-lock.json b/package-lock.json index fa637b09..56c62aa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -396,6 +396,7 @@ "integrity": "sha512-2BCOP7TN8M+gVDj7/ht3hsaO/B/n5oDbiAyyvnRlNOs+u1o+JWNYTQrmpuNp1/Wq2gcFrI01JAW+paEKDMx/CA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@babel/code-frame": "^7.27.1", "@babel/generator": "^7.28.3", @@ -2901,6 +2902,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.2.1.tgz", "integrity": "sha512-dKYCMuPO1bmrpuogcjQ8z7ICCH3FP6WmxpwC03yjzGfZhj9fTJg6+bS1+UAplekbN2C+M61UNllGOOoAfGCrdQ==", + "peer": true, "dependencies": { "@octokit/auth-token": "^4.0.0", "@octokit/graphql": "^7.1.0", @@ -3623,6 +3625,7 @@ "integrity": "sha512-Aq2dPqsQkxHOLfb2OPv43RnIvfj05nw8v/6n3B2NABIPpHnjQnaLo9QGMTvml+tv4korl/Cjfrb/BYhoL8UUTQ==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.10.0", "@typescript-eslint/scope-manager": "8.42.0", @@ -3662,6 +3665,7 @@ "integrity": "sha512-r1XG74QgShUgXph1BYseJ+KZd17bKQib/yF3SR+demvytiRXrwd12Blnz5eYGm8tXaeRdd4x88MlfwldHoudGg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.42.0", "@typescript-eslint/types": "8.42.0", @@ -4214,6 +4218,7 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4992,6 +4997,7 @@ } ], "license": "MIT", + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001737", "electron-to-chromium": "^1.5.211", @@ -5576,6 +5582,7 @@ "integrity": "sha512-QePbBFMJFjgmlE+cXAlbHZbHpdFVS2E/6vzCy7aKlebddvl1vadiC4JFV5u/wqTkNUwEV8WrQi257jf5f06hrg==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -5637,6 +5644,7 @@ "integrity": "sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==", "dev": true, "license": "MIT", + "peer": true, "bin": { "eslint-config-prettier": "bin/cli.js" }, @@ -6314,6 +6322,7 @@ "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.11.0.tgz", "integrity": "sha512-mS1lbMsxgQj6hge1XZ6p7GPhbrtFwUFYi3wRzXAC/FmYnyXMTvvI3td3rjmQ2u8ewXueaSvRPWaEcgVVOT9Jnw==", "dev": true, + "peer": true, "engines": { "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" } @@ -6743,6 +6752,7 @@ "integrity": "sha512-F26gjC0yWN8uAA5m5Ss8ZQf5nDHWGlN/xWZIh8S5SRbsEKBovwZhxGd6LJlbZYxBgCYOtreSUyb8hpXyGC5O4A==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "@jest/core": "30.2.0", "@jest/types": "30.2.0", @@ -10856,6 +10866,7 @@ "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", "dev": true, "license": "MIT", + "peer": true, "bin": { "prettier": "bin/prettier.cjs" }, @@ -11628,6 +11639,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", "license": "Apache-2.0", + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" diff --git a/test/unit/action/decorate/summary.test.ts b/test/unit/action/decorate/summary.test.ts index af71d487..26b75d1c 100644 --- a/test/unit/action/decorate/summary.test.ts +++ b/test/unit/action/decorate/summary.test.ts @@ -147,7 +147,6 @@ describe('createSummaryBody', () => { expect(string).toContain('>+25'); expect(string).toContain('>0'); - console.log(string); summary.clear(); }); diff --git a/test/unit/helper/response.test.ts b/test/unit/helper/response.test.ts index 8ea6a2a8..f592a92a 100644 --- a/test/unit/helper/response.test.ts +++ b/test/unit/helper/response.test.ts @@ -50,13 +50,13 @@ describe('getRetryErrorMessage', () => { }); it('should return Error on RequestError of @tiobe/http-client with retry.', () => { - const message = getRetryErrorMessage(new TicsError('Error message here', 2)); + const message = getRetryErrorMessage(new TicsError('Error message here', 400, 2)); expect(message).toBe('Error message here (retried 2 times)'); }); it('should return Error on RequestError of @tiobe/http-client without retry.', () => { - const message = getRetryErrorMessage(new TicsError('Error message here', 0)); + const message = getRetryErrorMessage(new TicsError('Error message here', 400, 0)); expect(message).toBe('Error message here'); });