@ossy/deployment-tools 0.0.24 → 0.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -9743,7 +9743,7 @@ const AssumeRoleCommand_1 = __nccwpck_require__(78540);
9743
9743
  const AssumeRoleWithSAMLCommand_1 = __nccwpck_require__(15559);
9744
9744
  const AssumeRoleWithWebIdentityCommand_1 = __nccwpck_require__(50915);
9745
9745
  const DecodeAuthorizationMessageCommand_1 = __nccwpck_require__(72693);
9746
- const GetAccessKeyInfoCommand_1 = __nccwpck_require__(12818);
9746
+ const GetAccessKeyInfoCommand_1 = __nccwpck_require__(33041);
9747
9747
  const GetCallerIdentityCommand_1 = __nccwpck_require__(48244);
9748
9748
  const GetFederationTokenCommand_1 = __nccwpck_require__(10411);
9749
9749
  const GetSessionTokenCommand_1 = __nccwpck_require__(81755);
@@ -10086,7 +10086,7 @@ exports.DecodeAuthorizationMessageCommand = DecodeAuthorizationMessageCommand;
10086
10086
 
10087
10087
  /***/ }),
10088
10088
 
10089
- /***/ 12818:
10089
+ /***/ 33041:
10090
10090
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
10091
10091
 
10092
10092
 
@@ -10276,7 +10276,7 @@ tslib_1.__exportStar(__nccwpck_require__(78540), exports);
10276
10276
  tslib_1.__exportStar(__nccwpck_require__(15559), exports);
10277
10277
  tslib_1.__exportStar(__nccwpck_require__(50915), exports);
10278
10278
  tslib_1.__exportStar(__nccwpck_require__(72693), exports);
10279
- tslib_1.__exportStar(__nccwpck_require__(12818), exports);
10279
+ tslib_1.__exportStar(__nccwpck_require__(33041), exports);
10280
10280
  tslib_1.__exportStar(__nccwpck_require__(48244), exports);
10281
10281
  tslib_1.__exportStar(__nccwpck_require__(10411), exports);
10282
10282
  tslib_1.__exportStar(__nccwpck_require__(81755), exports);
@@ -13337,7 +13337,7 @@ const loadRestJsonErrorCode = (output, data) => {
13337
13337
  Object.defineProperty(exports, "__esModule", ({ value: true }));
13338
13338
  exports.getRuntimeConfig = void 0;
13339
13339
  const tslib_1 = __nccwpck_require__(43100);
13340
- const package_json_1 = tslib_1.__importDefault(__nccwpck_require__(22074));
13340
+ const package_json_1 = tslib_1.__importDefault(__nccwpck_require__(24665));
13341
13341
  const config_resolver_1 = __nccwpck_require__(30225);
13342
13342
  const hash_node_1 = __nccwpck_require__(13897);
13343
13343
  const middleware_retry_1 = __nccwpck_require__(20054);
@@ -13669,7 +13669,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
13669
13669
 
13670
13670
  /***/ }),
13671
13671
 
13672
- /***/ 84847:
13672
+ /***/ 64034:
13673
13673
  /***/ ((__unused_webpack_module, exports) => {
13674
13674
 
13675
13675
 
@@ -13690,7 +13690,7 @@ exports.getHostnameFromVariants = getHostnameFromVariants;
13690
13690
 
13691
13691
  Object.defineProperty(exports, "__esModule", ({ value: true }));
13692
13692
  exports.getRegionInfo = void 0;
13693
- const getHostnameFromVariants_1 = __nccwpck_require__(84847);
13693
+ const getHostnameFromVariants_1 = __nccwpck_require__(64034);
13694
13694
  const getResolvedHostname_1 = __nccwpck_require__(15751);
13695
13695
  const getResolvedPartition_1 = __nccwpck_require__(45970);
13696
13696
  const getResolvedSigningRegion_1 = __nccwpck_require__(82858);
@@ -19428,7 +19428,7 @@ exports.defaultUserAgent = exports.UA_APP_ID_INI_NAME = exports.UA_APP_ID_ENV_NA
19428
19428
  const node_config_provider_1 = __nccwpck_require__(71287);
19429
19429
  const os_1 = __nccwpck_require__(22037);
19430
19430
  const process_1 = __nccwpck_require__(77282);
19431
- const is_crt_available_1 = __nccwpck_require__(83002);
19431
+ const is_crt_available_1 = __nccwpck_require__(24078);
19432
19432
  exports.UA_APP_ID_ENV_NAME = "AWS_SDK_UA_APP_ID";
19433
19433
  exports.UA_APP_ID_INI_NAME = "sdk-ua-app-id";
19434
19434
  const defaultUserAgent = ({ serviceId, clientVersion }) => {
@@ -19467,7 +19467,7 @@ exports.defaultUserAgent = defaultUserAgent;
19467
19467
 
19468
19468
  /***/ }),
19469
19469
 
19470
- /***/ 83002:
19470
+ /***/ 24078:
19471
19471
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
19472
19472
 
19473
19473
 
@@ -23096,7 +23096,7 @@ exports.getRecursionDetectionPlugin = getRecursionDetectionPlugin;
23096
23096
 
23097
23097
  Object.defineProperty(exports, "__esModule", ({ value: true }));
23098
23098
  exports.AdaptiveRetryStrategy = void 0;
23099
- const config_1 = __nccwpck_require__(64034);
23099
+ const config_1 = __nccwpck_require__(6391);
23100
23100
  const DefaultRateLimiter_1 = __nccwpck_require__(43179);
23101
23101
  const StandardRetryStrategy_1 = __nccwpck_require__(89131);
23102
23102
  class AdaptiveRetryStrategy extends StandardRetryStrategy_1.StandardRetryStrategy {
@@ -23242,7 +23242,7 @@ exports.StandardRetryStrategy = void 0;
23242
23242
  const protocol_http_1 = __nccwpck_require__(67976);
23243
23243
  const service_error_classification_1 = __nccwpck_require__(83734);
23244
23244
  const uuid_1 = __nccwpck_require__(14115);
23245
- const config_1 = __nccwpck_require__(64034);
23245
+ const config_1 = __nccwpck_require__(6391);
23246
23246
  const constants_1 = __nccwpck_require__(724);
23247
23247
  const defaultRetryQuota_1 = __nccwpck_require__(57464);
23248
23248
  const delayDecider_1 = __nccwpck_require__(11355);
@@ -23344,7 +23344,7 @@ const asSdkError = (error) => {
23344
23344
 
23345
23345
  /***/ }),
23346
23346
 
23347
- /***/ 64034:
23347
+ /***/ 6391:
23348
23348
  /***/ ((__unused_webpack_module, exports) => {
23349
23349
 
23350
23350
 
@@ -23369,7 +23369,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
23369
23369
  exports.NODE_RETRY_MODE_CONFIG_OPTIONS = exports.CONFIG_RETRY_MODE = exports.ENV_RETRY_MODE = exports.resolveRetryConfig = exports.NODE_MAX_ATTEMPT_CONFIG_OPTIONS = exports.CONFIG_MAX_ATTEMPTS = exports.ENV_MAX_ATTEMPTS = void 0;
23370
23370
  const util_middleware_1 = __nccwpck_require__(18154);
23371
23371
  const AdaptiveRetryStrategy_1 = __nccwpck_require__(64277);
23372
- const config_1 = __nccwpck_require__(64034);
23372
+ const config_1 = __nccwpck_require__(6391);
23373
23373
  const StandardRetryStrategy_1 = __nccwpck_require__(89131);
23374
23374
  exports.ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";
23375
23375
  exports.CONFIG_MAX_ATTEMPTS = "max_attempts";
@@ -23506,7 +23506,7 @@ const tslib_1 = __nccwpck_require__(43100);
23506
23506
  tslib_1.__exportStar(__nccwpck_require__(64277), exports);
23507
23507
  tslib_1.__exportStar(__nccwpck_require__(43179), exports);
23508
23508
  tslib_1.__exportStar(__nccwpck_require__(89131), exports);
23509
- tslib_1.__exportStar(__nccwpck_require__(64034), exports);
23509
+ tslib_1.__exportStar(__nccwpck_require__(6391), exports);
23510
23510
  tslib_1.__exportStar(__nccwpck_require__(81209), exports);
23511
23511
  tslib_1.__exportStar(__nccwpck_require__(11355), exports);
23512
23512
  tslib_1.__exportStar(__nccwpck_require__(9683), exports);
@@ -25631,7 +25631,7 @@ exports.loadConfig = void 0;
25631
25631
  const property_provider_1 = __nccwpck_require__(36586);
25632
25632
  const fromEnv_1 = __nccwpck_require__(43287);
25633
25633
  const fromSharedConfigFiles_1 = __nccwpck_require__(20715);
25634
- const fromStatic_1 = __nccwpck_require__(33041);
25634
+ const fromStatic_1 = __nccwpck_require__(45367);
25635
25635
  const loadConfig = ({ environmentVariableSelector, configFileSelector, default: defaultValue }, configuration = {}) => (0, property_provider_1.memoize)((0, property_provider_1.chain)((0, fromEnv_1.fromEnv)(environmentVariableSelector), (0, fromSharedConfigFiles_1.fromSharedConfigFiles)(configFileSelector, configuration), (0, fromStatic_1.fromStatic)(defaultValue)));
25636
25636
  exports.loadConfig = loadConfig;
25637
25637
 
@@ -25695,7 +25695,7 @@ exports.fromSharedConfigFiles = fromSharedConfigFiles;
25695
25695
 
25696
25696
  /***/ }),
25697
25697
 
25698
- /***/ 33041:
25698
+ /***/ 45367:
25699
25699
  /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
25700
25700
 
25701
25701
 
@@ -28441,7 +28441,7 @@ exports.fromString = fromString;
28441
28441
 
28442
28442
  /***/ }),
