@microsoft/managed-apps-cli 0.9.2 → 0.11.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 (188) hide show
  1. package/README.md +18 -342
  2. package/dist/ArgumentProvider.d.ts.map +1 -1
  3. package/dist/ArgumentProvider.js +8 -1
  4. package/dist/ArgumentProvider.js.map +1 -1
  5. package/dist/Authentication/NodeMsalAuthenticationProvider.js +20 -1
  6. package/dist/Authentication/NodeMsalAuthenticationProvider.js.map +1 -1
  7. package/dist/Cli.d.ts.map +1 -1
  8. package/dist/Cli.js +15 -3
  9. package/dist/Cli.js.map +1 -1
  10. package/dist/Constants/CommandRegistry.d.ts +1 -2
  11. package/dist/Constants/CommandRegistry.d.ts.map +1 -1
  12. package/dist/Constants/CommandRegistry.js +26 -45
  13. package/dist/Constants/CommandRegistry.js.map +1 -1
  14. package/dist/Constants/HelpStrings.d.ts +12 -8
  15. package/dist/Constants/HelpStrings.d.ts.map +1 -1
  16. package/dist/Constants/HelpStrings.js +98 -80
  17. package/dist/Constants/HelpStrings.js.map +1 -1
  18. package/dist/Errors/GitHubErrorMap.d.ts +43 -14
  19. package/dist/Errors/GitHubErrorMap.d.ts.map +1 -1
  20. package/dist/Errors/GitHubErrorMap.js +189 -147
  21. package/dist/Errors/GitHubErrorMap.js.map +1 -1
  22. package/dist/Logger/CliLogger.d.ts +2 -0
  23. package/dist/Logger/CliLogger.d.ts.map +1 -1
  24. package/dist/Logger/CliLogger.js +12 -3
  25. package/dist/Logger/CliLogger.js.map +1 -1
  26. package/dist/Logger/ConsoleWriter.d.ts +2 -0
  27. package/dist/Logger/ConsoleWriter.d.ts.map +1 -1
  28. package/dist/Logger/ConsoleWriter.js +17 -7
  29. package/dist/Logger/ConsoleWriter.js.map +1 -1
  30. package/dist/Types/Argument.types.d.ts +1 -0
  31. package/dist/Types/Argument.types.d.ts.map +1 -1
  32. package/dist/Types/Command.types.d.ts +6 -0
  33. package/dist/Types/Command.types.d.ts.map +1 -1
  34. package/dist/Types/Command.types.js +8 -0
  35. package/dist/Types/Command.types.js.map +1 -1
  36. package/dist/Utils/BuildVerbDescriptionTable.d.ts.map +1 -1
  37. package/dist/Utils/BuildVerbDescriptionTable.js +6 -2
  38. package/dist/Utils/BuildVerbDescriptionTable.js.map +1 -1
  39. package/dist/Utils/ConnectorIds.d.ts +12 -0
  40. package/dist/Utils/ConnectorIds.d.ts.map +1 -0
  41. package/dist/Utils/ConnectorIds.js +20 -0
  42. package/dist/Utils/ConnectorIds.js.map +1 -0
  43. package/dist/Utils/DcfRecovery.d.ts +7 -7
  44. package/dist/Utils/DcfRecovery.d.ts.map +1 -1
  45. package/dist/Utils/DcfRecovery.js +17 -37
  46. package/dist/Utils/DcfRecovery.js.map +1 -1
  47. package/dist/Utils/DownloadTemplate.d.ts +45 -0
  48. package/dist/Utils/DownloadTemplate.d.ts.map +1 -0
  49. package/dist/Utils/DownloadTemplate.js +161 -0
  50. package/dist/Utils/DownloadTemplate.js.map +1 -0
  51. package/dist/Utils/EnvVars.d.ts +1 -1
  52. package/dist/Utils/EnvVars.d.ts.map +1 -1
  53. package/dist/Utils/EnvVars.js.map +1 -1
  54. package/dist/Utils/EnvironmentRoutingUtils.d.ts +20 -1
  55. package/dist/Utils/EnvironmentRoutingUtils.d.ts.map +1 -1
  56. package/dist/Utils/EnvironmentRoutingUtils.js +78 -3
  57. package/dist/Utils/EnvironmentRoutingUtils.js.map +1 -1
  58. package/dist/Utils/GitErrorClassifier.d.ts +40 -0
  59. package/dist/Utils/GitErrorClassifier.d.ts.map +1 -0
  60. package/dist/Utils/GitErrorClassifier.js +120 -0
  61. package/dist/Utils/GitErrorClassifier.js.map +1 -0
  62. package/dist/Utils/GitRunner.d.ts +107 -0
  63. package/dist/Utils/GitRunner.d.ts.map +1 -0
  64. package/dist/Utils/GitRunner.js +89 -0
  65. package/dist/Utils/GitRunner.js.map +1 -0
  66. package/dist/Utils/GitUtils.d.ts +12 -0
  67. package/dist/Utils/GitUtils.d.ts.map +1 -1
  68. package/dist/Utils/GitUtils.js +83 -20
  69. package/dist/Utils/GitUtils.js.map +1 -1
  70. package/dist/Utils/GitVersionChecker.d.ts +38 -0
  71. package/dist/Utils/GitVersionChecker.d.ts.map +1 -0
  72. package/dist/Utils/GitVersionChecker.js +64 -0
  73. package/dist/Utils/GitVersionChecker.js.map +1 -0
  74. package/dist/Utils/MaafAppConfig.d.ts +22 -0
  75. package/dist/Utils/MaafAppConfig.d.ts.map +1 -0
  76. package/dist/Utils/MaafAppConfig.js +32 -0
  77. package/dist/Utils/MaafAppConfig.js.map +1 -0
  78. package/dist/Utils/NodeVersionChecker.d.ts +3 -6
  79. package/dist/Utils/NodeVersionChecker.d.ts.map +1 -1
  80. package/dist/Utils/NodeVersionChecker.js +9 -26
  81. package/dist/Utils/NodeVersionChecker.js.map +1 -1
  82. package/dist/Utils/Paging.d.ts +6 -0
  83. package/dist/Utils/Paging.d.ts.map +1 -1
  84. package/dist/Utils/Paging.js +36 -1
  85. package/dist/Utils/Paging.js.map +1 -1
  86. package/dist/Utils/PinCli.d.ts +28 -0
  87. package/dist/Utils/PinCli.d.ts.map +1 -0
  88. package/dist/Utils/PinCli.js +58 -0
  89. package/dist/Utils/PinCli.js.map +1 -0
  90. package/dist/Utils/RepoDetails.d.ts +29 -0
  91. package/dist/Utils/RepoDetails.d.ts.map +1 -0
  92. package/dist/Utils/RepoDetails.js +37 -0
  93. package/dist/Utils/RepoDetails.js.map +1 -0
  94. package/dist/Utils/RepoOption.d.ts +35 -0
  95. package/dist/Utils/RepoOption.d.ts.map +1 -0
  96. package/dist/Utils/RepoOption.js +36 -0
  97. package/dist/Utils/RepoOption.js.map +1 -0
  98. package/dist/Utils/ResolveCommand.d.ts.map +1 -1
  99. package/dist/Utils/ResolveCommand.js +6 -4
  100. package/dist/Utils/ResolveCommand.js.map +1 -1
  101. package/dist/Utils/Spinner.d.ts.map +1 -1
  102. package/dist/Utils/Spinner.js +3 -0
  103. package/dist/Utils/Spinner.js.map +1 -1
  104. package/dist/Verbs/AddAction.js +6 -6
  105. package/dist/Verbs/AddAction.js.map +1 -1
  106. package/dist/Verbs/AddConnector.d.ts +6 -4
  107. package/dist/Verbs/AddConnector.d.ts.map +1 -1
  108. package/dist/Verbs/AddConnector.js +54 -14
  109. package/dist/Verbs/AddConnector.js.map +1 -1
  110. package/dist/Verbs/AddConnectorFlows.d.ts +29 -16
  111. package/dist/Verbs/AddConnectorFlows.d.ts.map +1 -1
  112. package/dist/Verbs/AddConnectorFlows.js +73 -25
  113. package/dist/Verbs/AddConnectorFlows.js.map +1 -1
  114. package/dist/Verbs/AddDataSource.d.ts +3 -4
  115. package/dist/Verbs/AddDataSource.d.ts.map +1 -1
  116. package/dist/Verbs/AddDataSource.js +9 -20
  117. package/dist/Verbs/AddDataSource.js.map +1 -1
  118. package/dist/Verbs/AddTable.js +7 -7
  119. package/dist/Verbs/AddTable.js.map +1 -1
  120. package/dist/Verbs/AuthStatus.d.ts.map +1 -1
  121. package/dist/Verbs/AuthStatus.js +7 -4
  122. package/dist/Verbs/AuthStatus.js.map +1 -1
  123. package/dist/Verbs/BuildMaafApp.js +1 -1
  124. package/dist/Verbs/BuildMaafApp.js.map +1 -1
  125. package/dist/Verbs/ConnectorHelpers.d.ts +5 -4
  126. package/dist/Verbs/ConnectorHelpers.d.ts.map +1 -1
  127. package/dist/Verbs/ConnectorHelpers.js +14 -9
  128. package/dist/Verbs/ConnectorHelpers.js.map +1 -1
  129. package/dist/Verbs/CreateMaafApp.d.ts +25 -42
  130. package/dist/Verbs/CreateMaafApp.d.ts.map +1 -1
  131. package/dist/Verbs/CreateMaafApp.js +346 -268
  132. package/dist/Verbs/CreateMaafApp.js.map +1 -1
  133. package/dist/Verbs/DeployMaafApp.d.ts.map +1 -1
  134. package/dist/Verbs/DeployMaafApp.js +4 -4
  135. package/dist/Verbs/DeployMaafApp.js.map +1 -1
  136. package/dist/Verbs/Dev.js +1 -1
  137. package/dist/Verbs/Dev.js.map +1 -1
  138. package/dist/Verbs/GetMaafApp.d.ts.map +1 -1
  139. package/dist/Verbs/GetMaafApp.js +10 -0
  140. package/dist/Verbs/GetMaafApp.js.map +1 -1
  141. package/dist/Verbs/GetMaafBuildStatus.d.ts.map +1 -1
  142. package/dist/Verbs/GetMaafBuildStatus.js +52 -3
  143. package/dist/Verbs/GetMaafBuildStatus.js.map +1 -1
  144. package/dist/Verbs/GetSettings.js +1 -1
  145. package/dist/Verbs/GetSettings.js.map +1 -1
  146. package/dist/Verbs/Init.d.ts.map +1 -1
  147. package/dist/Verbs/Init.js +183 -60
  148. package/dist/Verbs/Init.js.map +1 -1
  149. package/dist/Verbs/ListConnectorActions.js +12 -9
  150. package/dist/Verbs/ListConnectorActions.js.map +1 -1
  151. package/dist/Verbs/ListConnectors.d.ts.map +1 -1
  152. package/dist/Verbs/ListConnectors.js +3 -2
  153. package/dist/Verbs/ListConnectors.js.map +1 -1
  154. package/dist/Verbs/ListMaafApps.js +3 -3
  155. package/dist/Verbs/ListMaafApps.js.map +1 -1
  156. package/dist/Verbs/MaafAppPermissions.d.ts.map +1 -1
  157. package/dist/Verbs/MaafAppPermissions.js +89 -17
  158. package/dist/Verbs/MaafAppPermissions.js.map +1 -1
  159. package/dist/Verbs/Pack.d.ts +1 -1
  160. package/dist/Verbs/RefreshDataSource.js +1 -1
  161. package/dist/Verbs/RefreshDataSource.js.map +1 -1
  162. package/dist/Verbs/RefreshGitAuth.d.ts.map +1 -1
  163. package/dist/Verbs/RefreshGitAuth.js +3 -15
  164. package/dist/Verbs/RefreshGitAuth.js.map +1 -1
  165. package/dist/Verbs/{DeleteDataSource.d.ts → RemoveDataSource.d.ts} +2 -2
  166. package/dist/Verbs/RemoveDataSource.d.ts.map +1 -0
  167. package/dist/Verbs/RemoveDataSource.js +158 -0
  168. package/dist/Verbs/RemoveDataSource.js.map +1 -0
  169. package/dist/Verbs/SetSetting.js +2 -2
  170. package/dist/Verbs/SetSetting.js.map +1 -1
  171. package/dist/Verbs/ShareLinkList.js +1 -1
  172. package/dist/Verbs/ShareLinkList.js.map +1 -1
  173. package/dist/Verbs/ShowMaafApp.d.ts +6 -0
  174. package/dist/Verbs/ShowMaafApp.d.ts.map +1 -1
  175. package/dist/Verbs/ShowMaafApp.js +10 -2
  176. package/dist/Verbs/ShowMaafApp.js.map +1 -1
  177. package/dist/Verbs/VerbConstants.d.ts +20 -23
  178. package/dist/Verbs/VerbConstants.d.ts.map +1 -1
  179. package/dist/Verbs/VerbConstants.js +20 -23
  180. package/dist/Verbs/VerbConstants.js.map +1 -1
  181. package/dist/Verbs/index.d.ts +1 -1
  182. package/dist/Verbs/index.d.ts.map +1 -1
  183. package/dist/Verbs/index.js +1 -1
  184. package/dist/Verbs/index.js.map +1 -1
  185. package/package.json +11 -9
  186. package/dist/Verbs/DeleteDataSource.d.ts.map +0 -1
  187. package/dist/Verbs/DeleteDataSource.js +0 -105
  188. package/dist/Verbs/DeleteDataSource.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"EnvVars.js","sourceRoot":"","sources":["../../src/Utils/EnvVars.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,MAAM,MAAM,GAAG,GAAG,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC;AAmFvD,MAAM,UAAU,iBAAiB,CAAC,IAAmB;IACnD,OAAO,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC9C,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAmB;IAClD,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;AACvC,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,OAAO,CAA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AClD,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;AACvC,CAAC;AAED,sGAAsG;AACtG,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAmB,EAAE,KAAa;IAC7D,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;AAC/C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,IAAmB;IACjD,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC;AAC9C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,IAAY,EAAE,KAAa;IACzD,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,QAA4B;IACrD,OAAO,CAAC,GAAG,GAAG,EAAE,GAAG,QAAQ,EAAE,CAAC;AAChC,CAAC"}
