@microsoft/managed-apps-cli 0.9.1 → 0.10.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.
- package/README.md +23 -43
- package/dist/ArgumentProvider.d.ts.map +1 -1
- package/dist/ArgumentProvider.js +3 -0
- package/dist/ArgumentProvider.js.map +1 -1
- package/dist/Authentication/NodeMsalAuthenticationProvider.js +20 -1
- package/dist/Authentication/NodeMsalAuthenticationProvider.js.map +1 -1
- package/dist/Cli.d.ts.map +1 -1
- package/dist/Cli.js +14 -2
- package/dist/Cli.js.map +1 -1
- package/dist/Constants/CommandRegistry.d.ts.map +1 -1
- package/dist/Constants/CommandRegistry.js +5 -24
- package/dist/Constants/CommandRegistry.js.map +1 -1
- package/dist/Constants/HelpStrings.d.ts +8 -7
- package/dist/Constants/HelpStrings.d.ts.map +1 -1
- package/dist/Constants/HelpStrings.js +78 -73
- package/dist/Constants/HelpStrings.js.map +1 -1
- package/dist/Constants.d.ts +1 -1
- package/dist/Constants.d.ts.map +1 -1
- package/dist/Constants.js +4 -9
- package/dist/Constants.js.map +1 -1
- package/dist/Errors/GitHubErrorMap.d.ts +43 -14
- package/dist/Errors/GitHubErrorMap.d.ts.map +1 -1
- package/dist/Errors/GitHubErrorMap.js +188 -147
- package/dist/Errors/GitHubErrorMap.js.map +1 -1
- package/dist/Logger/CliLogger.d.ts +1 -0
- package/dist/Logger/CliLogger.d.ts.map +1 -1
- package/dist/Logger/CliLogger.js +5 -3
- package/dist/Logger/CliLogger.js.map +1 -1
- package/dist/Logger/LoggerSettings.d.ts +2 -3
- package/dist/Logger/LoggerSettings.d.ts.map +1 -1
- package/dist/Logger/LoggerSettings.js +3 -39
- package/dist/Logger/LoggerSettings.js.map +1 -1
- package/dist/Logger/OneDSWriter.d.ts.map +1 -1
- package/dist/Logger/OneDSWriter.js +3 -3
- package/dist/Logger/OneDSWriter.js.map +1 -1
- package/dist/Types/Argument.types.d.ts +1 -0
- package/dist/Types/Argument.types.d.ts.map +1 -1
- package/dist/Utils/BuildPolling.d.ts +27 -2
- package/dist/Utils/BuildPolling.d.ts.map +1 -1
- package/dist/Utils/BuildPolling.js +98 -22
- package/dist/Utils/BuildPolling.js.map +1 -1
- package/dist/Utils/DcfRecovery.d.ts +7 -7
- package/dist/Utils/DcfRecovery.d.ts.map +1 -1
- package/dist/Utils/DcfRecovery.js +17 -37
- package/dist/Utils/DcfRecovery.js.map +1 -1
- package/dist/Utils/DownloadTemplate.d.ts +45 -0
- package/dist/Utils/DownloadTemplate.d.ts.map +1 -0
- package/dist/Utils/DownloadTemplate.js +159 -0
- package/dist/Utils/DownloadTemplate.js.map +1 -0
- package/dist/Utils/EnvVars.d.ts +1 -1
- package/dist/Utils/EnvVars.d.ts.map +1 -1
- package/dist/Utils/GitVersionChecker.d.ts +38 -0
- package/dist/Utils/GitVersionChecker.d.ts.map +1 -0
- package/dist/Utils/GitVersionChecker.js +61 -0
- package/dist/Utils/GitVersionChecker.js.map +1 -0
- package/dist/Utils/MaafAppConfig.d.ts +22 -0
- package/dist/Utils/MaafAppConfig.d.ts.map +1 -0
- package/dist/Utils/MaafAppConfig.js +32 -0
- package/dist/Utils/MaafAppConfig.js.map +1 -0
- package/dist/Utils/NodeVersionChecker.d.ts +10 -0
- package/dist/Utils/NodeVersionChecker.d.ts.map +1 -0
- package/dist/Utils/NodeVersionChecker.js +21 -0
- package/dist/Utils/NodeVersionChecker.js.map +1 -0
- package/dist/Utils/Paging.d.ts +5 -0
- package/dist/Utils/Paging.d.ts.map +1 -1
- package/dist/Utils/Paging.js +29 -0
- package/dist/Utils/Paging.js.map +1 -1
- package/dist/Utils/PinCli.d.ts +28 -0
- package/dist/Utils/PinCli.d.ts.map +1 -0
- package/dist/Utils/PinCli.js +58 -0
- package/dist/Utils/PinCli.js.map +1 -0
- package/dist/Utils/RepoOption.d.ts +35 -0
- package/dist/Utils/RepoOption.d.ts.map +1 -0
- package/dist/Utils/RepoOption.js +36 -0
- package/dist/Utils/RepoOption.js.map +1 -0
- package/dist/Utils/Spinner.d.ts.map +1 -1
- package/dist/Utils/Spinner.js +3 -0
- package/dist/Utils/Spinner.js.map +1 -1
- package/dist/Verbs/AddAction.js +6 -6
- package/dist/Verbs/AddAction.js.map +1 -1
- package/dist/Verbs/AddConnector.d.ts +5 -3
- package/dist/Verbs/AddConnector.d.ts.map +1 -1
- package/dist/Verbs/AddConnector.js +45 -11
- package/dist/Verbs/AddConnector.js.map +1 -1
- package/dist/Verbs/AddConnectorFlows.d.ts +27 -14
- package/dist/Verbs/AddConnectorFlows.d.ts.map +1 -1
- package/dist/Verbs/AddConnectorFlows.js +70 -20
- package/dist/Verbs/AddConnectorFlows.js.map +1 -1
- package/dist/Verbs/AddDataSource.d.ts +3 -4
- package/dist/Verbs/AddDataSource.d.ts.map +1 -1
- package/dist/Verbs/AddDataSource.js +9 -20
- package/dist/Verbs/AddDataSource.js.map +1 -1
- package/dist/Verbs/AddTable.js +6 -6
- package/dist/Verbs/AddTable.js.map +1 -1
- package/dist/Verbs/AuthStatus.d.ts.map +1 -1
- package/dist/Verbs/AuthStatus.js +7 -4
- package/dist/Verbs/AuthStatus.js.map +1 -1
- package/dist/Verbs/BuildMaafApp.js +1 -1
- package/dist/Verbs/BuildMaafApp.js.map +1 -1
- package/dist/Verbs/ConnectorHelpers.d.ts +3 -4
- package/dist/Verbs/ConnectorHelpers.d.ts.map +1 -1
- package/dist/Verbs/ConnectorHelpers.js +8 -9
- package/dist/Verbs/ConnectorHelpers.js.map +1 -1
- package/dist/Verbs/CreateMaafApp.d.ts +0 -29
- package/dist/Verbs/CreateMaafApp.d.ts.map +1 -1
- package/dist/Verbs/CreateMaafApp.js +100 -171
- package/dist/Verbs/CreateMaafApp.js.map +1 -1
- package/dist/Verbs/DeleteDataSource.js +6 -6
- package/dist/Verbs/DeleteDataSource.js.map +1 -1
- package/dist/Verbs/DeployMaafApp.d.ts.map +1 -1
- package/dist/Verbs/DeployMaafApp.js +18 -81
- package/dist/Verbs/DeployMaafApp.js.map +1 -1
- package/dist/Verbs/Dev.js +1 -1
- package/dist/Verbs/Dev.js.map +1 -1
- package/dist/Verbs/GetMaafBuildStatus.d.ts.map +1 -1
- package/dist/Verbs/GetMaafBuildStatus.js +56 -40
- package/dist/Verbs/GetMaafBuildStatus.js.map +1 -1
- package/dist/Verbs/GetSettings.js +1 -1
- package/dist/Verbs/GetSettings.js.map +1 -1
- package/dist/Verbs/Init.d.ts.map +1 -1
- package/dist/Verbs/Init.js +166 -58
- package/dist/Verbs/Init.js.map +1 -1
- package/dist/Verbs/ListConnectorActions.js +12 -9
- package/dist/Verbs/ListConnectorActions.js.map +1 -1
- package/dist/Verbs/ListConnectors.js +2 -2
- package/dist/Verbs/ListConnectors.js.map +1 -1
- package/dist/Verbs/ListMaafApps.js +3 -3
- package/dist/Verbs/ListMaafApps.js.map +1 -1
- package/dist/Verbs/MaafAppPermissions.js +2 -2
- package/dist/Verbs/MaafAppPermissions.js.map +1 -1
- package/dist/Verbs/RefreshDataSource.js +1 -1
- package/dist/Verbs/RefreshDataSource.js.map +1 -1
- package/dist/Verbs/RefreshGitAuth.d.ts.map +1 -1
- package/dist/Verbs/RefreshGitAuth.js +3 -15
- package/dist/Verbs/RefreshGitAuth.js.map +1 -1
- package/dist/Verbs/SetSetting.js +2 -2
- package/dist/Verbs/SetSetting.js.map +1 -1
- package/dist/Verbs/ShowMaafApp.js +2 -2
- package/dist/Verbs/ShowMaafApp.js.map +1 -1
- package/dist/Verbs/VerbConstants.d.ts +19 -22
- package/dist/Verbs/VerbConstants.d.ts.map +1 -1
- package/dist/Verbs/VerbConstants.js +19 -22
- package/dist/Verbs/VerbConstants.js.map +1 -1
- package/package.json +11 -9
|
@@ -11,7 +11,7 @@ export class OneDSWriter {
|
|
|
11
11
|
const commonProperties = {
|
|
12
12
|
environmentId,
|
|
13
13
|
isOnePlayer: 'false',
|
|
14
|
-
webPlayerScenario: '
|
|
14
|
+
webPlayerScenario: 'ManagedApps_CLI_Authoring',
|
|
15
15
|
cloud: region === 'preview' ? 'prod' : region,
|
|
16
16
|
sessionStartTime: new Date().toISOString(),
|
|
17
17
|
station: 'Unknown',
|
|
@@ -26,7 +26,7 @@ export class OneDSWriter {
|
|
|
26
26
|
commonProperties.geoLocation = geoLocation;
|
|
27
27
|
}
|
|
28
28
|
this._provider = new OneDsTelemetryProvider({
|
|
29
|
-
clientType:
|
|
29
|
+
clientType: 'ManagedAppsCLI',
|
|
30
30
|
clusterCategory: regionToClusterCategory(region),
|
|
31
31
|
telemetryLocation,
|
|
32
32
|
commonProperties,
|
|
@@ -101,7 +101,7 @@ export class OneDSWriter {
|
|
|
101
101
|
setCustomDimension(_key, _value) {
|
|
102
102
|
this._provider.setDefaultProperty(_key, _value);
|
|
103
103
|
}
|
|
104
|
-
static _EVENT_PREFIX = '
|
|
104
|
+
static _EVENT_PREFIX = 'ManagedAppsCLI.';
|
|
105
105
|
_trackEvent(eventName, eventData) {
|
|
106
106
|
const operationName = eventData.operationName || '';
|
|
107
107
|
const scrubbed = getScrubbedCustomDimensions(eventName, operationName, eventData);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OneDSWriter.js","sourceRoot":"","sources":["../../src/Logger/OneDSWriter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAe,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAC/F,OAAO,EACL,sBAAsB,EACtB,eAAe,EACf,mBAAmB,GAEpB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAE/E,MAAM,OAAO,WAAW;IACd,SAAS,CAAyB;IAClC,eAAe,GAAW,CAAC,CAAC;IAEpC,YACE,SAAiB,EACjB,MAAc,EACd,iBAAoC,EACpC,aAAqB,EACrB,KAAa,EACb,WAA+B,EAC/B,UAAkB,EAClB,SAAiB;QAEjB,MAAM,gBAAgB,GAA2B;YAC/C,aAAa;YACb,WAAW,EAAE,OAAO;Y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,GAAG,CAAC,GAAG,KAAK,CAAC;YAC1B,CAAC;iBAAM,CAAC;gBACN,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;QACH,CAAC;QAED,IAAI,aAAa,EAAE,CAAC;YAClB,UAAU,CAAC,aAAa,GAAG,GAAG,WAAW,CAAC,aAAa,GAAG,aAAa,EAAE,CAAC;QAC5E,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YACnB,SAAS;YACT,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,QAAQ,EAAE,MAAM;YAChB,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE;YACtC,UAAU;SACX,CAAC,CAAC;IACL,CAAC"}
|
|
@@ -20,6 +20,7 @@ export interface CliOption<T = unknown> {
|
|
|
20
20
|
env?: CliEnvVarName;
|
|
21
21
|
description?: string;
|
|
22
22
|
default?: T;
|
|
23
|
+
parseArg?: (value: string, previous: unknown) => unknown;
|
|
23
24
|
customPrompt?: () => Promise<T>;
|
|
24
25
|
optionalInNonInteractive?: boolean;
|
|
25
26
|
hidden?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Argument.types.d.ts","sourceRoot":"","sources":["../../src/Types/Argument.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,KAAK,EAAE,KAAK,CAAC;IACb;;;;OAIG;IACH,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAGhC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
|
1
|
+
{"version":3,"file":"Argument.types.d.ts","sourceRoot":"","sources":["../../src/Types/Argument.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,WAAW,SAAS,CAAC,CAAC,GAAG,OAAO;IACpC,KAAK,EAAE,KAAK,CAAC;IACb;;;;OAIG;IACH,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,OAAO,CAAC,EAAE,CAAC,CAAC;IACZ,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,OAAO,CAAC;IACzD,YAAY,CAAC,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,CAAC;IAGhC,wBAAwB,CAAC,EAAE,OAAO,CAAC;IAEnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB"}
|
|
@@ -2,17 +2,42 @@
|
|
|
2
2
|
* Copyright (C) Microsoft Corporation. All rights reserved.
|
|
3
3
|
*/
|
|
4
4
|
import type { MaafBuildPollResult } from '@microsoft/managed-apps-actions';
|
|
5
|
+
export interface BuildErrorDetail {
|
|
6
|
+
errorMessage?: string;
|
|
7
|
+
buildOutput?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Extracts human-readable error detail from a `MaafBuildPollResult.result` value.
|
|
11
|
+
* Handles the documented `{ code, message }` structured shape, legacy plain-string
|
|
12
|
+
* results, and extended server fields (`error.message`, `error.buildOutput`,
|
|
13
|
+
* `buildOutput`) that may be present in actual responses beyond the typed contract.
|
|
14
|
+
*
|
|
15
|
+
* Shared between `build-status`, `build`, and `deploy` so all three commands
|
|
16
|
+
* surface identical error details when a server build fails.
|
|
17
|
+
*/
|
|
18
|
+
export declare function extractBuildErrorDetail(result: unknown): BuildErrorDetail;
|
|
5
19
|
export interface WaitForBuildStatusArgs {
|
|
6
20
|
appName: string;
|
|
7
21
|
commitSha: string;
|
|
8
22
|
initialWaitMs: number;
|
|
9
23
|
isJsonMode: boolean;
|
|
10
24
|
spinnerLabel?: string;
|
|
25
|
+
/** If set, polling throws after this many ms. No deadline by default. */
|
|
26
|
+
deadlineMs?: number;
|
|
27
|
+
/** Caps the server-provided Retry-After to prevent hanging for hours. No cap by default. */
|
|
28
|
+
maxIntervalMs?: number;
|
|
11
29
|
}
|
|
12
30
|
/**
|
|
13
31
|
* Polls `buildStatusAsync` for the given app + commit until the build reaches a
|
|
14
|
-
* terminal state. Shared between `ms app build
|
|
15
|
-
* so
|
|
32
|
+
* terminal state. Shared between `ms app build`, `ms app deploy`, and
|
|
33
|
+
* `ms app play --mode preview` so all verbs surface identical waiting/error UX.
|
|
34
|
+
*
|
|
35
|
+
* note: This function outputs to the console directly (e.g. spinner, error details).
|
|
36
|
+
*
|
|
37
|
+
* When `deadlineMs` is set, throws an `AppError` if the build hasn't completed
|
|
38
|
+
* within that many milliseconds (measured from when polling starts).
|
|
39
|
+
* When `maxIntervalMs` is set, clamps the server-provided `Retry-After` header
|
|
40
|
+
* to prevent a slow/hostile server from making the CLI hang for hours.
|
|
16
41
|
*/
|
|
17
42
|
export declare function waitForBuildStatusAsync(args: WaitForBuildStatusArgs): Promise<MaafBuildPollResult>;
|
|
18
43
|
//# sourceMappingURL=BuildPolling.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildPolling.d.ts","sourceRoot":"","sources":["../../src/Utils/BuildPolling.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"BuildPolling.d.ts","sourceRoot":"","sources":["../../src/Utils/BuildPolling.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAU3E,MAAM,WAAW,gBAAgB;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,OAAO,GAAG,gBAAgB,CAuDzE;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,mBAAmB,CAAC,CAyD9B"}
|
|
@@ -4,20 +4,88 @@
|
|
|
4
4
|
import { buildStatusAsync } from '@microsoft/managed-apps-actions';
|
|
5
5
|
import { getCliLogger } from '../CliSettings.js';
|
|
6
6
|
import { AppError } from '../Errors/CliError.js';
|
|
7
|
+
import { printInfo } from './ConsoleOutput.js';
|
|
7
8
|
import { CliSpinner } from './Spinner.js';
|
|
8
9
|
const MIN_POLL_INTERVAL_MS = 1000;
|
|
10
|
+
/**
|
|
11
|
+
* Extracts human-readable error detail from a `MaafBuildPollResult.result` value.
|
|
12
|
+
* Handles the documented `{ code, message }` structured shape, legacy plain-string
|
|
13
|
+
* results, and extended server fields (`error.message`, `error.buildOutput`,
|
|
14
|
+
* `buildOutput`) that may be present in actual responses beyond the typed contract.
|
|
15
|
+
*
|
|
16
|
+
* Shared between `build-status`, `build`, and `deploy` so all three commands
|
|
17
|
+
* surface identical error details when a server build fails.
|
|
18
|
+
*/
|
|
19
|
+
export function extractBuildErrorDetail(result) {
|
|
20
|
+
if (typeof result === 'string') {
|
|
21
|
+
const value = result.trim();
|
|
22
|
+
return value ? { errorMessage: value } : {};
|
|
23
|
+
}
|
|
24
|
+
if (!result || typeof result !== 'object') {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
const maybeResult = result;
|
|
28
|
+
const topLevelCode = typeof maybeResult.code === 'string' && maybeResult.code.trim()
|
|
29
|
+
? maybeResult.code.trim()
|
|
30
|
+
: undefined;
|
|
31
|
+
if (typeof maybeResult.error === 'string') {
|
|
32
|
+
const value = maybeResult.error.trim();
|
|
33
|
+
const errorMessage = composeErrorMessage(topLevelCode, value || undefined);
|
|
34
|
+
return errorMessage ? { errorMessage } : {};
|
|
35
|
+
}
|
|
36
|
+
let errorCode;
|
|
37
|
+
let errorMessage;
|
|
38
|
+
let buildOutput;
|
|
39
|
+
if (maybeResult.error && typeof maybeResult.error === 'object') {
|
|
40
|
+
const code = maybeResult.error.code;
|
|
41
|
+
const message = maybeResult.error.message;
|
|
42
|
+
const nestedBuildOutput = maybeResult.error.buildOutput;
|
|
43
|
+
errorCode = typeof code === 'string' && code.trim() ? code.trim() : undefined;
|
|
44
|
+
errorMessage = typeof message === 'string' && message.trim() ? message.trim() : undefined;
|
|
45
|
+
buildOutput =
|
|
46
|
+
typeof nestedBuildOutput === 'string' && nestedBuildOutput.trim()
|
|
47
|
+
? nestedBuildOutput.trim()
|
|
48
|
+
: undefined;
|
|
49
|
+
}
|
|
50
|
+
if (!errorMessage && typeof maybeResult.message === 'string' && maybeResult.message.trim()) {
|
|
51
|
+
errorMessage = maybeResult.message.trim();
|
|
52
|
+
}
|
|
53
|
+
if (!buildOutput &&
|
|
54
|
+
typeof maybeResult.buildOutput === 'string' &&
|
|
55
|
+
maybeResult.buildOutput.trim()) {
|
|
56
|
+
buildOutput = maybeResult.buildOutput.trim();
|
|
57
|
+
}
|
|
58
|
+
const formattedErrorMessage = composeErrorMessage(errorCode ?? topLevelCode, errorMessage);
|
|
59
|
+
return formattedErrorMessage || buildOutput
|
|
60
|
+
? { errorMessage: formattedErrorMessage, buildOutput }
|
|
61
|
+
: {};
|
|
62
|
+
}
|
|
9
63
|
/**
|
|
10
64
|
* Polls `buildStatusAsync` for the given app + commit until the build reaches a
|
|
11
|
-
* terminal state. Shared between `ms app build
|
|
12
|
-
* so
|
|
65
|
+
* terminal state. Shared between `ms app build`, `ms app deploy`, and
|
|
66
|
+
* `ms app play --mode preview` so all verbs surface identical waiting/error UX.
|
|
67
|
+
*
|
|
68
|
+
* note: This function outputs to the console directly (e.g. spinner, error details).
|
|
69
|
+
*
|
|
70
|
+
* When `deadlineMs` is set, throws an `AppError` if the build hasn't completed
|
|
71
|
+
* within that many milliseconds (measured from when polling starts).
|
|
72
|
+
* When `maxIntervalMs` is set, clamps the server-provided `Retry-After` header
|
|
73
|
+
* to prevent a slow/hostile server from making the CLI hang for hours.
|
|
13
74
|
*/
|
|
14
75
|
export async function waitForBuildStatusAsync(args) {
|
|
15
76
|
const logger = getCliLogger();
|
|
16
|
-
|
|
77
|
+
const MIN_INTERVAL = MIN_POLL_INTERVAL_MS;
|
|
78
|
+
const MAX_INTERVAL = args.maxIntervalMs ?? Infinity;
|
|
79
|
+
let waitMs = Math.min(MAX_INTERVAL, Math.max(MIN_INTERVAL, args.initialWaitMs));
|
|
80
|
+
const deadline = args.deadlineMs != null ? Date.now() + args.deadlineMs : null;
|
|
17
81
|
const spinner = args.isJsonMode ? null : new CliSpinner();
|
|
18
82
|
spinner?.start(args.spinnerLabel ?? 'Waiting for build status...');
|
|
19
83
|
try {
|
|
20
84
|
for (;;) {
|
|
85
|
+
if (deadline !== null && Date.now() >= deadline) {
|
|
86
|
+
throw new AppError(`Build did not complete within ${Math.round(args.deadlineMs / 60_000)} minutes. ` +
|
|
87
|
+
`Commit SHA: ${args.commitSha}.`);
|
|
88
|
+
}
|
|
21
89
|
await sleep(waitMs);
|
|
22
90
|
const status = await buildStatusAsync({
|
|
23
91
|
logger,
|
|
@@ -27,14 +95,29 @@ export async function waitForBuildStatusAsync(args) {
|
|
|
27
95
|
case 'Succeeded':
|
|
28
96
|
return status;
|
|
29
97
|
case 'Failed':
|
|
30
|
-
case 'Canceled':
|
|
31
|
-
|
|
98
|
+
case 'Canceled': {
|
|
99
|
+
// Spinner.stop() is idempotent (no-op once stopped), so calling it
|
|
100
|
+
// here to clear the line before printing buildOutput is safe even
|
|
101
|
+
// though the finally block calls it again as the throw propagates.
|
|
102
|
+
spinner?.stop();
|
|
103
|
+
const errorDetail = extractBuildErrorDetail(status.result);
|
|
104
|
+
if (!args.isJsonMode && errorDetail.buildOutput) {
|
|
105
|
+
printInfo(errorDetail.buildOutput);
|
|
106
|
+
}
|
|
107
|
+
const statusDetail = errorDetail.errorMessage ?? '';
|
|
108
|
+
const statusMessage = statusDetail
|
|
109
|
+
? `Build ${status.status.toLowerCase()}: ${statusDetail}.`
|
|
110
|
+
: `Build ${status.status.toLowerCase()}.`;
|
|
111
|
+
throw new AppError(statusMessage + (args.commitSha ? ` Commit SHA: ${args.commitSha}.` : ''));
|
|
112
|
+
}
|
|
32
113
|
case 'NotStarted':
|
|
33
|
-
case 'Running':
|
|
34
|
-
|
|
114
|
+
case 'Running': {
|
|
115
|
+
const next = status.retryAfterMs ?? waitMs;
|
|
116
|
+
waitMs = Math.min(MAX_INTERVAL, Math.max(MIN_INTERVAL, next));
|
|
35
117
|
break;
|
|
118
|
+
}
|
|
36
119
|
default:
|
|
37
|
-
return status;
|
|
120
|
+
return assertUnreachableStatus(status.status);
|
|
38
121
|
}
|
|
39
122
|
}
|
|
40
123
|
}
|
|
@@ -42,20 +125,13 @@ export async function waitForBuildStatusAsync(args) {
|
|
|
42
125
|
spinner?.stop();
|
|
43
126
|
}
|
|
44
127
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
parts.push(result.code);
|
|
53
|
-
if (typeof result.message === 'string' && result.message)
|
|
54
|
-
parts.push(result.message);
|
|
55
|
-
if (parts.length > 0)
|
|
56
|
-
return `: ${parts.join(' - ')}`;
|
|
57
|
-
}
|
|
58
|
-
return '';
|
|
128
|
+
function assertUnreachableStatus(status) {
|
|
129
|
+
throw new AppError(`Unexpected build status from server: ${String(status)}.`);
|
|
130
|
+
}
|
|
131
|
+
function composeErrorMessage(code, message) {
|
|
132
|
+
if (code && message)
|
|
133
|
+
return `${code}: ${message}`;
|
|
134
|
+
return code ?? message;
|
|
59
135
|
}
|
|
60
136
|
function sleep(ms) {
|
|
61
137
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BuildPolling.js","sourceRoot":"","sources":["../../src/Utils/BuildPolling.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAEnE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,MAAM,oBAAoB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"BuildPolling.js","sourceRoot":"","sources":["../../src/Utils/B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AE,IAAI,CAAC,CAAC,CAAC;oBAC9D,MAAM;gBACR,CAAC;gBACD;oBACE,OAAO,uBAAuB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAClD,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,MAAa;IAC5C,MAAM,IAAI,QAAQ,CAAC,wCAAwC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;AAChF,CAAC;AAED,SAAS,mBAAmB,CAAC,IAAa,EAAE,OAAgB;IAC1D,IAAI,IAAI,IAAI,OAAO;QAAE,OAAO,GAAG,IAAI,KAAK,OAAO,EAAE,CAAC;IAClD,OAAO,IAAI,IAAI,OAAO,CAAC;AACzB,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -15,10 +15,10 @@ export interface DcfRecoveryOptions {
|
|
|
15
15
|
/**
|
|
16
16
|
* Inline DCF recovery branch for the github catch-and-retry. SIGINT handling
|
|
17
17
|
* is scoped to this helper so Ctrl+C during the device-code polling loop
|
|
18
|
-
* doesn't leak a listener back to the verb's outer body.
|
|
19
|
-
* by `authenticateForRepoAsync` are
|
|
20
|
-
* {@link
|
|
21
|
-
*
|
|
18
|
+
* doesn't leak a listener back to the verb's outer body. Structured server
|
|
19
|
+
* errors thrown by `authenticateForRepoAsync` are normalized through
|
|
20
|
+
* {@link formatServerError} before being rethrown so the verb's outer catch
|
|
21
|
+
* (and the single-retry contract) sees CLI-typed errors.
|
|
22
22
|
*
|
|
23
23
|
* Telemetry event prefix is derived from the verb (e.g. `'app create'` →
|
|
24
24
|
* `'Maaf.Create.GitHubDcfRecovery'`) — keeps the call site a one-liner that
|
|
@@ -64,9 +64,9 @@ export interface WithGitHubDcfRecoveryOptions {
|
|
|
64
64
|
* error escapes untouched so native/none verbs behave identically to the
|
|
65
65
|
* un-wrapped call.
|
|
66
66
|
* - First-attempt errors that {@link matchGitHubAuthError} doesn't recognize
|
|
67
|
-
* are
|
|
68
|
-
*
|
|
69
|
-
* as-is.
|
|
67
|
+
* are normalized via {@link formatServerError} (which handles
|
|
68
|
+
* `GrsServerError`, `HttpClientError`, and structured `Error` envelopes)
|
|
69
|
+
* before being rethrown; everything else escapes as-is.
|
|
70
70
|
* - A matching first-attempt error with no `externalRepoUrl` throws a
|
|
71
71
|
* verb-agnostic {@link AuthenticationError} before DCF is invoked — DCF
|
|
72
72
|
* itself requires a URL to derive host/owner/repo.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DcfRecovery.d.ts","sourceRoot":"","sources":["../../src/Utils/DcfRecovery.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"DcfRecovery.d.ts","sourceRoot":"","sources":["../../src/Utils/DcfRecovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AAatE,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,YAAY,CAAC;AAErF,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,gGAAgG;IAChG,IAAI,EAAE,eAAe,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6EpF;AAqDD,MAAM,WAAW,4BAA4B;IAC3C;;;;;OAKG;IACH,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC/B;;;;;OAKG;IACH,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC;IACrB,IAAI,EAAE,eAAe,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,0BAA0B,CAAC,CAAC,EAChD,OAAO,EAAE,CAAC,OAAO,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,KAAK,OAAO,CAAC,CAAC,CAAC,EACtD,OAAO,EAAE,4BAA4B,EACrC,cAAc,GAAE,OAAO,mBAAyC,GAC/D,OAAO,CAAC,CAAC,CAAC,CA6DZ"}
|
|
@@ -11,20 +11,20 @@
|
|
|
11
11
|
* display selection, and error mapping all live here so the caller can stay
|
|
12
12
|
* focused on its own happy-path flow.
|
|
13
13
|
*/
|
|
14
|
-
import { authenticateForRepoAsync
|
|
14
|
+
import { authenticateForRepoAsync } from '@microsoft/managed-apps-actions';
|
|
15
15
|
import { getCliLogger } from '../CliSettings.js';
|
|
16
16
|
import { AuthenticationError } from '../Errors/CliError.js';
|
|
17
|
-
import { mapGitHubServerErrorToCliError, matchGitHubAuthError } from '../Errors/GitHubErrorMap.js';
|
|
17
|
+
import { formatServerError, mapGitHubServerErrorToCliError, matchGitHubAuthError, } from '../Errors/GitHubErrorMap.js';
|
|
18
18
|
import { printInfo } from './ConsoleOutput.js';
|
|
19
19
|
import { ConsoleGitHubDcfDisplay, JsonGitHubDcfDisplay } from './GitHubDcfFlow.js';
|
|
20
20
|
import { computeRepoHash, parseRemoteUrl } from './RepoUrl.js';
|
|
21
21
|
/**
|
|
22
22
|
* Inline DCF recovery branch for the github catch-and-retry. SIGINT handling
|
|
23
23
|
* is scoped to this helper so Ctrl+C during the device-code polling loop
|
|
24
|
-
* doesn't leak a listener back to the verb's outer body.
|
|
25
|
-
* by `authenticateForRepoAsync` are
|
|
26
|
-
* {@link
|
|
27
|
-
*
|
|
24
|
+
* doesn't leak a listener back to the verb's outer body. Structured server
|
|
25
|
+
* errors thrown by `authenticateForRepoAsync` are normalized through
|
|
26
|
+
* {@link formatServerError} before being rethrown so the verb's outer catch
|
|
27
|
+
* (and the single-retry contract) sees CLI-typed errors.
|
|
28
28
|
*
|
|
29
29
|
* Telemetry event prefix is derived from the verb (e.g. `'app create'` →
|
|
30
30
|
* `'Maaf.Create.GitHubDcfRecovery'`) — keeps the call site a one-liner that
|
|
@@ -52,7 +52,7 @@ export async function runDcfRecoveryAsync(options) {
|
|
|
52
52
|
repoHash,
|
|
53
53
|
});
|
|
54
54
|
if (!jsonMode) {
|
|
55
|
-
printInfo('GitHub authentication is required
|
|
55
|
+
printInfo('GitHub authentication is required for this action.');
|
|
56
56
|
}
|
|
57
57
|
const display = composeRecoveryDisplay({ isJson: jsonMode, openBrowser });
|
|
58
58
|
// SIGINT plumbing: a Ctrl+C during the (potentially 15-minute) polling
|
|
@@ -84,17 +84,8 @@ export async function runDcfRecoveryAsync(options) {
|
|
|
84
84
|
repoHost: host,
|
|
85
85
|
repoHash,
|
|
86
86
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
code: error.code,
|
|
90
|
-
message: error.message,
|
|
91
|
-
status: error.status,
|
|
92
|
-
details: error.details,
|
|
93
|
-
}, { repoUrl: remoteUrl, verb });
|
|
94
|
-
if (mapped)
|
|
95
|
-
throw mapped;
|
|
96
|
-
}
|
|
97
|
-
throw error;
|
|
87
|
+
const mapped = formatServerError(error);
|
|
88
|
+
throw mapped ?? error;
|
|
98
89
|
}
|
|
99
90
|
finally {
|
|
100
91
|
process.removeListener('SIGINT', onSigint);
|
|
@@ -178,9 +169,9 @@ function telemetryEventPrefixForVerb(verb) {
|
|
|
178
169
|
* error escapes untouched so native/none verbs behave identically to the
|
|
179
170
|
* un-wrapped call.
|
|
180
171
|
* - First-attempt errors that {@link matchGitHubAuthError} doesn't recognize
|
|
181
|
-
* are
|
|
182
|
-
*
|
|
183
|
-
* as-is.
|
|
172
|
+
* are normalized via {@link formatServerError} (which handles
|
|
173
|
+
* `GrsServerError`, `HttpClientError`, and structured `Error` envelopes)
|
|
174
|
+
* before being rethrown; everything else escapes as-is.
|
|
184
175
|
* - A matching first-attempt error with no `externalRepoUrl` throws a
|
|
185
176
|
* verb-agnostic {@link AuthenticationError} before DCF is invoked — DCF
|
|
186
177
|
* itself requires a URL to derive host/owner/repo.
|
|
@@ -194,14 +185,6 @@ function telemetryEventPrefixForVerb(verb) {
|
|
|
194
185
|
*/
|
|
195
186
|
export async function withGitHubDcfRecoveryAsync(attempt, options, runDcfRecovery = runDcfRecoveryAsync) {
|
|
196
187
|
const { repoType, externalRepoUrl, tenantId, jsonMode, openBrowser, verb } = options;
|
|
197
|
-
// Local helper: if `e` is a recognized GrsServerError, return the friendly
|
|
198
|
-
// CLI-typed error; otherwise null. Closes over `externalRepoUrl`/`verb` so
|
|
199
|
-
// the two non-matching call sites below stay one line each and can't drift.
|
|
200
|
-
const mapGrsError = (e) => {
|
|
201
|
-
if (!(e instanceof GrsServerError))
|
|
202
|
-
return null;
|
|
203
|
-
return mapGitHubServerErrorToCliError({ code: e.code, message: e.message, status: e.status, details: e.details }, { repoUrl: externalRepoUrl, verb });
|
|
204
|
-
};
|
|
205
188
|
try {
|
|
206
189
|
// Happy path: attempt succeeds on the first try, no DCF, no retry.
|
|
207
190
|
return await attempt({ isRetry: false });
|
|
@@ -211,9 +194,9 @@ export async function withGitHubDcfRecoveryAsync(attempt, options, runDcfRecover
|
|
|
211
194
|
throw err;
|
|
212
195
|
const matched = matchGitHubAuthError(err);
|
|
213
196
|
if (!matched) {
|
|
214
|
-
// Non-matching first-attempt error:
|
|
215
|
-
// CLI errors, otherwise rethrow untouched.
|
|
216
|
-
const mapped =
|
|
197
|
+
// Non-matching first-attempt error: normalize known structured server
|
|
198
|
+
// errors to friendly CLI errors, otherwise rethrow untouched.
|
|
199
|
+
const mapped = formatServerError(err);
|
|
217
200
|
if (mapped)
|
|
218
201
|
throw mapped;
|
|
219
202
|
throw err;
|
|
@@ -249,14 +232,11 @@ export async function withGitHubDcfRecoveryAsync(attempt, options, runDcfRecover
|
|
|
249
232
|
// the device-code flow and another loop would just hang. Fall through
|
|
250
233
|
// to `retryErr` if the mapper somehow returns null (defensive — the
|
|
251
234
|
// mapper recognizes every code matchGitHubAuthError matches on).
|
|
252
|
-
const mapped = mapGitHubServerErrorToCliError(remapped.payload
|
|
253
|
-
repoUrl: externalRepoUrl,
|
|
254
|
-
verb,
|
|
255
|
-
});
|
|
235
|
+
const mapped = mapGitHubServerErrorToCliError(remapped.payload);
|
|
256
236
|
throw mapped ?? retryErr;
|
|
257
237
|
}
|
|
258
238
|
// Non-matching retry error: same map-or-rethrow shape as the first attempt.
|
|
259
|
-
const mapped =
|
|
239
|
+
const mapped = formatServerError(retryErr);
|
|
260
240
|
if (mapped)
|
|
261
241
|
throw mapped;
|
|
262
242
|
throw retryErr;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DcfRecovery.js","sourceRoot":"","sources":["../../src/Utils/DcfRecovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;GASG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"DcfRecovery.js","sourceRoot":"","sources":["../../src/Utils/DcfRecovery.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAAE,wBAAwB,EAAyB,MAAM,iCAAiC,CAAC;AAGlG,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EACL,iBAAiB,EACjB,8BAA8B,EAC9B,oBAAoB,GACrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,oBAAo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corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
export interface ParsedGithubTemplate {
|
|
5
|
+
owner: string;
|
|
6
|
+
repo: string;
|
|
7
|
+
/** Empty string when the whole repo is the template (no subdir). */
|
|
8
|
+
subdir: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional branch or tag specified via the `#ref` suffix. Commit SHAs are
|
|
11
|
+
* NOT supported — the downloader passes this value to `git clone --branch`,
|
|
12
|
+
* which only resolves named refs, not raw commit hashes.
|
|
13
|
+
*/
|
|
14
|
+
ref: string | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Parses a template source. Accepted shapes:
|
|
18
|
+
*
|
|
19
|
+
* github:<owner>/<repo>[/<subdir>...][#<ref>]
|
|
20
|
+
* gh:<owner>/<repo>[/<subdir>...][#<ref>] (shorthand)
|
|
21
|
+
* <owner>/<repo>[/<subdir>...][#<ref>] (prefix optional)
|
|
22
|
+
* https://github.com/<owner>/<repo>[.git][#<ref>]
|
|
23
|
+
* https://github.com/<owner>/<repo>/tree/<ref>[/<subdir>]
|
|
24
|
+
*
|
|
25
|
+
* Throws `UsageError` for any other shape — non-github providers (`gitlab:`,
|
|
26
|
+
* `bitbucket:`, …), arbitrary tarball URLs, and github file URLs (`/blob/...`).
|
|
27
|
+
* The CLI is intentionally github-only here: github is the only provider in
|
|
28
|
+
* real use, and authentication against private github repos already flows
|
|
29
|
+
* through the user's normal git credential setup.
|
|
30
|
+
*/
|
|
31
|
+
export declare function parseGithubTemplate(source: string): ParsedGithubTemplate;
|
|
32
|
+
/**
|
|
33
|
+
* Downloads a github-hosted template into `dir`. Uses a shallow + partial +
|
|
34
|
+
* sparse clone so only the requested subdirectory is fetched, then copies the
|
|
35
|
+
* working tree into place via `fs.cpSync` and discards the temporary clone.
|
|
36
|
+
*
|
|
37
|
+
* Requires `git` on PATH; callers should run `ensureGitInstalled` in preflight
|
|
38
|
+
* so a missing-git failure surfaces before any server call. Authentication for
|
|
39
|
+
* private repos flows through the user's existing git credential setup
|
|
40
|
+
* (gh, GCM, SSH key, PAT) — the CLI does not inject tokens at this layer.
|
|
41
|
+
*/
|
|
42
|
+
export declare function downloadTemplate(source: string, options: {
|
|
43
|
+
dir: string;
|
|
44
|
+
}): void;
|
|
45
|
+
//# sourceMappingURL=DownloadTemplate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DownloadTemplate.d.ts","sourceRoot":"","sources":["../../src/Utils/DownloadTemplate.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,oEAAoE;IACpE,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACzB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CA2FxE;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkD/E"}
|