@webiny/cli-core 0.0.0-unstable.9f53ea597d → 0.0.0-unstable.a85ef555b2

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 (134) hide show
  1. package/Cli.d.ts +2 -1
  2. package/Cli.js +2 -2
  3. package/Cli.js.map +1 -1
  4. package/abstractions/services/DefaultAppsService.d.ts +8 -0
  5. package/abstractions/services/DefaultAppsService.js +5 -0
  6. package/abstractions/services/DefaultAppsService.js.map +1 -0
  7. package/abstractions/services/index.d.ts +1 -0
  8. package/abstractions/services/index.js +1 -0
  9. package/createCliContainer.d.ts +1 -1
  10. package/createCliContainer.js +22 -24
  11. package/createCliContainer.js.map +1 -1
  12. package/decorators/index.d.ts +0 -1
  13. package/decorators/index.js +0 -1
  14. package/features/BuildCommand/BuildCommand.d.ts +5 -3
  15. package/features/BuildCommand/BuildCommand.js +27 -14
  16. package/features/BuildCommand/BuildCommand.js.map +1 -1
  17. package/features/DeployCommand/index.d.ts +20 -1
  18. package/features/DeployCommand/index.js +0 -1
  19. package/features/DepsSync/ListAllPackages.d.ts +1 -1
  20. package/features/DepsSync/ListAllPackages.js +5 -3
  21. package/features/DepsSync/ListAllPackages.js.map +1 -1
  22. package/features/DepsSync/commands/SyncDepsCommand.js +1 -1
  23. package/features/DepsSync/commands/SyncDepsCommand.js.map +1 -1
  24. package/features/DepsSync/commands/VerifyDepsCommand.js +1 -1
  25. package/features/DepsSync/commands/VerifyDepsCommand.js.map +1 -1
  26. package/features/DepsSync/createDependencyTree.d.ts +1 -1
  27. package/features/DepsSync/createDependencyTree.js +8 -5
  28. package/features/DepsSync/createDependencyTree.js.map +1 -1
  29. package/features/DepsSync/paths.js +2 -2
  30. package/features/DepsSync/paths.js.map +1 -1
  31. package/features/InfoCommand/InfoCommand.js +5 -1
  32. package/features/InfoCommand/InfoCommand.js.map +1 -1
  33. package/features/UpgradeCommand/UpgradeCommandHandler.js +3 -3
  34. package/features/UpgradeCommand/UpgradeCommandHandler.js.map +1 -1
  35. package/features/Wcp/LinkProjectCommand.js +1 -1
  36. package/features/Wcp/LinkProjectCommand.js.map +1 -1
  37. package/features/globalOptions/TraceGlobalOption.d.ts +5 -0
  38. package/features/globalOptions/TraceGlobalOption.js +22 -0
  39. package/features/globalOptions/TraceGlobalOption.js.map +1 -0
  40. package/features/globalOptions/index.d.ts +1 -0
  41. package/features/globalOptions/index.js +1 -0
  42. package/features/gracefulErrorHandlers/index.d.ts +0 -2
  43. package/features/gracefulErrorHandlers/index.js +0 -2
  44. package/features/index.d.ts +0 -5
  45. package/features/index.js +0 -5
  46. package/package.json +18 -16
  47. package/services/DefaultAppsService/DefaultAppsService.d.ts +5 -0
  48. package/services/DefaultAppsService/DefaultAppsService.js +15 -0
  49. package/services/DefaultAppsService/DefaultAppsService.js.map +1 -0
  50. package/services/DefaultAppsService/index.d.ts +1 -0
  51. package/services/DefaultAppsService/index.js +1 -0
  52. package/services/GetCliRunnerService/GetCliRunnerService.js +5 -1
  53. package/services/GetCliRunnerService/GetCliRunnerService.js.map +1 -1
  54. package/services/UiService/UiService.d.ts +18 -0
  55. package/services/UiService/UiService.js +18 -2
  56. package/services/UiService/UiService.js.map +1 -1
  57. package/services/index.d.ts +1 -0
  58. package/services/index.js +1 -0
  59. package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.d.ts +1 -0
  60. package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js +53 -0
  61. package/utils/ensureSameWebinyPackageVersions/ensureSameWebinyPackageVersions.js.map +1 -0
  62. package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.d.ts +1 -0
  63. package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.js +12 -0
  64. package/utils/ensureSameWebinyPackageVersions/getCacheFilePath.js.map +1 -0
  65. package/utils/ensureSameWebinyPackageVersions/hashYarnLock.d.ts +1 -0
  66. package/utils/ensureSameWebinyPackageVersions/hashYarnLock.js +16 -0
  67. package/utils/ensureSameWebinyPackageVersions/hashYarnLock.js.map +1 -0
  68. package/utils/ensureSameWebinyPackageVersions/index.d.ts +6 -0
  69. package/utils/ensureSameWebinyPackageVersions/index.js +6 -0
  70. package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.d.ts +1 -0
  71. package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js +31 -0
  72. package/utils/ensureSameWebinyPackageVersions/listWebinyPackageVersions.js.map +1 -0
  73. package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.d.ts +1 -0
  74. package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js +13 -0
  75. package/utils/ensureSameWebinyPackageVersions/readClearedYarnLockHash.js.map +1 -0
  76. package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.d.ts +1 -0
  77. package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js +24 -0
  78. package/utils/ensureSameWebinyPackageVersions/writeClearedYarnLockHash.js.map +1 -0
  79. package/utils/suppressPunycodeWarnings.d.ts +4 -0
  80. package/utils/suppressPunycodeWarnings.js +7 -0
  81. package/utils/suppressPunycodeWarnings.js.map +1 -0
  82. package/decorators/DeployCommandWithTelemetry.d.ts +0 -11
  83. package/decorators/DeployCommandWithTelemetry.js +0 -81
  84. package/decorators/DeployCommandWithTelemetry.js.map +0 -1
  85. package/features/DeployCommand/DeployCommand.d.ts +0 -30
  86. package/features/DeployCommand/DeployCommand.js +0 -176
  87. package/features/DeployCommand/DeployCommand.js.map +0 -1
  88. package/features/DeployCommand/deployOutputs/BaseDeployOutput.d.ts +0 -20
  89. package/features/DeployCommand/deployOutputs/BaseDeployOutput.js +0 -15
  90. package/features/DeployCommand/deployOutputs/BaseDeployOutput.js.map +0 -1
  91. package/features/DeployCommand/deployOutputs/DeployOutput.d.ts +0 -5
  92. package/features/DeployCommand/deployOutputs/DeployOutput.js +0 -23
  93. package/features/DeployCommand/deployOutputs/DeployOutput.js.map +0 -1
  94. package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.d.ts +0 -4
  95. package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js +0 -96
  96. package/features/DeployCommand/deployOutputs/NoDeploymentLogsDeployOutput.js.map +0 -1
  97. package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.d.ts +0 -4
  98. package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js +0 -31
  99. package/features/DeployCommand/deployOutputs/WithDeploymentLogsDeployOutput.js.map +0 -1
  100. package/features/DestroyCommand/DestroyCommand.d.ts +0 -22
  101. package/features/DestroyCommand/DestroyCommand.js +0 -82
  102. package/features/DestroyCommand/DestroyCommand.js.map +0 -1
  103. package/features/DestroyCommand/index.d.ts +0 -1
  104. package/features/DestroyCommand/index.js +0 -1
  105. package/features/OutputCommand.d.ts +0 -12
  106. package/features/OutputCommand.js +0 -66
  107. package/features/OutputCommand.js.map +0 -1
  108. package/features/PulumiCommand/PulumiCommand.d.ts +0 -13
  109. package/features/PulumiCommand/PulumiCommand.js +0 -57
  110. package/features/PulumiCommand/PulumiCommand.js.map +0 -1
  111. package/features/PulumiCommand/index.d.ts +0 -1
  112. package/features/PulumiCommand/index.js +0 -1
  113. package/features/RefreshCommand/RefreshCommand.d.ts +0 -12
  114. package/features/RefreshCommand/RefreshCommand.js +0 -51
  115. package/features/RefreshCommand/RefreshCommand.js.map +0 -1
  116. package/features/RefreshCommand/index.d.ts +0 -1
  117. package/features/RefreshCommand/index.js +0 -1
  118. package/features/WatchCommand/WatchCommand.d.ts +0 -11
  119. package/features/WatchCommand/WatchCommand.js +0 -143
  120. package/features/WatchCommand/WatchCommand.js.map +0 -1
  121. package/features/WatchCommand/createPrefixer.d.ts +0 -2
  122. package/features/WatchCommand/createPrefixer.js +0 -16
  123. package/features/WatchCommand/createPrefixer.js.map +0 -1
  124. package/features/WatchCommand/getRandomColorForString.d.ts +0 -1
  125. package/features/WatchCommand/getRandomColorForString.js +0 -89
  126. package/features/WatchCommand/getRandomColorForString.js.map +0 -1
  127. package/features/WatchCommand/index.d.ts +0 -1
  128. package/features/WatchCommand/index.js +0 -1
  129. package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.d.ts +0 -6
  130. package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js +0 -27
  131. package/features/gracefulErrorHandlers/DdbPutItemConditionalCheckFailedGracefulErrorHandler.js.map +0 -1
  132. package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.d.ts +0 -6
  133. package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js +0 -29
  134. package/features/gracefulErrorHandlers/PendingOperationsGracefulErrorHandler.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"features/InfoCommand/InfoCommand.js","sources":["../../../src/features/InfoCommand/InfoCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { IBaseAppParams } from \"~/abstractions/features/types.js\";\nimport { PrintInfoForEnv } from \"./PrintInfoForEnv.js\";\nimport { createBaseAppOptions } from \"~/features/common/index.js\";\n\nexport type IInfoCommandParams = Omit<IBaseAppParams, \"app\">;\n\nexport class InfoCommand implements CliCommandFactory.Interface<IInfoCommandParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute(): Promise<CliCommandFactory.CommandDefinition<IInfoCommandParams>> {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"info\",\n description: \"Lists relevant URLs for your Webiny project\",\n options: createBaseAppOptions(projectSdk),\n handler: async params => {\n const ui = this.uiService;\n\n const printInfoForEnv = new PrintInfoForEnv({\n getProjectSdkService: this.getProjectSdkService,\n uiService: this.uiService\n });\n\n if (params.env) {\n await printInfoForEnv.execute({ env: params.env, variant: params.variant });\n ui.emptyLine();\n } else {\n const existingEnvs = await projectSdk.listDeployedEnvironments();\n\n if (existingEnvs.length === 0) {\n ui.info(\n \"It seems that no environments have been deployed yet. Please deploy the project first.\"\n );\n return;\n }\n\n if (existingEnvs.length === 1) {\n ui.info(\"There is one deployed environment.\");\n ui.info(\"Here is the information for the environment.\");\n } else {\n ui.info(\n \"There's a total of %d deployed environments.\",\n existingEnvs.length\n );\n ui.info(\"Here is the information for each environment.\");\n console.log();\n }\n\n for (const { env, variant } of existingEnvs) {\n await printInfoForEnv.execute({ env, variant });\n ui.emptyLine();\n }\n }\n\n ui.info(\n \"If some of the information is missing for a particular environment, make sure that the project has been fully deployed into that environment. You can do that by running the %s command.\",\n \"yarn webiny deploy --env {ENVIRONMENT_NAME}\"\n );\n }\n };\n }\n}\n\nexport const infoCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: InfoCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["InfoCommand","getProjectSdkService","uiService","projectSdk","createBaseAppOptions","params","ui","printInfoForEnv","PrintInfoForEnv","existingEnvs","console","env","variant","infoCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAQO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAA4E;QAC9E,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YACb,SAASC,qBAAqBD;YAC9B,SAAS,OAAME;gBACX,MAAMC,KAAK,IAAI,CAAC,SAAS;gBAEzB,MAAMC,kBAAkB,IAAIC,gBAAgB;oBACxC,sBAAsB,IAAI,CAAC,oBAAoB;oBAC/C,WAAW,IAAI,CAAC,SAAS;gBAC7B;gBAEA,IAAIH,OAAO,GAAG,EAAE;oBACZ,MAAME,gBAAgB,OAAO,CAAC;wBAAE,KAAKF,OAAO,GAAG;wBAAE,SAASA,OAAO,OAAO;oBAAC;oBACzEC,GAAG,SAAS;gBAChB,OAAO;oBACH,MAAMG,eAAe,MAAMN,WAAW,wBAAwB;oBAE9D,IAAIM,AAAwB,MAAxBA,aAAa,MAAM,EAAQ,YAC3BH,GAAG,IAAI,CACH;oBAKR,IAAIG,AAAwB,MAAxBA,aAAa,MAAM,EAAQ;wBAC3BH,GAAG,IAAI,CAAC;wBACRA,GAAG,IAAI,CAAC;oBACZ,OAAO;wBACHA,GAAG,IAAI,CACH,gDACAG,aAAa,MAAM;wBAEvBH,GAAG,IAAI,CAAC;wBACRI,QAAQ,GAAG;oBACf;oBAEA,KAAK,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAE,IAAIH,aAAc;wBACzC,MAAMF,gBAAgB,OAAO,CAAC;4BAAEI;4BAAKC;wBAAQ;wBAC7CN,GAAG,SAAS;oBAChB;gBACJ;gBAEAA,GAAG,IAAI,CACH,4LACA;YAER;QACJ;IACJ;AACJ;AAEO,MAAMO,cAAcC,qBAAqB;IAC5C,aAAaC;IACb,gBAAgBf;IAChB,cAAc;QAACgB;QAAsBC;KAAU;AACnD"}
1
+ {"version":3,"file":"features/InfoCommand/InfoCommand.js","sources":["../../../src/features/InfoCommand/InfoCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { IBaseAppParams } from \"~/abstractions/features/types.js\";\nimport { PrintInfoForEnv } from \"./PrintInfoForEnv.js\";\nimport { createBaseAppOptions } from \"~/features/common/index.js\";\n\nexport type IInfoCommandParams = Omit<IBaseAppParams, \"app\">;\n\nexport class InfoCommand implements CliCommandFactory.Interface<IInfoCommandParams> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute(): Promise<CliCommandFactory.CommandDefinition<IInfoCommandParams>> {\n const projectSdk = await this.getProjectSdkService.execute();\n\n return {\n name: \"info\",\n description: \"Lists relevant URLs for your Webiny project\",\n // No default env here: without `--env`, we list info for all deployed environments.\n options: createBaseAppOptions(projectSdk, { env: { default: undefined } }),\n handler: async params => {\n const ui = this.uiService;\n\n const printInfoForEnv = new PrintInfoForEnv({\n getProjectSdkService: this.getProjectSdkService,\n uiService: this.uiService\n });\n\n if (params.env) {\n await printInfoForEnv.execute({ env: params.env, variant: params.variant });\n ui.emptyLine();\n } else {\n const existingEnvs = await projectSdk.listDeployedEnvironments();\n\n if (existingEnvs.length === 0) {\n ui.info(\n \"It seems that no environments have been deployed yet. Please deploy the project first.\"\n );\n return;\n }\n\n if (existingEnvs.length === 1) {\n ui.info(\"There is one deployed environment.\");\n ui.info(\"Here is the information for the environment.\");\n } else {\n ui.info(\n \"There's a total of %d deployed environments.\",\n existingEnvs.length\n );\n ui.info(\"Here is the information for each environment.\");\n console.log();\n }\n\n for (const { env, variant } of existingEnvs) {\n await printInfoForEnv.execute({ env, variant });\n ui.emptyLine();\n }\n }\n\n ui.info(\n \"If some of the information is missing for a particular environment, make sure that the project has been fully deployed into that environment. You can do that by running the %s command.\",\n \"yarn webiny deploy --env {ENVIRONMENT_NAME}\"\n );\n }\n };\n }\n}\n\nexport const infoCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: InfoCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["InfoCommand","getProjectSdkService","uiService","projectSdk","createBaseAppOptions","undefined","params","ui","printInfoForEnv","PrintInfoForEnv","existingEnvs","console","env","variant","infoCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAQO,MAAMA;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAA4E;QAC9E,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,OAAO;YACH,MAAM;YACN,aAAa;YAEb,SAASC,qBAAqBD,YAAY;gBAAE,KAAK;oBAAE,SAASE;gBAAU;YAAE;YACxE,SAAS,OAAMC;gBACX,MAAMC,KAAK,IAAI,CAAC,SAAS;gBAEzB,MAAMC,kBAAkB,IAAIC,gBAAgB;oBACxC,sBAAsB,IAAI,CAAC,oBAAoB;oBAC/C,WAAW,IAAI,CAAC,SAAS;gBAC7B;gBAEA,IAAIH,OAAO,GAAG,EAAE;oBACZ,MAAME,gBAAgB,OAAO,CAAC;wBAAE,KAAKF,OAAO,GAAG;wBAAE,SAASA,OAAO,OAAO;oBAAC;oBACzEC,GAAG,SAAS;gBAChB,OAAO;oBACH,MAAMG,eAAe,MAAMP,WAAW,wBAAwB;oBAE9D,IAAIO,AAAwB,MAAxBA,aAAa,MAAM,EAAQ,YAC3BH,GAAG,IAAI,CACH;oBAKR,IAAIG,AAAwB,MAAxBA,aAAa,MAAM,EAAQ;wBAC3BH,GAAG,IAAI,CAAC;wBACRA,GAAG,IAAI,CAAC;oBACZ,OAAO;wBACHA,GAAG,IAAI,CACH,gDACAG,aAAa,MAAM;wBAEvBH,GAAG,IAAI,CAAC;wBACRI,QAAQ,GAAG;oBACf;oBAEA,KAAK,MAAM,EAAEC,GAAG,EAAEC,OAAO,EAAE,IAAIH,aAAc;wBACzC,MAAMF,gBAAgB,OAAO,CAAC;4BAAEI;4BAAKC;wBAAQ;wBAC7CN,GAAG,SAAS;oBAChB;gBACJ;gBAEAA,GAAG,IAAI,CACH,4LACA;YAER;QACJ;IACJ;AACJ;AAEO,MAAMO,cAAcC,qBAAqB;IAC5C,aAAaC;IACb,gBAAgBhB;IAChB,cAAc;QAACiB;QAAsBC;KAAU;AACnD"}
@@ -1,6 +1,6 @@
1
1
  import { UpgradeCommandHandler } from "./abstraction.js";
2
2
  import chalk from "chalk";
3
- import execa from "execa";
3
+ import { execa, execaSync } from "execa";
4
4
  import { UiService } from "../../abstractions/index.js";
5
5
  const GITHUB_REPOSITORY_URL = "https://github.com/webiny/webiny-upgrades-v6";
6
6
  class UpgradeCommandHandlerImpl {
@@ -12,7 +12,7 @@ class UpgradeCommandHandlerImpl {
12
12
  if (!skipChecks) {
13
13
  let gitStatus = "";
14
14
  try {
15
- const { stdout } = execa.sync("git", [
15
+ const { stdout } = execaSync("git", [
16
16
  "status",
17
17
  "--porcelain"
18
18
  ]);
@@ -43,7 +43,7 @@ class UpgradeCommandHandlerImpl {
43
43
  ].filter(Boolean);
44
44
  const npx = execa("npx", command, {
45
45
  env: {
46
- FORCE_COLOR: true
46
+ FORCE_COLOR: "1"
47
47
  },
48
48
  stdin: process.stdin
49
49
  });
@@ -1 +1 @@
1
- {"version":3,"file":"features/UpgradeCommand/UpgradeCommandHandler.js","sources":["../../../src/features/UpgradeCommand/UpgradeCommandHandler.ts"],"sourcesContent":["import { UpgradeCommandHandler as UpgradeCommandHandlerAbstraction } from \"./abstraction.js\";\nimport chalk from \"chalk\";\nimport execa from \"execa\";\nimport { UiService } from \"~/abstractions/index.js\";\n\nconst GITHUB_REPOSITORY_URL = \"https://github.com/webiny/webiny-upgrades-v6\";\n\ntype LogType = \"debug\" | \"success\" | \"warning\" | \"warn\" | \"error\" | \"fatal\" | \"done\" | \"info\";\n\ninterface IUpgradeLine {\n type: LogType;\n message: string;\n data?: {\n stack?: string;\n [key: string]: any;\n };\n}\n\nexport class UpgradeCommandHandlerImpl implements UpgradeCommandHandlerAbstraction.Interface {\n public constructor(private ui: UiService.Interface) {}\n\n public async handle(params: UpgradeCommandHandlerAbstraction.Params): Promise<void> {\n const {\n version,\n skipChecks,\n debug,\n logLevel,\n showLogs,\n showStackTrace,\n installVersion,\n force,\n registry,\n packageManager,\n skipDependencyGuard\n } = params;\n\n if (!skipChecks) {\n /**\n * Before doing any upgrading, there must not be any active changes in the current branch.\n */\n let gitStatus = \"\";\n try {\n const { stdout } = execa.sync(\"git\", [\"status\", \"--porcelain\"]);\n gitStatus = stdout.trim();\n } catch {}\n\n if (gitStatus) {\n this.ui.error(\n chalk.red(\"This git repository has untracked files or uncommitted changes:\") +\n \"\\n\\n\" +\n gitStatus\n .split(\"\\n\")\n .map(line => {\n const matched = line.match(/ .*/g);\n if (!matched || !matched[0]) {\n return \"\";\n }\n return matched[0].trim();\n })\n .join(\"\\n\") +\n \"\\n\\n\" +\n chalk.red(\n \"Remove untracked files, stash or commit any changes, and try again.\"\n )\n );\n process.exit(1);\n }\n }\n\n const command = [\n GITHUB_REPOSITORY_URL,\n version || undefined,\n debug ? \"--debug\" : \"\",\n showLogs ? `--showLogs=${showLogs}` : \"\",\n showStackTrace ? `--showStackTrace=${showStackTrace}` : \"\",\n logLevel ? `--logLevel=${logLevel}` : \"--logLevel=debug\",\n installVersion ? `--installVersion=${installVersion}` : \"\",\n force ? \"--force\" : \"\",\n registry ? `--registry=${registry}` : \"\",\n packageManager ? `--packageManager=${packageManager}` : \"\",\n skipDependencyGuard ? \"--skipDependencyGuard\" : \"\",\n \"--json\"\n ].filter(Boolean);\n\n const npx = execa(\"npx\", command, {\n env: {\n // TODO determine if this actually works\n // @ts-expect-error\n FORCE_COLOR: true\n },\n stdin: process.stdin\n });\n\n npx.stdout!.on(\"data\", data => {\n const lines = data.toString().replace(/\\n$/, \"\").split(\"\\n\") as string[];\n for (const line of lines) {\n if (!line || !line.trim()) {\n continue;\n }\n this.output(line);\n }\n });\n\n npx.stderr!.on(\"data\", data => {\n this.ui.error(data.toString());\n });\n\n try {\n await npx;\n } catch (ex) {\n this.ui.error(`Upgrade process failed: ${ex.message}`);\n }\n }\n\n private output(line: string): void {\n try {\n const json = JSON.parse(line) as IUpgradeLine;\n switch (json.type) {\n case \"debug\":\n this.ui.debug(json.message);\n if (!json.data?.stack) {\n return;\n }\n this.ui.debug(json.data?.stack);\n return;\n case \"info\":\n this.ui.info(json.message);\n return;\n case \"success\":\n case \"done\":\n this.ui.success(json.message);\n return;\n case \"warning\":\n case \"warn\":\n this.ui.warning(json.message);\n return;\n case \"error\":\n case \"fatal\":\n this.ui.error(json.message);\n if (!json.data?.stack) {\n return;\n }\n this.ui.debug(json.data?.stack);\n return;\n default:\n console.log(json);\n }\n } catch {\n console.log(line);\n }\n }\n}\n\nexport const UpgradeCommandHandler = UpgradeCommandHandlerAbstraction.createImplementation({\n implementation: UpgradeCommandHandlerImpl,\n dependencies: [UiService]\n});\n"],"names":["GITHUB_REPOSITORY_URL","UpgradeCommandHandlerImpl","ui","params","version","skipChecks","debug","logLevel","showLogs","showStackTrace","installVersion","force","registry","packageManager","skipDependencyGuard","gitStatus","stdout","execa","chalk","line","matched","process","command","undefined","Boolean","npx","data","lines","ex","json","JSON","console","UpgradeCommandHandler","UpgradeCommandHandlerAbstraction","UiService"],"mappings":";;;;AAKA,MAAMA,wBAAwB;AAavB,MAAMC;IACT,YAA2BC,EAAuB,CAAE;aAAzBA,EAAE,GAAFA;IAA0B;IAErD,MAAa,OAAOC,MAA+C,EAAiB;QAChF,MAAM,EACFC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,KAAK,EACLC,QAAQ,EACRC,cAAc,EACdC,mBAAmB,EACtB,GAAGX;QAEJ,IAAI,CAACE,YAAY;YAIb,IAAIU,YAAY;YAChB,IAAI;gBACA,MAAM,EAAEC,MAAM,EAAE,GAAGC,MAAM,IAAI,CAAC,OAAO;oBAAC;oBAAU;iBAAc;gBAC9DF,YAAYC,OAAO,IAAI;YAC3B,EAAE,OAAM,CAAC;YAET,IAAID,WAAW;gBACX,IAAI,CAAC,EAAE,CAAC,KAAK,CACTG,MAAM,GAAG,CAAC,qEACN,SACAH,UACK,KAAK,CAAC,MACN,GAAG,CAACI,CAAAA;oBACD,MAAMC,UAAUD,KAAK,KAAK,CAAC;oBAC3B,IAAI,CAACC,WAAW,CAACA,OAAO,CAAC,EAAE,EACvB,OAAO;oBAEX,OAAOA,OAAO,CAAC,EAAE,CAAC,IAAI;gBAC1B,GACC,IAAI,CAAC,QACV,SACAF,MAAM,GAAG,CACL;gBAGZG,QAAQ,IAAI,CAAC;YACjB;QACJ;QAEA,MAAMC,UAAU;YACZtB;YACAI,WAAWm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AK,IAAI,EAAE;oBACzB;gBACJ,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,IAAI,CAACA,KAAK,OAAO;oBACzB;gBACJ,KAAK;gBACL,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,OAAO,CAACA,KAAK,OAAO;oBAC5B;gBACJ,KAAK;gBACL,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,OAAO,CAACA,KAAK,OAAO;oBAC5B;gBACJ,KAAK;gBACL,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,KAAK,CAACA,KAAK,OAAO;oBAC1B,IAAI,CAACA,KAAK,IAAI,EAAE,OACZ;oBAEJ,IAAI,CAAC,EAAE,CAAC,KAAK,CAACA,KAAK,IAAI,EAAE;oBACzB;gBACJ;oBACIE,QAAQ,GAAG,CAACF;YACpB;QACJ,EAAE,OAAM;YACJE,QAAQ,GAAG,CAACZ;QAChB;IACJ;AACJ;AAEO,MAAMa,8CAAwBC,sBAAAA,oBAAqD,CAAC;IACvF,gBAAgBhC;IAChB,cAAc;QAACiC;KAAU;AAC7B"}
1
+ {"version":3,"file":"features/UpgradeCommand/UpgradeCommandHandler.js","sources":["../../../src/features/UpgradeCommand/UpgradeCommandHandler.ts"],"sourcesContent":["import { UpgradeCommandHandler as UpgradeCommandHandlerAbstraction } from \"./abstraction.js\";\nimport chalk from \"chalk\";\nimport { execa, execaSync } from \"execa\";\nimport { UiService } from \"~/abstractions/index.js\";\n\nconst GITHUB_REPOSITORY_URL = \"https://github.com/webiny/webiny-upgrades-v6\";\n\ntype LogType = \"debug\" | \"success\" | \"warning\" | \"warn\" | \"error\" | \"fatal\" | \"done\" | \"info\";\n\ninterface IUpgradeLine {\n type: LogType;\n message: string;\n data?: {\n stack?: string;\n [key: string]: any;\n };\n}\n\nexport class UpgradeCommandHandlerImpl implements UpgradeCommandHandlerAbstraction.Interface {\n public constructor(private ui: UiService.Interface) {}\n\n public async handle(params: UpgradeCommandHandlerAbstraction.Params): Promise<void> {\n const {\n version,\n skipChecks,\n debug,\n logLevel,\n showLogs,\n showStackTrace,\n installVersion,\n force,\n registry,\n packageManager,\n skipDependencyGuard\n } = params;\n\n if (!skipChecks) {\n /**\n * Before doing any upgrading, there must not be any active changes in the current branch.\n */\n let gitStatus = \"\";\n try {\n const { stdout } = execaSync(\"git\", [\"status\", \"--porcelain\"]);\n gitStatus = stdout.trim();\n } catch {}\n\n if (gitStatus) {\n this.ui.error(\n chalk.red(\"This git repository has untracked files or uncommitted changes:\") +\n \"\\n\\n\" +\n gitStatus\n .split(\"\\n\")\n .map(line => {\n const matched = line.match(/ .*/g);\n if (!matched || !matched[0]) {\n return \"\";\n }\n return matched[0].trim();\n })\n .join(\"\\n\") +\n \"\\n\\n\" +\n chalk.red(\n \"Remove untracked files, stash or commit any changes, and try again.\"\n )\n );\n process.exit(1);\n }\n }\n\n const command = [\n GITHUB_REPOSITORY_URL,\n version || undefined,\n debug ? \"--debug\" : \"\",\n showLogs ? `--showLogs=${showLogs}` : \"\",\n showStackTrace ? `--showStackTrace=${showStackTrace}` : \"\",\n logLevel ? `--logLevel=${logLevel}` : \"--logLevel=debug\",\n installVersion ? `--installVersion=${installVersion}` : \"\",\n force ? \"--force\" : \"\",\n registry ? `--registry=${registry}` : \"\",\n packageManager ? `--packageManager=${packageManager}` : \"\",\n skipDependencyGuard ? \"--skipDependencyGuard\" : \"\",\n \"--json\"\n ].filter(Boolean);\n\n const npx = execa(\"npx\", command, {\n env: {\n FORCE_COLOR: \"1\"\n },\n stdin: process.stdin\n });\n\n npx.stdout!.on(\"data\", data => {\n const lines = data.toString().replace(/\\n$/, \"\").split(\"\\n\") as string[];\n for (const line of lines) {\n if (!line || !line.trim()) {\n continue;\n }\n this.output(line);\n }\n });\n\n npx.stderr!.on(\"data\", data => {\n this.ui.error(data.toString());\n });\n\n try {\n await npx;\n } catch (ex) {\n this.ui.error(`Upgrade process failed: ${ex.message}`);\n }\n }\n\n private output(line: string): void {\n try {\n const json = JSON.parse(line) as IUpgradeLine;\n switch (json.type) {\n case \"debug\":\n this.ui.debug(json.message);\n if (!json.data?.stack) {\n return;\n }\n this.ui.debug(json.data?.stack);\n return;\n case \"info\":\n this.ui.info(json.message);\n return;\n case \"success\":\n case \"done\":\n this.ui.success(json.message);\n return;\n case \"warning\":\n case \"warn\":\n this.ui.warning(json.message);\n return;\n case \"error\":\n case \"fatal\":\n this.ui.error(json.message);\n if (!json.data?.stack) {\n return;\n }\n this.ui.debug(json.data?.stack);\n return;\n default:\n console.log(json);\n }\n } catch {\n console.log(line);\n }\n }\n}\n\nexport const UpgradeCommandHandler = UpgradeCommandHandlerAbstraction.createImplementation({\n implementation: UpgradeCommandHandlerImpl,\n dependencies: [UiService]\n});\n"],"names":["GITHUB_REPOSITORY_URL","UpgradeCommandHandlerImpl","ui","params","version","skipChecks","debug","logLevel","showLogs","showStackTrace","installVersion","force","registry","packageManager","skipDependencyGuard","gitStatus","stdout","execaSync","chalk","line","matched","process","command","undefined","Boolean","npx","execa","data","lines","ex","json","JSON","console","UpgradeCommandHandler","UpgradeCommandHandlerAbstraction","UiService"],"mappings":";;;;AAKA,MAAMA,wBAAwB;AAavB,MAAMC;IACT,YAA2BC,EAAuB,CAAE;aAAzBA,EAAE,GAAFA;IAA0B;IAErD,MAAa,OAAOC,MAA+C,EAAiB;QAChF,MAAM,EACFC,OAAO,EACPC,UAAU,EACVC,KAAK,EACLC,QAAQ,EACRC,QAAQ,EACRC,cAAc,EACdC,cAAc,EACdC,KAAK,EACLC,QAAQ,EACRC,cAAc,EACdC,mBAAmB,EACtB,GAAGX;QAEJ,IAAI,CAACE,YAAY;YAIb,IAAIU,YAAY;YAChB,IAAI;gBACA,MAAM,EAAEC,MAAM,EAAE,GAAGC,UAAU,OAAO;oBAAC;oBAAU;iBAAc;gBAC7DF,YAAYC,OAAO,IAAI;YAC3B,EAAE,OAAM,CAAC;YAET,IAAID,WAAW;gBACX,IAAI,CAAC,EAAE,CAAC,KAAK,CACTG,MAAM,GAAG,CAAC,qEAC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KAAK,CAAC,CAAC,wBAAwB,EAAEA,GAAG,OAAO,EAAE;QACzD;IACJ;IAEQ,OAAOV,IAAY,EAAQ;QAC/B,IAAI;YACA,MAAMW,OAAOC,KAAK,KAAK,CAACZ;YACxB,OAAQW,KAAK,IAAI;gBACb,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,KAAK,CAACA,KAAK,OAAO;oBAC1B,IAAI,CAACA,KAAK,IAAI,EAAE,OACZ;oBAEJ,IAAI,CAAC,EAAE,CAAC,KAAK,CAACA,KAAK,IAAI,EAAE;oBACzB;gBACJ,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,IAAI,CAACA,KAAK,OAAO;oBACzB;gBACJ,KAAK;gBACL,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,OAAO,CAACA,KAAK,OAAO;oBAC5B;gBACJ,KAAK;gBACL,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,OAAO,CAACA,KAAK,OAAO;oBAC5B;gBACJ,KAAK;gBACL,KAAK;oBACD,IAAI,CAAC,EAAE,CAAC,KAAK,CAACA,KAAK,OAAO;oBAC1B,IAAI,CAACA,KAAK,IAAI,EAAE,OACZ;oBAEJ,IAAI,CAAC,EAAE,CAAC,KAAK,CAACA,KAAK,IAAI,EAAE;oBACzB;gBACJ;oBACIE,QAAQ,GAAG,CAACF;YACpB;QACJ,EAAE,OAAM;YACJE,QAAQ,GAAG,CAACb;QAChB;IACJ;AACJ;AAEO,MAAMc,8CAAwBC,sBAAAA,oBAAqD,CAAC;IACvF,gBAAgBjC;IAChB,cAAc;QAACkC;KAAU;AAC7B"}
@@ -1,5 +1,4 @@
1
1
  import { createImplementation } from "@webiny/di";
2
- import inquirer from "inquirer";
3
2
  import { CliCommandFactory, GetProjectSdkService, UiService } from "../../abstractions/index.js";
4
3
  import { setTimeout as promises_setTimeout } from "node:timers/promises";
5
4
  const sleep = (ms = 1500)=>promises_setTimeout(ms);
@@ -19,6 +18,7 @@ class LinkProjectCommand {
19
18
  "$0 link-project"
20
19
  ],
21
20
  handler: async ()=>{
21
+ const { default: inquirer } = await import("inquirer");
22
22
  const user = await wcp.getUser();
23
23
  if (!user) return void ui.error("You must be logged in to link a project.");
24
24
  const orgProjectId = await projectSdk.getProjectId();
@@ -1 +1 @@
1
- {"version":3,"file":"features/Wcp/LinkProjectCommand.js","sources":["../../../src/features/Wcp/LinkProjectCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport inquirer from \"inquirer\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { setTimeout } from \"node:timers/promises\";\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class LinkProjectCommand implements CliCommandFactory.Interface<void> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n const wcp = projectSdk.wcp;\n const ui = this.uiService;\n\n return {\n name: \"link-project\",\n description: \"Link a Webiny project with Webiny Control Panel\",\n examples: [\"$0 link-project\"],\n handler: async () => {\n const user = await wcp.getUser();\n\n if (!user) {\n ui.error(\"You must be logged in to link a project.\");\n return;\n }\n\n // User already linked a project?\n const orgProjectId = await projectSdk.getProjectId();\n if (orgProjectId) {\n const [, projectId] = orgProjectId.split(\"/\");\n const project = user.projects.find(item => item.id === projectId);\n if (project) {\n ui.info(\"Your %s project is already linked.\", orgProjectId);\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to re-link it?\",\n type: \"confirm\",\n default: false\n });\n\n if (!proceed) {\n return;\n }\n\n ui.emptyLine();\n }\n }\n\n const wcpAppUrl = projectSdk.wcp.getWcpAppUrl().toString();\n\n // Get user's organizations.\n if (!user.orgs.length) {\n ui.info(\n \"It seems you're not part of any organization. Please log in to Webiny Control Panel and create one.\"\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to do that now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedOrg;\n if (user.orgs.length === 1) {\n selectedOrg = user.orgs[0];\n } else {\n ui.info(\"It seems you're part of multiple organizations. \");\n const choices = user.orgs.map(item => ({\n name: item.name,\n value: item\n }));\n\n const prompt = inquirer.createPromptModule();\n selectedOrg = await prompt({\n name: \"org\",\n message: \"Select organization:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.org);\n }\n\n const orgProjects = user.projects.filter(item => item.org.id === selectedOrg.id);\n\n // Get user's projects.\n if (!orgProjects.length) {\n ui.info(\n \"It seems there are no projects created within the %s organization.\",\n selectedOrg.name\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to create one now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedProject;\n if (orgProjects.length === 1) {\n selectedProject = user.projects[0];\n } else {\n ui.info(\n `It seems there are multiple projects created within the organization.`,\n selectedOrg.name\n );\n const choices = orgProjects.map(item => ({\n name: item.name,\n value: item\n }));\n const prompt = inquirer.createPromptModule();\n selectedProject = await prompt({\n name: \"project\",\n message: \"Select project:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.project);\n }\n\n await sleep();\n ui.emptyLine();\n\n ui.info(\"Linking %s project...\", selectedProject.name);\n\n await sleep();\n\n // Assign the necessary IDs into root `webiny.project.ts` project file.\n await projectSdk.setProjectId(`${selectedOrg.id}/${selectedProject.id}`, {\n force: true\n });\n\n ui.success(`%s Project %s linked successfully.`, \"✔\", selectedProject.name);\n\n await sleep();\n\n ui.emptyLine();\n ui.textBold(\"Next Steps\");\n\n ui.text(`‣ deploy your project via the yarn webiny deploy command`);\n }\n };\n }\n}\n\nexport const linkProjectCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: LinkProjectCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["sleep","ms","setTimeout","LinkProjectCommand","getProjectSdkService","uiService","projectSdk","wcp","ui","user","orgProjectId","projectId","project","item","prompt","inquirer","proceed","wcpAppUrl","open","selectedOrg","choices","result","orgProjects","selectedProject","linkProjectCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;;AAKA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,MAAMC,MAAMD,WAAW,GAAG;QAC1B,MAAME,KAAK,IAAI,CAAC,SAAS;QAEzB,OAAO;YACH,MAAM;YACN,aAAa;YACb,UAAU;gBAAC;aAAkB;YAC7B,SAAS;gBACL,MAAMC,OAAO,MAAMF,IAAI,OAAO;gBAE9B,IAAI,CAACE,MAAM,YACPD,GAAG,KAAK,CAAC;gBAKb,MAAME,eAAe,MAAMJ,WAAW,YAAY;gBAClD,IAAII,cAAc;oBACd,MAAM,GAAGC,UAAU,GAAGD,aAAa,KAAK,CAAC;oBACzC,MAAME,UAAUH,KAAK,QAAQ,CAAC,IAAI,CAACI,CAAAA,OAAQA,KAAK,EAAE,KAAKF;oBACvD,IAAIC,SAAS;wBACTJ,GAAG,IAAI,CAAC,sCAAsCE;wBAE9C,MAAMI,SAASC,SAAS,kBAAkB;wBAC1C,MAAM,EAAEC,OAAO,EAAE,GAAG,MAAMF,OAAO;4BAC7B,MAAM;4BACN,SAAS;4BACT,MAAM;4BACN,SAAS;wBACb;wBAEA,IAAI,CAACE,SACD;wBAGJR,GAAG,SAAS;oBAChB;gBACJ;gBAEA,MAAMS,YAAYX,WAAW,GAAG,CAAC,YAAY,GAAG,QAAQ;gBAGxD,IAAI,CAACG,KAAK,IAAI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UAAUE,YAAY,GAAG,CAACT,CAAAA,OAAS;4BACrC,MAAMA,KAAK,IAAI;4BACf,OAAOA;wBACX;oBACA,MAAMC,SAASC,SAAS,kBAAkB;oBAC1CQ,kBAAkB,MAAMT,OAAO;wBAC3B,MAAM;wBACN,SAAS;wBACT,MAAM;wBACNM;wBACA,SAASA,OAAO,CAAC,EAAE,CAAC,KAAK;oBAC7B,GAAG,IAAI,CAACC,CAAAA,SAAUA,OAAO,OAAO;gBACpC;gBAEA,MAAMrB;gBACNQ,GAAG,SAAS;gBAEZA,GAAG,IAAI,CAAC,yBAAyBe,gBAAgB,IAAI;gBAErD,MAAMvB;gBAGN,MAAMM,WAAW,YAAY,CAAC,GAAGa,YAAY,EAAE,CAAC,CAAC,EAAEI,gBAAgB,EAAE,EAAE,EAAE;oBACrE,OAAO;gBACX;gBAEAf,GAAG,OAAO,CAAC,sCAAsC,KAAKe,gBAAgB,IAAI;gBAE1E,MAAMvB;gBAENQ,GAAG,SAAS;gBACZA,GAAG,QAAQ,CAAC;gBAEZA,GAAG,IAAI,CAAC;YACZ;QACJ;IACJ;AACJ;AAEO,MAAMgB,qBAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;QAAsBC;KAAU;AACnD"}
1
+ {"version":3,"file":"features/Wcp/LinkProjectCommand.js","sources":["../../../src/features/Wcp/LinkProjectCommand.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { CliCommandFactory, GetProjectSdkService, UiService } from \"~/abstractions/index.js\";\nimport { setTimeout } from \"node:timers/promises\";\n\nconst sleep = (ms: number = 1500) => setTimeout(ms);\n\nexport class LinkProjectCommand implements CliCommandFactory.Interface<void> {\n constructor(\n private getProjectSdkService: GetProjectSdkService.Interface,\n private uiService: UiService.Interface\n ) {}\n\n async execute() {\n const projectSdk = await this.getProjectSdkService.execute();\n const wcp = projectSdk.wcp;\n const ui = this.uiService;\n\n return {\n name: \"link-project\",\n description: \"Link a Webiny project with Webiny Control Panel\",\n examples: [\"$0 link-project\"],\n handler: async () => {\n // Imported here rather than at the top of the file. The CLI imports every command's\n // code on every run, even `webiny --help`, and inquirer with its dependencies is about\n // 60 modules that only this command's prompts ever need.\n const { default: inquirer } = await import(\"inquirer\");\n\n const user = await wcp.getUser();\n\n if (!user) {\n ui.error(\"You must be logged in to link a project.\");\n return;\n }\n\n // User already linked a project?\n const orgProjectId = await projectSdk.getProjectId();\n if (orgProjectId) {\n const [, projectId] = orgProjectId.split(\"/\");\n const project = user.projects.find(item => item.id === projectId);\n if (project) {\n ui.info(\"Your %s project is already linked.\", orgProjectId);\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to re-link it?\",\n type: \"confirm\",\n default: false\n });\n\n if (!proceed) {\n return;\n }\n\n ui.emptyLine();\n }\n }\n\n const wcpAppUrl = projectSdk.wcp.getWcpAppUrl().toString();\n\n // Get user's organizations.\n if (!user.orgs.length) {\n ui.info(\n \"It seems you're not part of any organization. Please log in to Webiny Control Panel and create one.\"\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to do that now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedOrg;\n if (user.orgs.length === 1) {\n selectedOrg = user.orgs[0];\n } else {\n ui.info(\"It seems you're part of multiple organizations. \");\n const choices = user.orgs.map(item => ({\n name: item.name,\n value: item\n }));\n\n const prompt = inquirer.createPromptModule();\n selectedOrg = await prompt({\n name: \"org\",\n message: \"Select organization:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.org);\n }\n\n const orgProjects = user.projects.filter(item => item.org.id === selectedOrg.id);\n\n // Get user's projects.\n if (!orgProjects.length) {\n ui.info(\n \"It seems there are no projects created within the %s organization.\",\n selectedOrg.name\n );\n\n const prompt = inquirer.createPromptModule();\n const { proceed } = await prompt({\n name: \"proceed\",\n message: \"Would you like to create one now?\",\n type: \"confirm\",\n default: false\n });\n\n if (proceed) {\n open(wcpAppUrl);\n }\n return;\n }\n\n let selectedProject;\n if (orgProjects.length === 1) {\n selectedProject = user.projects[0];\n } else {\n ui.info(\n `It seems there are multiple projects created within the organization.`,\n selectedOrg.name\n );\n const choices = orgProjects.map(item => ({\n name: item.name,\n value: item\n }));\n const prompt = inquirer.createPromptModule();\n selectedProject = await prompt({\n name: \"project\",\n message: \"Select project:\",\n type: \"select\",\n choices,\n default: choices[0].value\n }).then(result => result.project);\n }\n\n await sleep();\n ui.emptyLine();\n\n ui.info(\"Linking %s project...\", selectedProject.name);\n\n await sleep();\n\n // Assign the necessary IDs into root `webiny.project.ts` project file.\n await projectSdk.setProjectId(`${selectedOrg.id}/${selectedProject.id}`, {\n force: true\n });\n\n ui.success(`%s Project %s linked successfully.`, \"✔\", selectedProject.name);\n\n await sleep();\n\n ui.emptyLine();\n ui.textBold(\"Next Steps\");\n\n ui.text(`‣ deploy your project via the yarn webiny deploy command`);\n }\n };\n }\n}\n\nexport const linkProjectCommand = createImplementation({\n abstraction: CliCommandFactory,\n implementation: LinkProjectCommand,\n dependencies: [GetProjectSdkService, UiService]\n});\n"],"names":["sleep","ms","setTimeout","LinkProjectCommand","getProjectSdkService","uiService","projectSdk","wcp","ui","inquirer","user","orgProjectId","projectId","project","item","prompt","proceed","wcpAppUrl","open","selectedOrg","choices","result","orgProjects","selectedProject","linkProjectCommand","createImplementation","CliCommandFactory","GetProjectSdkService","UiService"],"mappings":";;;AAIA,MAAMA,QAAQ,CAACC,KAAa,IAAI,GAAKC,oBAAWD;AAEzC,MAAME;IACT,YACYC,oBAAoD,EACpDC,SAA8B,CACxC;aAFUD,oBAAoB,GAApBA;aACAC,SAAS,GAATA;IACT;IAEH,MAAM,UAAU;QACZ,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAC1D,MAAMC,MAAMD,WAAW,GAAG;QAC1B,MAAME,KAAK,IA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a,YAAY,EAAE,CAAC,CAAC,EAAEI,gBAAgB,EAAE,EAAE,EAAE;oBACrE,OAAO;gBACX;gBAEAf,GAAG,OAAO,CAAC,sCAAsC,KAAKe,gBAAgB,IAAI;gBAE1E,MAAMvB;gBAENQ,GAAG,SAAS;gBACZA,GAAG,QAAQ,CAAC;gBAEZA,GAAG,IAAI,CAAC;YACZ;QACJ;IACJ;AACJ;AAEO,MAAMgB,qBAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBvB;IAChB,cAAc;QAACwB;QAAsBC;KAAU;AACnD"}
@@ -0,0 +1,5 @@
1
+ import { GlobalCliOption } from "../../abstractions/index.js";
2
+ export declare class TraceGlobalOption implements GlobalCliOption.Interface {
3
+ execute(): GlobalCliOption.Definition;
4
+ }
5
+ export declare const traceGlobalOption: import("@webiny/di").Implementation<typeof TraceGlobalOption>;
@@ -0,0 +1,22 @@
1
+ import { createImplementation } from "@webiny/di";
2
+ import { GlobalCliOption } from "../../abstractions/index.js";
3
+ class TraceGlobalOption {
4
+ execute() {
5
+ return {
6
+ name: "trace",
7
+ config: {
8
+ type: "boolean",
9
+ default: false,
10
+ description: "Print a timing breakdown of the run"
11
+ }
12
+ };
13
+ }
14
+ }
15
+ const traceGlobalOption = createImplementation({
16
+ abstraction: GlobalCliOption,
17
+ implementation: TraceGlobalOption,
18
+ dependencies: []
19
+ });
20
+ export { TraceGlobalOption, traceGlobalOption };
21
+
22
+ //# sourceMappingURL=TraceGlobalOption.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"features/globalOptions/TraceGlobalOption.js","sources":["../../../src/features/globalOptions/TraceGlobalOption.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { GlobalCliOption } from \"~/abstractions/index.js\";\n\n/*\n * Declared here only so the flag shows up in `webiny --help`. The CLI entrypoint reads it straight\n * off `process.argv`, because tracing has to be on before yargs is built.\n */\nexport class TraceGlobalOption implements GlobalCliOption.Interface {\n execute(): GlobalCliOption.Definition {\n return {\n name: \"trace\",\n config: {\n type: \"boolean\",\n default: false,\n description: \"Print a timing breakdown of the run\"\n }\n };\n }\n}\n\nexport const traceGlobalOption = createImplementation({\n abstraction: GlobalCliOption,\n implementation: TraceGlobalOption,\n dependencies: []\n});\n"],"names":["TraceGlobalOption","traceGlobalOption","createImplementation","GlobalCliOption"],"mappings":";;AAOO,MAAMA;IACT,UAAsC;QAClC,OAAO;YACH,MAAM;YACN,QAAQ;gBACJ,MAAM;gBACN,SAAS;gBACT,aAAa;YACjB;QACJ;IACJ;AACJ;AAEO,MAAMC,oBAAoBC,qBAAqB;IAClD,aAAaC;IACb,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -1,3 +1,4 @@
1
1
  export * from "./ShowLogsGlobalOption.js";
2
2
  export * from "./LogLevelGlobalOption.js";
3
3
  export * from "./StackTraceGlobalOption.js";
4
+ export * from "./TraceGlobalOption.js";
@@ -1,3 +1,4 @@
1
1
  export * from "./ShowLogsGlobalOption.js";
2
2
  export * from "./LogLevelGlobalOption.js";
3
3
  export * from "./StackTraceGlobalOption.js";
4
+ export * from "./TraceGlobalOption.js";
@@ -1,3 +1 @@
1
- export * from "./DdbPutItemConditionalCheckFailedGracefulErrorHandler.js";
2
1
  export * from "./MissingFilesInBuildGracefulErrorHandler.js";
3
- export * from "./PendingOperationsGracefulErrorHandler.js";
@@ -1,3 +1 @@
1
- export * from "./DdbPutItemConditionalCheckFailedGracefulErrorHandler.js";
2
1
  export * from "./MissingFilesInBuildGracefulErrorHandler.js";
3
- export * from "./PendingOperationsGracefulErrorHandler.js";
@@ -2,19 +2,14 @@ export * from "./AboutCommand.js";
2
2
  export * from "./BuildCommand/index.js";
3
3
  export * from "./ConfigCommand.js";
4
4
  export * from "./DeployCommand/index.js";
5
- export * from "./DestroyCommand/index.js";
6
5
  export * from "./ExtensionCommand/index.js";
7
6
  export * from "./InfoCommand/index.js";
8
7
  export * from "./IsCi/index.js";
9
8
  export * from "./OpenCommand.js";
10
9
  export * from "./DisableTelemetryCommand.js";
11
10
  export * from "./EnableTelemetryCommand.js";
12
- export * from "./OutputCommand.js";
13
- export * from "./PulumiCommand/index.js";
14
- export * from "./RefreshCommand/index.js";
15
11
  export * from "./UpgradeCommand/index.js";
16
12
  export * from "./DepsSync/index.js";
17
- export * from "./WatchCommand/index.js";
18
13
  export * from "./Wcp/LinkProjectCommand.js";
19
14
  export * from "./Wcp/LoginCommand.js";
20
15
  export * from "./Wcp/LogoutCommand.js";
package/features/index.js CHANGED
@@ -2,19 +2,14 @@ export * from "./AboutCommand.js";
2
2
  export * from "./BuildCommand/index.js";
3
3
  export * from "./ConfigCommand.js";
4
4
  export * from "./DeployCommand/index.js";
5
- export * from "./DestroyCommand/index.js";
6
5
  export * from "./ExtensionCommand/index.js";
7
6
  export * from "./InfoCommand/index.js";
8
7
  export * from "./IsCi/index.js";
9
8
  export * from "./OpenCommand.js";
10
9
  export * from "./DisableTelemetryCommand.js";
11
10
  export * from "./EnableTelemetryCommand.js";
12
- export * from "./OutputCommand.js";
13
- export * from "./PulumiCommand/index.js";
14
- export * from "./RefreshCommand/index.js";
15
11
  export * from "./UpgradeCommand/index.js";
16
12
  export * from "./DepsSync/index.js";
17
- export * from "./WatchCommand/index.js";
18
13
  export * from "./Wcp/LinkProjectCommand.js";
19
14
  export * from "./Wcp/LoginCommand.js";
20
15
  export * from "./Wcp/LogoutCommand.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/cli-core",
3
- "version": "0.0.0-unstable.9f53ea597d",
3
+ "version": "0.0.0-unstable.a85ef555b2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -13,35 +13,37 @@
13
13
  "description": "A command line interface (CLI) for managing Webiny projects.",
14
14
  "license": "MIT",
15
15
  "dependencies": {
16
- "@webiny/di": "1.0.2",
17
- "@webiny/feature": "0.0.0-unstable.9f53ea597d",
18
- "@webiny/project": "0.0.0-unstable.9f53ea597d",
19
- "@webiny/pulumi-sdk": "0.0.0-unstable.9f53ea597d",
20
- "@webiny/telemetry": "0.0.0-unstable.9f53ea597d",
21
- "chalk": "5.6.2",
16
+ "@webiny/di": "2.0.0",
17
+ "@webiny/feature": "0.0.0-unstable.a85ef555b2",
18
+ "@webiny/project": "0.0.0-unstable.a85ef555b2",
19
+ "@webiny/stdlib": "0.0.21",
20
+ "@webiny/telemetry": "0.0.0-unstable.a85ef555b2",
21
+ "chalk": "6.0.0",
22
22
  "ci-info": "4.4.0",
23
- "execa": "5.1.1",
23
+ "execa": "10.0.1",
24
24
  "fast-glob": "3.3.3",
25
25
  "find-up": "8.0.0",
26
- "get-yarn-workspaces": "1.0.2",
27
- "humanize-duration": "3.34.0",
28
- "inquirer": "14.0.2",
26
+ "humanize-duration": "3.34.1",
27
+ "inquirer": "14.1.0",
29
28
  "load-json-file": "7.0.1",
30
- "open": "11.0.0",
29
+ "open": "11.0.1",
31
30
  "ora": "9.4.1",
32
31
  "pino": "10.3.1",
33
32
  "pino-pretty": "13.1.3",
34
33
  "semver": "7.8.5",
35
34
  "type-fest": "5.8.0",
35
+ "wrap-ansi": "9.0.2",
36
36
  "write-json-file": "7.0.0",
37
- "yargs": "18.0.0",
37
+ "yargs": "18.1.0",
38
38
  "zod": "4.4.3"
39
39
  },
40
40
  "devDependencies": {
41
- "@types/lodash": "4.17.24",
42
- "@webiny/build-tools": "0.0.0-unstable.9f53ea597d",
41
+ "@types/lodash": "4.17.25",
42
+ "@webiny/build-tools": "0.0.0-unstable.a85ef555b2",
43
43
  "rimraf": "6.1.3",
44
- "typescript": "7.0.2"
44
+ "strip-ansi": "7.2.0",
45
+ "typescript": "7.0.2",
46
+ "vitest": "4.1.11"
45
47
  },
46
48
  "publishConfig": {
47
49
  "access": "public"
@@ -0,0 +1,5 @@
1
+ import { DefaultAppsService } from "../../abstractions/index.js";
2
+ export declare class EmptyDefaultAppsService implements DefaultAppsService.Interface {
3
+ execute(): Promise<string[]>;
4
+ }
5
+ export declare const defaultAppsService: import("@webiny/di").Implementation<typeof EmptyDefaultAppsService>;
@@ -0,0 +1,15 @@
1
+ import { createImplementation } from "@webiny/di";
2
+ import { DefaultAppsService } from "../../abstractions/index.js";
3
+ class EmptyDefaultAppsService {
4
+ async execute() {
5
+ return [];
6
+ }
7
+ }
8
+ const defaultAppsService = createImplementation({
9
+ abstraction: DefaultAppsService,
10
+ implementation: EmptyDefaultAppsService,
11
+ dependencies: []
12
+ });
13
+ export { EmptyDefaultAppsService, defaultAppsService };
14
+
15
+ //# sourceMappingURL=DefaultAppsService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"services/DefaultAppsService/DefaultAppsService.js","sources":["../../../src/services/DefaultAppsService/DefaultAppsService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { DefaultAppsService } from \"~/abstractions/index.js\";\n\nexport class EmptyDefaultAppsService implements DefaultAppsService.Interface {\n async execute(): Promise<string[]> {\n return [];\n }\n}\n\nexport const defaultAppsService = createImplementation({\n abstraction: DefaultAppsService,\n implementation: EmptyDefaultAppsService,\n dependencies: []\n});\n"],"names":["EmptyDefaultAppsService","defaultAppsService","createImplementation","DefaultAppsService"],"mappings":";;AAGO,MAAMA;IACT,MAAM,UAA6B;QAC/B,OAAO,EAAE;IACb;AACJ;AAEO,MAAMC,qBAAqBC,qBAAqB;IACnD,aAAaC;IACb,gBAAgBH;IAChB,cAAc,EAAE;AACpB"}
@@ -0,0 +1 @@
1
+ export * from "./DefaultAppsService.js";
@@ -0,0 +1 @@
1
+ export * from "./DefaultAppsService.js";
@@ -3,6 +3,7 @@ import { CommandsRegistryService, GetArgvService, GetCliRunnerService, GetProjec
3
3
  import yargs_yargs from "yargs/yargs";
4
4
  import chalk from "chalk";
5
5
  import { GracefulError } from "@webiny/project";
6
+ import { traceRecorder } from "@webiny/project/utils/trace/index.js";
6
7
  import { ManuallyReportedError } from "../../utils/ManuallyReportedError.js";
7
8
  const { blue: blue, bgYellow: bgYellow, bold: bold } = chalk;
8
9
  class DefaultGetCliRunnerService {
@@ -75,7 +76,10 @@ class DefaultGetCliRunnerService {
75
76
  });
76
77
  const commands = this.commandsRegistryService.execute();
77
78
  for (const command of commands){
78
- const { name, description, params = [], options = [], handler } = await command.execute();
79
+ const startedAt = performance.now();
80
+ const definition = await command.execute();
81
+ const { name, description, params = [], options = [], handler } = definition;
82
+ traceRecorder.record(`build "${name}" command`, startedAt, performance.now());
79
83
  let yargsCommand = name;
80
84
  const paramVersionExists = params.some((p)=>"version" === p.name);
81
85
  if (paramVersionExists) {
@@ -1 +1 @@
1
- {"version":3,"file":"services/GetCliRunnerService/GetCliRunnerService.js","sources":["../../../src/services/GetCliRunnerService/GetCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n CliCommandFactory,\n CommandsRegistryService,\n GetArgvService,\n GetCliRunnerService,\n GlobalOptionsRegistryService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport yargs from \"yargs/yargs\";\nimport chalk from \"chalk\";\nimport { Argv } from \"yargs\";\nimport { GracefulError } from \"@webiny/project\";\nimport { ManuallyReportedError } from \"~/utils/ManuallyReportedError.js\";\n\nconst { blue, bgYellow, bold } = chalk;\n\nexport class DefaultGetCliRunnerService implements GetCliRunnerService.Interface {\n constructor(\n private readonly commandsRegistryService: CommandsRegistryService.Interface,\n private readonly globalOptionsRegistryService: GlobalOptionsRegistryService.Interface,\n private readonly uiService: UiService.Interface,\n private readonly getProjectSdkService: GetProjectSdkService.Interface,\n private readonly getArgvService: GetArgvService.Interface\n ) {}\n\n private yargsRunner: Argv | null = null;\n\n async execute() {\n if (this.yargsRunner) {\n return this.yargsRunner;\n }\n\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n\n const yargsRunner = yargs()\n .usage(\"Usage: $0 <command> [options]\")\n .help(false)\n .demandCommand(1)\n .recommendCommands()\n .scriptName(\"webiny\")\n .epilogue(\n `To find more information, docs and tutorials, see ${blue(\n \"https://www.webiny.com/docs\"\n )}.`\n )\n .epilogue(`Want to contribute? ${blue(\"https://github.com/webiny/webiny-js\")}.`);\n\n // Register global options.\n const globalOptions = this.globalOptionsRegistryService.execute();\n for (const globalOption of globalOptions) {\n const { name, config } = await globalOption.execute();\n yargsRunner.option(name, {\n type: config.type,\n default: config.default,\n desc: config.description,\n alias: config.alias,\n choices: config.choices,\n global: true\n });\n }\n\n yargsRunner.fail((invalidParamsMessage, error) => {\n if (invalidParamsMessage) {\n if (invalidParamsMessage.includes(\"Not enough non-option arguments\")) {\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Some non-optional arguments are missing. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n if (invalidParamsMessage.includes(\"Missing required argument\")) {\n const args = invalidParamsMessage\n .split(\":\")[1]\n .split(\",\")\n .map(v => v.trim());\n\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Missing required argument(s): ${args.join(\n \", \"\n )}. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n ui.emptyLine();\n ui.error(invalidParamsMessage);\n\n process.exit(1);\n }\n\n const logger = projectSdk.getLogger();\n logger.error({ err: error }, \"CLI command execution failed.\");\n\n const realError = (error.cause as Error) || error;\n\n if (realError instanceof ManuallyReportedError) {\n // Do nothing as the error reporting has already been\n // handled within the invoked CLI command.\n } else {\n ui.error(realError.message);\n }\n\n const argv = this.getArgvService.execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n });\n\n const commands = this.commandsRegistryService.execute();\n\n for (const command of commands) {\n const {\n name,\n description,\n params = [],\n options = [],\n handler\n } = await command.execute();\n\n let yargsCommand = name;\n const paramVersionExists = params.some(p => {\n return p.name === \"version\";\n });\n if (paramVersionExists) {\n ui.error(\n `The command \"${name}\" cannot have a parameter named \"version\" as it conflicts with the global --version option.`\n );\n process.exit();\n }\n\n if (params.length > 0) {\n yargsCommand +=\n \" \" +\n params\n .map(param => {\n const paramName = param.array ? `${param.name}..` : param.name;\n return param.required ? `<${paramName}>` : `[${paramName}]`;\n })\n .join(\" \");\n }\n\n yargsRunner.command(\n yargsCommand,\n description,\n yargs => {\n params.forEach((param: CliCommandFactory.ParamDefinition<unknown>) => {\n const { name, required, validation, array, ...rest } = param;\n\n const yargsParam = yargs.positional(name, {\n ...rest,\n ...(array && { array: true }),\n demandOption: required\n });\n\n if (validation) {\n yargsParam.check(validation);\n }\n });\n\n options.forEach((option: CliCommandFactory.OptionDefinition<unknown>) => {\n const { name, required, validation, ...rest } = option;\n\n const yargsOption = yargs.option(name, {\n ...rest,\n demandOption: required\n });\n\n if (option.group) {\n yargsOption.group(option.name, option.group);\n }\n\n if (validation) {\n yargsOption.check(validation);\n }\n });\n },\n handler\n );\n }\n\n yargsRunner.help(true);\n yargsRunner.version(projectSdk.getProjectVersion());\n this.yargsRunner = yargsRunner;\n return this.yargsRunner;\n }\n}\n\nexport const getCliRunnerService = createImplementation({\n abstraction: GetCliRunnerService,\n implementation: DefaultGetCliRunnerService,\n dependencies: [\n CommandsRegistryService,\n GlobalOptionsRegistryService,\n UiService,\n GetProjectSdkService,\n GetArgvService\n ]\n});\n"],"names":["blue","bgYellow","bold","chalk","DefaultGetCliRunnerService","commandsRegistryService","globalOptionsRegistryService","uiService","getProjectSdkService","getArgvService","ui","projectSdk","yargsRunner","yargs","globalOptions","globalOption","name","config","invalidParamsMessage","error","process","args","v","logger","realError","ManuallyReportedError","argv","GracefulError","commands","command","description","params","options","handler","yargsCommand","paramVersionExists","p","param","paramName","required","validation","array","rest","yargsParam","option","yargsOption","getCliRunnerService","createImplementation","GetCliRunnerService","CommandsRegistryService","GlobalOptions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AO,KAAK,EACZC,YAAY,KAAK,CAACD,OAAO,IAAI,EAAEA,OAAO,KAAK;oBAG/C,IAAIJ,YACAK,YAAY,KAAK,CAACL;gBAE1B;YACJ,GACAP;QAER;QAEArB,YAAY,IAAI,CAAC;QACjBA,YAAY,OAAO,CAACD,WAAW,iBAAiB;QAChD,IAAI,CAAC,WAAW,GAAGC;QACnB,OAAO,IAAI,CAAC,WAAW;IAC3B;AACJ;AAEO,MAAMkC,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgB5C;IAChB,cAAc;QACV6C;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
1
+ {"version":3,"file":"services/GetCliRunnerService/GetCliRunnerService.js","sources":["../../../src/services/GetCliRunnerService/GetCliRunnerService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport {\n CliCommandFactory,\n CommandsRegistryService,\n GetArgvService,\n GetCliRunnerService,\n GlobalOptionsRegistryService,\n GetProjectSdkService,\n UiService\n} from \"~/abstractions/index.js\";\nimport yargs from \"yargs/yargs\";\nimport chalk from \"chalk\";\nimport { Argv } from \"yargs\";\nimport { GracefulError } from \"@webiny/project\";\nimport { traceRecorder } from \"@webiny/project/utils/trace/index.js\";\nimport { ManuallyReportedError } from \"~/utils/ManuallyReportedError.js\";\n\nconst { blue, bgYellow, bold } = chalk;\n\nexport class DefaultGetCliRunnerService implements GetCliRunnerService.Interface {\n constructor(\n private readonly commandsRegistryService: CommandsRegistryService.Interface,\n private readonly globalOptionsRegistryService: GlobalOptionsRegistryService.Interface,\n private readonly uiService: UiService.Interface,\n private readonly getProjectSdkService: GetProjectSdkService.Interface,\n private readonly getArgvService: GetArgvService.Interface\n ) {}\n\n private yargsRunner: Argv | null = null;\n\n async execute() {\n if (this.yargsRunner) {\n return this.yargsRunner;\n }\n\n const ui = this.uiService;\n const projectSdk = await this.getProjectSdkService.execute();\n\n const yargsRunner = yargs()\n .usage(\"Usage: $0 <command> [options]\")\n .help(false)\n .demandCommand(1)\n .recommendCommands()\n .scriptName(\"webiny\")\n .epilogue(\n `To find more information, docs and tutorials, see ${blue(\n \"https://www.webiny.com/docs\"\n )}.`\n )\n .epilogue(`Want to contribute? ${blue(\"https://github.com/webiny/webiny-js\")}.`);\n\n // Register global options.\n const globalOptions = this.globalOptionsRegistryService.execute();\n for (const globalOption of globalOptions) {\n const { name, config } = await globalOption.execute();\n yargsRunner.option(name, {\n type: config.type,\n default: config.default,\n desc: config.description,\n alias: config.alias,\n choices: config.choices,\n global: true\n });\n }\n\n yargsRunner.fail((invalidParamsMessage, error) => {\n if (invalidParamsMessage) {\n if (invalidParamsMessage.includes(\"Not enough non-option arguments\")) {\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Some non-optional arguments are missing. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n if (invalidParamsMessage.includes(\"Missing required argument\")) {\n const args = invalidParamsMessage\n .split(\":\")[1]\n .split(\",\")\n .map(v => v.trim());\n\n ui.emptyLine();\n ui.error(\"Command was not invoked as expected.\");\n ui.info(\n `Missing required argument(s): ${args.join(\n \", \"\n )}. See the usage examples printed below.`\n );\n ui.emptyLine();\n yargsRunner.showHelp();\n process.exit(1);\n }\n\n ui.emptyLine();\n ui.error(invalidParamsMessage);\n\n process.exit(1);\n }\n\n const logger = projectSdk.getLogger();\n logger.error({ err: error }, \"CLI command execution failed.\");\n\n const realError = (error.cause as Error) || error;\n\n if (realError instanceof ManuallyReportedError) {\n // Do nothing as the error reporting has already been\n // handled within the invoked CLI command.\n } else {\n ui.error(realError.message);\n }\n\n const argv = this.getArgvService.execute();\n if (argv.showStackTrace && realError.stack) {\n ui.emptyLine();\n ui.debug(\"Stack trace:\");\n ui.text(realError.stack);\n }\n\n if (error instanceof GracefulError) {\n ui.emptyLine();\n ui.text(bgYellow(bold(\"💡 How can I resolve this?\")));\n ui.text(error.message);\n }\n\n process.exit(1);\n });\n\n const commands = this.commandsRegistryService.execute();\n\n // Every registered command's definition is built on every run, no matter which command was\n // actually invoked, so each one is timed separately.\n for (const command of commands) {\n const startedAt = performance.now();\n const definition = await command.execute();\n\n const { name, description, params = [], options = [], handler } = definition;\n\n traceRecorder.record(`build \"${name}\" command`, startedAt, performance.now());\n\n let yargsCommand = name;\n const paramVersionExists = params.some(p => {\n return p.name === \"version\";\n });\n if (paramVersionExists) {\n ui.error(\n `The command \"${name}\" cannot have a parameter named \"version\" as it conflicts with the global --version option.`\n );\n process.exit();\n }\n\n if (params.length > 0) {\n yargsCommand +=\n \" \" +\n params\n .map(param => {\n const paramName = param.array ? `${param.name}..` : param.name;\n return param.required ? `<${paramName}>` : `[${paramName}]`;\n })\n .join(\" \");\n }\n\n yargsRunner.command(\n yargsCommand,\n description,\n yargs => {\n params.forEach((param: CliCommandFactory.ParamDefinition<unknown>) => {\n const { name, required, validation, array, ...rest } = param;\n\n const yargsParam = yargs.positional(name, {\n ...rest,\n ...(array && { array: true }),\n demandOption: required\n });\n\n if (validation) {\n yargsParam.check(validation);\n }\n });\n\n options.forEach((option: CliCommandFactory.OptionDefinition<unknown>) => {\n const { name, required, validation, ...rest } = option;\n\n const yargsOption = yargs.option(name, {\n ...rest,\n demandOption: required\n });\n\n if (option.group) {\n yargsOption.group(option.name, option.group);\n }\n\n if (validation) {\n yargsOption.check(validation);\n }\n });\n },\n handler\n );\n }\n\n yargsRunner.help(true);\n yargsRunner.version(projectSdk.getProjectVersion());\n this.yargsRunner = yargsRunner;\n return this.yargsRunner;\n }\n}\n\nexport const getCliRunnerService = createImplementation({\n abstraction: GetCliRunnerService,\n implementation: DefaultGetCliRunnerService,\n dependencies: [\n CommandsRegistryService,\n GlobalOptionsRegistryService,\n UiService,\n GetProjectSdkService,\n GetArgvService\n ]\n});\n"],"names":["blue","bgYellow","bold","chalk","DefaultGetCliRunnerService","commandsRegistryService","globalOptionsRegistryService","uiService","getProjectSdkService","getArgvService","ui","projectSdk","yargsRunner","yargs","globalOptions","globalOption","name","config","invalidParamsMessage","error","process","args","v","logger","realError","ManuallyReportedError","argv","GracefulError","commands","command","startedAt","performance","definition","description","params","options","handler","traceRecorder","yargsCommand","paramVersionExists","p","param","paramName","required","validation","array","rest","yargsParam","option","yargsOption","getCliRunnerService","createImplementation","GetCliRunnerService","CommandsRegistryService","GlobalOptionsRegistryService","UiService","GetProjectSdkService","GetArgvService"],"mappings":";;;;;;;AAiBA,MAAM,EAAEA,MAAAA,IAAI,EAAEC,UAAAA,QAAQ,EAAEC,MAAAA,IAAI,EAAE,GAAGC;AAE1B,MAAMC;IACT,YACqBC,uBAA0D,EAC1DC,4BAAoE,EACpEC,SAA8B,EAC9BC,oBAAoD,EACpDC,cAAwC,CAC3D;aALmBJ,uBAAuB,GAAvBA;aACAC,4BAA4B,GAA5BA;aACAC,SAAS,GAATA;aACAC,oBAAoB,GAApBA;aACAC,cAAc,GAAdA;aAGb,WAAW,GAAgB;IAFhC;IAIH,MAAM,UAAU;QACZ,IAAI,IAAI,CAAC,WAAW,EAChB,OAAO,IAAI,CAAC,WAAW;QAG3B,MAAMC,KAAK,IAAI,CAAC,SAAS;QACzB,MAAMC,aAAa,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO;QAE1D,MAAMC,cAAcC,cACf,KAAK,CAAC,iCACN,IAAI,CAAC,OACL,aAAa,CAAC,GACd,iBAAiB,GACjB,UAAU,CAAC,UACX,QAAQ,CACL,CAAC,kDAAkD,EAAEb,KACjD,+BACF,CAAC,CAAC,EAEP,QAAQ,CAAC,CAAC,oBAAoB,EAAEA,KAAK,uCAAuC,CAAC,CAAC;QAGnF,MAAMc,gBAAgB,IAAI,CAAC,4BAA4B,CAAC,OAAO;QAC/D,KAAK,MAAMC,gBAAgBD,cAAe;YACtC,MAAM,EAAEE,IAAI,EAAEC,MAAM,EAAE,GAAG,MAAMF,aAAa,OAAO;YACnDH,YAAY,MAAM,CAACI,MAAM;gBACrB,MAAMC,OAAO,IAAI;gBACjB,SAASA,OAAO,OAAO;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,GAAG8B,IAAI;wBACP,GAAID,SAAS;4BAAE,OAAO;wBAAK,CAAC;wBAC5B,cAAcF;oBAClB;oBAEA,IAAIC,YACAG,WAAW,KAAK,CAACH;gBAEzB;gBAEAT,QAAQ,OAAO,CAAC,CAACa;oBACb,MAAM,EAAEhC,IAAI,EAAE2B,QAAQ,EAAEC,UAAU,EAAE,GAAGE,MAAM,GAAGE;oBAEhD,MAAMC,cAAcpC,MAAM,MAAM,CAACG,MAAM;wBACnC,GAAG8B,IAAI;wBACP,cAAcH;oBAClB;oBAEA,IAAIK,OAAO,KAAK,EACZC,YAAY,KAAK,CAACD,OAAO,IAAI,EAAEA,OAAO,KAAK;oBAG/C,IAAIJ,YACAK,YAAY,KAAK,CAACL;gBAE1B;YACJ,GACAR;QAER;QAEAxB,YAAY,IAAI,CAAC;QACjBA,YAAY,OAAO,CAACD,WAAW,iBAAiB;QAChD,IAAI,CAAC,WAAW,GAAGC;QACnB,OAAO,IAAI,CAAC,WAAW;IAC3B;AACJ;AAEO,MAAMsC,sBAAsBC,qBAAqB;IACpD,aAAaC;IACb,gBAAgBhD;IAChB,cAAc;QACViD;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
@@ -13,5 +13,23 @@ export declare class DefaultUiService implements UiService.Interface {
13
13
  error(text: string, ...args: any[]): void;
14
14
  debug(text: string, ...args: any[]): void;
15
15
  private typedColorizedText;
16
+ /**
17
+ * Prefixes every line of `message` with the gutter, wrapping the text to the terminal width
18
+ * first.
19
+ *
20
+ * The wrap has to happen here rather than being left to the terminal. Writing the whole message
21
+ * as one long line means the terminal wraps it at column 0, with no knowledge of the gutter -
22
+ * so continuation lines start underneath the pipe instead of underneath the text, and a wrapped
23
+ * sentence reads as though it belongs to a different paragraph.
24
+ */
25
+ private applyGutter;
26
+ /**
27
+ * Width available for the text itself, or `null` when there is nothing to wrap to.
28
+ *
29
+ * `columns` is undefined whenever stdout is not a TTY - piped to a file, or read by another
30
+ * process. Wrapping to a guessed width there would bake line breaks into output that something
31
+ * else is going to reflow anyway, so the message is left as a single line.
32
+ */
33
+ private getTextWidth;
16
34
  }
17
35
  export declare const uiService: import("@webiny/di").Implementation<typeof DefaultUiService>;
@@ -1,9 +1,12 @@
1
1
  import { createImplementation } from "@webiny/di";
2
2
  import chalk from "chalk";
3
3
  import util from "util";
4
+ import wrap_ansi from "wrap-ansi";
4
5
  import { IsCi, StdioService, UiService } from "../../abstractions/index.js";
5
6
  const NEW_LINE = "\n";
6
7
  const PIPE_SYMBOL = "┃";
8
+ const GUTTER_WIDTH = 2;
9
+ const MIN_TEXT_WIDTH = 20;
7
10
  const LOG_COLORS = {
8
11
  info: chalk.blueBright,
9
12
  error: chalk.red,
@@ -49,9 +52,22 @@ class DefaultUiService {
49
52
  const prefix = `${type}: `;
50
53
  return this.text(prefix + util.format(text, ...args));
51
54
  }
52
- const prefix = `${LOG_COLORS[type](PIPE_SYMBOL)} `;
55
+ const gutter = `${LOG_COLORS[type](PIPE_SYMBOL)} `;
53
56
  const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, (match)=>LOG_COLORS[type](match));
54
- return this.text(prefix + util.format(textWithColorizedPlaceholders, ...args));
57
+ const message = util.format(textWithColorizedPlaceholders, ...args);
58
+ return this.text(this.applyGutter(message, gutter));
59
+ }
60
+ applyGutter(message, gutter) {
61
+ const textWidth = this.getTextWidth();
62
+ const wrapped = textWidth ? wrap_ansi(message, textWidth, {
63
+ hard: true
64
+ }) : message;
65
+ return wrapped.split(NEW_LINE).map((line)=>gutter + line).join(NEW_LINE);
66
+ }
67
+ getTextWidth() {
68
+ const columns = this.stdio.getStdout().columns;
69
+ if (!columns) return null;
70
+ return Math.max(columns - GUTTER_WIDTH, MIN_TEXT_WIDTH);
55
71
  }
56
72
  }
57
73
  const uiService = createImplementation({
@@ -1 +1 @@
1
- {"version":3,"file":"services/UiService/UiService.js","sources":["../../../src/services/UiService/UiService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport chalk from \"chalk\";\nimport util from \"util\";\nimport { UiService, StdioService, IsCi } from \"~/abstractions/index.js\";\n\nconst NEW_LINE = \"\\n\";\nconst PIPE_SYMBOL = \"┃\";\n\nconst LOG_COLORS = {\n info: chalk.blueBright,\n error: chalk.red,\n warning: chalk.yellow,\n success: chalk.green,\n debug: chalk.gray\n} as const;\n\nexport class DefaultUiService implements UiService.Interface {\n constructor(\n private readonly stdio: StdioService.Interface,\n private readonly isCi: IsCi.Interface\n ) {}\n\n raw(text: string) {\n this.stdio.getStdout().write(text);\n }\n\n text(text: string) {\n this.stdio.getStdout().write(text);\n this.stdio.getStdout().write(NEW_LINE);\n }\n\n textBold(text: string) {\n this.text(chalk.bold(text));\n }\n\n emptyLine() {\n this.stdio.getStdout().write(chalk.gray(\"∙\") + NEW_LINE);\n }\n\n // The following methods are used to print texts with a specific type prefix.\n success(text: string, ...args: any[]) {\n this.typedColorizedText(\"success\", text, ...args);\n }\n\n info(text: string, ...args: any[]) {\n this.typedColorizedText(\"info\", text, ...args);\n }\n\n warning(text: string, ...args: any[]) {\n this.typedColorizedText(\"warning\", text, ...args);\n }\n\n error(text: string, ...args: any[]) {\n this.typedColorizedText(\"error\", text, ...args);\n }\n\n debug(text: string, ...args: any[]) {\n this.typedColorizedText(\"debug\", text, ...args);\n }\n\n private typedColorizedText(type: keyof typeof LOG_COLORS, text: string, ...args: any[]) {\n // Use plain text format in CI environments.\n if (this.isCi.execute()) {\n const prefix = `${type}: `;\n return this.text(prefix + util.format(text, ...args));\n }\n\n const prefix = `${LOG_COLORS[type](PIPE_SYMBOL)} `;\n\n // Replace all placeholders (match with `/%[a-zA-Z]/g` regex) with colorized values.\n const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, match => {\n return LOG_COLORS[type](match);\n });\n\n return this.text(prefix + util.format(textWithColorizedPlaceholders, ...args));\n }\n}\n\nexport const uiService = createImplementation({\n abstraction: UiService,\n implementation: DefaultUiService,\n dependencies: [StdioService, IsCi]\n});\n"],"names":["NEW_LINE","PIPE_SYMBOL","LOG_COLORS","chalk","DefaultUiService","stdio","isCi","text","args","type","prefix","util","textWithColorizedPlaceholders","match","uiService","createImplementation","UiService","StdioService","IsCi"],"mappings":";;;;AAKA,MAAMA,WAAW;AACjB,MAAMC,cAAc;AAEpB,MAAMC,aAAa;IACf,MAAMC,MAAM,UAAU;IACtB,OAAOA,MAAM,GAAG;IAChB,SAASA,MAAM,MAAM;IACrB,SAASA,MAAM,KAAK;IACpB,OAAOA,MAAM,IAAI;AACrB;AAEO,MAAMC;IACT,YACqBC,KAA6B,EAC7BC,IAAoB,CACvC;aAFmBD,KAAK,GAALA;aACAC,IAAI,GAAJA;IAClB;IAEH,IAAIC,IAAY,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;IACjC;IAEA,KAAKA,IAAY,EAAE;QACf,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACP;IACjC;IAEA,SAASO,IAAY,EAAE;QACnB,IAAI,CAAC,IAAI,CAACJ,MAAM,IAAI,CAACI;IACzB;IAEA,YAAY;QACR,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACJ,MAAM,IAAI,CAAC,OAAOH;IACnD;IAGA,QAAQO,IAAY,EAAE,GAAGC,IAAW,EAAE;QAClC,IAAI,CAAC,kBAAkB,CAAC,WAAWD,SAASC;IAChD;IAEA,KAAKD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAC/B,IAAI,CAAC,kBAAkB,CAAC,QAAQD,SAASC;IAC7C;IAEA,QAAQD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAClC,IAAI,CAAC,kBAAkB,CAAC,WAAWD,SAASC;IAChD;IAEA,MAAMD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAChC,IAAI,CAAC,kBAAkB,CAAC,SAASD,SAASC;IAC9C;IAEA,MAAMD,IAAY,EAAE,GAAGC,IAAW,EAAE;QAChC,IAAI,CAAC,kBAAkB,CAAC,SAASD,SAASC;IAC9C;IAEQ,mBAAmBC,IAA6B,EAAEF,IAAY,EAAE,GAAGC,IAAW,EAAE;QAEpF,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI;YACrB,MAAME,SAAS,GAAGD,KAAK,EAAE,CAAC;YAC1B,OAAO,IAAI,CAAC,IAAI,CAACC,SAASC,KAAK,MAAM,CAACJ,SAASC;QACnD;QAEA,MAAME,SAAS,GAAGR,UAAU,CAACO,KAAK,CAACR,aAAa,CAAC,CAAC;QAGlD,MAAMW,gCAAgCL,KAAK,OAAO,CAAC,cAAcM,CAAAA,QACtDX,UAAU,CAACO,KAAK,CAACI;QAG5B,OAAO,IAAI,CAAC,IAAI,CAACH,SAASC,KAAK,MAAM,CAACC,kCAAkCJ;IAC5E;AACJ;AAEO,MAAMM,YAAYC,qBAAqB;IAC1C,aAAaC;IACb,gBAAgBZ;IAChB,cAAc;QAACa;QAAcC;KAAK;AACtC"}
1
+ {"version":3,"file":"services/UiService/UiService.js","sources":["../../../src/services/UiService/UiService.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport chalk from \"chalk\";\nimport util from \"util\";\nimport wrapAnsi from \"wrap-ansi\";\nimport { UiService, StdioService, IsCi } from \"~/abstractions/index.js\";\n\nconst NEW_LINE = \"\\n\";\nconst PIPE_SYMBOL = \"┃\";\n\n// Visible width of the `┃ ` gutter that prefixes every line of a typed message. Hardcoded rather\n// than measured because the pipe is a single-column glyph and the colour codes around it occupy no\n// columns at all.\nconst GUTTER_WIDTH = 2;\n\n// A floor for very narrow terminals, so the wrap width can never go to zero or negative.\nconst MIN_TEXT_WIDTH = 20;\n\nconst LOG_COLORS = {\n info: chalk.blueBright,\n error: chalk.red,\n warning: chalk.yellow,\n success: chalk.green,\n debug: chalk.gray\n} as const;\n\nexport class DefaultUiService implements UiService.Interface {\n constructor(\n private readonly stdio: StdioService.Interface,\n private readonly isCi: IsCi.Interface\n ) {}\n\n raw(text: string) {\n this.stdio.getStdout().write(text);\n }\n\n text(text: string) {\n this.stdio.getStdout().write(text);\n this.stdio.getStdout().write(NEW_LINE);\n }\n\n textBold(text: string) {\n this.text(chalk.bold(text));\n }\n\n emptyLine() {\n this.stdio.getStdout().write(chalk.gray(\"∙\") + NEW_LINE);\n }\n\n // The following methods are used to print texts with a specific type prefix.\n success(text: string, ...args: any[]) {\n this.typedColorizedText(\"success\", text, ...args);\n }\n\n info(text: string, ...args: any[]) {\n this.typedColorizedText(\"info\", text, ...args);\n }\n\n warning(text: string, ...args: any[]) {\n this.typedColorizedText(\"warning\", text, ...args);\n }\n\n error(text: string, ...args: any[]) {\n this.typedColorizedText(\"error\", text, ...args);\n }\n\n debug(text: string, ...args: any[]) {\n this.typedColorizedText(\"debug\", text, ...args);\n }\n\n private typedColorizedText(type: keyof typeof LOG_COLORS, text: string, ...args: any[]) {\n // Use plain text format in CI environments.\n if (this.isCi.execute()) {\n const prefix = `${type}: `;\n return this.text(prefix + util.format(text, ...args));\n }\n\n const gutter = `${LOG_COLORS[type](PIPE_SYMBOL)} `;\n\n // Replace all placeholders (match with `/%[a-zA-Z]/g` regex) with colorized values.\n const textWithColorizedPlaceholders = text.replace(/%[a-zA-Z]/g, match => {\n return LOG_COLORS[type](match);\n });\n\n const message = util.format(textWithColorizedPlaceholders, ...args);\n\n return this.text(this.applyGutter(message, gutter));\n }\n\n /**\n * Prefixes every line of `message` with the gutter, wrapping the text to the terminal width\n * first.\n *\n * The wrap has to happen here rather than being left to the terminal. Writing the whole message\n * as one long line means the terminal wraps it at column 0, with no knowledge of the gutter -\n * so continuation lines start underneath the pipe instead of underneath the text, and a wrapped\n * sentence reads as though it belongs to a different paragraph.\n */\n private applyGutter(message: string, gutter: string) {\n const textWidth = this.getTextWidth();\n\n // `hard` also breaks words longer than a whole line - a long file path, or a URL. Letting\n // those overflow would hand them straight back to the terminal's own wrapping, which is\n // the column-0 behaviour this method exists to avoid.\n const wrapped = textWidth ? wrapAnsi(message, textWidth, { hard: true }) : message;\n\n return wrapped\n .split(NEW_LINE)\n .map(line => gutter + line)\n .join(NEW_LINE);\n }\n\n /**\n * Width available for the text itself, or `null` when there is nothing to wrap to.\n *\n * `columns` is undefined whenever stdout is not a TTY - piped to a file, or read by another\n * process. Wrapping to a guessed width there would bake line breaks into output that something\n * else is going to reflow anyway, so the message is left as a single line.\n */\n private getTextWidth() {\n const columns = this.stdio.getStdout().columns;\n if (!columns) {\n return null;\n }\n\n return Math.max(columns - GUTTER_WIDTH, MIN_TEXT_WIDTH);\n }\n}\n\nexport const uiService = createImplementation({\n abstraction: UiService,\n implementation: DefaultUiService,\n dependencies: [StdioService, IsCi]\n});\n"],"names":["NEW_LINE","PIPE_SYMBOL","GUTTER_WIDTH","MIN_TEXT_WIDTH","LOG_COLORS","chalk","DefaultUiService","stdio","isCi","text","args","type","prefix","util","gutter","textWithColorizedPlaceholders","match","message","textWidth","wrapped","wrapAnsi","line","columns","Math","uiService","createImplementation","UiService","StdioService","IsCi"],"mappings":";;;;;AAMA,MAAMA,WAAW;AACjB,MAAMC,cAAc;AAKpB,MAAMC,eAAe;AAGrB,MAAMC,iBAAiB;AAEvB,MAAMC,aAAa;IACf,MAAMC,MAAM,UAAU;IACtB,OAAOA,MAAM,GAAG;IAChB,SAASA,MAAM,MAAM;IACrB,SAASA,MAAM,KAAK;IACpB,OAAOA,MAAM,IAAI;AACrB;AAEO,MAAMC;IACT,YACqBC,KAA6B,EAC7BC,IAAoB,CACvC;aAFmBD,KAAK,GAALA;aACAC,IAAI,GAAJA;IAClB;IAEH,IAAIC,IAAY,EAAE;QACd,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;IACjC;IAEA,KAAKA,IAAY,EAAE;QACf,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACA;QAC7B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAACT;IACjC;IAEA,SAASS,IAAY,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QAKnC,MAAMC,UAAUD,YAAYE,UAASH,SAASC,WAAW;YAAE,MAAM;QAAK,KAAKD;QAE3E,OAAOE,QACF,KAAK,CAACnB,UACN,GAAG,CAACqB,CAAAA,OAAQP,SAASO,MACrB,IAAI,CAACrB;IACd;IASQ,eAAe;QACnB,MAAMsB,UAAU,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,OAAO;QAC9C,IAAI,CAACA,SACD,OAAO;QAGX,OAAOC,KAAK,GAAG,CAACD,UAAUpB,cAAcC;IAC5C;AACJ;AAEO,MAAMqB,YAAYC,qBAAqB;IAC1C,aAAaC;IACb,gBAAgBpB;IAChB,cAAc;QAACqB;QAAcC;KAAK;AACtC"}
@@ -1,4 +1,5 @@
1
1
  export * from "./ArgvParserService/index.js";
2
+ export * from "./DefaultAppsService/index.js";
2
3
  export * from "./CliParamsService/index.js";
3
4
  export * from "./CommandsRegistryService/index.js";
4
5
  export * from "./GetArgvService/index.js";
package/services/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./ArgvParserService/index.js";
2
+ export * from "./DefaultAppsService/index.js";
2
3
  export * from "./CliParamsService/index.js";
3
4
  export * from "./CommandsRegistryService/index.js";
4
5
  export * from "./GetArgvService/index.js";
@@ -0,0 +1 @@
1
+ export declare const ensureSameWebinyPackageVersions: () => void;