28443
28443
 
28444
- /***/ 29608:
28444
+ /***/ 52086:
28445
28445
  /***/ ((__unused_webpack_module, exports) => {
28446
28446
 
28447
28447
 
@@ -28472,7 +28472,7 @@ exports.booleanSelector = booleanSelector;
28472
28472
 
28473
28473
  Object.defineProperty(exports, "__esModule", ({ value: true }));
28474
28474
  const tslib_1 = __nccwpck_require__(43100);
28475
- tslib_1.__exportStar(__nccwpck_require__(29608), exports);
28475
+ tslib_1.__exportStar(__nccwpck_require__(52086), exports);
28476
28476
 
28477
28477
 
28478
28478
  /***/ }),
@@ -29490,7 +29490,7 @@ var createError = __nccwpck_require__(45379)
29490
29490
  var destroy = __nccwpck_require__(38454)
29491
29491
  var getBody = __nccwpck_require__(21098)
29492
29492
  var iconv = __nccwpck_require__(52341)
29493
- var onFinished = __nccwpck_require__(52086)
29493
+ var onFinished = __nccwpck_require__(1103)
29494
29494
  var unpipe = __nccwpck_require__(89890)
29495
29495
  var zlib = __nccwpck_require__(59796)
29496
29496
 
@@ -34569,7 +34569,7 @@ function tryRender(view, options, callback) {
34569
34569
 
34570
34570
  var bodyParser = __nccwpck_require__(47749)
34571
34571
  var EventEmitter = (__nccwpck_require__(82361).EventEmitter);
34572
- var mixin = __nccwpck_require__(24665);
34572
+ var mixin = __nccwpck_require__(61878);
34573
34573
  var proto = __nccwpck_require__(19796);
34574
34574
  var Route = __nccwpck_require__(10791);
34575
34575
  var Router = __nccwpck_require__(42658);
@@ -35334,7 +35334,7 @@ var encodeUrl = __nccwpck_require__(14099);
35334
35334
  var escapeHtml = __nccwpck_require__(51414);
35335
35335
  var http = __nccwpck_require__(13685);
35336
35336
  var isAbsolute = (__nccwpck_require__(30589).isAbsolute);
35337
- var onFinished = __nccwpck_require__(52086);
35337
+ var onFinished = __nccwpck_require__(1103);
35338
35338
  var path = __nccwpck_require__(71017);
35339
35339
  var statuses = __nccwpck_require__(31266)
35340
35340
  var merge = __nccwpck_require__(22859);
@@ -39618,7 +39618,7 @@ exports.getTraversalObj = getTraversalObj;
39618
39618
  var debug = __nccwpck_require__(2423)('finalhandler')
39619
39619
  var encodeUrl = __nccwpck_require__(14099)
39620
39620
  var escapeHtml = __nccwpck_require__(51414)
39621
- var onFinished = __nccwpck_require__(52086)
39621
+ var onFinished = __nccwpck_require__(1103)
39622
39622
  var parseUrl = __nccwpck_require__(4955)
39623
39623
  var statuses = __nccwpck_require__(31266)
39624
39624
  var unpipe = __nccwpck_require__(89890)
@@ -40601,7 +40601,7 @@ module.exports = function GetIntrinsic(name, allowMissing) {
40601
40601
 
40602
40602
 
40603
40603
  var origSymbol = typeof Symbol !== 'undefined' && Symbol;
40604
- var hasSymbolSham = __nccwpck_require__(24078);
40604
+ var hasSymbolSham = __nccwpck_require__(61663);
40605
40605
 
40606
40606
  module.exports = function hasNativeSymbols() {
40607
40607
  if (typeof origSymbol !== 'function') { return false; }
@@ -40615,7 +40615,7 @@ module.exports = function hasNativeSymbols() {
40615
40615
 
40616
40616
  /***/ }),
40617
40617
 
40618
- /***/ 24078:
40618
+ /***/ 61663:
40619
40619
  /***/ ((module) => {
40620
40620
 
40621
40621
 
@@ -44716,7 +44716,7 @@ function splitType(string) {
44716
44716
 
44717
44717
  /***/ }),
44718
44718
 
44719
- /***/ 24665:
44719
+ /***/ 61878:
44720
44720
  /***/ ((module) => {
44721
44721
 
44722
44722
  /*!
@@ -46840,7 +46840,7 @@ module.exports = __nccwpck_require__(73837).inspect;
46840
46840
 
46841
46841
  /***/ }),
46842
46842
 
46843
- /***/ 52086:
46843
+ /***/ 1103:
46844
46844
  /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
46845
46845
 
46846
46846
  /*!
@@ -49306,7 +49306,7 @@ var fresh = __nccwpck_require__(13620)
49306
49306
  var fs = __nccwpck_require__(57147)
49307
49307
  var mime = __nccwpck_require__(62138)
49308
49308
  var ms = __nccwpck_require__(45725)
49309
- var onFinished = __nccwpck_require__(52086)
49309
+ var onFinished = __nccwpck_require__(1103)
49310
49310
  var parseRange = __nccwpck_require__(31792)
49311
49311
  var path = __nccwpck_require__(71017)
49312
49312
  var statuses = __nccwpck_require__(31266)
@@ -58055,7 +58055,7 @@ module.exports = JSON.parse('{"name":"@aws-sdk/client-sso","description":"AWS SD
58055
58055
 
58056
58056
  /***/ }),
58057
58057
 
58058
- /***/ 22074:
58058
+ /***/ 24665:
58059
58059
  /***/ ((module) => {
58060
58060
 
58061
58061
  module.exports = JSON.parse('{"name":"@aws-sdk/client-sso","description":"AWS SDK for JavaScript Sso Client for Node.js, Browser and React Native","version":"3.188.0","scripts":{"build":"concurrently \'yarn:build:cjs\' \'yarn:build:es\' \'yarn:build:types\'","build:cjs":"tsc -p tsconfig.cjs.json","build:docs":"typedoc","build:es":"tsc -p tsconfig.es.json","build:include:deps":"lerna run --scope $npm_package_name --include-dependencies build","build:types":"tsc -p tsconfig.types.json","build:types:downlevel":"downlevel-dts dist-types dist-types/ts3.4","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","sideEffects":false,"dependencies":{"@aws-crypto/sha256-browser":"2.0.0","@aws-crypto/sha256-js":"2.0.0","@aws-sdk/config-resolver":"3.188.0","@aws-sdk/fetch-http-handler":"3.188.0","@aws-sdk/hash-node":"3.188.0","@aws-sdk/invalid-dependency":"3.188.0","@aws-sdk/middleware-content-length":"3.188.0","@aws-sdk/middleware-host-header":"3.188.0","@aws-sdk/middleware-logger":"3.188.0","@aws-sdk/middleware-recursion-detection":"3.188.0","@aws-sdk/middleware-retry":"3.188.0","@aws-sdk/middleware-serde":"3.188.0","@aws-sdk/middleware-stack":"3.188.0","@aws-sdk/middleware-user-agent":"3.188.0","@aws-sdk/node-config-provider":"3.188.0","@aws-sdk/node-http-handler":"3.188.0","@aws-sdk/protocol-http":"3.188.0","@aws-sdk/smithy-client":"3.188.0","@aws-sdk/types":"3.188.0","@aws-sdk/url-parser":"3.188.0","@aws-sdk/util-base64-browser":"3.188.0","@aws-sdk/util-base64-node":"3.188.0","@aws-sdk/util-body-length-browser":"3.188.0","@aws-sdk/util-body-length-node":"3.188.0","@aws-sdk/util-defaults-mode-browser":"3.188.0","@aws-sdk/util-defaults-mode-node":"3.188.0","@aws-sdk/util-user-agent-browser":"3.188.0","@aws-sdk/util-user-agent-node":"3.188.0","@aws-sdk/util-utf8-browser":"3.188.0","@aws-sdk/util-utf8-node":"3.188.0","tslib":"^2.3.1"},"devDependencies":{"@aws-sdk/service-client-documentation-generator":"3.188.0","@tsconfig/recommended":"1.0.1","@types/node":"^12.7.5","concurrently":"7.0.0","downlevel-dts":"0.10.1","rimraf":"3.0.2","typedoc":"0.19.2","typescript":"~4.6.2"},"overrides":{"typedoc":{"typescript":"~4.6.2"}},"engines":{"node":">=12.0.0"},"typesVersions":{"<4.0":{"dist-types/*":["dist-types/ts3.4/*"]}},"files":["dist-*"],"author":{"name":"AWS SDK for JavaScript Team","url":"https://aws.amazon.com/javascript/"},"license":"Apache-2.0","browser":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.browser"},"react-native":{"./dist-es/runtimeConfig":"./dist-es/runtimeConfig.native"},"homepage":"https://github.com/aws/aws-sdk-js-v3/tree/main/clients/client-sso","repository":{"type":"git","url":"https://github.com/aws/aws-sdk-js-v3.git","directory":"clients/client-sso"}}');
@@ -58213,6 +58213,18 @@ module.exports = JSON.parse('{"100":"Continue","101":"Switching Protocols","102"
58213
58213
  /******/ __nccwpck_require__.m = __webpack_modules__;
58214
58214
  /******/
58215
58215
  /************************************************************************/
58216
+ /******/ /* webpack/runtime/compat get default export */
58217
+ /******/ (() => {
58218
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
58219
+ /******/ __nccwpck_require__.n = (module) => {
58220
+ /******/ var getter = module && module.__esModule ?
58221
+ /******/ () => (module['default']) :
58222
+ /******/ () => (module);
58223
+ /******/ __nccwpck_require__.d(getter, { a: getter });
58224
+ /******/ return getter;
58225
+ /******/ };
58226
+ /******/ })();
58227
+ /******/
58216
58228
  /******/ /* webpack/runtime/define property getters */
58217
58229
  /******/ (() => {
58218
58230
  /******/ // define getter functions for harmony exports
@@ -58340,14 +58352,42 @@ var __webpack_exports__ = {};
58340
58352
  // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
58341
58353
  (() => {
58342
58354
 
58343
- // EXTERNAL MODULE: external "os"
58344
- var external_os_ = __nccwpck_require__(22037);
58345
- // EXTERNAL MODULE: external "child_process"
58346
- var external_child_process_ = __nccwpck_require__(32081);
58355
+ ;// CONCATENATED MODULE: ./src/log/index.ts
58356
+ const log = ({ type, message } = { type: 'info', message: '' }) => {
58357
+ const messagePrefix = `[${type.toUpperCase()}]${message.startsWith('[') ? '' : ': '}`;
58358
+ console.log(`${messagePrefix}${message}`);
58359
+ };
58360
+
58347
58361
  // EXTERNAL MODULE: ./node_modules/arg/index.js
58348
58362
  var arg = __nccwpck_require__(11958);
58349
- // EXTERNAL MODULE: ./node_modules/express/index.js
58350
- var express = __nccwpck_require__(55274);
58363
+ var arg_default = /*#__PURE__*/__nccwpck_require__.n(arg);
58364
+ // EXTERNAL MODULE: external "os"
58365
+ var external_os_ = __nccwpck_require__(22037);
58366
+ // EXTERNAL MODULE: external "path"
58367
+ var external_path_ = __nccwpck_require__(71017);
58368
+ var external_path_default = /*#__PURE__*/__nccwpck_require__.n(external_path_);
58369
+ // EXTERNAL MODULE: external "fs"
58370
+ var external_fs_ = __nccwpck_require__(57147);
58371
+ var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
58372
+ ;// CONCATENATED MODULE: ./src/types/index.ts
58373
+ var SupportedRegions;
58374
+ (function (SupportedRegions) {
58375
+ SupportedRegions["North"] = "eu-north-1";
58376
+ })(SupportedRegions || (SupportedRegions = {}));
58377
+ var SupportedEnvironments;
58378
+ (function (SupportedEnvironments) {
58379
+ SupportedEnvironments["LOCAL"] = "local";
58380
+ SupportedEnvironments["QA"] = "qa";
58381
+ SupportedEnvironments["TEST"] = "test";
58382
+ SupportedEnvironments["DEMO"] = "demo";
58383
+ SupportedEnvironments["PROD"] = "prod";
58384
+ })(SupportedEnvironments || (SupportedEnvironments = {}));
58385
+ var SupportedDeploymentTypes;
58386
+ (function (SupportedDeploymentTypes) {
58387
+ SupportedDeploymentTypes["Container"] = "CONTAINER";
58388
+ // Static = 'STATIC'
58389
+ })(SupportedDeploymentTypes || (SupportedDeploymentTypes = {}));
58390
+
58351
58391
  ;// CONCATENATED MODULE: external "node:http"
58352
58392
  const external_node_http_namespaceObject = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http");
58353
58393
  ;// CONCATENATED MODULE: external "node:https"
@@ -60461,123 +60501,111 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
60461
60501
  });
60462
60502
  }
60463
60503
 
60464
- ;// CONCATENATED MODULE: ./src/config.js
60465
- const platformName = process.env.DEPLOYMENT_TOOLS_PLATFORM_NAME
60466
- const domain = process.env.DEPLOYMENT_TOOLS_DOMAIN || 'localhost'
60467
- const environmentName = process.env.DEPLOYMENT_TOOLS_ENVIRONMENT_NAME || 'dev'
60468
- const ciSubDomain = process.env.DEPLOYMENT_TOOLS_CI_SUB_DOMAIN || 'ci'
60469
- const port = process.env.DEPLOYMENT_TOOLS_PORT || 3000
60470
- const awsAccountId = process.env.AWS_ACCOUNT_ID
60471
- const awsRegion = process.env.AWS_REGION
60472
-
60473
- const deploymentQueueUrl = `https://sqs.${awsRegion}.amazonaws.com/${awsAccountId}/${platformName}-${environmentName}`
60474
-
60475
- ;// CONCATENATED MODULE: ./src/caddy-client.js
60476
-
60504
+ ;// CONCATENATED MODULE: ./src/caddy-client.ts
60477
60505
 
60478
60506
 
60479
60507
  const Matchers = {
60480
- host: host => ({ host: [host] }),
60481
- path: path => ({ path: [path] })
60482
- }
60483
-
60508
+ host: host => ({ host: [host] }),
60509
+ path: path => ({ path: [path] })
60510
+ };
60484
60511
  const Handlers = {
60485
- reverseProxy: upstreamPort => ({
60486
- handler: 'reverse_proxy',
60487
- upstreams: [{ dial: `localhost:${upstreamPort}` }]
60488
- }),
60489
- subroute: routes => ( {
60490
- handler: 'subroute',
60491
- routes
60492
- })
60493
- }
60494
-
60495
- class CaddyClient {
60496
-
60497
- static new(serverName) {
60498
- return new CaddyClient(serverName)
60499
- }
60500
-
60501
- constructor(serverName = 'ci-client') {
60502
- this.serverName = serverName
60503
- }
60504
-
60505
- deploy({ domain, targetPort }) {
60506
- return fetch(`http://localhost:2019/config/apps/http/servers/${this.serverName}/routes/0/handle`, {
60507
- method: 'POST',
60508
- headers: { 'Content-Type': 'application/json' },
60509
- body: JSON.stringify( Handlers.subroute([
60510
- {
60511
- match: [Matchers.host(domain)],
60512
- handle: [Handlers.subroute([{ handle: [Handlers.reverseProxy(targetPort)]}])]
60513
- }
60514
- ]))
60512
+ reverseProxy: upstreamPort => ({
60513
+ handler: 'reverse_proxy',
60514
+ upstreams: [{ dial: `localhost:${upstreamPort}` }]
60515
+ }),
60516
+ subroute: routes => ({
60517
+ handler: 'subroute',
60518
+ routes
60515
60519
  })
60516
- }
60517
-
60518
- applyDefaultServerConfig() {
60519
- return fetch('http://localhost:2019/load', {
60520
- method: 'POST',
60521
- headers: { 'Content-Type': 'application/json' },
60522
- body: JSON.stringify({
60523
- apps: {
60524
- http: {
60525
- servers: {
60526
- [this.serverName]: {
60527
- listen: [':80', ':443'],
60528
- routes: [
60529
- {
60530
- match: [Matchers.host(`*.${environmentName}.${domain}`)],
60531
- handle: [],
60532
- terminal: true
60533
- }
60534
- ]
60535
- }
60536
- }
60537
- },
60538
- tls: {
60539
- automation: {
60540
- policies: [
60520
+ };
60521
+ class CaddyClient {
60522
+ static deploy(deploymentPlatform, deploymentRequest) {
60523
+ const url = `${deploymentRequest.subdomain}.${deploymentPlatform.activeEnvironment}.${deploymentPlatform.domain}`;
60524
+ log({
60525
+ type: 'info',
60526
+ message: `[CaddyClient] Updating caddy config to route ${url} to localhost:${deploymentRequest.hostPort}`
60527
+ });
60528
+ return fetch(`http://localhost:2019/config/apps/http/servers/${deploymentPlatform.ciServerName}/routes/0/handle`, {
60529
+ method: 'POST',
60530
+ headers: { 'Content-Type': 'application/json' },
60531
+ body: JSON.stringify(Handlers.subroute([
60541
60532
  {
60542
- subjects:['*.qa.ossy.com'],
60543
- issuers:[
60544
- {
60545
- challenges:{
60546
- dns:{
60547
- provider:{
60548
- 'max_retries': 10,
60549
- name: 'route53',
60550
- 'aws_profile': 'ci-client'
60551
- }
60533
+ match: [Matchers.host(url)],
60534
+ handle: [Handlers.subroute([{ handle: [Handlers.reverseProxy(deploymentRequest.hostPort)] }])]
60535
+ }
60536
+ ]))
60537
+ })
60538
+ .catch(() => log({ type: 'error', message: `[CaddyClient] Could not update caddy config to include ${url}` }));
60539
+ }
60540
+ static applyDefaultServerConfig(deploymentPlatform) {
60541
+ log({ type: 'info', message: '[CaddyClient] Applying default caddy config' });
60542
+ return fetch('http://localhost:2019/load', {
60543
+ method: 'POST',
60544
+ headers: { 'Content-Type': 'application/json' },
60545
+ body: JSON.stringify({
60546
+ apps: {
60547
+ http: {
60548
+ servers: {
60549
+ [deploymentPlatform.ciServerName]: {
60550
+ listen: [':80', ':443'],
60551
+ routes: [
60552
+ {
60553
+ match: [Matchers.host(`*.${deploymentPlatform.activeEnvironment}.${deploymentPlatform.domain}`)],
60554
+ handle: [Handlers.subroute([
60555
+ {
60556
+ match: [Matchers.host(`${deploymentPlatform.ciSubDomain}.${deploymentPlatform.activeEnvironment}.${deploymentPlatform.domain}`)],
60557
+ handle: [Handlers.subroute([{ handle: [Handlers.reverseProxy(deploymentPlatform.ciInternalServerPort)] }])]
60558
+ }
60559
+ ])],
60560
+ terminal: true
60561
+ }
60562
+ ]
60563
+ }
60552
60564
  }
60553
- },
60554
- module: 'acme'
60555
60565
  },
60556
- {
60557
- challenges:{
60558
- dns:{
60559
- provider:{
60560
- 'max_retries': 10,
60561
- name: 'route53'
60562
- }
60566
+ tls: {
60567
+ automation: {
60568
+ policies: [
60569
+ {
60570
+ subjects: ['*.qa.ossy.com'],
60571
+ issuers: [
60572
+ {
60573
+ challenges: {
60574
+ dns: {
60575
+ provider: {
60576
+ 'max_retries': 10,
60577
+ name: 'route53',
60578
+ 'aws_profile': 'ci-client'
60579
+ }
60580
+ }
60581
+ },
60582
+ module: 'acme'
60583
+ },
60584
+ {
60585
+ challenges: {
60586
+ dns: {
60587
+ provider: {
60588
+ 'max_retries': 10,
60589
+ name: 'route53'
60590
+ }
60591
+ }
60592
+ },
60593
+ module: 'zerossl'
60594
+ }
60595
+ ]
60596
+ }
60597
+ ]
60563
60598
  }
60564
- },
60565
- module: 'zerossl'
60566
60599
  }
60567
- ]
60568
60600
  }
60569
- ]
60570
- }
60571
- }
60572
- }
60573
- })
60574
- })
60575
- }
60576
-
60601
+ })
60602
+ })
60603
+ .catch(() => log({ type: 'error', message: '[CaddyClient] Could not apply default caddy config' }));
60604
+ }
60577
60605
  }
60578
60606
 
60579
- // EXTERNAL MODULE: external "fs"
60580
- var external_fs_ = __nccwpck_require__(57147);
60607
+ // EXTERNAL MODULE: external "child_process"
60608
+ var external_child_process_ = __nccwpck_require__(32081);
60581
60609
  // EXTERNAL MODULE: external "crypto"
60582
60610
  var external_crypto_ = __nccwpck_require__(6113);
60583
60611
  ;// CONCATENATED MODULE: ./node_modules/nanoid/url-alphabet/index.js
@@ -60631,468 +60659,338 @@ let nanoid = (size = 21) => {
60631
60659
  return id
60632
60660
  }
60633
60661
 
60634
- // EXTERNAL MODULE: external "path"
60635
- var external_path_ = __nccwpck_require__(71017);
60636
60662
  // EXTERNAL MODULE: external "url"
60637
60663
  var external_url_ = __nccwpck_require__(57310);
60638
- ;// CONCATENATED MODULE: ./src/docker-client.js
60639
-
60664
+ ;// CONCATENATED MODULE: ./src/docker-client.ts
60640
60665
 
60641
60666
 
60642
60667
 
60643
60668
 
60644
60669
 
60645
- const docker_client_filename = (0,external_url_.fileURLToPath)("file:///Users/ossy/Projects/ossy/packages/deployment-tools/src/docker-client.js")
60646
- const docker_client_dirname = external_path_.dirname(docker_client_filename)
60647
60670
 
60671
+ const docker_client_filename = (0,external_url_.fileURLToPath)("file:///Users/ossy/Projects/ossy/packages/deployment-tools/src/docker-client.ts");
60672
+ const docker_client_dirname = external_path_default().dirname(docker_client_filename);
60648
60673
  class DockerClient {
60649
-
60650
- static new() {
60651
- return new DockerClient()
60652
- }
60653
-
60654
- constructor() {
60655
- this.networkName = 'deployment-tools'
60656
- ;(0,external_child_process_.exec)(`sudo docker network create ${this.networkName}`)
60657
- }
60658
-
60659
- stopContainer({ image }) {
60660
- const name = image.replaceAll('/', '_')
60661
- return `sudo docker stop ${name} ||`
60662
- }
60663
-
60664
- startContainer({ image, containerPort, hostPort, registry, env }) {
60665
- const name = image.replaceAll('/', '_')
60666
- const imageUrl = !!registry ? `${registry}/${image}` : image
60667
- const envsAsString = Object.entries(env || {}).reduce((envs, [name, value]) => `${envs} --env ${name}=${value}`, '')
60668
- return `sudo docker run -d -p ${hostPort}:${containerPort} --name=${name} --network=${this.networkName} --network-alias=${name} --rm ${envsAsString} ${imageUrl}`
60669
- }
60670
-
60671
- resolveCredentials({ registry, username, authentication }) {
60672
- return (username || authentication)
60673
- ? `sudo docker login ${registry} -u ${username} -p ${authentication}`
60674
- : 'echo No credentials provided, assuming image is publicly hosted'
60675
- }
60676
-
60677
- deploy({
60678
- image,
60679
- registry,
60680
- username,
60681
- authentication,
60682
- containerPort,
60683
- hostPort,
60684
- env
60685
- }) {
60686
- return new Promise(resolve => {
60687
- const dockerCommandScript = `'#!/bin/bash'
60688
- ${this.stopContainer({ image })}
60689
- ${this.resolveCredentials({ registry, username, authentication })}
60690
- ${this.startContainer({ image, containerPort, hostPort, registry, env })}`
60691
-
60692
- const deploymentId = nanoid()
60693
-
60694
- const FilePaths = {
60695
- DeploymentScript: `${docker_client_dirname}/${deploymentId}.sh`
60696
- }
60697
-
60698
- external_fs_.writeFileSync(FilePaths.DeploymentScript, dockerCommandScript)
60699
- const command = (0,external_child_process_.exec)(`bash ${FilePaths.DeploymentScript}`)
60700
-
60701
- command.stdout.on('data', (data) => {
60702
- console.log(`[DockerClient]: ${data}`)
60703
- })
60704
-
60705
- command.stderr.on('data', (data) => {
60706
- console.error(`[DockerClient]: ${data}`)
60707
- })
60708
-
60709
- command.on('close', (code) => {
60710
- console.log(`[DockerClient] command exited with code ${code}`)
60711
- external_fs_.unlinkSync(FilePaths.DeploymentScript)
60712
- resolve()
60713
- })
60714
- })
60715
-
60716
- }
60717
-
60674
+ static createDockerNetworkForContainerManagerServer(deploymentPlatform) {
60675
+ log({ type: 'info', message: '[DockerClient] Creating docker network for comunication between containers' });
60676
+ (0,external_child_process_.exec)(`sudo docker network create ${deploymentPlatform.ciDockerNetworkName}`);
60677
+ }
60678
+ static stopContainer(deploymentRequest) {
60679
+ const name = deploymentRequest.image.replaceAll('/', '_');
60680
+ log({ type: 'info', message: `Running docker stop for image with the name of ${name}` });
60681
+ return `sudo docker stop ${name} ||`;
60682
+ }
60683
+ static startContainer(deploymentPlatform, { image, containerPort, hostPort, registry, env }) {
60684
+ const name = image.replaceAll('/', '_');
60685
+ const imageUrl = !!registry ? `${registry}/${image}` : image;
60686
+ const envsAsString = Object.entries(env || {}).reduce((envs, [name, value]) => `${envs} --env ${name}=${value}`, '');
60687
+ log({ type: 'info', message: `Running docker start for image with the name of ${name} with port mapping ${hostPort}:${containerPort} and source ${imageUrl}` });
60688
+ return `sudo docker run -d -p ${hostPort}:${containerPort} --name=${name} --network=${deploymentPlatform.ciDockerNetworkName} --network-alias=${name} --rm ${envsAsString} ${imageUrl}`;
60689
+ }
60690
+ static resolveCredentials({ registry, username, authentication }) {
60691
+ const shouldAuthenticate = username || authentication;
60692
+ if (!shouldAuthenticate) {
60693
+ log({ type: 'info', message: 'No docker credentials provided, assuming image is publicly hosted' });
60694
+ return '';
60695
+ }
60696
+ log({ type: 'info', message: `Resolving docker credentials for ${registry}` });
60697
+ return `sudo docker login ${registry} -u ${username} -p ${authentication}`;
60698
+ }
60699
+ static deploy(deploymentPlatform, deploymentRequest) {
60700
+ return new Promise(resolve => {
60701
+ log({ type: 'info', message: 'Starting docker deployment sequence' });
60702
+ const dockerCommandScript = `'#!/bin/bash'
60703
+ ${DockerClient.stopContainer(deploymentRequest)}
60704
+ ${DockerClient.resolveCredentials(deploymentRequest)}
60705
+ ${DockerClient.startContainer(deploymentPlatform, deploymentRequest)}`;
60706
+ const deploymentId = nanoid();
60707
+ const FilePaths = {
60708
+ DeploymentScript: `${docker_client_dirname}/${deploymentId}.sh`
60709
+ };
60710
+ external_fs_default().writeFileSync(FilePaths.DeploymentScript, dockerCommandScript);
60711
+ const command = (0,external_child_process_.exec)(`bash ${FilePaths.DeploymentScript}`);
60712
+ command.stdout.on('data', data => {
60713
+ log({ type: 'info', message: `[DockerClient]: ${data}` });
60714
+ });
60715
+ command.stderr.on('data', (data) => {
60716
+ log({ type: 'error', message: `[DockerClient]: ${data}` });
60717
+ });
60718
+ command.on('close', code => {
60719
+ log({ type: 'info', message: `[DockerClient] command exited with code ${code}` });
60720
+ external_fs_default().unlinkSync(FilePaths.DeploymentScript);
60721
+ resolve();
60722
+ });
60723
+ });
60724
+ }
60718
60725
  }
60719
60726
 
60720
60727
  // EXTERNAL MODULE: ./node_modules/@aws-sdk/client-sqs/dist-cjs/index.js
60721
60728
  var dist_cjs = __nccwpck_require__(90470);
60722
- ;// CONCATENATED MODULE: ./src/deployment-queue-client.js
60723
-
60724
-
60725
-
60726
- class DeploymentQueueClient {
60727
-
60728
- static new({ queueUrl, region, credentials } = {}) {
60729
-
60730
- const deploymentQueueClientDefaultConfig = {
60731
- queueUrl: queueUrl || deploymentQueueUrl,
60732
- region: region || awsRegion,
60733
- credentials
60734
- }
60735
-
60736
- return new DeploymentQueueClient(deploymentQueueClientDefaultConfig)
60737
- }
60738
-
60739
- constructor({ queueUrl, region, credentials }) {
60740
- this.queueUrl = queueUrl
60741
- this.sqs = new dist_cjs.SQSClient({ region, credentials })
60742
- }
60743
-
60744
- sendMessage(messageBody) {
60745
- const command = new dist_cjs.SendMessageCommand({
60746
- QueueUrl: this.queueUrl,
60747
- MessageBody: JSON.stringify(messageBody)
60748
- })
60749
-
60750
- return this.sqs.send(command)
60751
- .then(() => console.log('Success'))
60752
- .catch(err => console.log(err))
60753
- }
60754
-
60755
- receiveMessages() {
60756
- const command = new dist_cjs.ReceiveMessageCommand({ QueueUrl: this.queueUrl })
60757
-
60758
- return this.sqs.send(command)
60759
- .catch(error => console.log('Error', error))
60760
- }
60761
-
60762
- deleteMessage(receiptHandle) {
60763
- const command = new dist_cjs.DeleteMessageCommand({
60764
- QueueUrl: this.queueUrl,
60765
- ReceiptHandle: receiptHandle
60766
- })
60767
-
60768
- return this.sqs.send(command)
60769
- .then(() => console.log('success'))
60770
- .catch(error => console.log('Error', error))
60771
-
60772
- }
60773
-
60774
- }
60775
-
60776
- ;// CONCATENATED MODULE: ./src/container-manager-server.js
60777
-
60778
-
60779
-
60780
-
60781
-
60782
-
60783
- class ContainerManagerServer {
60784
-
60785
- static start() {
60786
- return new ContainerManagerServer()
60787
- }
60788
-
60789
- constructor() {
60790
- this.server = express()
60791
- this.dockerClient = DockerClient["new"]()
60792
- this.caddyClient = CaddyClient["new"]()
60793
- this.deploymentQueueClient = DeploymentQueueClient["new"]()
60794
-
60795
- this.applyDefaultCaddyConfig()
60796
- this.setupServerEndpoints()
60797
- this.pollForDeploymentRequests()
60798
- }
60799
-
60800
- setupServerEndpoints() {
60801
- this.server.use(express.json())
60802
-
60803
- this.server.get('/', (req, res) => {
60804
- res.redirect('/status')
60805
- })
60806
-
60807
- this.server.get('/status', (req, res) => {
60808
- res.json('Server is live')
60809
- })
60810
-
60811
- this.server.listen(port, () => {
60812
- console.log(`Web API is live on port ${port}`)
60813
- })
60814
- }
60815
-
60816
- applyDefaultCaddyConfig() {
60817
- this.caddyClient.applyDefaultServerConfig()
60818
- .then(() => this.caddyClient.deploy({
60819
- domain: `${ciSubDomain}.${environmentName}.${domain}`,
60820
- targetPort: port
60821
- }))
60822
- }
60823
-
60824
- pollForDeploymentRequests() {
60825
- const FIVE_MINUTES = 3000
60826
-
60827
- const handleIcomingMessages = () => this.deploymentQueueClient.receiveMessages()
60828
- .then(data => data.Messages.map(message => {
60829
- console.log('[ContainerManagerServer] handleIcomingMessages')
60830
- this.deploy(message)
60831
- this.deploymentQueueClient.deleteMessage(message.ReceiptHandle)
60832
- }))
60833
- .catch(error => console.log('[ContainerManagerServer] handleIcomingMessages error', error))
60834
-
60835
- setInterval(handleIcomingMessages, FIVE_MINUTES)
60836
- }
60837
-
60838
- deploy(deploymentRequestMessage) {
60839
-
60840
- const {
60841
- registry,
60842
- username,
60843
- authentication,
60844
- containerPort,
60845
- hostPort,
60846
- image,
60847
- domain,
60848
- env
60849
- } = deploymentRequestMessage
60850
-
60851
- this.dockerClient.deploy({
60852
- image,
60853
- registry,
60854
- username,
60855
- authentication,
60856
- containerPort,
60857
- hostPort,
60858
- env
60859
- })
60860
-
60861
- domain && this.caddyClient.deploy({ domain, targetPort: hostPort })
60862
-
60863
- }
60864
-
60865
- }
60866
-
60867
60729
  // EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
60868
60730
  var core = __nccwpck_require__(49326);
60869
60731
  // EXTERNAL MODULE: ./node_modules/@aws-sdk/client-sts/dist-cjs/index.js
60870
60732
  var client_sts_dist_cjs = __nccwpck_require__(11451);
60871
- ;// CONCATENATED MODULE: ./src/aws-credentials-client.js
60872
-
60733
+ ;// CONCATENATED MODULE: ./src/aws-credentials-client.ts
60873
60734
 
60874
60735
 
60875
60736
  class AwsCredentialsClient {
60876
-
60877
- static getTemporaryCredentials(awsAccountId, region, roleToAssume = 'github-ci-role') {
60878
- const stsClient = new client_sts_dist_cjs.STSClient({ region })
60879
-
60880
- return core.getIDToken('sts.amazonaws.com')
60881
- .then(webIdentityToken => stsClient.send(new client_sts_dist_cjs.AssumeRoleWithWebIdentityCommand({
60882
- RoleArn: `arn:aws:iam::${awsAccountId}:role/${roleToAssume}`,
60883
- RoleSessionName: 'GitHubActions',
60884
- DurationSeconds: 15 * 60,
60885
- WebIdentityToken: webIdentityToken
60886
- })))
60887
- .then(responseData => ({
60888
- accessKeyId: responseData.Credentials.AccessKeyId,
60889
- secretAccessKey: responseData.Credentials.SecretAccessKey,
60890
- sessionToken: responseData.Credentials.SessionToken
60891
- }))
60892
-
60893
- }
60894
-
60737
+ static resolveAwsCredentials(deploymentPlatform) {
60738
+ // If awsRoleToAssume is present, then we assume we run in a github workflow
60739
+ // If awsRoleToAssume is not present, then we assume they are resolved localy by aws-sdk
60740
+ return deploymentPlatform.awsRoleToAssume
60741
+ ? AwsCredentialsClient.getTemporaryCredentials(deploymentPlatform)
60742
+ : Promise.resolve(undefined);
60743
+ }
60744
+ static getTemporaryCredentials({ awsAccountId, awsRegion, awsRoleToAssume }) {
60745
+ const stsClient = new client_sts_dist_cjs.STSClient({ region: awsRegion });
60746
+ return core.getIDToken('sts.amazonaws.com')
60747
+ .then(webIdentityToken => stsClient.send(new client_sts_dist_cjs.AssumeRoleWithWebIdentityCommand({
60748
+ RoleArn: `arn:aws:iam::${awsAccountId}:role/${awsRoleToAssume}`,
60749
+ RoleSessionName: 'GitHubActions',
60750
+ DurationSeconds: 15 * 60,
60751
+ WebIdentityToken: webIdentityToken
60752
+ })))
60753
+ .then(responseData => ({
60754
+ accessKeyId: responseData.Credentials.AccessKeyId,
60755
+ secretAccessKey: responseData.Credentials.SecretAccessKey,
60756
+ sessionToken: responseData.Credentials.SessionToken
60757
+ }));
60758
+ }
60895
60759
  }
60896
60760
 
60897
- ;// CONCATENATED MODULE: ./src/container-manager-client.js
60898
-
60899
-
60761
+ ;// CONCATENATED MODULE: ./src/deployment-queue-client.ts
60900
60762
 
60901
60763
 
60902
60764
 
60903
- class ContainerManagerClient {
60904
-
60905
- //eslint-disable-next-line max-params
60906
- static deploy(
60907
- username,
60908
- authentication,
60909
- targetEnvironment = 'local-dev',
60910
- pathToDeploymentPlatforms,
60911
- pathToOssyFile
60912
- ) {
60913
- const containerManagerClient = new ContainerManagerClient()
60914
- return containerManagerClient.deploy(
60915
- username,
60916
- authentication,
60917
- targetEnvironment,
60918
- pathToDeploymentPlatforms,
60919
- pathToOssyFile
60920
- )
60921
- }
60922
-
60923
- constructor() {}
60765
+ class DeploymentQueueClient {
60766
+ static sendDeploymentRequest(deploymentPlatform, deploymentRequest) {
60767
+ log({ type: 'info', message: '[DeploymentQueueClient] Sending deployment request...' });
60768
+ return DeploymentQueueClient.createAwsSqsClient(deploymentPlatform)
60769
+ .then(sqsClient => {
60770
+ const command = new dist_cjs.SendMessageCommand({
60771
+ QueueUrl: deploymentPlatform.awsDeploymentSqsArn,
60772
+ MessageBody: JSON.stringify(deploymentRequest)
60773
+ });
60774
+ return sqsClient.send(command)
60775
+ .then(() => log({ type: 'info', message: '[DeploymentQueueClient] Deployment request sent' }))
60776
+ .catch(() => log({ type: 'error', message: '[DeploymentQueueClient] Could not send deployment request' }));
60777
+ });
60778
+ }
60779
+ static pollForDeploymentRequests(deploymentPlatform, handleDeploymentRequest) {
60780
+ log({ type: 'info', message: '[DeploymentQueueClient] Starting polling for deployment requests' });
60781
+ DeploymentQueueClient.createAwsSqsClient(deploymentPlatform).then(sqsClient => {
60782
+ const FIVE_MINUTES = 3000;
60783
+ setInterval(() => {
60784
+ const receiveMessageCommand = new dist_cjs.ReceiveMessageCommand({ QueueUrl: deploymentPlatform.awsDeploymentSqsArn });
60785
+ sqsClient.send(receiveMessageCommand)
60786
+ .then(data => data.Messages.map(message => {
60787
+ log({ type: 'info', message: '[DeploymentQueueClient] Received deployment request' });
60788
+ handleDeploymentRequest(JSON.parse(message.Body))
60789
+ .then(() => {
60790
+ const deleteMessageCommand = new dist_cjs.DeleteMessageCommand({
60791
+ QueueUrl: deploymentPlatform.awsDeploymentSqsArn,
60792
+ ReceiptHandle: message.ReceiptHandle
60793
+ });
60794
+ sqsClient.send(deleteMessageCommand)
60795
+ .then(() => log({ type: 'info', message: '[DeploymentQueueClient] Removing deployment request from queue' }))
60796
+ .catch(() => log({ type: 'error', message: '[DeploymentQueueClient] Removing deployment request from queue' }));
60797
+ });
60798
+ }))
60799
+ .catch(() => log({ type: 'error', message: '[ContainerManagerServer] Could not handle incoming deployment request' }));
60800
+ }, FIVE_MINUTES);
60801
+ });
60802
+ }
60803
+ static createAwsSqsClient(deploymentPlatform) {
60804
+ return AwsCredentialsClient.resolveAwsCredentials(deploymentPlatform)
60805
+ .then(awsCredentials => new dist_cjs.SQSClient({
60806
+ region: deploymentPlatform.awsRegion,
60807
+ credentials: awsCredentials
60808
+ }));
60809
+ }
60810
+ }
60924
60811
 
60925
- getDeployments(pathToOssyFile) {
60926
- const ossyfile = JSON.parse((0,external_fs_.readFileSync)((0,external_path_.resolve)(pathToOssyFile), 'utf8'))
60927
- return Promise.resolve(ossyfile.deployments || [])
60928
- }
60812
+ // EXTERNAL MODULE: ./node_modules/express/index.js
60813
+ var express = __nccwpck_require__(55274);
60814
+ var express_default = /*#__PURE__*/__nccwpck_require__.n(express);
60815
+ ;// CONCATENATED MODULE: ./src/ci-rest-api.ts
60929
60816
 
60930
- getDeploymentPlatforms(pathToDeploymentPlatforms) {
60931
60817
 
60932
- const localDevPlatform = {
60933
- name: 'dev',
60934
- domain: 'localhost',
60935
- supportedDeploymentTypes: ['CONTAINER']
60818
+ class CiRestApi {
60819
+ static start(deploymentPlatform) {
60820
+ const server = express_default()();
60821
+ server.use(express_default().json());
60822
+ server.get('/', (req, res) => {
60823
+ res.redirect('/status');
60824
+ });
60825
+ server.get('/status', (req, res) => {
60826
+ res.send('Server is live');
60827
+ });
60828
+ server.listen(deploymentPlatform.ciInternalServerPort, () => {
60829
+ log({ type: 'info', message: `[ContainerManagerServer] API is live on port ${deploymentPlatform.ciInternalServerPort}` });
60830
+ });
60936
60831
  }
60832
+ }
60937
60833
 
60938
- if (!pathToDeploymentPlatforms) return [localDevPlatform]
60834
+ ;// CONCATENATED MODULE: ./src/deployment-platform-client.ts
60939
60835
 
60940
- const deploymentPlatforms = JSON.parse((0,external_fs_.readFileSync)((0,external_path_.resolve)(pathToDeploymentPlatforms), 'utf8'))
60941
- return Promise.resolve(deploymentPlatforms || [localDevPlatform])
60942
- }
60943
60836
 
60944
- getDeploymentTargetURL(targetEnvironment, deploymentPlatform, deployment) {
60945
- let domain = targetEnvironment !== 'prod'
60946
- ? `${targetEnvironment}.`
60947
- : ''
60948
60837
 
60949
- domain = deployment.subdomain
60950
- ? `${domain}${deployment.subdomain}.${deploymentPlatform.domain}`
60951
- : `${domain}${deploymentPlatform.domain}`
60952
60838
 
60953
- return domain
60954
- }
60955
60839
 
60956
- getEnvironmentVariables(targetEnvironment, deployment) {
60957
- const envs = deployment.env || {}
60958
- return {
60959
- ...(envs.shared || {}),
60960
- ...(envs[targetEnvironment] || {})
60961
- }
60962
- }
60963
-
60964
- //eslint-disable-next-line max-params
60965
- deploy(
60966
- username,
60967
- authentication,
60968
- targetEnvironment,
60969
- pathToDeploymentPlatforms,
60970
- pathToOssyFile
60971
- ) {
60972
- console.log('pathToDeploymentPlatforms', pathToDeploymentPlatforms)
60973
- console.log('pathToOssyFile', pathToOssyFile)
60974
- console.log('pathToOssyFile resolved', (0,external_path_.resolve)(pathToOssyFile))
60975
- return Promise.all([
60976
- this.getDeploymentPlatforms(pathToDeploymentPlatforms),
60977
- this.getDeployments(pathToOssyFile)
60978
- ])
60979
- .then(([platforms, deployments]) => {
60980
- deployments.map(deployment => {
60981
- const platform = platforms.find(platform => platform.name === deployment.targetDeploymentPlatform)
60982
-
60983
- if (!platform) {
60984
- return Promise.reject(
60985
- `Could not find a deployment platform with the name ${deployment.targetDeploymentPlatform}`
60986
- )
60987
- }
60988
60840
 
60989
- process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0
60990
-
60991
- const body = {
60992
- image: deployment.image,
60993
- hostPort: deployment.hostPort,
60994
- containerPort: deployment.containerPort,
60995
- domain: this.getDeploymentTargetURL(targetEnvironment, platform, deployment),
60996
- env: this.getEnvironmentVariables(targetEnvironment, deployment),
60997
- registry: deployment.registry,
60998
- username: username,
60999
- authentication: authentication
61000
- }
61001
60841
 
61002
- return AwsCredentialsClient.getTemporaryCredentials(platform.awsAccountId, platform.awsRegion)
61003
- .then(credentials => {
61004
- const deploymentQueueClient = DeploymentQueueClient["new"]({ credentials })
61005
- return deploymentQueueClient.sendMessage(body)
61006
- .then(() => console.log('[ContainerManagerCommands] Deployment request has been sent'))
61007
- .catch(error => console.log('[ContainerManagerCommands] Could not send deployment request', error))
61008
60842
 
61009
- })
60843
+ class DeploymentPlatformClient {
60844
+ static start(pathToDeploymentPlatforms) {
60845
+ DeploymentPlatformClient.getDeploymentPlatforms(pathToDeploymentPlatforms).then(([firstPlatformFound]) => {
60846
+ if (!firstPlatformFound) {
60847
+ log({ type: 'error', message: '[DeploymentPlatformClient] Could not find a deployment platform' });
60848
+ return Promise.reject();
60849
+ }
60850
+ CiRestApi.start(firstPlatformFound);
60851
+ CaddyClient.applyDefaultServerConfig(firstPlatformFound);
60852
+ DeploymentQueueClient.pollForDeploymentRequests(firstPlatformFound, (deploymentRequest) => {
60853
+ DockerClient.deploy(firstPlatformFound, deploymentRequest);
60854
+ CaddyClient.deploy(firstPlatformFound, deploymentRequest);
60855
+ return Promise.resolve();
60856
+ });
61010
60857
  })
61011
- })
61012
- .catch(error => console.log(error))
61013
- }
61014
-
60858
+ .catch(() => log({ type: 'error', message: '[DeploymentPlatformClient] Could not start the deployment platform' }));
60859
+ }
60860
+ //eslint-disable-next-line max-params
60861
+ static deploy(username, authentication, targetEnvironment, pathToDeploymentPlatforms, pathToOssyFile) {
60862
+ return Promise.all([
60863
+ DeploymentPlatformClient.getDeploymentPlatforms(pathToDeploymentPlatforms),
60864
+ DeploymentPlatformClient.getDeploymentTemplates(pathToOssyFile)
60865
+ ])
60866
+ .then(([platforms, deploymentTemplates]) => {
60867
+ deploymentTemplates.map(deploymentTemplate => {
60868
+ const deploymentPlatform = platforms.find(platform => platform.name === deploymentTemplate.targetDeploymentPlatform);
60869
+ if (!deploymentPlatform) {
60870
+ log({ type: 'error', message: `[DeploymentPlatformClient] Could not find a deployment platform with the name ${deploymentTemplate.targetDeploymentPlatform}` });
60871
+ return Promise.reject();
60872
+ }
60873
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
60874
+ if (deploymentTemplate.type !== SupportedDeploymentTypes.Container) {
60875
+ log({ type: 'error', message: `[DeploymentPlatformClient] Unsupported deployment type of ${deploymentTemplate.type}` });
60876
+ return Promise.reject();
60877
+ }
60878
+ const deploymentRequest = Object.assign(Object.assign({}, deploymentTemplate), { env: DeploymentPlatformClient.getEnvironmentVariables(targetEnvironment, deploymentTemplate), username: username, authentication: authentication });
60879
+ return DeploymentQueueClient.sendDeploymentRequest(deploymentPlatform, deploymentRequest);
60880
+ });
60881
+ })
60882
+ .catch(error => console.log(error));
60883
+ }
60884
+ static getDeploymentTemplates(pathToOssyFile) {
60885
+ const ossyfile = JSON.parse((0,external_fs_.readFileSync)((0,external_path_.resolve)(pathToOssyFile), 'utf8'));
60886
+ return Promise.resolve(ossyfile.deployments || []);
60887
+ }
60888
+ static getDeploymentPlatforms(pathToDeploymentPlatforms) {
60889
+ let deploymentPlatforms = JSON.parse((0,external_fs_.readFileSync)((0,external_path_.resolve)(pathToDeploymentPlatforms), 'utf8'));
60890
+ if (!Array.isArray(deploymentPlatforms)) {
60891
+ deploymentPlatforms = [deploymentPlatforms];
60892
+ }
60893
+ return Promise.resolve((deploymentPlatforms || []).map(DeploymentPlatformClient.resolveDeploymentPlatformValues));
60894
+ }
60895
+ static getEnvironmentVariables(targetEnvironment, deploymentRequest) {
60896
+ const envs = deploymentRequest.env || {};
60897
+ return Object.assign(Object.assign({}, (envs.shared || {})), (envs[targetEnvironment] || {}));
60898
+ }
60899
+ static resolveDeploymentPlatformValues(deploymentPlatform) {
60900
+ return DeploymentPlatformClient.setCalculatedDeploymentPlatformValues(DeploymentPlatformClient.setDefaultDeploymentPlatformValues(deploymentPlatform));
60901
+ }
60902
+ static setDefaultDeploymentPlatformValues(deploymentPlatform) {
60903
+ return Object.assign({ platformName: SupportedEnvironments.LOCAL, domain: 'localhost', activeEnvironment: SupportedEnvironments.LOCAL, supportedDeploymentTypes: ['CONTAINER'], ciSubDomain: 'ci', ciInternalServerPort: 3000, ciServerName: 'ci-client', ciDockerNetworkName: 'deployment-tools' }, deploymentPlatform);
60904
+ }
60905
+ static setCalculatedDeploymentPlatformValues(deploymentPlatform) {
60906
+ return Object.assign({ awsDeploymentSqsArn: `https://sqs.${deploymentPlatform.awsRegion}.amazonaws.com/${deploymentPlatform.awsAccountId}/${deploymentPlatform.platformName}-${deploymentPlatform.activeEnvironment}` }, deploymentPlatform);
60907
+ }
61015
60908
  }
61016
60909
 
61017
- ;// CONCATENATED MODULE: ./src/index.js
61018
-
61019
-
60910
+ ;// CONCATENATED MODULE: ./src/cli-commands/start-handler.ts
61020
60911
 
61021
60912
 
61022
60913
 
61023
60914
 
61024
- const [_, __, command, ...restArgs] = process.argv
60915
+ const startHandler = cliArgs => {
60916
+ log({ type: 'info', message: 'Running start command' });
60917
+ const Platforms = {
60918
+ windows: 'win32',
60919
+ mac: 'darwin'
60920
+ };
60921
+ if ([Platforms.windows].includes((0,external_os_.platform)())) {
60922
+ return log({ type: 'error', message: 'Deployment tools do not support this os' });
60923
+ }
60924
+ const parsedArgs = arg_default()({
60925
+ '--platforms': String,
60926
+ '-p': '--platforms'
60927
+ }, { argv: cliArgs });
60928
+ DeploymentPlatformClient.start(parsedArgs['--platforms']);
60929
+ };
61025
60930
 
61026
- const startHandler = () => {
61027
- console.log('Running start command')
60931
+ ;// CONCATENATED MODULE: ./src/cli-commands/stop-handler.ts
61028
60932
 
61029
- const Platforms = {
61030
- windows: 'win32',
61031
- mac: 'darwin'
61032
- }
61033
60933
 
61034
- if ([Platforms.windows].includes((0,external_os_.platform)())) {
61035
- return console.error('Deployment tools do not support this os')
61036
- }
60934
+ const stopHandler = () => {
60935
+ log({ type: 'info', message: 'Running stop command' });
60936
+ (0,external_child_process_.exec)('systemctl stop deployment-tools.service');
60937
+ };
61037
60938
 
61038
- ContainerManagerServer.start()
61039
- }
60939
+ ;// CONCATENATED MODULE: ./src/cli-commands/status-handler.ts
61040
60940
 
61041
- const stopHandler = () => {
61042
- console.log('Running stop command')
61043
- ;(0,external_child_process_.exec)('systemctl stop deployment-tools.service')
61044
- }
61045
60941
 
61046
60942
  const statusHandler = () => {
61047
- console.log('Running status command')
61048
- ;(0,external_child_process_.exec)('systemctl status deployment-tools.service')
61049
- }
60943
+ log({ type: 'info', message: 'Running status command' });
60944
+ (0,external_child_process_.exec)('systemctl status deployment-tools.service');
60945
+ };
61050
60946
 
61051
- const deployHandler = () => {
61052
- console.log('Running deploy command')
60947
+ ;// CONCATENATED MODULE: ./src/cli-commands/deploy-handler.ts
61053
60948
 
61054
- const args = arg({
61055
- '--username': String,
61056
- '-u': '--username',
61057
60949
 
61058
- '--authentication': String,
61059
- '--a': '--authentication',
61060
60950
 
61061
- '--target-env': String,
61062
- '-t': '--target-env',
60951
+ const deployHandler = cliArgs => {
60952
+ log({ type: 'info', message: 'Running deploy command' });
60953
+ const parsedArgs = arg_default()({
60954
+ '--username': String,
60955
+ '-u': '--username',
60956
+ '--authentication': String,
60957
+ '--a': '--authentication',
60958
+ '--target-env': String,
60959
+ '-t': '--target-env',
60960
+ '--ossyfile': String,
60961
+ '-o': '--ossyfile',
60962
+ '--platforms': String,
60963
+ '-p': '--platforms'
60964
+ }, { argv: cliArgs });
60965
+ DeploymentPlatformClient.deploy(parsedArgs['--username'], parsedArgs['--authentication'], parsedArgs['--target-env'], parsedArgs['--platforms'], parsedArgs['--ossyfile']);
60966
+ };
61063
60967
 
61064
- '--ossyfile': String,
61065
- '-o': '--ossyfile',
60968
+ ;// CONCATENATED MODULE: ./src/cli-commands/index.ts
61066
60969
 
61067
- '--platforms': String,
61068
- '-p': '--platforms'
61069
- }, { argv: restArgs })
61070
60970
 
61071
- console.log('args', args)
61072
60971
 
61073
- ContainerManagerClient.deploy(
61074
- args['--username'],
61075
- args['--authentication'],
61076
- args['--target-env'],
61077
- args['--platforms'],
61078
- args['--ossyfile']
61079
- )
61080
- }
61081
60972
 
61082
- const Commands = {
61083
- start: startHandler,
61084
- stop: stopHandler,
61085
- status: statusHandler,
61086
- deploy: deployHandler
61087
- }
61088
60973
 
61089
- const commandHandler = Commands[command]
60974
+ const runCliCommand = ({ name, args }) => {
60975
+ if (!name)
60976
+ return log({ type: 'error', message: 'No command provided' });
60977
+ const commandHandler = {
60978
+ start: startHandler,
60979
+ stop: stopHandler,
60980
+ status: statusHandler,
60981
+ deploy: deployHandler
60982
+ }[name];
60983
+ if (!commandHandler) {
60984
+ return log({ type: 'error', message: 'Command not implemented, did you spell it correctly?' });
60985
+ }
60986
+ commandHandler(args);
60987
+ };
61090
60988
 
61091
- if (!commandHandler) {
61092
- console.log('Command not implemented, did you spell it correctly?')
61093
- }
60989
+ ;// CONCATENATED MODULE: ./src/index.ts
61094
60990
 
61095
- commandHandler()
60991
+ //eslint-disable-next-line no-unused-vars
60992
+ const [_, __, command, ...restArgs] = process.argv;
60993
+ runCliCommand({ name: command, args: restArgs });
61096
60994
 
61097
60995
  })();
61098
60996