rsm-hcd / AndcultureCode.Cli

and-cli command-line tool to manage the development of software applications
https://andculture.com
Apache License 2.0
14 stars 15 forks source link

Jenkins deploy command throws runtime error: config.profiles.indexof is not a function #135

Closed brandongregoryscott closed 3 years ago

brandongregoryscott commented 3 years ago

Upon running and-cli deploy jenkins --init, adding a profile and then attempting to run it via the --profile flag, a runtime error is thrown. After some debugging with @dylanjustice, it looks like this is a mistake from a version that was using arrays to hold profiles.

(node:26732) UnhandledPromiseRejectionWarning: TypeError: config.profiles.indexof is not a function
    at Object.build (C:\Users\bscot\acc\fork\brandongregoryscott.AndcultureCode.Cli\and-cli-deploy-jenkins.js:54:33)
    at Object.run (C:\Users\bscot\acc\fork\brandongregoryscott.AndcultureCode.Cli\and-cli-deploy-jenkins.js:141:24)
    at require.run (C:\Users\bscot\acc\fork\brandongregoryscott.AndcultureCode.Cli\and-cli-deploy-jenkins.js:188:25)
    at Object.module.exports.run (C:\Users\bscot\acc\fork\brandongregoryscott.AndcultureCode.Cli\command-runner.js:10:11)
    at Object.<anonymous> (C:\Users\bscot\acc\fork\brandongregoryscott.AndcultureCode.Cli\and-cli-deploy-jenkins.js:3:29)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
(node:26732) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 4)
(node:26732) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Line 53 in and-cli-deploy-jenkins.js should probably index into the POJO with bracket syntax to check for its existence, ie:

if (config.profiles[profile] == null) {
    // Error and exit here
}
brandongregoryscott commented 3 years ago

FWIW, this has been fixed in #130 for the TS port, but still exists in main until that is fully released.