@@ -31,6 +31,22 @@ export declare function resolveRoutingEnvironmentIdAsync(resultPromise: Promise<
31
31
  export declare function startPdeRoutingAsync(argumentProvider: ArgumentProvider, tenantId: string, logger: ILogger, telemetryNamespace: string, options?: {
32
32
  trackBackgroundFailure?: boolean;
33
33
  }): Promise<string>;
34
+ /**
35
+ * Awaits a PDE routing promise that was started in the background by
36
+ * {@link startPdeRoutingAsync}. If the environment was already resolved
37
+ * (e.g. via `--environment-id` flag or config), returns it immediately
38
+ * without awaiting the promise.
39
+ *
40
+ * On failure, prints a user-friendly error with a `--environment-id` hint
41
+ * so the user knows how to bypass automatic resolution, then re-throws
42
+ * the original error for the caller's top-level handler.
43
+ *
44
+ * Both `app create` and `app init` share this pattern; extracting it here
45
+ * keeps the hint message consistent and ensures that *all* error types —
46
+ * HTTP error codes, `operationSuccess: false` (200-level failures), and
47
+ * unexpected exceptions — surface the same recovery guidance.
48
+ */
49
+ export declare function awaitRoutingEnvironmentAsync(preResolvedEnvironmentId: string | undefined, routingEnvPromise: Promise<string> | undefined): Promise<string>;
34
50
  /**
35
51
  * Resolves an environment ID for read-only browse verbs (`ms connector list`,
36
52
  * `ms connector list-actions`, etc.) without ever prompting the user.
@@ -54,7 +70,10 @@ export declare function startPdeRoutingAsync(argumentProvider: ArgumentProvider,
54
70
  * target the right tenant cluster.
55
71
  *
56
72
  * Throws `UsageError` when the tenant ID can't be resolved (auth issue) or
57
- * when the routing service returns an actionable failure.
73
+ * when the routing service returns an actionable failure. When PDE routing
74
+ * fails (including a provisioning timeout), prints the shared
75
+ * `--environment-id` recovery hint before re-throwing, matching `app init` /
76
+ * `app create`.
58
77
  */
59
78
  export declare function resolveEnvironmentIdOrPdeAsync(argumentProvider: ArgumentProvider, logger: ILogger, options?: {
60
79
  jsonMode?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentRoutingUtils.d.ts","sourceRoot":"","sources":["../../src/Utils/EnvironmentRoutingUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAGnE,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAO/F,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0CAA0C,CAAC;AAExE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAK5D,wBAAsB,gCAAgC,CACpD,aAAa,EAAE,OAAO,CAAC,+BAA+B,CAAC,EACvD,UAAU,EAAE,WAAW,EACvB,MAAM,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kB,EAAE,MAAM,EAC1B,OAAO,CAAC,EAAE;IAAE,sBAAsB,CAAC,EAAE,OAAO,CAAA;CAAE,GAC7C,OAAO,CAAC,MAAM,CAAC,CAwBjB;AAqBD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,4BAA4B,CAChD,wBAAwB,EAAE,MAAM,GAAG,SAAS,EAC5C,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,SAAS,GAC7C,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,8BAA8B,CAClD,gBAAgB,EAAE,gBAAgB,EAClC,MAAM,EAAE,OAAO,EACf,OAAO,CAAC,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5D,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
@@ -6,7 +6,7 @@ import { NotFoundError, UsageError } from '@microsoft/managed-apps-common/errors
6
6
  import { getUserRoutingEnvironmentAsync, ManagedGovernanceError, ManagedGovernanceTimeoutError, pollRoutingEnvironmentAsync, } from '@microsoft/managed-apps-common/services';
7
7
  import { resolveEnvironmentId } from '../CliUtils.js';
8
8
  import { CLI_CLIENT_ID } from '../Constants.js';
9
- import { printInfo } from './ConsoleOutput.js';
9
+ import { printError, printInfo } from './ConsoleOutput.js';
10
10
  export async function resolveRoutingEnvironmentIdAsync(resultPromise, httpClient, logger) {
11
11
  // Translate routing-service errors into a UsageError so the user sees an actionable message
12
12
  // rather than the raw "ManagedGovernance request failed with status 403" implementation detail.
@@ -15,6 +15,15 @@ export async function resolveRoutingEnvironmentIdAsync(resultPromise, httpClient
15
15
  try {
16
16
  const result = await resultPromise;
17
17
  if (result.status === 200) {
18
+ // Mirror the checks in `pollRoutingEnvironmentAsync`: treat a 200 with
19
+ // `operationSuccess: false`, `environmentFound: false`, or a non-null
20
+ // `errorCode` as a governance failure so it flows through
21
+ // `toRoutingUsageError` and surfaces an actionable CLI message.
22
+ if (result.data.operationSuccess === false ||
23
+ result.data.environmentFound === false ||
24
+ !!result.data.errorCode) {
25
+ throw new ManagedGovernanceError(200, result.data.message, result.data.errorCode);
26
+ }
18
27
  const name = result.data.environment?.name;
19
28
  if (!name) {
20
29
  throw new NotFoundError('Routing service returned 200 with no environment name.');
@@ -82,6 +91,53 @@ export function startPdeRoutingAsync(argumentProvider, tenantId, logger, telemet
82
91
  }
83
92
  return promise;
84
93
  }
94
+ /**
95
+ * Prints a consistent, actionable error for a failed developer-environment
96
+ * resolution — HTTP failure, governance failure, or routing timeout — and
97
+ * points the user at the `--environment-id` escape hatch. Shared by `app init`,
98
+ * `app create`, and the read-only browse verbs (`connector list` /
99
+ * `connector list-actions`) so every command that auto-resolves a developer
100
+ * environment surfaces the same recovery guidance. Writes to stderr, so it is
101
+ * safe to call in JSON mode.
102
+ */
103
+ function printRoutingResolutionError(error) {
104
+ const detail = error instanceof Error ? error.message : String(error);
105
+ printError(`Failed to resolve a developer environment.\n\n` +
106
+ ` ${detail}\n\n` +
107
+ `To retry, run the same command again. ` +
108
+ `Alternatively, pass --environment-id <id> to use a known environment.`);
109
+ }
110
+ /**
111
+ * Awaits a PDE routing promise that was started in the background by
112
+ * {@link startPdeRoutingAsync}. If the environment was already resolved
113
+ * (e.g. via `--environment-id` flag or config), returns it immediately
114
+ * without awaiting the promise.
115
+ *
116
+ * On failure, prints a user-friendly error with a `--environment-id` hint
117
+ * so the user knows how to bypass automatic resolution, then re-throws
118
+ * the original error for the caller's top-level handler.
119
+ *
120
+ * Both `app create` and `app init` share this pattern; extracting it here
121
+ * keeps the hint message consistent and ensures that *all* error types —
122
+ * HTTP error codes, `operationSuccess: false` (200-level failures), and
123
+ * unexpected exceptions — surface the same recovery guidance.
124
+ */
125
+ export async function awaitRoutingEnvironmentAsync(preResolvedEnvironmentId, routingEnvPromise) {
126
+ if (preResolvedEnvironmentId) {
127
+ return preResolvedEnvironmentId;
128
+ }
129
+ if (!routingEnvPromise) {
130
+ throw new UsageError('Unable to resolve a developer environment. ' +
131
+ 'Pass --environment-id <id> to specify one explicitly.');
132
+ }
133
+ try {
134
+ return await routingEnvPromise;
135
+ }
136
+ catch (error) {
137
+ printRoutingResolutionError(error);
138
+ throw error;
139
+ }
140
+ }
85
141
  /**
86
142
  * Resolves an environment ID for read-only browse verbs (`ms connector list`,
87
143
  * `ms connector list-actions`, etc.) without ever prompting the user.
@@ -105,7 +161,10 @@ export function startPdeRoutingAsync(argumentProvider, tenantId, logger, telemet
105
161
  * target the right tenant cluster.
106
162
  *
107
163
  * Throws `UsageError` when the tenant ID can't be resolved (auth issue) or
108
- * when the routing service returns an actionable failure.
164
+ * when the routing service returns an actionable failure. When PDE routing
165
+ * fails (including a provisioning timeout), prints the shared
166
+ * `--environment-id` recovery hint before re-throwing, matching `app init` /
167
+ * `app create`.
109
168
  */
110
169
  export async function resolveEnvironmentIdOrPdeAsync(argumentProvider, logger, options) {
111
170
  const fromConfig = await resolveEnvironmentId(argumentProvider, { failIfMissing: false });
@@ -119,11 +178,27 @@ export async function resolveEnvironmentIdOrPdeAsync(argumentProvider, logger, o
119
178
  if (!options?.jsonMode) {
120
179
  printInfo('No environment specified — resolving your developer environment…');
121
180
  }
122
- const environmentId = await startPdeRoutingAsync(argumentProvider, tenantId, logger, options?.telemetryNamespace ?? 'BrowseVerb', { trackBackgroundFailure: false });
181
+ const environmentId = await resolvePdeWithHintAsync(argumentProvider, tenantId, logger, options?.telemetryNamespace ?? 'BrowseVerb');
123
182
  updateEnvironmentName(environmentId);
124
183
  if (!options?.jsonMode) {
125
184
  printInfo(`Using developer environment ${environmentId}.`);
126
185
  }
127
186
  return environmentId;
128
187
  }
188
+ /**
189
+ * Runs PDE routing for a browse verb and, on failure, prints the shared
190
+ * `--environment-id` recovery hint before re-throwing — mirroring the guidance
191
+ * `app init` / `app create` give via {@link awaitRoutingEnvironmentAsync}.
192
+ */
193
+ async function resolvePdeWithHintAsync(argumentProvider, tenantId, logger, telemetryNamespace) {
194
+ try {
195
+ return await startPdeRoutingAsync(argumentProvider, tenantId, logger, telemetryNamespace, {
196
+ trackBackgroundFailure: false,
197
+ });
198
+ }
199
+ catch (error) {
200
+ printRoutingResolutionError(error);
201
+ throw error;
202
+ }
203
+ }
129
204
  //# sourceMappingURL=EnvironmentRoutingUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EnvironmentRoutingUtils.js","sourceRoot":"","sources":["../../src/Utils/EnvironmentRoutingUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AAElF,OAAO,EACL,8BAA8B,EAC9B,sBAAsB,EACtB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,yCAAyC,CAAC;AAIjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,KAAK,UAAU,gCAAgC,CACpD,aAAuD,EACvD,UAAuB,EACvB,MAAe;IAEf,4FAA4F;IAC5F,gGAAgG;IAChG,4FAA4F;IAC5F,0CAA0C;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC;QAEnC,IAAI,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC1B,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC;YAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,MAAM,IAAI,aAAa,CAAC,wDAAwD,CAAC,CAAC;YACpF,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,8DAA8D;QAC9D,wEAAwE;QACxE,wEA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AA+B,aAAa,GAAG,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,uBAAuB,CACpC,gBAAkC,EAClC,QAAgB,EAChB,MAAe,EACf,kBAA0B;IAE1B,IAAI,CAAC;QACH,OAAO,MAAM,oBAAoB,CAAC,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,kBAAkB,EAAE;YACxF,sBAAsB,EAAE,KAAK;SAC9B,CAAC,CAAC;IACL,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,2BAA2B,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ /*!
2
+ * Copyright (C) Microsoft Corporation. All rights reserved.
3
+ */
4
+ import type { AppError } from '../Errors/CliError.js';
5
+ /**
6
+ * Context handed to {@link classifyLocalGitError} so the resulting message can
7
+ * name what the CLI was doing when git failed (e.g. "fetching from
8
+ * contoso.ghe.com"). The caller owns this string because the chokepoint only
9
+ * sees argv (`['fetch', 'origin']`) and can't reconstruct the remote host.
10
+ */
11
+ export interface GitClassifyContext {
12
+ /**
13
+ * Human phrase completing "... while {action}", e.g.
14
+ * `fetching from contoso.ghe.com`.
15
+ */
16
+ action: string;
17
+ }
18
+ /**
19
+ * Maps raw git failure output to a CLI-facing {@link AppError} subclass so a
20
+ * native (platform-managed) git operation that fails on auth or network reports
21
+ * the right exit code and a cause-specific, actionable message instead of an
22
+ * opaque `fatal: Authentication failed`.
23
+ *
24
+ * Auth failures are split into distinct buckets (credential rejected / no
25
+ * promptable credential / invalid-or-expired credential) so the user gets the
26
+ * fix that matches their situation rather than one generic "sign in again".
27
+ * Each returned error also carries a stable `errorData.classifierBucket` (plus
28
+ * the `action`) for telemetry without re-parsing the message text.
29
+ *
30
+ * The returned message embeds the original git output verbatim (callers and
31
+ * tests substring-match on git's own wording). Returns `null` for any output
32
+ * that doesn't clearly match a known category, signalling the caller to
33
+ * re-throw the original error unchanged.
34
+ *
35
+ * Note: this is deliberately scoped to the platform-managed (GRS) git flow,
36
+ * whose credentials come from Git Credential Manager's browser OAuth — NOT the
37
+ * external GitHub-repo flow (which has its own `git auth refresh` recovery).
38
+ */
39
+ export declare function classifyLocalGitError(rawOutput: string, context: GitClassifyContext): AppError | null;
40
+ //# sourceMappingURL=GitErrorClassifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitErrorClassifier.d.ts","sourceRoot":"","sources":["../../src/Utils/GitErrorClassifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAGnD;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAqGD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,kBAAkB,GAC1B,QAAQ,GAAG,IAAI,CAsBjB"}
@@ -0,0 +1,120 @@
1
+ /*!
2
+ * Copyright (C) Microsoft Corporation. All rights reserved.
3
+ */
4
+ import { AuthenticationError, NetworkError } from '../Errors/CliError.js';
5
+ // A single "authentication failed" message is too vague to act on. Git's stderr
6
+ // carries enough signal to separate the three auth failure modes the GRS flow
7
+ // hits, each with a different fix. Order matters: the credential-rejected (403)
8
+ // and prompt-unavailable rules are checked before the generic catch-all because
9
+ // their stderr often also contains the word "authentication".
10
+ const AUTH_RULES = [
11
+ // A credential was sent but the remote rejected it. For the GRS flow this is
12
+ // an authorization problem, not a bad password: either the signed-in account
13
+ // is wrong/under-permissioned, or GCM silently returned a cached credential
14
+ // for a different identity than the current `ms auth` profile.
15
+ {
16
+ patterns: [/403 forbidden/i, /returned error: 403/i, /access denied/i],
17
+ bucket: 'auth-403',
18
+ build: (action) => `Git reached the remote but access was denied while ${action} (HTTP 403). This usually ` +
19
+ `means one of:\n` +
20
+ ` - the signed-in account is in the wrong tenant, or lacks permission to this app's repo; or\n` +
21
+ ` - Git Credential Manager returned a cached credential for a different account than your ` +
22
+ `current 'ms auth' sign-in (a stale or mismatched credential).\n` +
23
+ `Confirm 'ms auth status' shows the account and tenant for this environment. If it doesn't ` +
24
+ `match, clear the cached git credential for the host ('git credential-manager erase', or ` +
25
+ `remove it from your OS credential store) so Git re-prompts, then re-run.`,
26
+ },
27
+ // No usable credential and git cannot prompt for one: either Git Credential
28
+ // Manager isn't configured, or the session is non-interactive (no TTY /
29
+ // GIT_TERMINAL_PROMPT=0) so the browser sign-in never opens.
30
+ {
31
+ patterns: [
32
+ /terminal prompts disabled/i,
33
+ /could not read username/i,
34
+ /could not read password/i,
35
+ ],
36
+ bucket: 'auth-prompt-unavailable',
37
+ build: (action) => `Git could not obtain a credential while ${action}: there is no cached credential and the ` +
38
+ `session can't prompt for one. Make sure Git Credential Manager is installed, then re-run ` +
39
+ `in an interactive terminal so the browser sign-in can complete.`,
40
+ },
41
+ // A credential was tried but is invalid or expired — the recoverable case is a
42
+ // fresh browser sign-in (or clearing a stale cached credential).
43
+ {
44
+ patterns: [/authentication failed/i, /invalid username or password/i],
45
+ bucket: 'auth-invalid-credential',
46
+ build: (action) => `Git authentication failed while ${action}: the credential was missing, invalid, or expired. ` +
47
+ `When the browser opens, sign in with the account for this environment's tenant; if a stale ` +
48
+ `credential is cached, clear it in Git Credential Manager and re-run.`,
49
+ },
50
+ ];
51
+ // Network patterns are intentionally conservative: only stderr we are confident
52
+ // maps to connectivity is classified. Anything ambiguous (e.g. "repository not
53
+ // found", "permission denied to a path", TLS/cert errors) is left unrecognized
54
+ // so the original error bubbles up untouched rather than being mislabeled.
55
+ const NETWORK_PATTERNS = [
56
+ /could not resolve host/i,
57
+ /could not resolve proxy/i,
58
+ /failed to connect/i,
59
+ /connection timed out/i,
60
+ /connection refused/i,
61
+ /network is unreachable/i,
62
+ /temporary failure in name resolution/i,
63
+ ];
64
+ /**
65
+ * Redacts credential-bearing userinfo from any URL in git's output before that
66
+ * output is embedded verbatim in a user-facing error message. The classified
67
+ * message can reach the `--json` envelope, which CI pipelines and agent
68
+ * orchestrators capture — so a credential must never ride along.
69
+ *
70
+ * The GRS flow's GCM browser-OAuth keeps tokens out of stderr, so this is
71
+ * defense-in-depth: a no-op in the normal case, but a guard against a
72
+ * PAT-in-URL helper or a GCM fallback that prints a credential-bearing remote
73
+ * like `https://oauth2:TOKEN@host/` or `git://TOKEN@host/`. We match any
74
+ * `scheme://` authority (http, https, ssh, git, …) and strip the entire
75
+ * userinfo (covering both `user:secret@` and bare `token@` forms) up to the
76
+ * `@`, without crossing a `/` or whitespace so only the authority is touched.
77
+ */
78
+ function redactUrlCredentials(text) {
79
+ return text.replace(/(\b[a-z][a-z0-9+.-]*:\/\/)[^/\s@]+@/gi, '$1[REDACTED]@');
80
+ }
81
+ /**
82
+ * Maps raw git failure output to a CLI-facing {@link AppError} subclass so a
83
+ * native (platform-managed) git operation that fails on auth or network reports
84
+ * the right exit code and a cause-specific, actionable message instead of an
85
+ * opaque `fatal: Authentication failed`.
86
+ *
87
+ * Auth failures are split into distinct buckets (credential rejected / no
88
+ * promptable credential / invalid-or-expired credential) so the user gets the
89
+ * fix that matches their situation rather than one generic "sign in again".
90
+ * Each returned error also carries a stable `errorData.classifierBucket` (plus
91
+ * the `action`) for telemetry without re-parsing the message text.
92
+ *
93
+ * The returned message embeds the original git output verbatim (callers and
94
+ * tests substring-match on git's own wording). Returns `null` for any output
95
+ * that doesn't clearly match a known category, signalling the caller to
96
+ * re-throw the original error unchanged.
97
+ *
98
+ * Note: this is deliberately scoped to the platform-managed (GRS) git flow,
99
+ * whose credentials come from Git Credential Manager's browser OAuth — NOT the
100
+ * external GitHub-repo flow (which has its own `git auth refresh` recovery).
101
+ */
102
+ export function classifyLocalGitError(rawOutput, context) {
103
+ const detail = redactUrlCredentials(rawOutput.trimEnd());
104
+ if (!detail)
105
+ return null;
106
+ for (const rule of AUTH_RULES) {
107
+ if (rule.patterns.some((p) => p.test(detail))) {
108
+ return new AuthenticationError(`${rule.build(context.action)}\n\nGit output:\n${detail}`, {
109
+ classifierBucket: rule.bucket,
110
+ action: context.action,
111
+ });
112
+ }
113
+ }
114
+ if (NETWORK_PATTERNS.some((p) => p.test(detail))) {
115
+ return new NetworkError(`Git could not reach the remote while ${context.action}. Check your network ` +
116
+ `connection (and proxy settings, if any) and try again.\n\nGit output:\n${detail}`, { classifierBucket: 'network', action: context.action });
117
+ }
118
+ return null;
119
+ }
120
+ //# sourceMappingURL=GitErrorClassifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitErrorClassifier.js","sourceRoot":"","sources":["../../src/Utils/GitErrorClassifier.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiCvE,gFAAgF;AAChF,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,8DAA8D;AAC9D,MAAM,UAAU,GAAe;IAC7B,6EAA6E;IAC7E,6EAA6E;IAC7E,4EAA4E;IAC5E,+DAA+D;IAC/D;QACE,QAAQ,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,gBAAgB,CAAC;QACtE,MAAM,EAAE,UAAU;QAClB,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAChB,sDAAsD,MAAM,4BAA4B;YACxF,iBAAiB;YACjB,gGAAgG;YAChG,4FAA4F;YAC5F,iEAAiE;YACjE,4FAA4F;YAC5F,0FAA0F;YAC1F,0EAA0E;KAC7E;IACD,4EAA4E;IAC5E,wEAAwE;IACxE,6DAA6D;IAC7D;QACE,QAAQ,EAAE;YACR,4BAA4B;YAC5B,0BAA0B;YAC1B,0BAA0B;SAC3B;QACD,MAAM,EAAE,yBAAyB;QACjC,KAAK,EAAE,CAAC,MAAM,EAAE,EAAE,CAChB,2CAA2C,MAAM,0CAA0C;YAC3F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IAED,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACjD,OAAO,IAAI,YAAY,CACrB,wCAAwC,OAAO,CAAC,MAAM,uBAAuB;YAC3E,0EAA0E,MAAM,EAAE,EACpF,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CACxD,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,107 @@
1
+ /*!
2
+ * Copyright (C) Microsoft Corporation. All rights reserved.
3
+ */
4
+ import { type GitClassifyContext } from './GitErrorClassifier.js';
5
+ /**
6
+ * Options for {@link runGit}.
7
+ */
8
+ export interface RunGitOptions {
9
+ /** Working directory the git command runs in. Defaults to `process.cwd()`. */
10
+ cwd?: string;
11
+ /**
12
+ * Marks a remote-touching op (fetch / push / clone). For a network op that is
13
+ * neither classified nor a silent probe, stderr is *inherited* so git's live
14
+ * progress and any interactive credential prompts reach the user's terminal in
15
+ * real time instead of being buffered and only re-emitted after the process
16
+ * exits (these call sites own their own messaging and don't need the captured
17
+ * text).
18
+ *
19
+ * Setting `classify` *overrides* this live-streaming behavior: a classified
20
+ * network op keeps stderr piped so the failure output is available to
21
+ * {@link classifyLocalGitError} (the user sees no live progress — only the
22
+ * classified message once the op finishes). `allowFailure` probes likewise
23
+ * keep stderr piped so the caller can inspect {@link GitResult.stderr}.
24
+ */
25
+ network?: boolean;
26
+ /**
27
+ * When true, a non-zero exit (or a spawn failure such as `git` missing from
28
+ * PATH) returns a {@link GitResult} with `success: false` instead of
29
+ * throwing. Use for probes whose failure is an expected, recoverable signal
30
+ * (e.g. `rev-parse --verify origin/main` on an empty repo, or `remote add`
31
+ * when origin already exists).
32
+ */
33
+ allowFailure?: boolean;
34
+ /**
35
+ * Capture the command's stdout and return it on {@link GitResult.stdout}.
36
+ * Defaults to false (stdout is discarded) since most git mutations write
37
+ * nothing useful to stdout.
38
+ */
39
+ captureStdout?: boolean;
40
+ /**
41
+ * Re-emit captured stderr to the parent process's stderr so the user still
42
+ * sees git's own message. Defaults to true. Set false for silent probes
43
+ * where a non-zero exit is an expected control-flow signal, not an error to
44
+ * surface.
45
+ */
46
+ emitStderr?: boolean;
47
+ /**
48
+ * Opt-in error classification for the throwing path (ignored when
49
+ * `allowFailure` is true). When set and the command fails, the captured
50
+ * output is run through {@link classifyLocalGitError}; a recognized
51
+ * auth/network failure is re-thrown as a typed {@link AppError} (carrying the
52
+ * right exit code) whose message embeds git's original output. Unrecognized
53
+ * output falls through to the normal emit-and-rethrow of the original error.
54
+ *
55
+ * Scoped to the platform-managed (GRS) git flow — do NOT set it for the
56
+ * external GitHub-repo clone or the template clone, which own their own
57
+ * messaging and use different credentials.
58
+ */
59
+ classify?: GitClassifyContext;
60
+ }
61
+ /**
62
+ * Structured outcome of a git invocation, modeled as a discriminated union on
63
+ * `success` so the type system encodes the failure invariant: a failed op
64
+ * always carries its caught {@link Error}, a successful one never does. `stderr`
65
+ * is populated only on the failure path (and for `allowFailure` probes):
66
+ * `execFileSync` exposes a command's stderr just on the thrown error, so a
67
+ * *successful* piped op's stderr is not captured here (it's discarded). On
68
+ * failure, the captured text is what enables downstream classification — e.g. a
69
+ * failed network op's `fatal: Authentication failed…` is available to the
70
+ * caller instead of vanishing into an inherited terminal stream.
71
+ */
72
+ export type GitResult = {
73
+ success: true;
74
+ /** Always 0 on the success path. */
75
+ status: 0;
76
+ stdout: string;
77
+ stderr: string;
78
+ } | {
79
+ success: false;
80
+ /** Process exit code, or null when the process could not be spawned. */
81
+ status: number | null;
82
+ stdout: string;
83
+ stderr: string;
84
+ /** The caught error (non-zero exit or spawn failure); always present. */
85
+ error: Error;
86
+ };
87
+ /**
88
+ * Single chokepoint for every `git` invocation in the CLI.
89
+ *
90
+ * Centralizing git here gives one stdio policy (stdin ignored so a child can
91
+ * never block waiting for input; stderr piped so a *failure's* output is
92
+ * captured rather than lost to an inherited stream) and one place to hang
93
+ * pre/post checks on. Because `execFileSync` only surfaces stderr via the
94
+ * thrown error, capture applies to the failure path: on failure the captured
95
+ * stderr is re-emitted by default so users still see git's own message, and is
96
+ * also returned (on `allowFailure`) or attached to the thrown error
97
+ * (`error.stderr`) for classification. A *successful* piped op's stderr is not
98
+ * captured (it is discarded). The one exception to piping is an un-classified,
99
+ * non-probe {@link RunGitOptions.network} op, whose stderr is inherited so live
100
+ * progress and credential prompts stream straight through on success too.
101
+ *
102
+ * On failure with `allowFailure: false` (the default), the *original* error is
103
+ * re-thrown so existing message-based handling keeps working — the caught error
104
+ * now additionally carries a populated `stderr` because we pipe it.
105
+ */
106
+ export declare function runGit(args: string[], options?: RunGitOptions): GitResult;
107
+ //# sourceMappingURL=GitRunner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GitRunner.d.ts","sourceRoot":"","sources":["../../src/Utils/GitRunner.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAyB,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAEtF;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,EAAE,kBAAkB,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,SAAS,GACjB;IACE,OAAO,EAAE,IAAI,CAAC;IACd,oCAAoC;IACpC,MAAM,EAAE,CAAC,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,wEAAwE;IACxE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,yEAAyE;IACzE,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAkBN;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAkB,GAAG,SAAS,CAgE7E"}
@@ -0,0 +1,89 @@
1
+ /*!
2
+ * Copyright (C) Microsoft Corporation. All rights reserved.
3
+ */
4
+ import { execFileSync } from 'child_process';
5
+ import { classifyLocalGitError } from './GitErrorClassifier.js';
6
+ function toStr(value) {
7
+ if (value == null)
8
+ return '';
9
+ return Buffer.isBuffer(value) ? value.toString() : value;
10
+ }
11
+ /**
12
+ * Explicit stdout/stderr capture ceiling for every git invocation. Node's
13
+ * `execFileSync` defaults to a 1 MB `maxBuffer`; exceeding it throws `ENOBUFS`
14
+ * (treated by callers as a generic failure). `ls-tree -r HEAD` on a large repo,
15
+ * or verbose clone/fetch progress, can blow past 1 MB — and an `allowFailure`
16
+ * probe would silently misread that `ENOBUFS` as its expected control-flow
17
+ * signal (e.g. "repo is empty"). A generous ceiling avoids those spurious
18
+ * failures while still guarding against runaway memory.
19
+ */
20
+ const GIT_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
21
+ /**
22
+ * Single chokepoint for every `git` invocation in the CLI.
23
+ *
24
+ * Centralizing git here gives one stdio policy (stdin ignored so a child can
25
+ * never block waiting for input; stderr piped so a *failure's* output is
26
+ * captured rather than lost to an inherited stream) and one place to hang
27
+ * pre/post checks on. Because `execFileSync` only surfaces stderr via the
28
+ * thrown error, capture applies to the failure path: on failure the captured
29
+ * stderr is re-emitted by default so users still see git's own message, and is
30
+ * also returned (on `allowFailure`) or attached to the thrown error
31
+ * (`error.stderr`) for classification. A *successful* piped op's stderr is not
32
+ * captured (it is discarded). The one exception to piping is an un-classified,
33
+ * non-probe {@link RunGitOptions.network} op, whose stderr is inherited so live
34
+ * progress and credential prompts stream straight through on success too.
35
+ *
36
+ * On failure with `allowFailure: false` (the default), the *original* error is
37
+ * re-thrown so existing message-based handling keeps working — the caught error
38
+ * now additionally carries a populated `stderr` because we pipe it.
39
+ */
40
+ export function runGit(args, options = {}) {
41
+ const { cwd, allowFailure = false, captureStdout = false, emitStderr = true, classify, network = false, } = options;
42
+ // A network op that is neither classified nor a silent probe streams git's
43
+ // stderr live (progress + interactive credential prompts) instead of
44
+ // buffering it; every other case pipes stderr so it can be captured for
45
+ // classification or returned to the caller.
46
+ const inheritStderr = network && !classify && !allowFailure;
47
+ try {
48
+ const stdout = execFileSync('git', args, {
49
+ cwd,
50
+ stdio: ['ignore', captureStdout ? 'pipe' : 'ignore', inheritStderr ? 'inherit' : 'pipe'],
51
+ maxBuffer: GIT_MAX_BUFFER_BYTES,
52
+ });
53
+ return {
54
+ success: true,
55
+ status: 0,
56
+ stdout: captureStdout ? toStr(stdout) : '',
57
+ stderr: '',
58
+ };
59
+ }
60
+ catch (err) {
61
+ const e = err;
62
+ const stderr = toStr(e.stderr);
63
+ // Classification runs on the throwing path only, and BEFORE we re-emit
64
+ // stderr: a recognized failure is re-thrown as a typed AppError whose
65
+ // message already embeds git's output, so emitting stderr here too would
66
+ // double-print it (the top-level catch prints the thrown message).
67
+ if (classify && !allowFailure) {
68
+ const text = stderr || toStr(e.stdout) || (err instanceof Error ? err.message : String(err));
69
+ const classified = classifyLocalGitError(text, classify);
70
+ if (classified) {
71
+ throw classified;
72
+ }
73
+ }
74
+ if (emitStderr && stderr) {
75
+ process.stderr.write(stderr);
76
+ }
77
+ if (!allowFailure) {
78
+ throw err;
79
+ }
80
+ return {
81
+ success: false,
82
+ status: typeof e.status === 'number' ? e.status : null,
83
+ stdout: toStr(e.stdout),
84
+ stderr,
85
+ error: err instanceof Error ? err : new Error(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C,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAC3D,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -6,6 +6,10 @@ export interface GitDefaults {
6
6
  commitSha: string;
7
7
  detached: boolean;
8
8
  }
9
+ export interface InitializeLocalGitRepoResult {
10
+ success: boolean;
11
+ error?: string;
12
+ }
9
13
  /**
10
14
  * Reads the current branch and commit SHA from the working directory's git repo.
11
15
  * Returns null when git is unavailable or the directory is not a git repo.
@@ -18,6 +22,14 @@ export declare function resolveGitDefaults(): GitDefaults | null;
18
22
  * Returns null when git is unavailable or the directory is not a git repo
19
23
  */
20
24
  export declare function getCurrentGitRemoteUrl(): string | undefined;
25
+ /**
26
+ * Initializes a local git repository in the current working directory and
27
+ * optionally configures the origin remote in the supplied working directory.
28
+ * Returns true when `git init` succeeds, false when git is unavailable or the
29
+ * command fails for any reason (e.g. permissions). Callers should treat false as
30
+ * a soft failure — the app was already created; git can be initialized manually.
31
+ */
32
+ export declare function initializeLocalGitRepo(remoteUrl?: string, cwd?: string): InitializeLocalGitRepoResult;
21
33
  /**
22
34
  * Returns true when the working tree has uncommitted changes (staged, unstaged, or untracked).
23
35
  * Returns null when git is unavailable or the directory is not a git repo, so callers can skip
@@ -1 +1 @@
1
- {"version":3,"file":"GitUtils.d.ts","sourceRoot":"","sources":["../../src/Utils/GitUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,GAAG,IAAI,CAQvD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,SAAS,CAS3D;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,GAAG,IAAI,CAOtD"}
1
+ {"version":3,"file":"GitUtils.d.ts","sourceRoot":"","sources":["../../src/Utils/GitUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,WAAW,GAAG,IAAI,CAkBvD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,GAAG,SAAS,CAQ3D;AA0BD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,CAAC,EAAE,MAAM,EAClB,GAAG,SAAgB,GAClB,4BAA4B,CA0B9B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,GAAG,IAAI,CAQtD"}