@atlassian/wrm-troubleshooting 0.0.0-snapshot.0

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +191 -0
  2. package/CODE_OF_CONDUCT.md +73 -0
  3. package/LICENSE +13 -0
  4. package/README.md +99 -0
  5. package/bin/cli.js +5 -0
  6. package/dist/analytics/analytics.js +74 -0
  7. package/dist/analytics/analytics.js.map +1 -0
  8. package/dist/analytics/events.js +27 -0
  9. package/dist/analytics/events.js.map +1 -0
  10. package/dist/applicationUrls.js +39 -0
  11. package/dist/applicationUrls.js.map +1 -0
  12. package/dist/atlassianPluginXml.js +69 -0
  13. package/dist/atlassianPluginXml.js.map +1 -0
  14. package/dist/checkForUpdate.js +58 -0
  15. package/dist/checkForUpdate.js.map +1 -0
  16. package/dist/cli.js +76 -0
  17. package/dist/cli.js.map +1 -0
  18. package/dist/cliUtils.js +21 -0
  19. package/dist/cliUtils.js.map +1 -0
  20. package/dist/globWithOptions.js +18 -0
  21. package/dist/globWithOptions.js.map +1 -0
  22. package/dist/maven/MavenError.js +14 -0
  23. package/dist/maven/MavenError.js.map +1 -0
  24. package/dist/paths.js +12 -0
  25. package/dist/paths.js.map +1 -0
  26. package/dist/pom.js +147 -0
  27. package/dist/pom.js.map +1 -0
  28. package/dist/steps/getEffectivePomConfig.js +94 -0
  29. package/dist/steps/getEffectivePomConfig.js.map +1 -0
  30. package/dist/steps/getEffectiveWebpackConfig.js +35 -0
  31. package/dist/steps/getEffectiveWebpackConfig.js.map +1 -0
  32. package/dist/steps/getWrmWebpackPlugin.js +22 -0
  33. package/dist/steps/getWrmWebpackPlugin.js.map +1 -0
  34. package/dist/steps/index.js +27 -0
  35. package/dist/steps/index.js.map +1 -0
  36. package/dist/steps/locatePomFile.js +30 -0
  37. package/dist/steps/locatePomFile.js.map +1 -0
  38. package/dist/steps/locateWebpackConfigFile.js +32 -0
  39. package/dist/steps/locateWebpackConfigFile.js.map +1 -0
  40. package/dist/steps/types.js +48 -0
  41. package/dist/steps/types.js.map +1 -0
  42. package/dist/steps/validateOptions.js +21 -0
  43. package/dist/steps/validateOptions.js.map +1 -0
  44. package/dist/steps/verifyPomConfigIsValid.js +22 -0
  45. package/dist/steps/verifyPomConfigIsValid.js.map +1 -0
  46. package/dist/steps/verifyWebpackBundle.js +26 -0
  47. package/dist/steps/verifyWebpackBundle.js.map +1 -0
  48. package/dist/steps/verifyWrmPluginHasValidConfig.js +28 -0
  49. package/dist/steps/verifyWrmPluginHasValidConfig.js.map +1 -0
  50. package/dist/steps/verifyWrmPluginScanFolders.js +15 -0
  51. package/dist/steps/verifyWrmPluginScanFolders.js.map +1 -0
  52. package/dist/steps/verifyWrmRuntime.js +139 -0
  53. package/dist/steps/verifyWrmRuntime.js.map +1 -0
  54. package/dist/troubleshooting.js +219 -0
  55. package/dist/troubleshooting.js.map +1 -0
  56. package/dist/troubleshootingOptions.js +12 -0
  57. package/dist/troubleshootingOptions.js.map +1 -0
  58. package/dist/types.js +3 -0
  59. package/dist/types.js.map +1 -0
  60. package/dist/webpack/webpack.js +149 -0
  61. package/dist/webpack/webpack.js.map +1 -0
  62. package/dist/webpack/webpackCli.js +167 -0
  63. package/dist/webpack/webpackCli.js.map +1 -0
  64. package/dist/webpack/webpackCliV3.js +33 -0
  65. package/dist/webpack/webpackCliV3.js.map +1 -0
  66. package/dist/webpack/webpackCliV4.js +33 -0
  67. package/dist/webpack/webpackCliV4.js.map +1 -0
  68. package/dist/webpack/webpackError.js +14 -0
  69. package/dist/webpack/webpackError.js.map +1 -0
  70. package/dist/webpackPlugin/WebpackRetrieveConfigPlugin.js +61 -0
  71. package/dist/webpackPlugin/WebpackRetrieveConfigPlugin.js.map +1 -0
  72. package/dist/webpackPlugin/webpack.config.js +10 -0
  73. package/dist/webpackPlugin/webpack.config.js.map +1 -0
  74. package/dist/webpackWrmPlugin.js +62 -0
  75. package/dist/webpackWrmPlugin.js.map +1 -0
  76. package/dist/wrm/fetchWithTimeout.js +23 -0
  77. package/dist/wrm/fetchWithTimeout.js.map +1 -0
  78. package/dist/wrm/wrmRestApi.js +93 -0
  79. package/dist/wrm/wrmRestApi.js.map +1 -0
  80. package/dist/wrm/wrmTypes.js +3 -0
  81. package/dist/wrm/wrmTypes.js.map +1 -0
  82. package/dist/xmlParser.js +42 -0
  83. package/dist/xmlParser.js.map +1 -0
  84. package/dist/yargsHelper.js +22 -0
  85. package/dist/yargsHelper.js.map +1 -0
  86. package/package.json +97 -0
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.checkForUpdate = void 0;
26
+ const fs = __importStar(require("fs"));
27
+ const path = __importStar(require("path"));
28
+ const update_notifier_1 = __importDefault(require("update-notifier"));
29
+ function checkForUpdate() {
30
+ if (process.env.NODE_ENV === 'test') {
31
+ return;
32
+ }
33
+ let packageVersion = null;
34
+ let packageName = null;
35
+ try {
36
+ const pkg = fs.readFileSync(path.join(__dirname, '../package.json'));
37
+ const { name, version } = JSON.parse(pkg.toString());
38
+ packageVersion = version;
39
+ packageName = name;
40
+ }
41
+ catch (e) {
42
+ console.log(e);
43
+ // eslint-disable-next-line no-empty
44
+ }
45
+ if (!packageName || !packageVersion) {
46
+ return;
47
+ }
48
+ const notifier = (0, update_notifier_1.default)({
49
+ packageName,
50
+ packageVersion,
51
+ updateCheckInterval: 0,
52
+ });
53
+ notifier.notify({
54
+ defer: true,
55
+ });
56
+ }
57
+ exports.checkForUpdate = checkForUpdate;
58
+ //# sourceMappingURL=checkForUpdate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkForUpdate.js","sourceRoot":"","sources":["../src/checkForUpdate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,sEAA6C;AAE7C,SAAgB,cAAc;IAC5B,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;QACnC,OAAO;KACR;IAED,IAAI,cAAc,GAAkB,IAAI,CAAC;IACzC,IAAI,WAAW,GAAkB,IAAI,CAAC;IAEtC,IAAI;QACF,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC,CAAC;QACrE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAY,CAAC;QAEhE,cAAc,GAAG,OAAO,CAAC;QACzB,WAAW,GAAG,IAAI,CAAC;KACpB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACf,oCAAoC;KACrC;IAED,IAAI,CAAC,WAAW,IAAI,CAAC,cAAc,EAAE;QACnC,OAAO;KACR;IAED,MAAM,QAAQ,GAAG,IAAA,yBAAc,EAAC;QAC9B,WAAW;QACX,cAAc;QACd,mBAAmB,EAAE,CAAC;KACvB,CAAC,CAAC;IACH,QAAQ,CAAC,MAAM,CAAC;QACd,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC;AACL,CAAC;AA/BD,wCA+BC"}
package/dist/cli.js ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ /* eslint-disable node/shebang */
8
+ const yargs_1 = __importDefault(require("yargs"));
9
+ const checkForUpdate_1 = require("./checkForUpdate");
10
+ const troubleshooting_1 = require("./troubleshooting");
11
+ const troubleshootingOptions_1 = require("./troubleshootingOptions");
12
+ const yargsHelper_1 = require("./yargsHelper");
13
+ // Check for a new version
14
+ (0, checkForUpdate_1.checkForUpdate)();
15
+ yargs_1.default
16
+ .command({
17
+ command: '$0 [options]',
18
+ // @ts-expect-error Yargs throws type errors here
19
+ desc: 'Run troubleshooting for webpack WRM plugin.',
20
+ builder: (yargs) => yargs
21
+ .option('webpack', {
22
+ describe: 'The path to webpack configuration file\ne.g. ./webpack.config.js',
23
+ type: 'string',
24
+ alias: 'w',
25
+ })
26
+ .option('pom', {
27
+ describe: 'The path to pom.xml file\ne.g. ./pom.xml',
28
+ type: 'string',
29
+ alias: 'p',
30
+ })
31
+ .option('applicationUrl', {
32
+ describe: 'Full application URL we will use to verify WRM runtime\ne.g. http://localhost:2990/jira',
33
+ type: 'string',
34
+ alias: 'u',
35
+ })
36
+ .option('resourceKey', {
37
+ describe: 'A web-resource key we will use to verify WRM runtime\ne.g. name-of-my-web-resource-key',
38
+ type: 'string',
39
+ alias: 'r',
40
+ })
41
+ .option('noWrm', {
42
+ describe: 'Skip running in-app WRM check',
43
+ type: 'boolean',
44
+ alias: 'nw',
45
+ default: false,
46
+ })
47
+ .option('yes', {
48
+ describe: 'Skip confirmation and run troubleshooting immediately',
49
+ type: 'boolean',
50
+ alias: 'y',
51
+ default: false,
52
+ })
53
+ .option('verbose', {
54
+ describe: 'Display verbose output',
55
+ type: 'boolean',
56
+ alias: 'v',
57
+ default: false,
58
+ })
59
+ .option('timeout', {
60
+ describe: 'A timeout in seconds for executing external commands.',
61
+ type: 'number',
62
+ alias: 't',
63
+ default: troubleshootingOptions_1.DEFAULT_TIMEOUT,
64
+ // Convert the seconds to milliseconds
65
+ coerce(seconds) {
66
+ if (!seconds || Number.isNaN(seconds) || seconds < 1) {
67
+ seconds = troubleshootingOptions_1.DEFAULT_TIMEOUT;
68
+ }
69
+ return seconds * 1000;
70
+ },
71
+ }),
72
+ handler: (0, yargsHelper_1.getAsyncHandler)(troubleshooting_1.troubleshootingCommand),
73
+ })
74
+ .strict()
75
+ .help().argv; // for --help and -h to work
76
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";;;;;;AACA,iCAAiC;AACjC,kDAA0B;AAE1B,qDAAkD;AAElD,uDAA2D;AAC3D,qEAA2D;AAC3D,+CAAgD;AAEhD,0BAA0B;AAC1B,IAAA,+BAAc,GAAE,CAAC;AAEjB,eAAK;KACF,OAAO,CAAyB;IAC/B,OAAO,EAAE,cAAc;IACvB,iDAAiD;IACjD,IAAI,EAAE,6CAA6C;IACnD,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CACjB,KAAK;SACF,MAAM,CAAC,SAAS,EAAE;QACjB,QAAQ,EAAE,kEAAkE;QAC5E,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;KACX,CAAC;SAED,MAAM,CAAC,KAAK,EAAE;QACb,QAAQ,EAAE,0CAA0C;QACpD,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;KACX,CAAC;SAED,MAAM,CAAC,gBAAgB,EAAE;QACxB,QAAQ,EAAE,yFAAyF;QACnG,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;KACX,CAAC;SAED,MAAM,CAAC,aAAa,EAAE;QACrB,QAAQ,EAAE,wFAAwF;QAClG,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;KACX,CAAC;SAED,MAAM,CAAC,OAAO,EAAE;QACf,QAAQ,EAAE,+BAA+B;QACzC,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,KAAK;KACf,CAAC;SAED,MAAM,CAAC,KAAK,EAAE;QACb,QAAQ,EAAE,uDAAuD;QACjE,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,KAAK;KACf,CAAC;SAED,MAAM,CAAC,SAAS,EAAE;QACjB,QAAQ,EAAE,wBAAwB;QAClC,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,KAAK;KACf,CAAC;SAED,MAAM,CAAC,SAAS,EAAE;QACjB,QAAQ,EAAE,uDAAuD;QACjE,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,GAAG;QACV,OAAO,EAAE,wCAAe;QACxB,sCAAsC;QACtC,MAAM,CAAC,OAAO;YACZ,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,CAAC,EAAE;gBACpD,OAAO,GAAG,wCAAe,CAAC;aAC3B;YAED,OAAO,OAAO,GAAG,IAAI,CAAC;QACxB,CAAC;KACF,CAAC;IACN,OAAO,EAAE,IAAA,6BAAe,EAAyB,wCAAsB,CAAC;CACzE,CAAC;KACD,MAAM,EAAE;KACR,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,4BAA4B"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.cliLink = void 0;
7
+ const cli_truncate_1 = __importDefault(require("cli-truncate"));
8
+ const terminal_link_1 = __importDefault(require("terminal-link"));
9
+ // Decrease the output size by 10% to avoid spanning the url link across full terminal width.
10
+ // We do that because a) the URLs can be quite long b) we indent the URLs when we display them in the terminal.
11
+ const maxColumns = process.stdout.columns - Math.floor(process.stdout.columns / 10);
12
+ function cliLink(url, label = url) {
13
+ const shortLabel = (0, cli_truncate_1.default)(label, maxColumns, { position: 'middle' });
14
+ return (0, terminal_link_1.default)(shortLabel, url, {
15
+ fallback(text, url) {
16
+ return url;
17
+ },
18
+ });
19
+ }
20
+ exports.cliLink = cliLink;
21
+ //# sourceMappingURL=cliUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cliUtils.js","sourceRoot":"","sources":["../src/cliUtils.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAuC;AACvC,kEAAyC;AAEzC,6FAA6F;AAC7F,+GAA+G;AAC/G,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC,CAAC;AAEpF,SAAgB,OAAO,CAAC,GAAW,EAAE,QAAgB,GAAG;IACtD,MAAM,UAAU,GAAG,IAAA,sBAAW,EAAC,KAAK,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE1E,OAAO,IAAA,uBAAY,EAAC,UAAU,EAAE,GAAG,EAAE;QACnC,QAAQ,CAAC,IAAI,EAAE,GAAG;YAChB,OAAO,GAAG,CAAC;QACb,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AARD,0BAQC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.globWithOptions = void 0;
7
+ const glob_promise_1 = __importDefault(require("glob-promise"));
8
+ const DEFAULT_IGNORED = ['**/node_modules/**', '**/target/**', '**/dist/**'];
9
+ async function globWithOptions(pattern, options = {}) {
10
+ return (0, glob_promise_1.default)(pattern, {
11
+ nodir: true,
12
+ ignore: DEFAULT_IGNORED,
13
+ absolute: true,
14
+ ...options,
15
+ });
16
+ }
17
+ exports.globWithOptions = globWithOptions;
18
+ //# sourceMappingURL=globWithOptions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globWithOptions.js","sourceRoot":"","sources":["../src/globWithOptions.ts"],"names":[],"mappings":";;;;;;AACA,gEAAgC;AAEhC,MAAM,eAAe,GAAG,CAAC,oBAAoB,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;AAEtE,KAAK,UAAU,eAAe,CAAC,OAAe,EAAE,UAAoB,EAAE;IAC3E,OAAO,IAAA,sBAAI,EAAC,OAAO,EAAE;QACnB,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,eAAe;QACvB,QAAQ,EAAE,IAAI;QACd,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAPD,0CAOC"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MavenError = void 0;
4
+ class MavenError extends Error {
5
+ constructor(message, mavenOutput) {
6
+ super(message);
7
+ this.mavenOutput = mavenOutput;
8
+ }
9
+ getMavenOutput() {
10
+ return this.mavenOutput;
11
+ }
12
+ }
13
+ exports.MavenError = MavenError;
14
+ //# sourceMappingURL=MavenError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MavenError.js","sourceRoot":"","sources":["../../src/maven/MavenError.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAW,SAAQ,KAAK;IAGnC,YAAY,OAAe,EAAE,WAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF;AAZD,gCAYC"}
package/dist/paths.js ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isSubDirectory = exports.getRelativePath = void 0;
4
+ const path = require("path");
5
+ const getRelativePath = (location) => path.relative(process.cwd(), location);
6
+ exports.getRelativePath = getRelativePath;
7
+ const isSubDirectory = (parent, child) => {
8
+ const relative = path.relative(parent, child);
9
+ return Boolean(relative && !relative.startsWith('..') && !path.isAbsolute(relative));
10
+ };
11
+ exports.isSubDirectory = isSubDirectory;
12
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":";;;AAAA,6BAA8B;AAEvB,MAAM,eAAe,GAAG,CAAC,QAAgB,EAAU,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC,CAAC;AAAvF,QAAA,eAAe,mBAAwE;AAE7F,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,KAAa,EAAW,EAAE;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAE9C,OAAO,OAAO,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC;AAJW,QAAA,cAAc,kBAIzB"}
package/dist/pom.js ADDED
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getAtlassianPluginKeyFromPom = exports.getAbsoluteScanFoldersConfig = exports.getScanFoldersConfig = exports.getPomXml = exports.askForPomXmlFile = exports.confirmRootPomFile = exports.findRootPomXmlFile = exports.SCAN_FOLDERS_KEY = void 0;
7
+ const path = require("path");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const fs_1 = require("fs");
10
+ const inquirer_1 = __importDefault(require("inquirer"));
11
+ const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
12
+ const lodash_get_1 = __importDefault(require("lodash.get"));
13
+ const globWithOptions_1 = require("./globWithOptions");
14
+ const paths_1 = require("./paths");
15
+ const xmlParser_1 = require("./xmlParser");
16
+ inquirer_1.default.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
17
+ const POM_FILE_PATTERN = 'pom.xml';
18
+ const POM_FILE_GLOB_PATTERN = `**/${POM_FILE_PATTERN}`;
19
+ exports.SCAN_FOLDERS_KEY = 'Atlassian-Scan-Folders';
20
+ async function findRootPomXmlFile() {
21
+ const [rootPomFile] = await (0, globWithOptions_1.globWithOptions)(POM_FILE_PATTERN);
22
+ return rootPomFile;
23
+ }
24
+ exports.findRootPomXmlFile = findRootPomXmlFile;
25
+ async function confirmRootPomFile(pomFile, rootPomFileFound) {
26
+ const answers = await inquirer_1.default.prompt({
27
+ type: 'confirm',
28
+ name: 'confirmRootPomFile',
29
+ message: `We have found ${rootPomFileFound ? 'a root ' : ''}pom file at "${chalk_1.default.green((0, paths_1.getRelativePath)(pomFile))}". Is it the file we should be using now?`,
30
+ });
31
+ if (answers.confirmRootPomFile) {
32
+ return pomFile;
33
+ }
34
+ return undefined;
35
+ }
36
+ exports.confirmRootPomFile = confirmRootPomFile;
37
+ async function askToSelectPomFile(fileLocations) {
38
+ const answers = await inquirer_1.default.prompt({
39
+ // @ts-expect-error We are using inquirer plugin that is causing TS error
40
+ type: 'autocomplete',
41
+ name: 'pomLocation',
42
+ message: 'Select a pom.xml file you want to use:',
43
+ source: (answersSoFar, input) => {
44
+ const userInput = input || '';
45
+ return fileLocations
46
+ .filter((fileLocation) => fileLocation.match(new RegExp(userInput, 'i')))
47
+ .map((fileLocation) => ({
48
+ name: (0, paths_1.getRelativePath)(fileLocation),
49
+ value: fileLocation,
50
+ }));
51
+ },
52
+ });
53
+ return answers.pomLocation;
54
+ }
55
+ async function askForPomFileLocation() {
56
+ const hasPomFileAnswers = await inquirer_1.default.prompt({
57
+ type: 'confirm',
58
+ name: 'hasPomFile',
59
+ message: 'Have you correctly set up and configured the Java project?',
60
+ });
61
+ if (!hasPomFileAnswers.hasPomFile) {
62
+ return new Error("The Java project wasn't configured.");
63
+ }
64
+ const answers = await inquirer_1.default.prompt({
65
+ type: 'input',
66
+ name: 'pomLocation',
67
+ message: 'Please provide a path to a pom config file you want to use:',
68
+ async validate(input) {
69
+ try {
70
+ await fs_1.promises.access(input);
71
+ return true;
72
+ }
73
+ catch (e) {
74
+ // eslint-disable-next-line no-empty
75
+ }
76
+ return 'Cannot find or read the file from provided path. Please correct the file path.';
77
+ },
78
+ });
79
+ return answers.pomLocation;
80
+ }
81
+ async function askForPomXmlFile(rooPomFileFound) {
82
+ if (!rooPomFileFound) {
83
+ console.log("We couldn't find a pom.xml file in root directory of your project. ");
84
+ }
85
+ let pomLocation;
86
+ console.log('We are now looking for the pom.xml files in your project...');
87
+ const fileLocations = await (0, globWithOptions_1.globWithOptions)(POM_FILE_GLOB_PATTERN);
88
+ // We have found some files that are looking like potential pom files
89
+ if (fileLocations.length) {
90
+ pomLocation = await askToSelectPomFile(fileLocations);
91
+ }
92
+ else {
93
+ console.log("We couldn't locate any files that look like pom.xml files in this project.");
94
+ pomLocation = await askForPomFileLocation();
95
+ }
96
+ return pomLocation;
97
+ }
98
+ exports.askForPomXmlFile = askForPomXmlFile;
99
+ function getPomXml(pomContent) {
100
+ const xml = (0, xmlParser_1.parseXmlContent)(pomContent);
101
+ if (xml instanceof Error) {
102
+ return xml;
103
+ }
104
+ return xml;
105
+ }
106
+ exports.getPomXml = getPomXml;
107
+ function getScanFoldersConfig(pomXml) {
108
+ const pluginsPath = ['project', 'build', 'plugins'];
109
+ const InstructionsPath = ['configuration', 'instructions'];
110
+ // We are using the above JSON Paths to access the XML nodes from the POM file. The "0" is pointing to the first element in the array.
111
+ // This convention is enforced by the structure of the parsed XML file.
112
+ const buildPluginsXmlPath = pluginsPath.flatMap((key) => [key, '0']);
113
+ const instructionsXmlPath = InstructionsPath.flatMap((key) => [key, '0']);
114
+ // Get array of build plugins
115
+ const buildPlugins = (0, lodash_get_1.default)(pomXml, buildPluginsXmlPath).plugin;
116
+ // Check if the build plugin contains scan folders setting
117
+ const scanFoldersValues = buildPlugins
118
+ .map((buildPlugin) => {
119
+ const instructions = (0, lodash_get_1.default)(buildPlugin, instructionsXmlPath);
120
+ return instructions ? instructions[exports.SCAN_FOLDERS_KEY] : undefined;
121
+ })
122
+ .filter(notEmpty);
123
+ // TODO: We are going to assume we have a single value here. yolo.
124
+ return Array.isArray(scanFoldersValues) && scanFoldersValues.length ? scanFoldersValues[0] : null;
125
+ }
126
+ exports.getScanFoldersConfig = getScanFoldersConfig;
127
+ function getAbsoluteScanFoldersConfig(pomXml, pomFile) {
128
+ const scanFolders = getScanFoldersConfig(pomXml);
129
+ const projectDir = path.resolve(path.dirname(pomFile));
130
+ // @ts-expect-error We should handle the null value
131
+ return path.join(projectDir, 'target', 'classes', scanFolders);
132
+ }
133
+ exports.getAbsoluteScanFoldersConfig = getAbsoluteScanFoldersConfig;
134
+ const getProject = (pomXml) => {
135
+ const project = pomXml['project'];
136
+ return project[0];
137
+ };
138
+ const getAtlassianPluginKeyFromPom = (pomXml) => {
139
+ // Naively construct the full plugin key
140
+ const { artifactId, groupId } = getProject(pomXml);
141
+ return `${groupId}.${artifactId}`;
142
+ };
143
+ exports.getAtlassianPluginKeyFromPom = getAtlassianPluginKeyFromPom;
144
+ function notEmpty(value) {
145
+ return value !== null && value !== undefined;
146
+ }
147
+ //# sourceMappingURL=pom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pom.js","sourceRoot":"","sources":["../src/pom.ts"],"names":[],"mappings":";;;;;;A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,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ var __importDefault = (this && this.__importDefault) || function (mod) {
22
+ return (mod && mod.__esModule) ? mod : { "default": mod };
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.getEffectivePomConfig = void 0;
26
+ const execa_1 = __importDefault(require("execa"));
27
+ const fs_1 = __importStar(require("fs"));
28
+ const lookpath_1 = require("lookpath");
29
+ const path = __importStar(require("path"));
30
+ const MavenError_1 = require("../maven/MavenError");
31
+ const types_1 = require("./types");
32
+ const getEffectivePomConfig = async (options, payload) => {
33
+ const { pomFile } = payload;
34
+ console.log('👀 We will retrieve pom configuration now. This might take some time...');
35
+ const pomFileWd = path.dirname(pomFile);
36
+ const xmlConfigOutput = path.resolve(pomFileWd, '.temp-pom-config.xml');
37
+ // We need to check if at least one of the following commands is available
38
+ const mvnCommands = ['atlas-mvn', 'mvn'];
39
+ let mvnCommand;
40
+ for (const mvnCmd of mvnCommands) {
41
+ mvnCommand = await (0, lookpath_1.lookpath)(mvnCmd);
42
+ if (mvnCommand) {
43
+ break;
44
+ }
45
+ }
46
+ // When we run integration tests locally with Jest we need to use a different maven command than `mvn`.
47
+ // For some reason, using `mvn` command will cause this error:
48
+ //
49
+ // Command failed with exit code 1: mvn help:effective-pom -Doutput=<<file-path>> --quiet
50
+ // mkdir: /.mvnvm: Read-only file system
51
+ //
52
+ // So for the integration tests we are running locally we need to use "atlas-mvn" from the Atlassian SDK.
53
+ if (process.env.NODE_ENV === 'test' && !process.env.CI) {
54
+ mvnCommand = 'atlas-mvn';
55
+ }
56
+ if (!mvnCommand) {
57
+ return (0, types_1.getFailedResult)(new MavenError_1.MavenError(`We can't run the "atlas-mvn" or "mvn" commands. Please ensure you have installed Atlassian SDK and one of those command can be executed.
58
+ Refer to the SDK Installation Guide: https://developer.atlassian.com/server/framework/atlassian-sdk/install-the-atlassian-sdk-on-a-linux-or-mac-system/`, ''));
59
+ }
60
+ try {
61
+ await (0, execa_1.default)(mvnCommand, ['help:effective-pom', `-Doutput=${xmlConfigOutput}`, '--quiet'], {
62
+ cwd: pomFileWd,
63
+ timeout: options.timeout,
64
+ });
65
+ }
66
+ catch (err) {
67
+ const error = err;
68
+ if (error.timedOut) {
69
+ return (0, types_1.getCommandTimeoutResult)('mvn', options.timeout);
70
+ }
71
+ const errorMessage = error.stdout || error.message || error.shortMessage;
72
+ return (0, types_1.getFailedResult)(new MavenError_1.MavenError('Maven "help:effective-pom" command failed.', errorMessage));
73
+ }
74
+ // Verify if the effective pom file was created
75
+ try {
76
+ await fs_1.promises.access(xmlConfigOutput);
77
+ }
78
+ catch (err) {
79
+ const error = err;
80
+ const errorMessage = error.message;
81
+ const xmlFilename = path.basename(xmlConfigOutput);
82
+ return (0, types_1.getFailedResult)(new MavenError_1.MavenError(`Maven "help:effective-pom" command failed. We couldn't create the "${xmlFilename}" file with effective pom configuration.`, errorMessage));
83
+ }
84
+ const pomConfig = fs_1.default.readFileSync(xmlConfigOutput, {
85
+ encoding: 'utf-8',
86
+ });
87
+ // Remove the temporary file that we don't need anymore
88
+ fs_1.default.unlinkSync(xmlConfigOutput);
89
+ return (0, types_1.getPassedResult)({
90
+ pomConfig,
91
+ });
92
+ };
93
+ exports.getEffectivePomConfig = getEffectivePomConfig;
94
+ //# sourceMappingURL=getEffectivePomConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEffectivePomConfig.js","sourceRoot":"","sources":["../../src/steps/getEffectivePomConfig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AACA,kDAA0B;AAC1B,yCAA6C;AAC7C,uCAAoC;AACpC,2CAA6B;AAE7B,oDAAiD;AAEjD,mCAAoF;AAU7E,MAAM,qBAAqB,GAI9B,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC7B,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE5B,OAAO,CAAC,GAAG,CAAC,yEAAyE,CAAC,CAAC;IAEvF,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IAExE,0EAA0E;IAC1E,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IACzC,IAAI,UAA8B,CAAC;IAEnC,KAAK,MAAM,MAAM,IAAI,WAAW,EAAE;QAChC,UAAU,GAAG,MAAM,IAAA,mBAAQ,EAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,UAAU,EAAE;YACd,MAAM;SACP;KACF;IAED,uGAAuG;IACvG,8DAA8D;IAC9D,EAAE;IACF,2FAA2F;IAC3F,4CAA4C;IAC5C,EAAE;IACF,yGAAyG;IACzG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE;QACtD,UAAU,GAAG,WAAW,CAAC;KAC1B;IAED,IAAI,CAAC,UAAU,EAAE;QAC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D,SAAS;KACV,CAAC,CAAC;AACL,CAAC,CAAC;AAzFW,QAAA,qBAAqB,yBAyFhC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getEffectiveWebpackConfig = void 0;
7
+ const chalk_1 = __importDefault(require("chalk"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const webpack_1 = require("../webpack/webpack");
10
+ const types_1 = require("./types");
11
+ const getEffectiveWebpackConfig = async (options, payload) => {
12
+ const { webpackConfigFile } = payload;
13
+ if (!options.yes) {
14
+ const answer = await inquirer_1.default.prompt({
15
+ type: 'confirm',
16
+ name: 'confirmRunningWebpack',
17
+ message: `We need to run ${chalk_1.default.bold('webpack CLI')} to retrieve the configuration file. Is that fine?`,
18
+ });
19
+ // Silly boy!
20
+ if (!answer.confirmRunningWebpack) {
21
+ const error = new Error(`We can't proceed without running the ${chalk_1.default.bold('webpack')}. Please run the troubleshooting command again when you are ready to run webpack.`);
22
+ return (0, types_1.getFailedResult)(error);
23
+ }
24
+ }
25
+ const webpackConfigResult = await (0, webpack_1.retrieveEffectiveWebpackConfig)(webpackConfigFile, options.timeout);
26
+ if (webpackConfigResult instanceof Error) {
27
+ return (0, types_1.getFailedResult)(webpackConfigResult);
28
+ }
29
+ return (0, types_1.getPassedResult)({
30
+ webpackCliInfo: webpackConfigResult.cliInfo,
31
+ webpackEffectiveConfig: webpackConfigResult.effectiveConfig,
32
+ });
33
+ };
34
+ exports.getEffectiveWebpackConfig = getEffectiveWebpackConfig;
35
+ //# sourceMappingURL=getEffectiveWebpackConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getEffectiveWebpackConfig.js","sourceRoot":"","sources":["../../src/steps/getEffectiveWebpackConfig.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAC1B,wDAAgC;AAGhC,gDAAoE;AAIpE,mCAA2D;AAWpD,MAAM,yBAAyB,GAIlC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC7B,MAAM,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC;IAEtC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;QAKhB,MAAM,MAAM,GAAW,MAAM,kBAAQ,CAAC,MAAM,CAAC;YAC3C,IAAI,EAAE,SAAS;YACf,IAAI,EAAE,uBAAuB;YAC7B,OAAO,EAAE,kBAAkB,eAAK,CAAC,IAAI,CAAC,aAAa,CAAC,oDAAoD;SACzG,CAAC,CAAC;QAEH,aAAa;QACb,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE;YACjC,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,wCAAwC,eAAK,CAAC,IAAI,CAChD,SAAS,CACV,mFAAmF,CACrF,CAAC;YAEF,OAAO,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC;SAC/B;KACF;IAED,MAAM,mBAAmB,GAAG,MAAM,IAAA,wCAA8B,EAAC,iBAAiB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IAErG,IAAI,mBAAmB,YAAY,KAAK,EAAE;QACxC,OAAO,IAAA,uBAAe,EAAC,mBAAmB,CAAC,CAAC;KAC7C;IAED,OAAO,IAAA,uBAAe,EAAyC;QAC7D,cAAc,EAAE,mBAAmB,CAAC,OAAO;QAC3C,sBAAsB,EAAE,mBAAmB,CAAC,eAAe;KAC5D,CAAC,CAAC;AACL,CAAC,CAAC;AAxCW,QAAA,yBAAyB,6BAwCpC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWrmWebpackPlugin = void 0;
4
+ const webpackWrmPlugin_1 = require("../webpackWrmPlugin");
5
+ const types_1 = require("./types");
6
+ const missingPluginError = new Error(`Provided webpack configuration is not using "${webpackWrmPlugin_1.NPM_PACKAGE_NAME}" webpack plugin.`);
7
+ const getWrmWebpackPlugin = async (options, payload) => {
8
+ const { webpackEffectiveConfig } = payload;
9
+ const { plugins } = webpackEffectiveConfig;
10
+ if (!Array.isArray(plugins)) {
11
+ return (0, types_1.getFailedResult)(missingPluginError);
12
+ }
13
+ const wrmWebpackPlugin = plugins.find((plugin) => plugin.pluginName === webpackWrmPlugin_1.WRM_PLUGIN_NAME);
14
+ if (!wrmWebpackPlugin) {
15
+ return (0, types_1.getFailedResult)(missingPluginError);
16
+ }
17
+ return (0, types_1.getPassedResult)({
18
+ wrmWebpackPlugin: wrmWebpackPlugin,
19
+ });
20
+ };
21
+ exports.getWrmWebpackPlugin = getWrmWebpackPlugin;
22
+ //# sourceMappingURL=getWrmWebpackPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getWrmWebpackPlugin.js","sourceRoot":"","sources":["../../src/steps/getWrmWebpackPlugin.ts"],"names":[],"mappings":";;;AAEA,0DAAwE;AAExE,mCAA2D;AAU3D,MAAM,kBAAkB,GAAG,IAAI,KAAK,CAClC,gDAAgD,mCAAgB,mBAAmB,CACpF,CAAC;AAEK,MAAM,mBAAmB,GAG5B,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE;IAC7B,MAAM,EAAE,sBAAsB,EAAE,GAAG,OAAO,CAAC;IAE3C,MAAM,EAAE,OAAO,EAAE,GAAG,sBAAsB,CAAC;IAE3C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,OAAO,IAAA,uBAAe,EAAC,kBAAkB,CAAC,CAAC;KAC5C;IAED,MAAM,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAA8B,EAAE,EAAE,CAAC,MAAM,CAAC,UAAU,KAAK,kCAAe,CAAC,CAAC;IAEjH,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,IAAA,uBAAe,EAAC,kBAAkB,CAAC,CAAC;KAC5C;IAED,OAAO,IAAA,uBAAe,EAAgC;QACpD,gBAAgB,EAAE,gBAAgE;KACnF,CAAC,CAAC;AACL,CAAC,CAAC;AArBW,QAAA,mBAAmB,uBAqB9B"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.verifyWrmPluginScanFolders = exports.verifyWrmPluginHasValidConfig = exports.verifyWebpackBundle = exports.verifyPomConfigIsValid = exports.validateOptions = exports.didPass = exports.didFail = exports.locateWebpackConfigFile = exports.locatePomFile = exports.getWrmWebpackPlugin = exports.getEffectiveWebpackConfig = exports.getEffectivePomConfig = void 0;
4
+ var getEffectivePomConfig_1 = require("./getEffectivePomConfig");
5
+ Object.defineProperty(exports, "getEffectivePomConfig", { enumerable: true, get: function () { return getEffectivePomConfig_1.getEffectivePomConfig; } });
6
+ var getEffectiveWebpackConfig_1 = require("./getEffectiveWebpackConfig");
7
+ Object.defineProperty(exports, "getEffectiveWebpackConfig", { enumerable: true, get: function () { return getEffectiveWebpackConfig_1.getEffectiveWebpackConfig; } });
8
+ var getWrmWebpackPlugin_1 = require("./getWrmWebpackPlugin");
9
+ Object.defineProperty(exports, "getWrmWebpackPlugin", { enumerable: true, get: function () { return getWrmWebpackPlugin_1.getWrmWebpackPlugin; } });
10
+ var locatePomFile_1 = require("./locatePomFile");
11
+ Object.defineProperty(exports, "locatePomFile", { enumerable: true, get: function () { return locatePomFile_1.locatePomFile; } });
12
+ var locateWebpackConfigFile_1 = require("./locateWebpackConfigFile");
13
+ Object.defineProperty(exports, "locateWebpackConfigFile", { enumerable: true, get: function () { return locateWebpackConfigFile_1.locateWebpackConfigFile; } });
14
+ var types_1 = require("./types");
15
+ Object.defineProperty(exports, "didFail", { enumerable: true, get: function () { return types_1.didFail; } });
16
+ Object.defineProperty(exports, "didPass", { enumerable: true, get: function () { return types_1.didPass; } });
17
+ var validateOptions_1 = require("./validateOptions");
18
+ Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return validateOptions_1.validateOptions; } });
19
+ var verifyPomConfigIsValid_1 = require("./verifyPomConfigIsValid");
20
+ Object.defineProperty(exports, "verifyPomConfigIsValid", { enumerable: true, get: function () { return verifyPomConfigIsValid_1.verifyPomConfigIsValid; } });
21
+ var verifyWebpackBundle_1 = require("./verifyWebpackBundle");
22
+ Object.defineProperty(exports, "verifyWebpackBundle", { enumerable: true, get: function () { return verifyWebpackBundle_1.verifyWebpackBundle; } });
23
+ var verifyWrmPluginHasValidConfig_1 = require("./verifyWrmPluginHasValidConfig");
24
+ Object.defineProperty(exports, "verifyWrmPluginHasValidConfig", { enumerable: true, get: function () { return verifyWrmPluginHasValidConfig_1.verifyWrmPluginHasValidConfig; } });
25
+ var verifyWrmPluginScanFolders_1 = require("./verifyWrmPluginScanFolders");
26
+ Object.defineProperty(exports, "verifyWrmPluginScanFolders", { enumerable: true, get: function () { return verifyWrmPluginScanFolders_1.verifyWrmPluginScanFolders; } });
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/steps/index.ts"],"names":[],"mappings":";;;AAAA,iEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,yEAAwE;AAA/D,sIAAA,yBAAyB,OAAA;AAClC,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,qEAAoE;AAA3D,kIAAA,uBAAuB,OAAA;AAChC,iCAA2C;AAAlC,gGAAA,OAAO,OAAA;AAAE,gGAAA,OAAO,OAAA;AACzB,qDAAoD;AAA3C,kHAAA,eAAe,OAAA;AACxB,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,iFAAgF;AAAvE,8IAAA,6BAA6B,OAAA;AACtC,2EAA0E;AAAjE,wIAAA,0BAA0B,OAAA"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.locatePomFile = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ const pom_1 = require("../pom");
9
+ const types_1 = require("./types");
10
+ const locatePomFile = async (options) => {
11
+ let pomFile = options.pom ? path_1.default.resolve(options.pom) : await (0, pom_1.findRootPomXmlFile)();
12
+ const rootPomFileFound = options.pom ? false : Boolean(pomFile);
13
+ // Skip asking for pom file if we have a root file
14
+ if (!options.yes || !pomFile) {
15
+ if (pomFile) {
16
+ pomFile = await (0, pom_1.confirmRootPomFile)(pomFile, rootPomFileFound);
17
+ }
18
+ if (!pomFile) {
19
+ pomFile = await (0, pom_1.askForPomXmlFile)(rootPomFileFound);
20
+ }
21
+ }
22
+ if (pomFile instanceof Error) {
23
+ return (0, types_1.getFailedResult)(pomFile);
24
+ }
25
+ return (0, types_1.getPassedResult)({
26
+ pomFile,
27
+ });
28
+ };
29
+ exports.locatePomFile = locatePomFile;
30
+ //# sourceMappingURL=locatePomFile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locatePomFile.js","sourceRoot":"","sources":["../../src/steps/locatePomFile.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,gCAAkF;AAElF,mCAA2D;AAMpD,MAAM,aAAa,GAA6C,KAAK,EAAE,OAAO,EAAE,EAAE;IACvF,IAAI,OAAO,GAA+B,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,IAAA,wBAAkB,GAAE,CAAC;IAC/G,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IAEhE,kDAAkD;IAClD,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE;QAC5B,IAAI,OAAO,EAAE;YACX,OAAO,GAAG,MAAM,IAAA,wBAAkB,EAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAC/D;QAED,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO,GAAG,MAAM,IAAA,sBAAgB,EAAC,gBAAgB,CAAC,CAAC;SACpD;KACF;IAED,IAAI,OAAO,YAAY,KAAK,EAAE;QAC5B,OAAO,IAAA,uBAAe,EAAC,OAAO,CAAC,CAAC;KACjC;IAED,OAAO,IAAA,uBAAe,EAAyB;QAC7C,OAAO;KACR,CAAC,CAAC;AACL,CAAC,CAAC;AAtBW,QAAA,aAAa,iBAsBxB"}