From af478cd8b56d7516a62811651db7ece334229e5a Mon Sep 17 00:00:00 2001 From: Geoff Lamrock Date: Wed, 13 Dec 2023 21:22:23 +1100 Subject: [PATCH] Upgrade to node 20 --- .github/workflows/dist.yml | 9 ++++ .github/workflows/test.yml | 5 +++ action.yml | 2 +- dist/index.js | 89 ++++++++++++++++++++++++++------------ package-lock.json | 50 ++++++++++++++------- package.json | 4 +- 6 files changed, 113 insertions(+), 46 deletions(-) diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml index 0912ed1..15ac92f 100644 --- a/.github/workflows/dist.yml +++ b/.github/workflows/dist.yml @@ -10,10 +10,18 @@ jobs: - uses: actions/checkout@v3 with: token: ${{ secrets.INTEGRATIONS_FNM_BOT_TOKEN }} + + - name: Setup node 20 + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: install run: npm ci + - name: build run: npm run build + - name: update README run: |- MAJOR_VERSION=$(cat package.json \ @@ -23,6 +31,7 @@ jobs: | sed 's/[", ]//g' \ | awk -F. '{ print $1 }') sed -i "s/\(uses: OctopusDeploy\/create-zip-package-action@\).*/\1v${MAJOR_VERSION}/g" README.md + - name: commit run: |- git config --global user.name "team-integrations-fnm-bot" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c284180..00707ed 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,6 +18,11 @@ jobs: steps: - uses: actions/checkout@v3 + - name: Setup node 20 + uses: actions/setup-node@v3 + with: + node-version: 20.x + - name: Install package dependencies run: npm install diff --git a/action.yml b/action.yml index f6ccb2e..6652c26 100644 --- a/action.yml +++ b/action.yml @@ -29,5 +29,5 @@ outputs: description: 'The filename, without the path, of the file that was created.' runs: - using: 'node16' + using: 'node20' main: 'dist/index.js' diff --git a/dist/index.js b/dist/index.js index 3f1e171..abe27e2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1829,11 +1829,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.AxiosAdapter = void 0; var axios_1 = __importDefault(__nccwpck_require__(8757)); var adapter_1 = __nccwpck_require__(937); +var createRequestHeaders_1 = __nccwpck_require__(7843); var AxiosAdapter = /** @class */ (function () { function AxiosAdapter() { } AxiosAdapter.prototype.execute = function (options) { - var _a, _b; + var _a; return __awaiter(this, void 0, void 0, function () { function formatError(response) { if (!response.data) { @@ -1841,6 +1842,7 @@ var AxiosAdapter = /** @class */ (function () { } var message = response.data.ErrorMessage; if (response.data.Errors) { + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions var errors = response.data.Errors; for (var i = 0; i < errors.length; i++) { message += "\n".concat(errors[i]); @@ -1849,21 +1851,19 @@ var AxiosAdapter = /** @class */ (function () { return message; } var config, userAgent, response, error_1; - return __generator(this, function (_c) { - switch (_c.label) { + return __generator(this, function (_b) { + switch (_b.label) { case 0: - _c.trys.push([0, 2, , 3]); + _b.trys.push([0, 2, , 3]); config = { httpsAgent: options.configuration.httpsAgent, url: options.url, maxContentLength: Infinity, maxBodyLength: Infinity, + // eslint-disable-next-line @typescript-eslint/consistent-type-assertions method: options.method, data: options.requestBody, - headers: { - "Accept-Encoding": "gzip,deflate,compress", - "X-Octopus-ApiKey": (_a = options.configuration.apiKey) !== null && _a !== void 0 ? _a : "", - }, + headers: (0, createRequestHeaders_1.createRequestHeaders)(options.configuration), responseType: "json", }; if (typeof XMLHttpRequest === "undefined") { @@ -1877,15 +1877,15 @@ var AxiosAdapter = /** @class */ (function () { } return [4 /*yield*/, axios_1.default.request(config)]; case 1: - response = _c.sent(); + response = _b.sent(); return [2 /*return*/, { data: response.data, statusCode: response.status, }]; case 2: - error_1 = _c.sent(); + error_1 = _b.sent(); if (axios_1.default.isAxiosError(error_1) && error_1.response) { - throw new adapter_1.AdapterError(error_1.response.status, (_b = formatError(error_1.response)) !== null && _b !== void 0 ? _b : error_1.message); + throw new adapter_1.AdapterError(error_1.response.status, (_a = formatError(error_1.response)) !== null && _a !== void 0 ? _a : error_1.message); } else { throw error_1; @@ -1901,6 +1901,34 @@ var AxiosAdapter = /** @class */ (function () { exports.AxiosAdapter = AxiosAdapter; +/***/ }), + +/***/ 7843: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.createRequestHeaders = void 0; +function createRequestHeaders(configuration) { + var headers = { + "Accept-Encoding": "gzip,deflate,compress", // HACK: required for https://github.com/axios/axios/issues/5346 -- this line can be removed once this bug has been fixed + }; + if (configuration.apiKey) { + headers["X-Octopus-ApiKey"] = configuration.apiKey; + } + if (configuration.accessToken) { + headers["Authorization"] = "Bearer ".concat(configuration.accessToken); + } + if (!configuration.accessToken && !configuration.apiKey) { + // Backward compatibility: Add the api key header in with a blank value + headers["X-Octopus-ApiKey"] = ""; + } + return headers; +} +exports.createRequestHeaders = createRequestHeaders; + + /***/ }), /***/ 1542: @@ -5210,14 +5238,13 @@ var DeploymentRepository = /** @class */ (function () { DeploymentRepository.prototype.create = function (command) { var _a, _b; return __awaiter(this, void 0, void 0, function () { - var serverInformation, serverVersion, response, mappedTasks; + var serverInformation, response, mappedTasks; return __generator(this, function (_c) { switch (_c.label) { case 0: return [4 /*yield*/, this.client.getServerInformation()]; case 1: serverInformation = _c.sent(); - serverVersion = new semver_1.SemVer(serverInformation.version); - if (serverVersion < new semver_1.SemVer("2022.3.5512")) { + if ((0, semver_1.lt)(serverInformation.version, "2022.3.5512")) { (_b = (_a = this.client).error) === null || _b === void 0 ? void 0 : _b.call(_a, "The Octopus instance doesn't support deploying releases using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); throw new Error("The Octopus instance doesn't support deploying releases using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); } @@ -5245,14 +5272,13 @@ var DeploymentRepository = /** @class */ (function () { DeploymentRepository.prototype.createTenanted = function (command) { var _a, _b; return __awaiter(this, void 0, void 0, function () { - var serverInformation, serverVersion, response, mappedTasks; + var serverInformation, response, mappedTasks; return __generator(this, function (_c) { switch (_c.label) { case 0: return [4 /*yield*/, this.client.getServerInformation()]; case 1: serverInformation = _c.sent(); - serverVersion = new semver_1.SemVer(serverInformation.version); - if (serverVersion < new semver_1.SemVer("2022.3.5512")) { + if ((0, semver_1.lt)(serverInformation.version, "2022.3.5512")) { (_b = (_a = this.client).error) === null || _b === void 0 ? void 0 : _b.call(_a, "The Octopus instance doesn't support deploying tenanted releases using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); throw new Error("The Octopus instance doesn't support deploying tenanted releases using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); } @@ -5426,14 +5452,13 @@ var ReleaseRepository = /** @class */ (function () { ReleaseRepository.prototype.create = function (command) { var _a, _b; return __awaiter(this, void 0, void 0, function () { - var serverInformation, serverVersion, response; + var serverInformation, response; return __generator(this, function (_c) { switch (_c.label) { case 0: return [4 /*yield*/, this.client.getServerInformation()]; case 1: serverInformation = _c.sent(); - serverVersion = new semver_1.SemVer(serverInformation.version); - if (serverVersion < new semver_1.SemVer("2022.3.5512")) { + if ((0, semver_1.lt)(serverInformation.version, "2022.3.5512")) { (_b = (_a = this.client).error) === null || _b === void 0 ? void 0 : _b.call(_a, "The Octopus instance doesn't support creating releases using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); throw new Error("The Octopus instance doesn't support creating releases using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); } @@ -5888,14 +5913,13 @@ var RunbookRunRepository = /** @class */ (function () { RunbookRunRepository.prototype.create = function (command) { var _a, _b; return __awaiter(this, void 0, void 0, function () { - var serverInformation, serverVersion, response, mappedTasks; + var serverInformation, response, mappedTasks; return __generator(this, function (_c) { switch (_c.label) { case 0: return [4 /*yield*/, this.client.getServerInformation()]; case 1: serverInformation = _c.sent(); - serverVersion = new semver_1.SemVer(serverInformation.version); - if (serverVersion < new semver_1.SemVer("2022.3.5512")) { + if ((0, semver_1.lt)(serverInformation.version, "2022.3.5512")) { (_b = (_a = this.client).error) === null || _b === void 0 ? void 0 : _b.call(_a, "The Octopus instance doesn't support running runbooks using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); throw new Error("The Octopus instance doesn't support running runbooks using the Executions API, it will need to be upgraded to at least 2022.3.5512 in order to access this API."); } @@ -6705,18 +6729,29 @@ var TenantRepository = /** @class */ (function (_super) { return _super.call(this, client, spaceName, "".concat(__1.spaceScopedRoutePrefix, "/tenants"), "skip,projectId,tags,take,ids,clone,partialName,clonedFromTenantId") || this; } TenantRepository.prototype.tagTest = function (tenantIds, tags) { - return this.client.request("".concat(__1.spaceScopedRoutePrefix, "/tenants/tag-test{?tenantIds,tags}"), { tenantIds: tenantIds, tags: tags }); + return this.client.request("".concat(__1.spaceScopedRoutePrefix, "/tenants/tag-test{?tenantIds,tags}"), { + spaceName: this.spaceName, + tenantIds: tenantIds, + tags: tags, + }); }; TenantRepository.prototype.getVariables = function (tenant) { - return this.client.request("".concat(__1.spaceScopedRoutePrefix, "/tenants/{id}/variables")); + return this.client.request("".concat(__1.spaceScopedRoutePrefix, "/tenants/{id}/variables"), { + spaceName: this.spaceName, + id: tenant.Id, + }); }; TenantRepository.prototype.setVariables = function (tenant, variables) { - return this.client.doUpdate("".concat(__1.spaceScopedRoutePrefix, "/tenants/{id}/variables"), variables); + return this.client.doUpdate("".concat(__1.spaceScopedRoutePrefix, "/tenants/{id}/variables"), variables, { + spaceName: this.spaceName, + id: tenant.Id, + }); }; TenantRepository.prototype.missingVariables = function (filterOptions, includeDetails) { if (filterOptions === void 0) { filterOptions = {}; } if (includeDetails === void 0) { includeDetails = false; } var payload = { + spaceName: this.spaceName, environmentId: filterOptions.environmentId, includeDetails: includeDetails, projectId: filterOptions.projectId, @@ -7213,7 +7248,7 @@ function resolveSpaceId(client, spaceName) { return [2 /*return*/, knownSpaces[spaceName]]; } client.debug("Resolving space from name '".concat(spaceName, "'")); - return [4 /*yield*/, client.get("".concat(apiLocation_1.apiLocation, "/spaces?partialName=").concat(spaceName, "&skip=0&take=").concat(features_1.BasicRepository.TakeAll))]; + return [4 /*yield*/, client.get("".concat(apiLocation_1.apiLocation, "/spaces?partialName=").concat(encodeURIComponent(spaceName), "&skip=0&take=").concat(features_1.BasicRepository.TakeAll))]; case 1: spaces = _a.sent(); spaceId = ""; diff --git a/package-lock.json b/package-lock.json index f451906..54afdd6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "@actions/core": "^1.10.0", - "@octopusdeploy/api-client": "^v3.0.3", + "@octopusdeploy/api-client": "^3.2.0", "glob": "^8.1.0" }, "devDependencies": { @@ -18,7 +18,7 @@ "@types/jest": "^29.4.0", "@types/json-patch": "^0.0.30", "@types/lodash": "^4.14.191", - "@types/node": "^18.11.18", + "@types/node": "^20.10.4", "@types/tmp": "^0.2.3", "@typescript-eslint/parser": "^5.49.0", "@vercel/ncc": "^0.36.1", @@ -1228,9 +1228,9 @@ } }, "node_modules/@octopusdeploy/api-client": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.0.4.tgz", - "integrity": "sha512-ieXccPQY2hoQ70a6EW2lJijKnEMKqs6dgXBrm4J8KZ4RNPaTBeOxT/fwNKL4mZxBXMFeVvum7ZYwmPqd11X6gg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.2.0.tgz", + "integrity": "sha512-0TrbsXaFc/Xi3yfsEEAvf5mOveZx4K347LmBRwCuLd2pLl8tj3NJYJn7nRzz3kr4j6o46oUv1RukemEXqu91Dg==", "dependencies": { "adm-zip": "^0.5.9", "axios": "^1.2.1", @@ -1390,10 +1390,13 @@ "dev": true }, "node_modules/@types/node": { - "version": "18.11.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", - "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==", - "dev": true + "version": "20.10.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.4.tgz", + "integrity": "sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@types/prettier": { "version": "2.7.2", @@ -6257,6 +6260,12 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/update-browserslist-db": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", @@ -7427,9 +7436,9 @@ } }, "@octopusdeploy/api-client": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.0.4.tgz", - "integrity": "sha512-ieXccPQY2hoQ70a6EW2lJijKnEMKqs6dgXBrm4J8KZ4RNPaTBeOxT/fwNKL4mZxBXMFeVvum7ZYwmPqd11X6gg==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@octopusdeploy/api-client/-/api-client-3.2.0.tgz", + "integrity": "sha512-0TrbsXaFc/Xi3yfsEEAvf5mOveZx4K347LmBRwCuLd2pLl8tj3NJYJn7nRzz3kr4j6o46oUv1RukemEXqu91Dg==", "requires": { "adm-zip": "^0.5.9", "axios": "^1.2.1", @@ -7589,10 +7598,13 @@ "dev": true }, "@types/node": { - "version": "18.11.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", - "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==", - "dev": true + "version": "20.10.4", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.4.tgz", + "integrity": "sha512-D08YG6rr8X90YB56tSIuBaddy/UXAA9RKJoFvrsnogAum/0pmjkgi4+2nx96A330FmioegBWmEYQ+syqCFaveg==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } }, "@types/prettier": { "version": "2.7.2", @@ -11121,6 +11133,12 @@ "which-boxed-primitive": "^1.0.2" } }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "update-browserslist-db": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.10.tgz", diff --git a/package.json b/package.json index c4c6613..57f7b99 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ }, "dependencies": { "@actions/core": "^1.10.0", - "@octopusdeploy/api-client": "^v3.0.4", + "@octopusdeploy/api-client": "^3.2.0", "glob": "^8.1.0" }, "description": "GitHub Action to create a Zip package for Octopus Deploy", @@ -14,7 +14,7 @@ "@types/jest": "^29.4.0", "@types/json-patch": "^0.0.30", "@types/lodash": "^4.14.191", - "@types/node": "^18.11.18", + "@types/node": "^20.10.4", "@types/tmp": "^0.2.3", "@typescript-eslint/parser": "^5.49.0", "@vercel/ncc": "^0.36.1",