Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
@@ -0,0 +1,13 @@
export declare class ActionInjector {
static hasActionWithName(provisionNode: any, action: string, name: string): any;
static getTeamsAppIdEnvName(provisionNode: any): string | undefined;
static generateAuthAction(actionName: string, authName: string, teamsAppIdEnvName: string, specRelativePath: string, envName: string, flow?: string): any;
static injectCreateOAuthAction(ymlPath: string, authName: string, specRelativePath: string, forceToAddNew: boolean): Promise<AuthActionInjectResult | undefined>;
static injectCreateAPIKeyAction(ymlPath: string, authName: string, specRelativePath: string, forceToAddNew: boolean): Promise<AuthActionInjectResult | undefined>;
static findNextAvailableEnvName(baseEnvName: string, existingEnvNames: string[]): string;
}
export interface AuthActionInjectResult {
defaultRegistrationIdEnvName: string | undefined;
registrationIdEnvName: string | undefined;
}
//# sourceMappingURL=actionInjector.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"actionInjector.d.ts","sourceRoot":"","sources":["../../../src/component/configManager/actionInjector.ts"],"names":[],"mappings":"AAQA,qBAAa,cAAc;IACzB,MAAM,CAAC,iBAAiB,CAAC,aAAa,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG;IAO/E,MAAM,CAAC,oBAAoB,CAAC,aAAa,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS;IAUnE,MAAM,CAAC,kBAAkB,CACvB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,iBAAiB,EAAE,MAAM,EACzB,gBAAgB,EAAE,MAAM,EACxB,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,GACZ,GAAG;WAwBO,uBAAuB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;WAgEjC,wBAAwB,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,MAAM,EACxB,aAAa,EAAE,OAAO,GACrB,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC;IA8D9C,MAAM,CAAC,wBAAwB,CAAC,WAAW,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM;CASzF;AAED,MAAM,WAAW,sBAAsB;IACrC,4BAA4B,EAAE,MAAM,GAAG,SAAS,CAAC;IACjD,qBAAqB,EAAE,MAAM,GAAG,SAAS,CAAC;CAC3C"}
@@ -0,0 +1,159 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActionInjector = void 0;
const tslib_1 = require("tslib");
const m365_spec_parser_1 = require("@microsoft/m365-spec-parser");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const yaml_1 = require("yaml");
const common_1 = require("../../error/common");
class ActionInjector {
static hasActionWithName(provisionNode, action, name) {
const hasAuthAction = provisionNode.items.some((item) => { var _a; return item.get("uses") === action && ((_a = item.get("with")) === null || _a === void 0 ? void 0 : _a.get("name")) === name; });
return hasAuthAction;
}
static getTeamsAppIdEnvName(provisionNode) {
var _a;
for (const item of provisionNode.items) {
if (item.get("uses") === "teamsApp/create") {
return (_a = item.get("writeToEnvironmentFile")) === null || _a === void 0 ? void 0 : _a.get("teamsAppId");
}
}
return undefined;
}
static generateAuthAction(actionName, authName, teamsAppIdEnvName, specRelativePath, envName, flow) {
const result = {
uses: actionName,
with: {
name: `${authName}`,
appId: `\${{${teamsAppIdEnvName}}}`,
apiSpecPath: specRelativePath,
},
};
if (flow) {
result.with.flow = flow;
result.writeToEnvironmentFile = {
configurationId: envName,
};
}
else {
result.writeToEnvironmentFile = {
registrationId: envName,
};
}
return result;
}
static async injectCreateOAuthAction(ymlPath, authName, specRelativePath, forceToAddNew // If it from add plugin, then we will add another CreateOAuthAction
) {
const ymlContent = await fs_extra_1.default.readFile(ymlPath, "utf-8");
const actionName = "oauth/register";
const document = (0, yaml_1.parseDocument)(ymlContent);
const provisionNode = document.get("provision");
if (provisionNode) {
const hasOAuthAction = ActionInjector.hasActionWithName(provisionNode, actionName, authName);
if (!hasOAuthAction || forceToAddNew) {
provisionNode.items = provisionNode.items.filter((item) => {
const uses = item.get("uses");
if (forceToAddNew) {
return uses;
}
else {
return uses !== actionName && uses !== "apiKey/register";
}
});
const existingConfigurationIdEnvNames = provisionNode.items
.filter((item) => {
const uses = item.get("uses");
return uses == actionName;
})
.map((item) => { var _a; return (_a = item.get("writeToEnvironmentFile")) === null || _a === void 0 ? void 0 : _a.get("configurationId"); })
.filter((item) => {
return !!item;
});
const defaultEnvName = m365_spec_parser_1.Utils.getSafeRegistrationIdEnvName(`${authName}_CONFIGURATION_ID`);
const registrationIdEnvName = this.findNextAvailableEnvName(defaultEnvName, existingConfigurationIdEnvNames);
const teamsAppIdEnvName = ActionInjector.getTeamsAppIdEnvName(provisionNode);
if (teamsAppIdEnvName) {
const index = provisionNode.items.findIndex((item) => item.get("uses") === "teamsApp/create");
const flow = "authorizationCode";
const action = ActionInjector.generateAuthAction(actionName, authName, teamsAppIdEnvName, specRelativePath, registrationIdEnvName, flow);
provisionNode.items.splice(index + 1, 0, action);
}
else {
throw new common_1.InjectOAuthActionFailedError();
}
await fs_extra_1.default.writeFile(ymlPath, document.toString(), "utf8");
return {
defaultRegistrationIdEnvName: defaultEnvName,
registrationIdEnvName: registrationIdEnvName,
};
}
}
else {
throw new common_1.InjectOAuthActionFailedError();
}
return undefined;
}
static async injectCreateAPIKeyAction(ymlPath, authName, specRelativePath, forceToAddNew // If it from add plugin, then we will add another CreateApiKeyAction
) {
const ymlContent = await fs_extra_1.default.readFile(ymlPath, "utf-8");
const actionName = "apiKey/register";
const document = (0, yaml_1.parseDocument)(ymlContent);
const provisionNode = document.get("provision");
if (provisionNode) {
const hasApiKeyAction = ActionInjector.hasActionWithName(provisionNode, actionName, authName);
if (!hasApiKeyAction || forceToAddNew) {
provisionNode.items = provisionNode.items.filter((item) => {
const uses = item.get("uses");
if (forceToAddNew) {
return uses;
}
else {
return uses !== actionName && uses !== "oauth/register";
}
});
const existingRegistrationIdEnvNames = provisionNode.items
.filter((item) => {
const uses = item.get("uses");
return uses == actionName;
})
.map((item) => { var _a; return (_a = item.get("writeToEnvironmentFile")) === null || _a === void 0 ? void 0 : _a.get("registrationId"); })
.filter((item) => {
return !!item;
});
const teamsAppIdEnvName = ActionInjector.getTeamsAppIdEnvName(provisionNode);
const defaultEnvName = m365_spec_parser_1.Utils.getSafeRegistrationIdEnvName(`${authName}_REGISTRATION_ID`);
const registrationIdEnvName = this.findNextAvailableEnvName(defaultEnvName, existingRegistrationIdEnvNames);
if (teamsAppIdEnvName) {
const index = provisionNode.items.findIndex((item) => item.get("uses") === "teamsApp/create");
const action = ActionInjector.generateAuthAction(actionName, authName, teamsAppIdEnvName, specRelativePath, registrationIdEnvName);
provisionNode.items.splice(index + 1, 0, action);
}
else {
throw new common_1.InjectAPIKeyActionFailedError();
}
await fs_extra_1.default.writeFile(ymlPath, document.toString(), "utf8");
return {
defaultRegistrationIdEnvName: defaultEnvName,
registrationIdEnvName: registrationIdEnvName,
};
}
}
else {
throw new common_1.InjectAPIKeyActionFailedError();
}
return undefined;
}
static findNextAvailableEnvName(baseEnvName, existingEnvNames) {
let suffix = 1;
let envName = baseEnvName;
while (existingEnvNames.includes(envName)) {
envName = `${baseEnvName}${suffix}`;
suffix++;
}
return envName;
}
}
exports.ActionInjector = ActionInjector;
//# sourceMappingURL=actionInjector.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,19 @@
/**
* @author yefuwang@microsoft.com
*/
export declare enum SummaryConstant {
Succeeded = "(\u221A) Done:",
Failed = "(\u00D7) Error:",
NotExecuted = "(!) Warning:",
Warning = "(!) Warning:"
}
export declare const component = "ConfigManager";
export declare const lifecycleExecutionEvent = "lifecycle-execution";
export declare enum TelemetryProperty {
Lifecycle = "lifecycle",
Actions = "actions",
ResolvedPlaceholders = "resolved",
UnresolvedPlaceholders = "unresolved",
FailedAction = "failed-action"
}
//# sourceMappingURL=constant.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../src/component/configManager/constant.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,oBAAY,eAAe;IACzB,SAAS,mBAAc;IACvB,MAAM,oBAAe;IACrB,WAAW,iBAAiB;IAC5B,OAAO,iBAAiB;CACzB;AAED,eAAO,MAAM,SAAS,kBAAkB,CAAC;AAEzC,eAAO,MAAM,uBAAuB,wBAAwB,CAAC;AAE7D,oBAAY,iBAAiB;IAC3B,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,oBAAoB,aAAa;IACjC,sBAAsB,eAAe;IACrC,YAAY,kBAAkB;CAC/B"}
@@ -0,0 +1,26 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TelemetryProperty = exports.lifecycleExecutionEvent = exports.component = exports.SummaryConstant = void 0;
/**
* @author yefuwang@microsoft.com
*/
var SummaryConstant;
(function (SummaryConstant) {
SummaryConstant["Succeeded"] = "(\u221A) Done:";
SummaryConstant["Failed"] = "(\u00D7) Error:";
SummaryConstant["NotExecuted"] = "(!) Warning:";
SummaryConstant["Warning"] = "(!) Warning:";
})(SummaryConstant = exports.SummaryConstant || (exports.SummaryConstant = {}));
exports.component = "ConfigManager";
exports.lifecycleExecutionEvent = "lifecycle-execution";
var TelemetryProperty;
(function (TelemetryProperty) {
TelemetryProperty["Lifecycle"] = "lifecycle";
TelemetryProperty["Actions"] = "actions";
TelemetryProperty["ResolvedPlaceholders"] = "resolved";
TelemetryProperty["UnresolvedPlaceholders"] = "unresolved";
TelemetryProperty["FailedAction"] = "failed-action";
})(TelemetryProperty = exports.TelemetryProperty || (exports.TelemetryProperty = {}));
//# sourceMappingURL=constant.js.map
@@ -0,0 +1 @@
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../src/component/configManager/constant.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AAEH,IAAY,eAKX;AALD,WAAY,eAAe;IACzB,+CAAuB,CAAA;IACvB,6CAAqB,CAAA;IACrB,+CAA4B,CAAA;IAC5B,2CAAwB,CAAA;AAC1B,CAAC,EALW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAK1B;AAEY,QAAA,SAAS,GAAG,eAAe,CAAC;AAE5B,QAAA,uBAAuB,GAAG,qBAAqB,CAAC;AAE7D,IAAY,iBAMX;AAND,WAAY,iBAAiB;IAC3B,4CAAuB,CAAA;IACvB,wCAAmB,CAAA;IACnB,sDAAiC,CAAA;IACjC,0DAAqC,CAAA;IACrC,mDAA8B,CAAA;AAChC,CAAC,EANW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAM5B"}
@@ -0,0 +1,102 @@
/**
* @author yefuwang@microsoft.com
*/
import { FxError, LogProvider, Result } from "@microsoft/teamsfx-api";
import { DriverContext } from "../driver/interface/commonArgs";
import { StepDriver } from "../driver/interface/stepDriver";
export declare type AdditionalMetadata = {
[key: string]: unknown;
};
export declare type RawProjectModel = {
registerApp?: DriverDefinition[];
provision?: DriverDefinition[];
configureApp?: DriverDefinition[];
deploy?: DriverDefinition[];
publish?: DriverDefinition[];
environmentFolderPath?: string;
version: string;
additionalMetadata?: AdditionalMetadata;
};
export declare type ProjectModel = {
registerApp?: ILifecycle;
provision?: ILifecycle;
configureApp?: ILifecycle;
deploy?: ILifecycle;
publish?: ILifecycle;
environmentFolderPath?: string;
version: string;
additionalMetadata?: AdditionalMetadata;
};
export declare type DriverDefinition = {
name?: string;
uses: string;
with: unknown;
env?: Record<string, string>;
writeToEnvironmentFile?: Record<string, string>;
};
export declare type DriverInstance = DriverDefinition & {
instance: StepDriver;
};
export declare type LifecycleNames = ["registerApp", "configureApp", "provision", "deploy", "publish"];
export declare const LifecycleNames: LifecycleNames;
declare type AnyElementOf<T extends unknown[]> = T[number];
export declare type LifecycleName = AnyElementOf<LifecycleNames>;
export declare type UnresolvedPlaceholders = string[];
export declare type ResolvedPlaceholders = string[];
export declare type Output = {
env: Map<string, string>;
unresolvedPlaceHolders: UnresolvedPlaceholders;
};
export declare type PartialSuccessReason = {
kind: "DriverError";
failedDriver: DriverDefinition;
error: FxError;
} | {
kind: "UnresolvedPlaceholders";
failedDriver: DriverDefinition;
unresolvedPlaceHolders: UnresolvedPlaceholders;
};
export declare type ExecutionOutput = Map<string, string>;
export declare type ExecutionError = {
kind: "PartialSuccess";
env: Map<string, string>;
reason: PartialSuccessReason;
} | {
kind: "Failure";
error: FxError;
};
export declare type ExecutionResult = {
result: Result<ExecutionOutput, ExecutionError>;
summaries: string[][];
};
export interface ILifecycle {
name: LifecycleName;
driverDefs: DriverDefinition[];
/**
* Resolve all placeholders in the driver's arguments based on the environment variables in-place.
* Unresolved placeholders will be returned. It can be used to get unresolved placeholders before actually
* executing a lifecycle. Useful for getting unresolved built-in placeholders like AZURE_SUBSCRIPTION_ID
* and RESOURCE_GROUP and asking for user input.
* @returns unresolved placeholder names
*/
resolvePlaceholders(): UnresolvedPlaceholders;
/**
* execute() will run drivers one by one. The difference between execute() and run()
* is: 1. execute() resolves a driver's placeholder before executing it. It's useful when driver2 references
* driver1's output.
* 2. execute() still returns the output of successful driver runs when encountering an error.
* 3. execute() returns a list of summaires
* @param ctx driver context
*/
execute(ctx: DriverContext): Promise<ExecutionResult>;
/**
* Try to search for driver instances defined by this.driverDefs.
* @param log LogProvider
*/
resolveDriverInstances(log: LogProvider): Result<DriverInstance[], FxError>;
}
export interface IYamlParser {
parse(path: string, validateSchema?: boolean): Promise<Result<ProjectModel, FxError>>;
}
export {};
//# sourceMappingURL=interface.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../../../src/component/configManager/interface.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,13 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.LifecycleNames = void 0;
exports.LifecycleNames = [
"registerApp",
"configureApp",
"provision",
"deploy",
"publish",
];
//# sourceMappingURL=interface.js.map
@@ -0,0 +1 @@
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../../../src/component/configManager/interface.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AA+CrB,QAAA,cAAc,GAAmB;IAC5C,aAAa;IACb,cAAc;IACd,WAAW;IACX,QAAQ;IACR,SAAS;CACV,CAAC"}
@@ -0,0 +1,20 @@
/**
* @author yefuwang@microsoft.com
*/
import { FxError, Result, LogProvider } from "@microsoft/teamsfx-api";
import { DriverContext } from "../driver/interface/commonArgs";
import { DriverDefinition, LifecycleName, ILifecycle, DriverInstance, UnresolvedPlaceholders, ResolvedPlaceholders, ExecutionResult } from "./interface";
export declare function resolveString(val: string, resolved: ResolvedPlaceholders, unresolved: UnresolvedPlaceholders): string;
export declare class Lifecycle implements ILifecycle {
version: string;
name: LifecycleName;
driverDefs: DriverDefinition[];
constructor(name: LifecycleName, driverDefs: DriverDefinition[], version: string);
resolvePlaceholders(): UnresolvedPlaceholders;
private static stringifyOutput;
execute(ctx: DriverContext): Promise<ExecutionResult>;
executeImpl(ctx: DriverContext, resolved: ResolvedPlaceholders, unresolved: ResolvedPlaceholders): Promise<ExecutionResult>;
private stringifyDriverDef;
resolveDriverInstances(log: LogProvider): Result<DriverInstance[], FxError>;
}
//# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/component/configManager/lifecycle.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,OAAO,EAAW,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAI/E,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAI/D,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,UAAU,EACV,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EAChB,MAAM,aAAa,CAAC;AA6DrB,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,oBAAoB,EAC9B,UAAU,EAAE,sBAAsB,GACjC,MAAM,CAyBR;AAED,qBAAa,SAAU,YAAW,UAAU;IAC1C,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,gBAAgB,EAAE,CAAC;gBACnB,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM;IAMhF,mBAAmB,IAAI,sBAAsB;IAK7C,OAAO,CAAC,MAAM,CAAC,eAAe;IAcxB,OAAO,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,eAAe,CAAC;IAyErD,WAAW,CACf,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAE,oBAAoB,EAC9B,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,eAAe,CAAC;IAwF3B,OAAO,CAAC,kBAAkB;IAOnB,sBAAsB,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAAC,cAAc,EAAE,EAAE,OAAO,CAAC;CAanF"}
@@ -0,0 +1,260 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Lifecycle = exports.resolveString = void 0;
const tslib_1 = require("tslib");
/**
* @author yefuwang@microsoft.com
*/
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const lodash_1 = tslib_1.__importStar(require("lodash"));
const typedi_1 = require("typedi");
const yml_1 = require("../../error/yml");
const teamsFxTelemetryReporter_1 = require("../utils/teamsFxTelemetryReporter");
const constant_1 = require("./constant");
const error_1 = require("../../error");
const globalVars_1 = require("../../common/globalVars");
function resolveDriverDef(def, resolved, unresolved) {
const args = def.with;
for (const k in args) {
const val = args[k];
args[k] = resolve(val, resolved, unresolved);
}
if (def.env) {
for (const k in def.env) {
const val = def.env[k];
def.env[k] = resolveString(val, resolved, unresolved);
}
}
}
// Replace placeholders in the driver definitions' `with` field inplace
// and returns resolved and unresolved placeholders
function resolvePlaceHolders(defs) {
const resolvedVars = [];
const unresolvedVars = [];
for (const def of defs) {
resolveDriverDef(def, resolvedVars, unresolvedVars);
}
return [resolvedVars, unresolvedVars];
}
function resolve(input, resolved, unresolved) {
if (input === undefined || input === null) {
return input;
}
else if (typeof input === "string") {
return resolveString(input, resolved, unresolved);
}
else if (Array.isArray(input)) {
const newArray = [];
for (const e of input) {
newArray.push(resolve(e, resolved, unresolved));
}
return newArray;
}
else if (input !== null && typeof input === "object") {
const newObj = lodash_1.default.cloneDeep(input);
Object.keys(newObj).forEach((key) => {
newObj[key] = resolve(newObj[key], resolved, unresolved);
});
return newObj;
}
else {
return input;
}
}
function resolveString(val, resolved, unresolved) {
const placeHolderReg = /\${{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*}}/g;
let matches = placeHolderReg.exec(val);
let newVal = val;
while (matches != null) {
const envVar = matches[1];
const envVal = process.env[envVar];
if (envVar === "APP_NAME_SUFFIX") {
if (envVal === undefined || envVal === null) {
unresolved.push(envVar);
}
else {
resolved.push(envVar);
newVal = newVal.replace(matches[0], envVal);
}
}
else {
if (!envVal) {
unresolved.push(envVar);
}
else {
resolved.push(envVar);
newVal = newVal.replace(matches[0], envVal);
}
}
matches = placeHolderReg.exec(val);
}
return newVal;
}
exports.resolveString = resolveString;
class Lifecycle {
constructor(name, driverDefs, version) {
this.driverDefs = driverDefs;
this.name = name;
this.version = version;
}
resolvePlaceholders() {
const result = resolvePlaceHolders(this.driverDefs);
return result[1];
}
static stringifyOutput(output) {
const obj = {};
for (const [k, v] of output) {
if (k.startsWith("SECRET_")) {
obj[k] = "******";
}
else {
obj[k] = v;
}
}
return JSON.stringify(obj);
}
async execute(ctx) {
var _a;
const actions = JSON.stringify(this.driverDefs.map((def) => (0, lodash_1.camelCase)(this.stringifyDriverDef(def))));
const telemetryReporter = new teamsFxTelemetryReporter_1.TeamsFxTelemetryReporter(ctx.telemetryReporter, {
componentName: constant_1.component,
});
telemetryReporter.sendStartEvent({
eventName: constant_1.lifecycleExecutionEvent,
properties: {
[constant_1.TelemetryProperty.Lifecycle]: this.name,
[constant_1.TelemetryProperty.Actions]: actions,
},
});
ctx.logProvider.info(`Executing lifecycle ${this.name}`);
const resolved = [];
const unresolved = [];
const { result, summaries } = await this.executeImpl(ctx, resolved, unresolved);
let e;
let failedAction;
if (result.isOk()) {
ctx.logProvider.info(`Finished Executing lifecycle ${this.name}. Result: ${Lifecycle.stringifyOutput(result.value)}`);
}
else {
if (result.error.kind === "Failure") {
e = result.error.error;
ctx.logProvider.error(`Failed to Execute lifecycle ${this.name}. ${e.name}:${e.message}`);
}
else if (result.error.kind === "PartialSuccess") {
failedAction = this.stringifyDriverDef(result.error.reason.failedDriver);
const output = Lifecycle.stringifyOutput(result.error.env);
if (result.error.reason.kind === "DriverError") {
e = result.error.reason.error;
ctx.logProvider.error(`Failed to Execute lifecycle ${this.name} due to failed action: ${failedAction}. ${e.name}:${e.message}. Env output: ${output}`);
}
else if (result.error.reason.kind === "UnresolvedPlaceholders") {
// This error is just for telemetry because sendEndEvent() needs an error as parameter.
e = new error_1.MissingEnvironmentVariablesError(constant_1.component, result.error.reason.unresolvedPlaceHolders.join(","));
ctx.logProvider.error(`Failed to Execute lifecycle ${this.name} because there are unresolved placeholders ${JSON.stringify(unresolved)} for action: ${failedAction}. Env output: ${output}`);
}
}
}
telemetryReporter.sendEndEvent({
eventName: constant_1.lifecycleExecutionEvent,
properties: {
[constant_1.TelemetryProperty.Lifecycle]: this.name,
[constant_1.TelemetryProperty.Actions]: actions,
[constant_1.TelemetryProperty.ResolvedPlaceholders]: JSON.stringify(resolved),
[constant_1.TelemetryProperty.UnresolvedPlaceholders]: JSON.stringify(unresolved),
[constant_1.TelemetryProperty.FailedAction]: (_a = (0, lodash_1.camelCase)(failedAction)) !== null && _a !== void 0 ? _a : "",
},
}, e);
return { result, summaries };
}
async executeImpl(ctx, resolved, unresolved) {
var _a;
const maybeDrivers = this.resolveDriverInstances(ctx.logProvider);
if (maybeDrivers.isErr()) {
return { result: (0, teamsfx_api_1.err)({ kind: "Failure", error: maybeDrivers.error }), summaries: [] };
}
const drivers = maybeDrivers.value;
const envOutput = new Map();
const summaries = [];
for (const driver of drivers) {
ctx.logProvider.verbose(`Executing action ${this.stringifyDriverDef(driver)} in lifecycle ${this.name}`);
if (driver.instance.progressTitle) {
await ((_a = ctx.progressBar) === null || _a === void 0 ? void 0 : _a.next(driver.instance.progressTitle));
}
resolveDriverDef(driver, resolved, unresolved);
if (unresolved.length > 0) {
ctx.logProvider.warning(`Unresolved placeholders(${unresolved.join(",")}) found for Action ${this.stringifyDriverDef(driver)} in lifecycle ${this.name}`);
summaries.push([
`${constant_1.SummaryConstant.Failed} Unresolved placeholders: ${unresolved.join(",")}`,
]);
return {
result: (0, teamsfx_api_1.err)({
kind: "PartialSuccess",
env: envOutput,
reason: {
kind: "UnresolvedPlaceholders",
failedDriver: driver,
unresolvedPlaceHolders: unresolved,
},
}),
summaries,
};
}
if (driver.env) {
for (const [envVar, value] of Object.entries(driver.env)) {
process.env[envVar] = value;
}
}
(0, globalVars_1.setErrorContext)({ component: (0, lodash_1.camelCase)(driver.uses), method: "execute" }); // set driver name as component name for telemetry
const r = await driver.instance.execute(driver.with, ctx, driver.writeToEnvironmentFile
? new Map(Object.entries(driver.writeToEnvironmentFile))
: undefined, this.version, driver.name);
const result = r.result;
const summary = r.summaries.map((s) => `${constant_1.SummaryConstant.Succeeded} ${s}`);
summaries.push(summary);
if (result.isErr()) {
summary.push(`${constant_1.SummaryConstant.Failed} ${result.error.message}`);
return {
result: (0, teamsfx_api_1.err)({
kind: "PartialSuccess",
env: envOutput,
reason: {
kind: "DriverError",
failedDriver: driver,
error: result.error,
},
}),
summaries,
};
}
for (const [envVar, value] of result.value) {
envOutput.set(envVar, value);
process.env[envVar] = value;
}
ctx.logProvider.verbose(`Action ${this.stringifyDriverDef(driver)} in lifecycle ${this.name} succeeded with output ${Lifecycle.stringifyOutput(result.value)}`);
}
return { result: (0, teamsfx_api_1.ok)(envOutput), summaries };
}
stringifyDriverDef(def) {
if (def.name) {
return JSON.stringify({ name: def.name, uses: def.uses });
}
return def.uses;
}
resolveDriverInstances(log) {
void log.debug(`Trying to resolve actions for lifecycle ${this.name}`);
const drivers = [];
for (const def of this.driverDefs) {
if (!typedi_1.Container.has(def.uses)) {
return (0, teamsfx_api_1.err)(new yml_1.InvalidYmlActionNameError(def.uses));
}
const driver = typedi_1.Container.get(def.uses);
drivers.push(Object.assign({ instance: driver }, def));
void log.debug(`Action ${this.stringifyDriverDef(def)} found for lifecycle ${this.name}`);
}
return (0, teamsfx_api_1.ok)(drivers);
}
}
exports.Lifecycle = Lifecycle;
//# sourceMappingURL=lifecycle.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/**
* @author yefuwang@microsoft.com
*/
import { FxError, Result } from "@microsoft/teamsfx-api";
import { IYamlParser, ProjectModel } from "./interface";
export declare class YamlParser implements IYamlParser {
parse(path: string, validateSchema?: boolean): Promise<Result<ProjectModel, FxError>>;
private parseRaw;
}
export declare const yamlParser: YamlParser;
//# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/component/configManager/parser.ts"],"names":[],"mappings":"AAGA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,EAAW,MAAM,wBAAwB,CAAC;AAKlE,OAAO,EACL,WAAW,EACX,YAAY,EAIb,MAAM,aAAa,CAAC;AAuFrB,qBAAa,UAAW,YAAW,WAAW;IACtC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;YA0B7E,QAAQ;CAqCvB;AAED,eAAO,MAAM,UAAU,YAAmB,CAAC"}
@@ -0,0 +1,143 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.yamlParser = exports.YamlParser = void 0;
const tslib_1 = require("tslib");
/**
* @author yefuwang@microsoft.com
*/
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const js_yaml_1 = require("js-yaml");
const globalVars_1 = require("../../common/globalVars");
const yml_1 = require("../../error/yml");
const interface_1 = require("./interface");
const lifecycle_1 = require("./lifecycle");
const validator_1 = require("./validator");
const localizeUtils_1 = require("../../common/localizeUtils");
const validator = new validator_1.Validator();
const environmentFolderPath = "environmentFolderPath";
const writeToEnvironmentFile = "writeToEnvironmentFile";
const versionNotSupportedKey = "error.yaml.VersionNotSupported";
function parseRawProjectModel(obj) {
const result = { version: "" };
if (environmentFolderPath in obj) {
if (typeof obj[environmentFolderPath] !== "string") {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError("environmentFolderPath", "string"));
}
result.environmentFolderPath = obj[environmentFolderPath];
}
if ("version" in obj) {
if (typeof obj["version"] !== "string") {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError("version", "string"));
}
result.version = obj["version"];
}
else {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldMissingError("version"));
}
if ("additionalMetadata" in obj) {
// No validation for additionalMetadata by design. This property is for telemetry related purpose only
// and should not affect user-observable behavior of TTK.
result.additionalMetadata = obj["additionalMetadata"];
}
for (const name of interface_1.LifecycleNames) {
if (name in obj) {
const value = obj[name];
if (!Array.isArray(value)) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(name, "array"));
}
for (const elem of value) {
if (!("uses" in elem)) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldMissingError(`${name}.uses`));
}
if (!(typeof elem["uses"] === "string")) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(`${name}.uses`, "string"));
}
if (!("with" in elem)) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldMissingError(`${name}.with`));
}
if (!(typeof elem["with"] === "object")) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(`${name}.with`, "object"));
}
if (elem["env"]) {
if (typeof elem["env"] !== "object" || Array.isArray(elem["env"])) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(`${name}.env`, "object"));
}
for (const envVar in elem["env"]) {
if (typeof elem["env"][envVar] !== "string") {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(`${name}.env.${envVar}`, "string"));
}
}
}
if (elem[writeToEnvironmentFile]) {
if (typeof elem[writeToEnvironmentFile] !== "object" ||
Array.isArray(elem[writeToEnvironmentFile])) {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(`${name}.writeToEnvironmentFile`, "object"));
}
for (const envVar in elem[writeToEnvironmentFile]) {
if (typeof elem[writeToEnvironmentFile][envVar] !== "string") {
return (0, teamsfx_api_1.err)(new yml_1.YamlFieldTypeError(`${name}.writeToEnvironmentFile.${envVar}`, "string"));
}
}
}
}
result[name] = value;
}
}
return (0, teamsfx_api_1.ok)(result);
}
class YamlParser {
async parse(path, validateSchema) {
const raw = await this.parseRaw(path, validateSchema);
if (raw.isErr()) {
return (0, teamsfx_api_1.err)(raw.error);
}
const result = { version: raw.value.version };
for (const name of interface_1.LifecycleNames) {
if (name in raw.value) {
const definitions = raw.value[name];
if (definitions) {
result[name] = new lifecycle_1.Lifecycle(name, definitions, result.version);
}
}
}
if (raw.value.environmentFolderPath) {
result.environmentFolderPath = raw.value.environmentFolderPath;
}
if (raw.value.additionalMetadata) {
result.additionalMetadata = raw.value.additionalMetadata;
}
return (0, teamsfx_api_1.ok)(result);
}
async parseRaw(path, validateSchema) {
try {
globalVars_1.globalVars.ymlFilePath = path;
const str = await fs_extra_1.default.readFile(path, "utf8");
const content = (0, js_yaml_1.load)(str);
const value = content;
const version = typeof value["version"] === "string" ? value["version"] : undefined;
// note: typeof null === "object" typeof undefined === "undefined" in js
if (typeof content !== "object" || Array.isArray(content) || content === null) {
return (0, teamsfx_api_1.err)(new yml_1.InvalidYamlSchemaError(path));
}
if (validateSchema) {
if (!validator.isVersionSupported(version !== null && version !== void 0 ? version : "undefined")) {
return (0, teamsfx_api_1.err)(new yml_1.InvalidYamlSchemaError(path, (0, localizeUtils_1.getLocalizedString)(versionNotSupportedKey, version, validator.supportedVersions().join(", "))));
}
const valid = validator.validate(value, version);
if (!valid) {
return (0, teamsfx_api_1.err)(new yml_1.InvalidYamlSchemaError(path));
}
}
return parseRawProjectModel(value);
}
catch (error) {
return (0, teamsfx_api_1.err)(new yml_1.InvalidYamlSchemaError(path));
}
}
}
exports.YamlParser = YamlParser;
exports.yamlParser = new YamlParser();
//# sourceMappingURL=parser.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
import { ValidateFunction } from "ajv";
declare type Version = string;
export declare class Validator {
impl: Map<Version, {
validator: ValidateFunction;
}>;
constructor();
private initVersion;
isVersionSupported(version: string): boolean;
supportedVersions(): string[];
private latestSupportedVersion;
validate(obj: Record<string, unknown>, version?: string): boolean;
}
export {};
//# sourceMappingURL=validator.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../src/component/configManager/validator.ts"],"names":[],"mappings":"AAGA,OAAY,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AAK5C,aAAK,OAAO,GAAG,MAAM,CAAC;AAGtB,qBAAa,SAAS;IACpB,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE;QAAE,SAAS,EAAE,gBAAgB,CAAA;KAAE,CAAC,CAAC;;IASpD,OAAO,CAAC,WAAW;IAWnB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO;IAI5C,iBAAiB,IAAI,MAAM,EAAE;IAI7B,OAAO,CAAC,sBAAsB;IAI9B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO;CAOlE"}
@@ -0,0 +1,46 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Validator = void 0;
const tslib_1 = require("tslib");
const ajv_1 = tslib_1.__importDefault(require("ajv"));
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
const folder_1 = require("../../folder");
const supportedVersions = ["1.0.0", "1.1.0", "v1.2", "v1.3", "v1.4", "v1.5", "v1.6", "v1.7"];
class Validator {
constructor() {
this.impl = new Map();
for (const version of this.supportedVersions()) {
this.initVersion(version);
}
}
initVersion(version) {
const ajv = new ajv_1.default({ allowUnionTypes: true });
ajv.addKeyword("deprecationMessage");
const schemaPath = path_1.default.join((0, folder_1.getResourceFolder)(), "yaml-schema", version, "yaml.schema.json");
const schema = fs_extra_1.default.readJSONSync(schemaPath);
this.impl.set(version, {
validator: ajv.compile(schema),
});
}
isVersionSupported(version) {
return this.supportedVersions().includes(version);
}
supportedVersions() {
return supportedVersions;
}
latestSupportedVersion() {
return this.supportedVersions()[this.supportedVersions().length - 1];
}
validate(obj, version) {
const impl = this.impl.get(version !== null && version !== void 0 ? version : this.latestSupportedVersion());
if (!impl) {
return false;
}
return !!impl.validator(obj);
}
}
exports.Validator = Validator;
//# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
{"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../src/component/configManager/validator.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,sDAA4C;AAC5C,gEAA0B;AAC1B,wDAAwB;AACxB,yCAAiD;AAGjD,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE7F,MAAa,SAAS;IAGpB;QACE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAC9C,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;SAC3B;IACH,CAAC;IAEO,WAAW,CAAC,OAAe;QACjC,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/C,GAAG,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;QACrC,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,IAAA,0BAAiB,GAAE,EAAE,aAAa,EAAE,OAAO,EAAE,kBAAkB,CAAC,CAAC;QAC9F,MAAM,MAAM,GAAG,kBAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAE3C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;YACrB,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;SAC/B,CAAC,CAAC;IACL,CAAC;IAED,kBAAkB,CAAC,OAAe;QAChC,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACpD,CAAC;IAED,iBAAiB;QACf,OAAO,iBAAiB,CAAC;IAC3B,CAAC;IAEO,sBAAsB;QAC5B,OAAO,IAAI,CAAC,iBAAiB,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,QAAQ,CAAC,GAA4B,EAAE,OAAgB;QACrD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC,CAAC;QACrE,IAAI,CAAC,IAAI,EAAE;YACT,OAAO,KAAK,CAAC;SACd;QACD,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;CACF;AAxCD,8BAwCC"}
@@ -0,0 +1,27 @@
/**
* @author Siglud <Siglud@gmail.com>
*/
export declare enum HttpStatusCode {
OK = 200,
CREATED = 201,
ACCEPTED = 202,
BAD_REQUEST = 400,
UNAUTHORIZED = 401,
FORBIDDEN = 403,
NOTFOUND = 404,
TOOMANYREQS = 429,
INTERNAL_SERVER_ERROR = 500
}
export declare class HttpMethod {
static readonly POST = "POST";
static readonly GET = "GET";
static readonly DELETE = "DELETE";
static readonly PATCH = "PATCH";
}
export declare class TelemetryConstant {
static readonly DEPLOY_COMPONENT_NAME = "deploy";
static readonly PROVISION_COMPONENT_NAME = "provision";
static readonly SCRIPT_COMPONENT = "script";
static readonly DEPLOY_TO_SWA_COMPONENT = "deploy_to_swa";
}
//# sourceMappingURL=commonConstant.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"commonConstant.d.ts","sourceRoot":"","sources":["../../../src/component/constant/commonConstant.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,cAAc;IACxB,EAAE,MAAM;IACR,OAAO,MAAM;IACb,QAAQ,MAAM;IACd,WAAW,MAAM;IACjB,YAAY,MAAM;IAClB,SAAS,MAAM;IACf,QAAQ,MAAM;IACd,WAAW,MAAM;IACjB,qBAAqB,MAAM;CAC5B;AAED,qBAAa,UAAU;IACrB,gBAAuB,IAAI,UAAU;IACrC,gBAAuB,GAAG,SAAS;IACnC,gBAAuB,MAAM,YAAY;IACzC,gBAAuB,KAAK,WAAW;CACxC;AAED,qBAAa,iBAAiB;IAE5B,gBAAuB,qBAAqB,YAAY;IAExD,gBAAuB,wBAAwB,eAAe;IAE9D,gBAAuB,gBAAgB,YAAY;IAEnD,gBAAuB,uBAAuB,mBAAmB;CAClE"}
@@ -0,0 +1,39 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TelemetryConstant = exports.HttpMethod = exports.HttpStatusCode = void 0;
/**
* @author Siglud <Siglud@gmail.com>
*/
var HttpStatusCode;
(function (HttpStatusCode) {
HttpStatusCode[HttpStatusCode["OK"] = 200] = "OK";
HttpStatusCode[HttpStatusCode["CREATED"] = 201] = "CREATED";
HttpStatusCode[HttpStatusCode["ACCEPTED"] = 202] = "ACCEPTED";
HttpStatusCode[HttpStatusCode["BAD_REQUEST"] = 400] = "BAD_REQUEST";
HttpStatusCode[HttpStatusCode["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
HttpStatusCode[HttpStatusCode["FORBIDDEN"] = 403] = "FORBIDDEN";
HttpStatusCode[HttpStatusCode["NOTFOUND"] = 404] = "NOTFOUND";
HttpStatusCode[HttpStatusCode["TOOMANYREQS"] = 429] = "TOOMANYREQS";
HttpStatusCode[HttpStatusCode["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
})(HttpStatusCode = exports.HttpStatusCode || (exports.HttpStatusCode = {}));
class HttpMethod {
}
exports.HttpMethod = HttpMethod;
HttpMethod.POST = "POST";
HttpMethod.GET = "GET";
HttpMethod.DELETE = "DELETE";
HttpMethod.PATCH = "PATCH";
class TelemetryConstant {
}
exports.TelemetryConstant = TelemetryConstant;
// the component name of the deployment life cycle
TelemetryConstant.DEPLOY_COMPONENT_NAME = "deploy";
// the component name of the provision life cycle
TelemetryConstant.PROVISION_COMPONENT_NAME = "provision";
// the script component name
TelemetryConstant.SCRIPT_COMPONENT = "script";
// the component name of the deployment to SWA script
TelemetryConstant.DEPLOY_TO_SWA_COMPONENT = "deploy_to_swa";
//# sourceMappingURL=commonConstant.js.map
@@ -0,0 +1 @@
{"version":3,"file":"commonConstant.js","sourceRoot":"","sources":["../../../src/component/constant/commonConstant.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AACH,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB,iDAAQ,CAAA;IACR,2DAAa,CAAA;IACb,6DAAc,CAAA;IACd,mEAAiB,CAAA;IACjB,qEAAkB,CAAA;IAClB,+DAAe,CAAA;IACf,6DAAc,CAAA;IACd,mEAAiB,CAAA;IACjB,uFAA2B,CAAA;AAC7B,CAAC,EAVW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAUzB;AAED,MAAa,UAAU;;AAAvB,gCAKC;AAJwB,eAAI,GAAG,MAAM,CAAC;AACd,cAAG,GAAG,KAAK,CAAC;AACZ,iBAAM,GAAG,QAAQ,CAAC;AAClB,gBAAK,GAAG,OAAO,CAAC;AAGzC,MAAa,iBAAiB;;AAA9B,8CASC;AARC,kDAAkD;AAC3B,uCAAqB,GAAG,QAAQ,CAAC;AACxD,iDAAiD;AAC1B,0CAAwB,GAAG,WAAW,CAAC;AAC9D,4BAA4B;AACL,kCAAgB,GAAG,QAAQ,CAAC;AACnD,qDAAqD;AAC9B,yCAAuB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,27 @@
export declare class DeployConstant {
static readonly DEPLOY_ERROR_TYPE = "DeployError";
static readonly DEPLOYMENT_TMP_FOLDER = ".deployment";
static readonly MILLIS_SECONDS: number;
static readonly ZIP_TIME_MS_GRANULARITY: number;
static readonly LATEST_TRUST_MS_TIME: Date;
static readonly DEPLOYMENT_ZIP_CACHE_FILE = "deployment.zip";
static readonly DEPLOY_TIMEOUT_IN_MS: number;
static readonly DEPLOY_CHECK_RETRY_TIMES = 120;
static readonly BACKOFF_TIME_S = 10;
static readonly AZURE_STORAGE_CONTAINER_NAME = "$web";
static readonly DAY_IN_MS: number;
static readonly SAS_TOKEN_LIFE_TIME_PADDING: number;
static readonly SAS_TOKEN_LIFE_TIME: number;
static readonly DEFAULT_INDEX_DOCUMENT = "index.html";
static readonly DEFAULT_ERROR_DOCUMENT = "index.html";
static readonly DEPLOY_OVER_TIME: number;
static readonly DEPLOY_UPLOAD_RETRY_TIMES = 2;
}
export declare enum DeployStatus {
Pending = 0,
Building = 1,
Deploying = 2,
Failed = 3,
Success = 4
}
//# sourceMappingURL=deployConstant.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"deployConstant.d.ts","sourceRoot":"","sources":["../../../src/component/constant/deployConstant.ts"],"names":[],"mappings":"AAGA,qBAAa,cAAc;IAEzB,gBAAuB,iBAAiB,iBAAiB;IAEzD,gBAAuB,qBAAqB,iBAAiB;IAE7D,gBAAuB,cAAc,EAAE,MAAM,CAAQ;IAErD,gBAAuB,uBAAuB,EAAE,MAAM,CAAqC;IAG3F,gBAAuB,oBAAoB,EAAE,IAAI,CAAwB;IAEzE,gBAAuB,yBAAyB,oBAAoB;IAEpE,gBAAuB,oBAAoB,EAAE,MAAM,CAAkB;IAErE,gBAAuB,wBAAwB,OAAO;IAEtD,gBAAuB,cAAc,MAAM;IAE3C,gBAAuB,4BAA4B,UAAU;IAE7D,gBAAuB,SAAS,SAAuB;IAEvD,gBAAuB,2BAA2B,SAA4B;IAE9E,gBAAuB,mBAAmB,SAAgC;IAE1E,gBAAuB,sBAAsB,gBAAgB;IAE7D,gBAAuB,sBAAsB,gBAAyC;IAEtF,gBAAuB,gBAAgB,SAAc;IAErD,gBAAuB,yBAAyB,KAAK;CACtD;AAED,oBAAY,YAAY;IACtB,OAAO,IAAI;IACX,QAAQ,IAAI;IACZ,SAAS,IAAI;IACb,MAAM,IAAI;IACV,OAAO,IAAI;CACZ"}
@@ -0,0 +1,52 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeployStatus = exports.DeployConstant = void 0;
class DeployConstant {
}
exports.DeployConstant = DeployConstant;
// deploy error type
DeployConstant.DEPLOY_ERROR_TYPE = "DeployError";
// deploy temp folder
DeployConstant.DEPLOYMENT_TMP_FOLDER = ".deployment";
// seconds to millisecond
DeployConstant.MILLIS_SECONDS = 1000;
// If mtime is valid and the two mtime is same in two-seconds, we think the two are same file.
DeployConstant.ZIP_TIME_MS_GRANULARITY = 2 * DeployConstant.MILLIS_SECONDS;
// Some files' mtime in node_modules are too old, which may be invalid,
// so we arbitrarily add a limitation to update this kind of files.
DeployConstant.LATEST_TRUST_MS_TIME = new Date(2000, 1, 1);
// deploy zip file name
DeployConstant.DEPLOYMENT_ZIP_CACHE_FILE = "deployment.zip";
// call zip deploy api timeout
DeployConstant.DEPLOY_TIMEOUT_IN_MS = 10 * 60 * 1000;
// check deploy status timeout
DeployConstant.DEPLOY_CHECK_RETRY_TIMES = 120; // Timeout: 20 min
// check deploy status interval
DeployConstant.BACKOFF_TIME_S = 10;
// azure storage container name for static website
DeployConstant.AZURE_STORAGE_CONTAINER_NAME = "$web";
// days to millisecond
DeployConstant.DAY_IN_MS = 1000 * 60 * 60 * 24;
// The time at which the Azure storage shared access signature becomes valid.
DeployConstant.SAS_TOKEN_LIFE_TIME_PADDING = DeployConstant.DAY_IN_MS;
// The time at which the Azure storage shared access signature becomes invalid.
DeployConstant.SAS_TOKEN_LIFE_TIME = DeployConstant.DAY_IN_MS * 3;
// default index document for Azure storage static website
DeployConstant.DEFAULT_INDEX_DOCUMENT = "index.html";
// default error document for Azure storage static website
DeployConstant.DEFAULT_ERROR_DOCUMENT = DeployConstant.DEFAULT_INDEX_DOCUMENT;
// default deploy over time
DeployConstant.DEPLOY_OVER_TIME = 1000 * 120;
// default deploy retry times
DeployConstant.DEPLOY_UPLOAD_RETRY_TIMES = 2;
var DeployStatus;
(function (DeployStatus) {
DeployStatus[DeployStatus["Pending"] = 0] = "Pending";
DeployStatus[DeployStatus["Building"] = 1] = "Building";
DeployStatus[DeployStatus["Deploying"] = 2] = "Deploying";
DeployStatus[DeployStatus["Failed"] = 3] = "Failed";
DeployStatus[DeployStatus["Success"] = 4] = "Success";
})(DeployStatus = exports.DeployStatus || (exports.DeployStatus = {}));
//# sourceMappingURL=deployConstant.js.map
@@ -0,0 +1 @@
{"version":3,"file":"deployConstant.js","sourceRoot":"","sources":["../../../src/component/constant/deployConstant.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,MAAa,cAAc;;AAA3B,wCAoCC;AAnCC,oBAAoB;AACG,gCAAiB,GAAG,aAAa,CAAC;AACzD,qBAAqB;AACE,oCAAqB,GAAG,aAAa,CAAC;AAC7D,yBAAyB;AACF,6BAAc,GAAW,IAAI,CAAC;AACrD,8FAA8F;AACvE,sCAAuB,GAAW,CAAC,GAAG,cAAc,CAAC,cAAc,CAAC;AAC3F,uEAAuE;AACvE,mEAAmE;AAC5C,mCAAoB,GAAS,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzE,uBAAuB;AACA,wCAAyB,GAAG,gBAAgB,CAAC;AACpE,8BAA8B;AACP,mCAAoB,GAAW,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AACrE,8BAA8B;AACP,uCAAwB,GAAG,GAAG,CAAC,CAAC,kBAAkB;AACzE,+BAA+B;AACR,6BAAc,GAAG,EAAE,CAAC;AAC3C,kDAAkD;AAC3B,2CAA4B,GAAG,MAAM,CAAC;AAC7D,sBAAsB;AACC,wBAAS,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AACvD,6EAA6E;AACtD,0CAA2B,GAAG,cAAc,CAAC,SAAS,CAAC;AAC9E,+EAA+E;AACxD,kCAAmB,GAAG,cAAc,CAAC,SAAS,GAAG,CAAC,CAAC;AAC1E,0DAA0D;AACnC,qCAAsB,GAAG,YAAY,CAAC;AAC7D,0DAA0D;AACnC,qCAAsB,GAAG,cAAc,CAAC,sBAAsB,CAAC;AACtF,2BAA2B;AACJ,+BAAgB,GAAG,IAAI,GAAG,GAAG,CAAC;AACrD,6BAA6B;AACN,wCAAyB,GAAG,CAAC,CAAC;AAGvD,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,qDAAW,CAAA;IACX,uDAAY,CAAA;IACZ,yDAAa,CAAA;IACb,mDAAU,CAAA;IACV,qDAAW,CAAA;AACb,CAAC,EANW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QAMvB"}
+88
View File
@@ -0,0 +1,88 @@
/**
* @author Huajie Zhang <huajiezhang@microsoft.com>
*/
import { OptionItem } from "@microsoft/teamsfx-api";
export declare enum SolutionError {
NoAppStudioToken = "NoAppStudioToken",
FailedToRetrieveUserInfo = "FailedToRetrieveUserInfo",
CannotFindUserInCurrentTenant = "CannotFindUserInCurrentTenant",
EmailCannotBeEmptyOrSame = "EmailCannotBeEmptyOrSame",
InvalidProjectPath = "InvalidProjectPath",
FailedToCreateAuthFiles = "FailedToCreateAuthFiles",
FailedToLoadDotEnvFile = "FailedToLoadDotEnvFile",
InvalidManifestError = "InvalidManifestError",
FailedToLoadManifestFile = "FailedToLoadManifestFile"
}
export declare const ViewAadAppHelpLinkV5 = "https://aka.ms/teamsfx-view-aad-app-v5";
export declare enum SolutionTelemetryEvent {
AddSsoStart = "add-sso-start",
AddSso = "add-sso"
}
export declare enum SolutionTelemetryProperty {
Component = "component",
Success = "success",
CollaboratorCount = "collaborator-count",
AadOwnerCount = "aad-owner-count",
AadPermission = "aad-permission",
ArmDeploymentError = "arm-deployment-error",
TeamsAppPermission = "teams-app-permission",
Env = "env",
SubscriptionId = "subscription-id",
M365TenantId = "m365-tenant-id",
PreviousM365TenantId = "previous-m365-tenant-id",
ConfirmRes = "confirm-res"
}
export declare enum SolutionTelemetrySuccess {
Yes = "yes",
No = "no"
}
export declare const SolutionTelemetryComponentName = "core";
export declare const SolutionSource = "core";
export declare const CoordinatorSource = "core";
export declare class AddSsoParameters {
static readonly filePath: string;
static readonly Bot = "bot";
static readonly Tab = "tab";
static readonly V3 = "V3";
static readonly V3AuthFolder = "TeamsFx-Auth";
static readonly Readme = "README.md";
static readonly ReadmeCSharp = "README.txt";
static readonly LearnMore: () => string;
static readonly LearnMoreUrl = "https://aka.ms/teamsfx-add-sso-readme";
static readonly AddSso = "addSso";
static readonly AppSettings = "appsettings.json";
static readonly AppSettingsDev = "appsettings.Development.json";
static readonly AppSettingsToAdd: {
Authentication: {
ClientId: string;
ClientSecret: string;
OAuthAuthority: string;
};
};
static readonly AppSettingsToAddForBot: {
Authentication: {
ClientId: string;
ClientSecret: string;
OAuthAuthority: string;
ApplicationIdUri: string;
Bot: {
InitiateLoginEndpoint: string;
};
};
};
}
export declare const SingleSignOnOptionItem: OptionItem;
export declare enum BotScenario {
NotificationBot = "notificationBot",
CommandAndResponseBot = "commandAndResponseBot",
WorkflowBot = "workflowBot"
}
export declare const AadConstants: {
DefaultTemplateFileName: string;
};
export declare const KiotaLastCommands: {
createPluginWithManifest: string;
createDeclarativeCopilotWithManifest: string;
addPlugin: string;
};
//# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/component/constants.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAIpD,oBAAY,aAAa;IACvB,gBAAgB,qBAAqB;IACrC,wBAAwB,6BAA6B;IACrD,6BAA6B,kCAAkC;IAC/D,wBAAwB,6BAA6B;IACrD,kBAAkB,uBAAuB;IACzC,uBAAuB,4BAA4B;IACnD,sBAAsB,2BAA2B;IACjD,oBAAoB,yBAAyB;IAC7C,wBAAwB,6BAA6B;CACtD;AAED,eAAO,MAAM,oBAAoB,2CAA2C,CAAC;AAK7E,oBAAY,sBAAsB;IAChC,WAAW,kBAAkB;IAC7B,MAAM,YAAY;CACnB;AAED,oBAAY,yBAAyB;IACnC,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,iBAAiB,uBAAuB;IACxC,aAAa,oBAAoB;IACjC,aAAa,mBAAmB;IAChC,kBAAkB,yBAAyB;IAC3C,kBAAkB,yBAAyB;IAC3C,GAAG,QAAQ;IACX,cAAc,oBAAoB;IAClC,YAAY,mBAAmB;IAC/B,oBAAoB,4BAA4B;IAChD,UAAU,gBAAgB;CAC3B;AAED,oBAAY,wBAAwB;IAClC,GAAG,QAAQ;IACX,EAAE,OAAO;CACV;AAED,eAAO,MAAM,8BAA8B,SAAS,CAAC;AACrD,eAAO,MAAM,cAAc,SAAS,CAAC;AACrC,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAExC,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,QAAQ,SAAmD;IAC3E,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,GAAG,SAAS;IAC5B,MAAM,CAAC,QAAQ,CAAC,EAAE,QAAQ;IAC1B,MAAM,CAAC,QAAQ,CAAC,YAAY,kBAAkB;IAC9C,MAAM,CAAC,QAAQ,CAAC,MAAM,eAAe;IACrC,MAAM,CAAC,QAAQ,CAAC,YAAY,gBAAgB;IAC5C,MAAM,CAAC,QAAQ,CAAC,SAAS,eAAwD;IACjF,MAAM,CAAC,QAAQ,CAAC,YAAY,2CAA2C;IACvE,MAAM,CAAC,QAAQ,CAAC,MAAM,YAAY;IAClC,MAAM,CAAC,QAAQ,CAAC,WAAW,sBAAsB;IACjD,MAAM,CAAC,QAAQ,CAAC,cAAc,kCAAkC;IAChE,MAAM,CAAC,QAAQ,CAAC,gBAAgB;;;;;;MAM9B;IACF,MAAM,CAAC,QAAQ,CAAC,sBAAsB;;;;;;;;;;MAUpC;CACH;AAED,eAAO,MAAM,sBAAsB,EAAE,UAapC,CAAC;AAEF,oBAAY,WAAW;IACrB,eAAe,oBAAoB;IACnC,qBAAqB,0BAA0B;IAC/C,WAAW,gBAAgB;CAC5B;AAED,eAAO,MAAM,YAAY;;CAExB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;CAI7B,CAAC"}
+111
View File
@@ -0,0 +1,111 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KiotaLastCommands = exports.AadConstants = exports.BotScenario = exports.SingleSignOnOptionItem = exports.AddSsoParameters = exports.CoordinatorSource = exports.SolutionSource = exports.SolutionTelemetryComponentName = exports.SolutionTelemetrySuccess = exports.SolutionTelemetryProperty = exports.SolutionTelemetryEvent = exports.ViewAadAppHelpLinkV5 = exports.SolutionError = void 0;
const tslib_1 = require("tslib");
const path_1 = tslib_1.__importDefault(require("path"));
const localizeUtils_1 = require("../common/localizeUtils");
var SolutionError;
(function (SolutionError) {
SolutionError["NoAppStudioToken"] = "NoAppStudioToken";
SolutionError["FailedToRetrieveUserInfo"] = "FailedToRetrieveUserInfo";
SolutionError["CannotFindUserInCurrentTenant"] = "CannotFindUserInCurrentTenant";
SolutionError["EmailCannotBeEmptyOrSame"] = "EmailCannotBeEmptyOrSame";
SolutionError["InvalidProjectPath"] = "InvalidProjectPath";
SolutionError["FailedToCreateAuthFiles"] = "FailedToCreateAuthFiles";
SolutionError["FailedToLoadDotEnvFile"] = "FailedToLoadDotEnvFile";
SolutionError["InvalidManifestError"] = "InvalidManifestError";
SolutionError["FailedToLoadManifestFile"] = "FailedToLoadManifestFile";
})(SolutionError = exports.SolutionError || (exports.SolutionError = {}));
exports.ViewAadAppHelpLinkV5 = "https://aka.ms/teamsfx-view-aad-app-v5";
// This is the max length specified in
// https://developer.microsoft.com/en-us/json-schemas/teams/v1.7/MicrosoftTeams.schema.json
var SolutionTelemetryEvent;
(function (SolutionTelemetryEvent) {
SolutionTelemetryEvent["AddSsoStart"] = "add-sso-start";
SolutionTelemetryEvent["AddSso"] = "add-sso";
})(SolutionTelemetryEvent = exports.SolutionTelemetryEvent || (exports.SolutionTelemetryEvent = {}));
var SolutionTelemetryProperty;
(function (SolutionTelemetryProperty) {
SolutionTelemetryProperty["Component"] = "component";
SolutionTelemetryProperty["Success"] = "success";
SolutionTelemetryProperty["CollaboratorCount"] = "collaborator-count";
SolutionTelemetryProperty["AadOwnerCount"] = "aad-owner-count";
SolutionTelemetryProperty["AadPermission"] = "aad-permission";
SolutionTelemetryProperty["ArmDeploymentError"] = "arm-deployment-error";
SolutionTelemetryProperty["TeamsAppPermission"] = "teams-app-permission";
SolutionTelemetryProperty["Env"] = "env";
SolutionTelemetryProperty["SubscriptionId"] = "subscription-id";
SolutionTelemetryProperty["M365TenantId"] = "m365-tenant-id";
SolutionTelemetryProperty["PreviousM365TenantId"] = "previous-m365-tenant-id";
SolutionTelemetryProperty["ConfirmRes"] = "confirm-res";
})(SolutionTelemetryProperty = exports.SolutionTelemetryProperty || (exports.SolutionTelemetryProperty = {}));
var SolutionTelemetrySuccess;
(function (SolutionTelemetrySuccess) {
SolutionTelemetrySuccess["Yes"] = "yes";
SolutionTelemetrySuccess["No"] = "no";
})(SolutionTelemetrySuccess = exports.SolutionTelemetrySuccess || (exports.SolutionTelemetrySuccess = {}));
exports.SolutionTelemetryComponentName = "core";
exports.SolutionSource = "core";
exports.CoordinatorSource = "core";
class AddSsoParameters {
}
exports.AddSsoParameters = AddSsoParameters;
AddSsoParameters.filePath = path_1.default.join("plugins", "resource", "aad", "auth");
AddSsoParameters.Bot = "bot";
AddSsoParameters.Tab = "tab";
AddSsoParameters.V3 = "V3";
AddSsoParameters.V3AuthFolder = "TeamsFx-Auth";
AddSsoParameters.Readme = "README.md";
AddSsoParameters.ReadmeCSharp = "README.txt";
AddSsoParameters.LearnMore = () => (0, localizeUtils_1.getLocalizedString)("core.provision.learnMore");
AddSsoParameters.LearnMoreUrl = "https://aka.ms/teamsfx-add-sso-readme";
AddSsoParameters.AddSso = "addSso";
AddSsoParameters.AppSettings = "appsettings.json";
AddSsoParameters.AppSettingsDev = "appsettings.Development.json";
AddSsoParameters.AppSettingsToAdd = {
Authentication: {
ClientId: "$clientId$",
ClientSecret: "$client-secret$",
OAuthAuthority: "$oauthAuthority$",
},
};
AddSsoParameters.AppSettingsToAddForBot = {
Authentication: {
ClientId: "$clientId$",
ClientSecret: "$client-secret$",
OAuthAuthority: "$oauthAuthority$",
ApplicationIdUri: "$applicationIdUri$",
Bot: {
InitiateLoginEndpoint: "$initiateLoginEndpoint$",
},
},
};
exports.SingleSignOnOptionItem = {
id: "sso",
label: `$(unlock) ${(0, localizeUtils_1.getLocalizedString)("core.SingleSignOnOption.label")}`,
detail: (0, localizeUtils_1.getLocalizedString)("core.SingleSignOnOption.detail"),
groupName: (0, localizeUtils_1.getLocalizedString)("core.options.separator.additional"),
data: "https://aka.ms/teamsfx-add-sso",
buttons: [
{
iconPath: "tasklist",
tooltip: (0, localizeUtils_1.getLocalizedString)("core.option.tutorial"),
command: "fx-extension.openTutorial",
},
],
};
var BotScenario;
(function (BotScenario) {
BotScenario["NotificationBot"] = "notificationBot";
BotScenario["CommandAndResponseBot"] = "commandAndResponseBot";
BotScenario["WorkflowBot"] = "workflowBot";
})(BotScenario = exports.BotScenario || (exports.BotScenario = {}));
exports.AadConstants = {
DefaultTemplateFileName: "aad.manifest.json",
};
exports.KiotaLastCommands = {
createPluginWithManifest: "createPluginWithManifest",
createDeclarativeCopilotWithManifest: "createDeclarativeCopilotWithManifest",
addPlugin: "addPlugin",
};
//# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/component/constants.ts"],"names":[],"mappings":";;;;AAMA,wDAAwB;AACxB,2DAA6D;AAE7D,IAAY,aAUX;AAVD,WAAY,aAAa;IACvB,sDAAqC,CAAA;IACrC,sEAAqD,CAAA;IACrD,gFAA+D,CAAA;IAC/D,sEAAqD,CAAA;IACrD,0DAAyC,CAAA;IACzC,oEAAmD,CAAA;IACnD,kEAAiD,CAAA;IACjD,8DAA6C,CAAA;IAC7C,sEAAqD,CAAA;AACvD,CAAC,EAVW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAUxB;AAEY,QAAA,oBAAoB,GAAG,wCAAwC,CAAC;AAE7E,sCAAsC;AACtC,2FAA2F;AAE3F,IAAY,sBAGX;AAHD,WAAY,sBAAsB;IAChC,uDAA6B,CAAA;IAC7B,4CAAkB,CAAA;AACpB,CAAC,EAHW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAGjC;AAED,IAAY,yBAaX;AAbD,WAAY,yBAAyB;IACnC,oDAAuB,CAAA;IACvB,gDAAmB,CAAA;IACnB,qEAAwC,CAAA;IACxC,8DAAiC,CAAA;IACjC,6DAAgC,CAAA;IAChC,wEAA2C,CAAA;IAC3C,wEAA2C,CAAA;IAC3C,wCAAW,CAAA;IACX,+DAAkC,CAAA;IAClC,4DAA+B,CAAA;IAC/B,6EAAgD,CAAA;IAChD,uDAA0B,CAAA;AAC5B,CAAC,EAbW,yBAAyB,GAAzB,iCAAyB,KAAzB,iCAAyB,QAapC;AAED,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,uCAAW,CAAA;IACX,qCAAS,CAAA;AACX,CAAC,EAHW,wBAAwB,GAAxB,gCAAwB,KAAxB,gCAAwB,QAGnC;AAEY,QAAA,8BAA8B,GAAG,MAAM,CAAC;AACxC,QAAA,cAAc,GAAG,MAAM,CAAC;AACxB,QAAA,iBAAiB,GAAG,MAAM,CAAC;AAExC,MAAa,gBAAgB;;AAA7B,4CA+BC;AA9BiB,yBAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;AAC3D,oBAAG,GAAG,KAAK,CAAC;AACZ,oBAAG,GAAG,KAAK,CAAC;AACZ,mBAAE,GAAG,IAAI,CAAC;AACV,6BAAY,GAAG,cAAc,CAAC;AAC9B,uBAAM,GAAG,WAAW,CAAC;AACrB,6BAAY,GAAG,YAAY,CAAC;AAC5B,0BAAS,GAAG,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,0BAA0B,CAAC,CAAC;AACjE,6BAAY,GAAG,uCAAuC,CAAC;AACvD,uBAAM,GAAG,QAAQ,CAAC;AAClB,4BAAW,GAAG,kBAAkB,CAAC;AACjC,+BAAc,GAAG,8BAA8B,CAAC;AAChD,iCAAgB,GAAG;IACjC,cAAc,EAAE;QACd,QAAQ,EAAE,YAAY;QACtB,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,kBAAkB;KACnC;CACF,CAAC;AACc,uCAAsB,GAAG;IACvC,cAAc,EAAE;QACd,QAAQ,EAAE,YAAY;QACtB,YAAY,EAAE,iBAAiB;QAC/B,cAAc,EAAE,kBAAkB;QAClC,gBAAgB,EAAE,oBAAoB;QACtC,GAAG,EAAE;YACH,qBAAqB,EAAE,yBAAyB;SACjD;KACF;CACF,CAAC;AAGS,QAAA,sBAAsB,GAAe;IAChD,EAAE,EAAE,KAAK;IACT,KAAK,EAAE,aAAa,IAAA,kCAAkB,EAAC,+BAA+B,CAAC,EAAE;IACzE,MAAM,EAAE,IAAA,kCAAkB,EAAC,gCAAgC,CAAC;IAC5D,SAAS,EAAE,IAAA,kCAAkB,EAAC,mCAAmC,CAAC;IAClE,IAAI,EAAE,gCAAgC;IACtC,OAAO,EAAE;QACP;YACE,QAAQ,EAAE,UAAU;YACpB,OAAO,EAAE,IAAA,kCAAkB,EAAC,sBAAsB,CAAC;YACnD,OAAO,EAAE,2BAA2B;SACrC;KACF;CACF,CAAC;AAEF,IAAY,WAIX;AAJD,WAAY,WAAW;IACrB,kDAAmC,CAAA;IACnC,8DAA+C,CAAA;IAC/C,0CAA2B,CAAA;AAC7B,CAAC,EAJW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAItB;AAEY,QAAA,YAAY,GAAG;IAC1B,uBAAuB,EAAE,mBAAmB;CAC7C,CAAC;AAEW,QAAA,iBAAiB,GAAG;IAC/B,wBAAwB,EAAE,0BAA0B;IACpD,oCAAoC,EAAE,sCAAsC;IAC5E,SAAS,EAAE,WAAW;CACvB,CAAC"}
@@ -0,0 +1,25 @@
import { Context, CreateProjectResult, FxError, Inputs, InputsWithProjectPath, Result } from "@microsoft/teamsfx-api";
import { DotenvParseOutput } from "dotenv";
import { ExecutionError, ExecutionOutput } from "../configManager/interface";
import { DriverContext } from "../driver/interface/commonArgs";
import { ActionContext } from "../middleware/actionExecutionMW";
declare class Coordinator {
create(context: Context, inputs: Inputs, actionContext?: ActionContext): Promise<Result<CreateProjectResult, FxError>>;
ensureTeamsFxInCsproj(projectPath: string): Promise<Result<undefined, FxError>>;
ensureTrackingId(projectPath: string, trackingId?: string | undefined): Promise<Result<string, FxError>>;
preProvisionForVS(ctx: DriverContext, inputs: InputsWithProjectPath): Promise<Result<{
needAzureLogin: boolean;
needM365Login: boolean;
resolvedAzureSubscriptionId?: string;
resolvedAzureResourceGroupName?: string;
}, FxError>>;
preCheckYmlAndEnvForVS(ctx: DriverContext, inputs: InputsWithProjectPath): Promise<Result<undefined, FxError>>;
provision(ctx: DriverContext, inputs: InputsWithProjectPath): Promise<Result<DotenvParseOutput, FxError>>;
convertExecuteResult(execRes: Result<ExecutionOutput, ExecutionError>, templatePath: string): [DotenvParseOutput, FxError | undefined];
deploy(ctx: DriverContext, inputs: InputsWithProjectPath): Promise<Result<DotenvParseOutput, FxError>>;
publish(ctx: DriverContext, inputs: InputsWithProjectPath): Promise<Result<DotenvParseOutput, FxError>>;
publishInDeveloperPortal(ctx: Context, inputs: InputsWithProjectPath): Promise<Result<undefined, FxError>>;
}
export declare const coordinator: Coordinator;
export {};
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/component/coordinator/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,OAAO,EACP,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,qBAAqB,EAErB,MAAM,EAGP,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAC;AAiC3C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAc,MAAM,4BAA4B,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAM/D,OAAO,EAAE,aAAa,EAAqB,MAAM,iCAAiC,CAAC;AAqBnF,cAAM,WAAW;IAUT,MAAM,CACV,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;IAkI1C,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAmC/E,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,UAAU,GAAE,MAAM,GAAG,SAAqB,GACzC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAY7B,iBAAiB,CACrB,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CACR,MAAM,CACJ;QACE,cAAc,EAAE,OAAO,CAAC;QACxB,aAAa,EAAE,OAAO,CAAC;QACvB,2BAA2B,CAAC,EAAE,MAAM,CAAC;QACrC,8BAA8B,CAAC,EAAE,MAAM,CAAC;KACzC,EACD,OAAO,CACR,CACF;IAwDK,sBAAsB,CAC1B,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAwBhC,SAAS,CACb,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IAoR9C,oBAAoB,CAClB,OAAO,EAAE,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC,EAChD,YAAY,EAAE,MAAM,GACnB,CAAC,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAC;IA+BrC,MAAM,CACV,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IA+DxC,OAAO,CACX,GAAG,EAAE,aAAa,EAClB,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC;IA0DxC,wBAAwB,CAC5B,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,qBAAqB,GAC5B,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;CA2BvC;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC"}
@@ -0,0 +1,760 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.coordinator = void 0;
const tslib_1 = require("tslib");
const lib_1 = require("@feathersjs/hooks/lib");
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const glob_1 = require("glob");
const jsonschema = tslib_1.__importStar(require("jsonschema"));
const lodash_1 = require("lodash");
const os_1 = require("os");
const path = tslib_1.__importStar(require("path"));
const uuid = tslib_1.__importStar(require("uuid"));
const xml2js = tslib_1.__importStar(require("xml2js"));
const constants_1 = require("../../common/constants");
const featureFlags_1 = require("../../common/featureFlags");
const globalVars_1 = require("../../common/globalVars");
const localizeUtils_1 = require("../../common/localizeUtils");
const stringUtils_1 = require("../../common/stringUtils");
const telemetry_1 = require("../../common/telemetry");
const versionMetadata_1 = require("../../common/versionMetadata");
const environmentName_1 = require("../../core/environmentName");
const azure_1 = require("../../error/azure");
const common_1 = require("../../error/common");
const yml_1 = require("../../error/yml");
const constants_2 = require("../../question/constants");
const constants_3 = require("../constants");
const deployUtils_1 = require("../deployUtils");
const developerPortalScaffoldUtils_1 = require("../developerPortalScaffoldUtils");
const appStudio_1 = require("../driver/teamsApp/appStudio");
const constants_4 = require("../driver/teamsApp/constants");
const ManifestUtils_1 = require("../driver/teamsApp/utils/ManifestUtils");
const generator_1 = require("../generator/generator");
const generatorProvider_1 = require("../generator/generatorProvider");
const actionExecutionMW_1 = require("../middleware/actionExecutionMW");
const provisionUtils_1 = require("../provisionUtils");
const ResourceGroupHelper_1 = require("../utils/ResourceGroupHelper");
const envUtil_1 = require("../utils/envUtil");
const metadataUtil_1 = require("../utils/metadataUtil");
const pathUtils_1 = require("../utils/pathUtils");
const settingsUtil_1 = require("../utils/settingsUtil");
const summary_1 = require("./summary");
const M365Actions = [
"botAadApp/create",
"teamsApp/create",
"teamsApp/update",
"aadApp/create",
"aadApp/update",
"botFramework/create",
"teamsApp/extendToM365",
];
const AzureActions = ["arm/deploy"];
const needTenantCheckActions = ["botAadApp/create", "aadApp/create", "botFramework/create"];
class Coordinator {
async create(context, inputs, actionContext) {
var _a, _b, _c;
// Handle command redirect to Kiota. Only happens in vscode.
if (inputs.platform === teamsfx_api_1.Platform.VSCode &&
featureFlags_1.featureFlagManager.getBooleanValue(featureFlags_1.FeatureFlags.KiotaIntegration) &&
inputs[constants_2.QuestionNames.ApiPluginType] === constants_2.ApiPluginStartOptions.apiSpec().id &&
!inputs[constants_2.QuestionNames.ApiPluginManifestPath] &&
(inputs[constants_2.QuestionNames.Capabilities] === constants_2.CapabilityOptions.apiPlugin().id ||
inputs[constants_2.QuestionNames.Capabilities] === constants_2.CapabilityOptions.declarativeCopilot().id)) {
const lastCommand = inputs[constants_2.QuestionNames.Capabilities] === constants_2.CapabilityOptions.apiPlugin().id
? constants_3.KiotaLastCommands.createPluginWithManifest
: constants_3.KiotaLastCommands.createDeclarativeCopilotWithManifest;
return (0, teamsfx_api_1.ok)({ projectPath: "", lastCommand: lastCommand });
}
let folder = inputs["folder"];
if (!folder) {
return (0, teamsfx_api_1.err)(new common_1.MissingRequiredInputError("folder"));
}
folder = path.resolve(folder);
const scratch = inputs[constants_2.QuestionNames.Scratch];
let projectPath = "";
let warnings = undefined;
if (scratch === constants_2.ScratchOptions.no().id) {
// create from sample
const sampleId = inputs[constants_2.QuestionNames.Samples];
if (!sampleId) {
throw new common_1.MissingRequiredInputError(constants_2.QuestionNames.Samples);
}
projectPath = path.join(folder, sampleId);
let suffix = 1;
while ((await fs_extra_1.default.pathExists(projectPath)) && (await fs_extra_1.default.readdir(projectPath)).length > 0) {
projectPath = path.join(folder, `${sampleId}_${suffix++}`);
}
inputs.projectPath = projectPath;
await fs_extra_1.default.ensureDir(projectPath);
const res = await generator_1.Generator.generateSample(context, projectPath, sampleId);
if (res.isErr())
return (0, teamsfx_api_1.err)(res.error);
downloadSampleHook(sampleId, projectPath);
}
else if (!scratch || scratch === constants_2.ScratchOptions.yes().id) {
// create from new
const appName = inputs[constants_2.QuestionNames.AppName];
if (undefined === appName)
return (0, teamsfx_api_1.err)(new common_1.MissingRequiredInputError(constants_2.QuestionNames.AppName));
const validateResult = jsonschema.validate(appName, {
pattern: constants_2.AppNamePattern,
});
if (validateResult.errors && validateResult.errors.length > 0) {
return (0, teamsfx_api_1.err)(new common_1.InputValidationError(constants_2.QuestionNames.AppName, validateResult.errors[0].message));
}
projectPath = path.join(folder, appName);
inputs.projectPath = projectPath;
await fs_extra_1.default.ensureDir(projectPath);
// set isVS global var when creating project
const language = inputs[constants_2.QuestionNames.ProgrammingLanguage];
globalVars_1.globalVars.isVS = language === "csharp";
const capability = inputs.capabilities;
const projectType = inputs[constants_2.QuestionNames.ProjectType];
delete inputs.folder;
(0, lodash_1.merge)(actionContext === null || actionContext === void 0 ? void 0 : actionContext.telemetryProps, {
[telemetry_1.TelemetryProperty.Capabilities]: capability,
[telemetry_1.TelemetryProperty.IsFromTdp]: (!!inputs.teamsAppFromTdp).toString(),
});
if (projectType === constants_2.ProjectTypeOptions.customCopilot().id ||
(projectType === constants_2.ProjectTypeOptions.bot().id && inputs.platform === teamsfx_api_1.Platform.VS)) {
(0, lodash_1.merge)(actionContext === null || actionContext === void 0 ? void 0 : actionContext.telemetryProps, {
[telemetry_1.TelemetryProperty.CustomCopilotRAG]: (_a = inputs["custom-copilot-rag"]) !== null && _a !== void 0 ? _a : "",
[telemetry_1.TelemetryProperty.CustomCopilotAgent]: (_b = inputs["custom-copilot-agent"]) !== null && _b !== void 0 ? _b : "",
[telemetry_1.TelemetryProperty.LlmService]: (_c = inputs["llm-service"]) !== null && _c !== void 0 ? _c : "",
[telemetry_1.TelemetryProperty.HasAzureOpenAIKey]: inputs["azure-openai-key"] ? "true" : "false",
[telemetry_1.TelemetryProperty.HasAzureOpenAIEndpoint]: inputs["azure-openai-endpoint"]
? "true"
: "false",
[telemetry_1.TelemetryProperty.HasAzureOpenAIDeploymentName]: inputs["azure-openai-deployment-name"]
? "true"
: "false",
[telemetry_1.TelemetryProperty.HasOpenAIKey]: inputs["openai-key"] ? "true" : "false",
});
}
// refactored generator
const generator = generatorProvider_1.Generators.find((g) => g.activate(context, inputs));
if (!generator) {
return (0, teamsfx_api_1.err)(new common_1.MissingRequiredInputError(constants_2.QuestionNames.Capabilities, "coordinator"));
}
const res = await generator.run(context, inputs, projectPath);
if (res.isErr())
return (0, teamsfx_api_1.err)(res.error);
else {
warnings = res.value.warnings;
}
}
// generate unique projectId in teamsapp.yaml (optional)
const ymlPath = path.join(projectPath, versionMetadata_1.MetadataV3.configFile);
if (await fs_extra_1.default.pathExists(ymlPath)) {
const ensureRes = await this.ensureTrackingId(projectPath, inputs.projectId);
if (ensureRes.isErr())
return (0, teamsfx_api_1.err)(ensureRes.error);
inputs.projectId = ensureRes.value;
}
context.projectPath = projectPath;
if (inputs.teamsAppFromTdp) {
const res = await developerPortalScaffoldUtils_1.developerPortalScaffoldUtils.updateFilesForTdp(context, inputs.teamsAppFromTdp, inputs);
if (res.isErr()) {
return (0, teamsfx_api_1.err)(res.error);
}
}
const trimRes = await ManifestUtils_1.manifestUtils.trimManifestShortName(projectPath);
if (trimRes.isErr())
return (0, teamsfx_api_1.err)(trimRes.error);
return (0, teamsfx_api_1.ok)({ projectPath: projectPath, warnings });
}
async ensureTeamsFxInCsproj(projectPath) {
const list = await fs_extra_1.default.readdir(projectPath);
const csprojFiles = list.filter((fileName) => fileName.endsWith(".csproj"));
if (csprojFiles.length === 0)
return (0, teamsfx_api_1.ok)(undefined);
const filePath = csprojFiles[0];
const xmlStringOld = (await fs_extra_1.default.readFile(filePath, { encoding: "utf8" })).toString();
const jsonObj = await xml2js.parseStringPromise(xmlStringOld);
let ItemGroup = jsonObj.Project.ItemGroup;
if (!ItemGroup) {
ItemGroup = [];
jsonObj.Project.ItemGroup = ItemGroup;
}
const existItems = ItemGroup.filter((item) => {
var _a;
if (item.ProjectCapability && item.ProjectCapability[0])
if (((_a = item.ProjectCapability[0]["$"]) === null || _a === void 0 ? void 0 : _a.Include) === "TeamsFx")
return true;
return false;
});
if (existItems.length === 0) {
const toAdd = {
ProjectCapability: [
{
$: {
Include: "TeamsFx",
},
},
],
};
ItemGroup.push(toAdd);
const builder = new xml2js.Builder();
const xmlStringNew = builder.buildObject(jsonObj);
await fs_extra_1.default.writeFile(filePath, xmlStringNew, { encoding: "utf8" });
}
return (0, teamsfx_api_1.ok)(undefined);
}
async ensureTrackingId(projectPath, trackingId = undefined) {
// generate unique trackingId in settings.json
const settingsRes = await settingsUtil_1.settingsUtil.readSettings(projectPath, false);
if (settingsRes.isErr())
return (0, teamsfx_api_1.err)(settingsRes.error);
const settings = settingsRes.value;
if (settings.trackingId && !trackingId)
return (0, teamsfx_api_1.ok)(settings.trackingId); // do nothing
settings.trackingId = trackingId || uuid.v4();
await settingsUtil_1.settingsUtil.writeSettings(projectPath, settings);
return (0, teamsfx_api_1.ok)(settings.trackingId);
}
async preProvisionForVS(ctx, inputs) {
const res = {
needAzureLogin: false,
needM365Login: false,
};
// 1. parse yml to cycles
const templatePath = inputs["workflowFilePath"] || pathUtils_1.pathUtils.getYmlFilePath(ctx.projectPath, inputs.env);
const maybeProjectModel = await metadataUtil_1.metadataUtil.parse(templatePath, inputs.env);
if (maybeProjectModel.isErr()) {
return (0, teamsfx_api_1.err)(maybeProjectModel.error);
}
const projectModel = maybeProjectModel.value;
const cycles = [
projectModel.registerApp,
projectModel.provision,
projectModel.configureApp,
].filter((c) => c !== undefined);
// 2. check each cycle
for (const cycle of cycles) {
const unresolvedPlaceholders = cycle.resolvePlaceholders();
let firstArmDriver;
for (const driver of cycle.driverDefs) {
if (AzureActions.includes(driver.uses)) {
res.needAzureLogin = true;
if (!firstArmDriver) {
firstArmDriver = driver;
}
}
if (M365Actions.includes(driver.uses)) {
res.needM365Login = true;
}
}
if (firstArmDriver) {
const withObj = firstArmDriver.with;
res.resolvedAzureSubscriptionId = unresolvedPlaceholders.includes("AZURE_SUBSCRIPTION_ID")
? undefined
: withObj["subscriptionId"];
res.resolvedAzureResourceGroupName = unresolvedPlaceholders.includes("AZURE_RESOURCE_GROUP_NAME")
? undefined
: withObj["resourceGroupName"];
}
}
return (0, teamsfx_api_1.ok)(res);
}
async preCheckYmlAndEnvForVS(ctx, inputs) {
const templatePath = inputs["workflowFilePath"] || pathUtils_1.pathUtils.getYmlFilePath(ctx.projectPath, inputs.env);
const maybeProjectModel = await metadataUtil_1.metadataUtil.parse(templatePath, inputs.env);
if (maybeProjectModel.isErr()) {
return (0, teamsfx_api_1.err)(maybeProjectModel.error);
}
const projectModel = maybeProjectModel.value;
const cycles = [projectModel.provision].filter((c) => c !== undefined);
let unresolvedPlaceholders = [];
// 2. check each cycle
for (const cycle of cycles) {
unresolvedPlaceholders = unresolvedPlaceholders.concat(cycle.resolvePlaceholders());
}
if (unresolvedPlaceholders.length > 0) {
return (0, teamsfx_api_1.err)(new yml_1.LifeCycleUndefinedError(unresolvedPlaceholders.join(",")));
}
return (0, teamsfx_api_1.ok)(undefined);
}
async provision(ctx, inputs) {
var _a, _b, _c, _d, _e, _f, _g, _h;
const output = {};
if (process.env.APP_NAME_SUFFIX === undefined && process.env.TEAMSFX_ENV) {
process.env.APP_NAME_SUFFIX = process.env.TEAMSFX_ENV;
output.APP_NAME_SUFFIX = process.env.TEAMSFX_ENV;
}
const folderName = path.parse(ctx.projectPath).name;
// 1. parse yml
const templatePath = inputs["workflowFilePath"] || pathUtils_1.pathUtils.getYmlFilePath(ctx.projectPath, inputs.env);
const maybeProjectModel = await metadataUtil_1.metadataUtil.parse(templatePath, inputs.env);
if (maybeProjectModel.isErr()) {
return (0, teamsfx_api_1.err)(maybeProjectModel.error);
}
const projectModel = maybeProjectModel.value;
const cycles = [
// projectModel.registerApp,
projectModel.provision,
// projectModel.configureApp,
].filter((c) => c !== undefined);
if (cycles.length === 0) {
return (0, teamsfx_api_1.err)(new yml_1.LifeCycleUndefinedError("provision"));
}
// 2. M365 sign in and tenant check if needed.
let containsM365 = false;
let containsAzure = false;
const tenantSwitchCheckActions = [];
cycles.forEach((cycle) => {
var _a;
(_a = cycle.driverDefs) === null || _a === void 0 ? void 0 : _a.forEach((def) => {
if (M365Actions.includes(def.uses)) {
containsM365 = true;
}
else if (AzureActions.includes(def.uses)) {
containsAzure = true;
}
if (needTenantCheckActions.includes(def.uses)) {
tenantSwitchCheckActions.push(def.uses);
}
});
});
let m365tenantInfo = undefined;
if (containsM365) {
const tenantInfoInTokenRes = await provisionUtils_1.provisionUtils.getM365TenantId(ctx.m365TokenProvider);
if (tenantInfoInTokenRes.isErr()) {
return (0, teamsfx_api_1.err)(tenantInfoInTokenRes.error);
}
m365tenantInfo = tenantInfoInTokenRes.value;
const checkM365TenatRes = provisionUtils_1.provisionUtils.ensureM365TenantMatchesV3(tenantSwitchCheckActions, m365tenantInfo === null || m365tenantInfo === void 0 ? void 0 : m365tenantInfo.tenantIdInToken);
if (checkM365TenatRes.isErr()) {
return (0, teamsfx_api_1.err)(checkM365TenatRes.error);
}
}
// We will update targetResourceGroupInfo if creating resource group is needed and create the resource group later after confirming with the user
let targetResourceGroupInfo = {
createNewResourceGroup: false,
name: "",
location: "",
};
let resolvedSubscriptionId;
let resolvedResourceGroupName;
let azureSubInfo = undefined;
if (containsAzure) {
//ensure RESOURCE_SUFFIX
if (!process.env.RESOURCE_SUFFIX) {
const suffix = process.env.RESOURCE_SUFFIX || uuid.v4().slice(0, 6);
process.env.RESOURCE_SUFFIX = suffix;
output.RESOURCE_SUFFIX = suffix;
}
// check whether placeholders are resolved
let subscriptionUnresolved = false;
let resourceGroupUnresolved = false;
for (const cycle of cycles) {
const unresolvedPlaceHolders = cycle.resolvePlaceholders();
if (unresolvedPlaceHolders.includes("AZURE_SUBSCRIPTION_ID"))
subscriptionUnresolved = true;
else {
(_a = cycle.driverDefs) === null || _a === void 0 ? void 0 : _a.forEach((driver) => {
const withObj = driver.with;
if (withObj && withObj.subscriptionId && resolvedSubscriptionId === undefined)
resolvedSubscriptionId = withObj.subscriptionId;
});
}
if (unresolvedPlaceHolders.includes("AZURE_RESOURCE_GROUP_NAME"))
resourceGroupUnresolved = true;
else {
(_b = cycle.driverDefs) === null || _b === void 0 ? void 0 : _b.forEach((driver) => {
const withObj = driver.with;
if (withObj && withObj.resourceGroupName && resolvedResourceGroupName === undefined)
resolvedResourceGroupName = withObj.resourceGroupName;
});
}
}
// ensure subscription, pop up UI to select if necessary
if (subscriptionUnresolved) {
if (inputs["targetSubscriptionId"]) {
process.env.AZURE_SUBSCRIPTION_ID = inputs["targetSubscriptionId"];
output.AZURE_SUBSCRIPTION_ID = inputs["targetSubscriptionId"];
}
else {
const ensureRes = await provisionUtils_1.provisionUtils.ensureSubscription(ctx.azureAccountProvider, undefined);
if (ensureRes.isErr())
return (0, teamsfx_api_1.err)(ensureRes.error);
const subInfo = ensureRes.value;
if (subInfo && subInfo.subscriptionId) {
process.env.AZURE_SUBSCRIPTION_ID = subInfo.subscriptionId;
output.AZURE_SUBSCRIPTION_ID = subInfo.subscriptionId;
}
}
resolvedSubscriptionId = process.env.AZURE_SUBSCRIPTION_ID;
}
// ensure resource group
if (resourceGroupUnresolved) {
const inputRG = inputs["targetResourceGroupName"];
const inputLocation = inputs["targetResourceLocationName"];
if (inputRG && inputLocation) {
// targetResourceGroupName is from VS inputs, which means create resource group if not exists
targetResourceGroupInfo.name = inputRG;
targetResourceGroupInfo.location = inputLocation;
targetResourceGroupInfo.createNewResourceGroup = true; // create resource group if not exists
}
else {
const defaultRg = `rg-${(0, stringUtils_1.convertToAlphanumericOnly)(folderName)}${process.env.RESOURCE_SUFFIX}-${inputs.env}`;
const ensureRes = await provisionUtils_1.provisionUtils.ensureResourceGroup(inputs, ctx.azureAccountProvider, resolvedSubscriptionId, undefined, defaultRg);
if (ensureRes.isErr())
return (0, teamsfx_api_1.err)(ensureRes.error);
targetResourceGroupInfo = ensureRes.value;
if (!targetResourceGroupInfo.createNewResourceGroup) {
process.env.AZURE_RESOURCE_GROUP_NAME = targetResourceGroupInfo.name;
output.AZURE_RESOURCE_GROUP_NAME = targetResourceGroupInfo.name;
}
}
resolvedResourceGroupName = targetResourceGroupInfo.name;
}
// consent user
await ctx.azureAccountProvider.getIdentityCredentialAsync(true); // make sure login if ensureSubScription() is not called.
try {
await ctx.azureAccountProvider.setSubscription(resolvedSubscriptionId); //make sure sub is correctly set if ensureSubscription() is not called.
}
catch (e) {
return (0, teamsfx_api_1.err)((0, common_1.assembleError)(e));
}
azureSubInfo = await ctx.azureAccountProvider.getSelectedSubscription(false);
if (!azureSubInfo) {
return (0, teamsfx_api_1.err)(new azure_1.SelectSubscriptionError());
}
const consentRes = await provisionUtils_1.provisionUtils.askForProvisionConsentV3(ctx, m365tenantInfo, azureSubInfo, inputs.env);
if (consentRes.isErr())
return (0, teamsfx_api_1.err)(consentRes.error);
// create resource group if necessary
if (targetResourceGroupInfo.createNewResourceGroup) {
const createRgRes = await ResourceGroupHelper_1.resourceGroupHelper.createNewResourceGroup(targetResourceGroupInfo.name, ctx.azureAccountProvider, resolvedSubscriptionId, targetResourceGroupInfo.location);
if (createRgRes.isErr()) {
const error = createRgRes.error;
if (!(error instanceof azure_1.ResourceGroupConflictError)) {
return (0, teamsfx_api_1.err)(error);
}
}
process.env.AZURE_RESOURCE_GROUP_NAME = targetResourceGroupInfo.name;
output.AZURE_RESOURCE_GROUP_NAME = targetResourceGroupInfo.name;
}
}
// execute
const summaryReporter = new summary_1.SummaryReporter(cycles, ctx.logProvider);
const steps = cycles.reduce((acc, cur) => acc + cur.driverDefs.length, 0);
let hasError = false;
try {
ctx.progressBar = (_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.createProgressBar((0, localizeUtils_1.getLocalizedString)("core.progress.provision"), steps);
await ((_d = ctx.progressBar) === null || _d === void 0 ? void 0 : _d.start());
const maybeDescription = summaryReporter.getLifecycleDescriptions();
if (maybeDescription.isErr()) {
hasError = true;
return (0, teamsfx_api_1.err)(maybeDescription.error);
}
ctx.logProvider.info(`Executing provision ${os_1.EOL}${os_1.EOL}${maybeDescription.value}${os_1.EOL}`);
for (const [index, cycle] of cycles.entries()) {
const execRes = await cycle.execute(ctx);
summaryReporter.updateLifecycleState(index, execRes);
const result = this.convertExecuteResult(execRes.result, templatePath);
(0, lodash_1.merge)(output, result[0]);
if (result[1]) {
hasError = true;
inputs.envVars = output;
return (0, teamsfx_api_1.err)(result[1]);
}
}
}
finally {
const summary = summaryReporter.getLifecycleSummary(inputs.createdEnvFile);
ctx.logProvider.info(`Execution summary:${os_1.EOL}${os_1.EOL}${summary}${os_1.EOL}`);
await ((_e = ctx.progressBar) === null || _e === void 0 ? void 0 : _e.end(!hasError));
}
// show provisioned resources
const msg = (0, localizeUtils_1.getLocalizedString)("core.common.LifecycleComplete.provision", steps, steps);
if (azureSubInfo) {
const url = (0, constants_1.getResourceGroupInPortal)(azureSubInfo.subscriptionId, azureSubInfo.tenantId, resolvedResourceGroupName);
if (url && ctx.platform !== teamsfx_api_1.Platform.CLI) {
const title = (0, localizeUtils_1.getLocalizedString)("core.provision.viewResources");
(_f = ctx.ui) === null || _f === void 0 ? void 0 : _f.showMessage("info", msg, false, title).then((result) => {
var _a;
const userSelected = result.isOk() ? result.value : undefined;
if (userSelected === title) {
(_a = ctx.ui) === null || _a === void 0 ? void 0 : _a.openUrl(url);
}
});
}
else {
if (url && ctx.platform === teamsfx_api_1.Platform.CLI) {
(_g = ctx.ui) === null || _g === void 0 ? void 0 : _g.showMessage("info", [
{
content: `${msg} View the provisioned resources from `,
color: teamsfx_api_1.Colors.BRIGHT_GREEN,
},
{
content: url,
color: teamsfx_api_1.Colors.BRIGHT_CYAN,
},
], false);
}
else {
(_h = ctx.ui) === null || _h === void 0 ? void 0 : _h.showMessage("info", msg, false);
}
}
}
else {
if (ctx.platform === teamsfx_api_1.Platform.VS) {
void ctx.ui.showMessage("info", (0, localizeUtils_1.getLocalizedString)("core.common.LifecycleComplete.prepareTeamsApp"), false);
}
else {
void ctx.ui.showMessage("info", msg, false);
}
}
if (ctx.platform !== teamsfx_api_1.Platform.CLI) {
ctx.logProvider.info(msg);
}
return (0, teamsfx_api_1.ok)(output);
}
convertExecuteResult(execRes, templatePath) {
var _a;
const output = {};
let error = undefined;
if (execRes.isErr()) {
const execError = execRes.error;
if (execError.kind === "Failure") {
error = execError.error;
}
else {
const partialOutput = execError.env;
const newOutput = envUtil_1.envUtil.map2object(partialOutput);
(0, lodash_1.merge)(output, newOutput);
const reason = execError.reason;
if (reason.kind === "DriverError") {
error = reason.error;
}
else if (reason.kind === "UnresolvedPlaceholders") {
const placeholders = ((_a = reason.unresolvedPlaceHolders) === null || _a === void 0 ? void 0 : _a.join(",")) || "";
error = new common_1.MissingEnvironmentVariablesError((0, lodash_1.camelCase)(reason.failedDriver.uses), placeholders, templatePath);
}
}
}
else {
const newOutput = envUtil_1.envUtil.map2object(execRes.value);
(0, lodash_1.merge)(output, newOutput);
}
return [output, error];
}
async deploy(ctx, inputs) {
var _a, _b, _c, _d;
const output = {};
const templatePath = inputs["workflowFilePath"] || pathUtils_1.pathUtils.getYmlFilePath(ctx.projectPath, inputs.env);
const maybeProjectModel = await metadataUtil_1.metadataUtil.parse(templatePath, inputs.env);
if (maybeProjectModel.isErr()) {
return (0, teamsfx_api_1.err)(maybeProjectModel.error);
}
const projectModel = maybeProjectModel.value;
if (projectModel.deploy) {
if (inputs.env !== environmentName_1.environmentNameManager.getLocalEnvName() &&
inputs.env !== environmentName_1.environmentNameManager.getTestToolEnvName()) {
const consent = await deployUtils_1.deployUtils.askForDeployConsentV3(ctx);
if (consent.isErr()) {
return (0, teamsfx_api_1.err)(consent.error);
}
}
const summaryReporter = new summary_1.SummaryReporter([projectModel.deploy], ctx.logProvider);
let hasError = false;
try {
const steps = projectModel.deploy.driverDefs.length;
ctx.progressBar = (_a = ctx.ui) === null || _a === void 0 ? void 0 : _a.createProgressBar((0, localizeUtils_1.getLocalizedString)("core.progress.deploy"), steps);
await ((_b = ctx.progressBar) === null || _b === void 0 ? void 0 : _b.start());
const maybeDescription = summaryReporter.getLifecycleDescriptions();
if (maybeDescription.isErr()) {
return (0, teamsfx_api_1.err)(maybeDescription.error);
}
ctx.logProvider.info(`Executing deploy ${os_1.EOL}${os_1.EOL}${maybeDescription.value}${os_1.EOL}`);
const execRes = await projectModel.deploy.execute(ctx);
summaryReporter.updateLifecycleState(0, execRes);
const result = this.convertExecuteResult(execRes.result, templatePath);
(0, lodash_1.merge)(output, result[0]);
if (result[1]) {
hasError = true;
inputs.envVars = output;
return (0, teamsfx_api_1.err)(result[1]);
}
// show message box after deploy
const botTroubleShootMsg = getBotTroubleShootMessage(false);
const msg = (0, localizeUtils_1.getLocalizedString)("core.common.LifecycleComplete.deploy", steps, steps) +
botTroubleShootMsg.textForLogging;
if (ctx.platform !== teamsfx_api_1.Platform.VS) {
(_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("info", msg, false);
}
}
finally {
const summary = summaryReporter.getLifecycleSummary();
ctx.logProvider.info(`Execution summary:${os_1.EOL}${os_1.EOL}${summary}${os_1.EOL}`);
await ((_d = ctx.progressBar) === null || _d === void 0 ? void 0 : _d.end(!hasError));
}
}
else {
return (0, teamsfx_api_1.err)(new yml_1.LifeCycleUndefinedError("deploy"));
}
return (0, teamsfx_api_1.ok)(output);
}
async publish(ctx, inputs) {
var _a, _b, _c, _d, _e;
const output = {};
const templatePath = pathUtils_1.pathUtils.getYmlFilePath(ctx.projectPath, inputs.env);
const maybeProjectModel = await metadataUtil_1.metadataUtil.parse(templatePath, inputs.env);
if (maybeProjectModel.isErr()) {
return (0, teamsfx_api_1.err)(maybeProjectModel.error);
}
const projectModel = maybeProjectModel.value;
let hasError = false;
if (projectModel.publish) {
const summaryReporter = new summary_1.SummaryReporter([projectModel.publish], ctx.logProvider);
try {
const steps = projectModel.publish.driverDefs.length;
ctx.progressBar = (_a = ctx.ui) === null || _a === void 0 ? void 0 : _a.createProgressBar((0, localizeUtils_1.getLocalizedString)("core.progress.publish"), steps);
await ((_b = ctx.progressBar) === null || _b === void 0 ? void 0 : _b.start());
const maybeDescription = summaryReporter.getLifecycleDescriptions();
if (maybeDescription.isErr()) {
hasError = true;
return (0, teamsfx_api_1.err)(maybeDescription.error);
}
ctx.logProvider.info(`Executing publish ${os_1.EOL}${os_1.EOL}${maybeDescription.value}${os_1.EOL}`);
const execRes = await projectModel.publish.execute(ctx);
const result = this.convertExecuteResult(execRes.result, templatePath);
(0, lodash_1.merge)(output, result[0]);
summaryReporter.updateLifecycleState(0, execRes);
if (result[1]) {
hasError = true;
inputs.envVars = output;
return (0, teamsfx_api_1.err)(result[1]);
}
else {
const msg = (0, localizeUtils_1.getLocalizedString)("core.common.LifecycleComplete.publish", steps, steps);
const adminPortal = (0, localizeUtils_1.getLocalizedString)("plugins.appstudio.adminPortal");
if (ctx.platform !== teamsfx_api_1.Platform.CLI) {
(_c = ctx.ui) === null || _c === void 0 ? void 0 : _c.showMessage("info", msg, false, adminPortal).then((value) => {
if (value.isOk() && value.value === adminPortal) {
void ctx.ui.openUrl(constants_4.Constants.TEAMS_ADMIN_PORTAL);
}
});
}
else {
(_d = ctx.ui) === null || _d === void 0 ? void 0 : _d.showMessage("info", msg, false);
}
}
}
finally {
const summary = summaryReporter.getLifecycleSummary();
ctx.logProvider.info(`Execution summary:${os_1.EOL}${os_1.EOL}${summary}${os_1.EOL}`);
await ((_e = ctx.progressBar) === null || _e === void 0 ? void 0 : _e.end(!hasError));
}
}
else {
return (0, teamsfx_api_1.err)(new yml_1.LifeCycleUndefinedError("publish"));
}
return (0, teamsfx_api_1.ok)(output);
}
async publishInDeveloperPortal(ctx, inputs) {
// update teams app
if (!ctx.tokenProvider) {
return (0, teamsfx_api_1.err)(new common_1.InputValidationError("tokenProvider", "undefined"));
}
if (!inputs[constants_2.QuestionNames.AppPackagePath]) {
return (0, teamsfx_api_1.err)(new common_1.InputValidationError("appPackagePath", "undefined"));
}
const updateRes = await (0, appStudio_1.updateTeamsAppV3ForPublish)(ctx, inputs);
if (updateRes.isErr()) {
return (0, teamsfx_api_1.err)(updateRes.error);
}
let loginHint = "";
const accountRes = await ctx.tokenProvider.m365TokenProvider.getJsonObject({
scopes: constants_1.AppStudioScopes,
});
if (accountRes.isOk()) {
loginHint = accountRes.value.unique_name;
}
await ctx.userInteraction.openUrl(`https://dev.teams.microsoft.com/apps/${updateRes.value}/distributions/app-catalog?login_hint=${loginHint}&referrer=teamstoolkit_${inputs.platform}`);
return (0, teamsfx_api_1.ok)(undefined);
}
}
tslib_1.__decorate([
(0, lib_1.hooks)([
(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" }),
(0, actionExecutionMW_1.ActionExecutionMW)({
enableTelemetry: true,
telemetryEventName: telemetry_1.TelemetryEvent.CreateProject,
telemetryComponentName: "coordinator",
errorSource: constants_3.CoordinatorSource,
}),
]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "create", null);
tslib_1.__decorate([
(0, lib_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" })]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "preProvisionForVS", null);
tslib_1.__decorate([
(0, lib_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" })]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "preCheckYmlAndEnvForVS", null);
tslib_1.__decorate([
(0, lib_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" })]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "provision", null);
tslib_1.__decorate([
(0, lib_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" })]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "deploy", null);
tslib_1.__decorate([
(0, lib_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" })]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "publish", null);
tslib_1.__decorate([
(0, lib_1.hooks)([(0, globalVars_1.ErrorContextMW)({ component: "Coordinator" })]),
tslib_1.__metadata("design:type", Function),
tslib_1.__metadata("design:paramtypes", [Object, Object]),
tslib_1.__metadata("design:returntype", Promise)
], Coordinator.prototype, "publishInDeveloperPortal", null);
exports.coordinator = new Coordinator();
function getBotTroubleShootMessage(isBot) {
const botTroubleShootLink = "https://aka.ms/teamsfx-bot-help#how-can-i-troubleshoot-issues-when-teams-bot-isnt-responding-on-azure";
const botTroubleShootDesc = (0, localizeUtils_1.getLocalizedString)("core.deploy.botTroubleShoot");
const botTroubleShootLearnMore = (0, localizeUtils_1.getLocalizedString)("core.deploy.botTroubleShoot.learnMore");
const botTroubleShootMsg = `${botTroubleShootDesc} ${botTroubleShootLearnMore}: ${botTroubleShootLink}.`;
return {
troubleShootLink: botTroubleShootLink,
textForLogging: isBot ? botTroubleShootMsg : "",
textForMsgBox: botTroubleShootDesc,
textForActionButton: botTroubleShootLearnMore,
};
}
function downloadSampleHook(sampleId, sampleAppPath) {
// A temporary solution to aundefined duplicate componentId
if (sampleId === "todo-list-SPFx") {
const originalId = "c314487b-f51c-474d-823e-a2c3ec82b1ff";
const componentId = uuid.v4();
glob_1.glob.glob(`${sampleAppPath}/**/*.json`, { nodir: true, dot: true }, (err, files) => {
void Promise.all(files.map(async (file) => {
let content = (await fs_extra_1.default.readFile(file)).toString();
const reg = new RegExp(originalId, "g");
content = content.replace(reg, componentId);
await fs_extra_1.default.writeFile(file, content);
}));
});
}
}
//# sourceMappingURL=index.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,23 @@
import { FxError, LogProvider, Result } from "@microsoft/teamsfx-api";
import { ExecutionResult, ILifecycle } from "../configManager/interface";
declare type LifecycleState = {
name: string;
status: "succeeded" | "failed" | "notExecuted";
actionStates: ActionState[];
};
declare type ActionState = {
name: string;
status: "succeeded" | "failed" | "notExecuted";
summaries: string[];
};
export declare class SummaryReporter {
private lifecycles;
lifecycleStates: LifecycleState[];
private log;
constructor(lifecycles: ILifecycle[], log: LogProvider);
getLifecycleDescriptions(): Result<string, FxError>;
updateLifecycleState(index: number, execResult: ExecutionResult): void;
getLifecycleSummary(createdEnvFile?: undefined): string;
}
export {};
//# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../../src/component/coordinator/summary.ts"],"names":[],"mappings":"AAGA,OAAO,EAAW,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAC/E,OAAO,EAAoB,eAAe,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAuC3F,aAAK,cAAc,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC/C,YAAY,EAAE,WAAW,EAAE,CAAC;CAC7B,CAAC;AAoBF,aAAK,WAAW,GAAG;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,GAAG,QAAQ,GAAG,aAAa,CAAC;IAC/C,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AA0GF,qBAAa,eAAe;IAC1B,OAAO,CAAC,UAAU,CAAe;IACjC,eAAe,EAAE,cAAc,EAAE,CAAC;IAClC,OAAO,CAAC,GAAG,CAAc;gBAEb,UAAU,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE,WAAW;IAOtD,wBAAwB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAMnD,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,eAAe,GAAG,IAAI;IAItE,mBAAmB,CAAC,cAAc,YAAY,GAAG,MAAM;CAaxD"}
@@ -0,0 +1,145 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.SummaryReporter = void 0;
const tslib_1 = require("tslib");
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const os_1 = require("os");
const constant_1 = require("../configManager/constant");
const lodash_1 = tslib_1.__importDefault(require("lodash"));
const localizeUtils_1 = require("../../common/localizeUtils");
const indent = " ";
function getActionName(driverDef) {
return driverDef.name ? `${driverDef.uses}(${driverDef.name})` : driverDef.uses;
}
function getDriverDescription(log, lifecycle) {
const n = lifecycle.driverDefs.length;
return lifecycle.resolveDriverInstances(log).map((instances) => {
return instances.map((instance, i) => {
const actionName = getActionName(instance);
const desc = instance.instance.description ? `: ${instance.instance.description}` : "";
return `(${i + 1}/${n}) ${(0, localizeUtils_1.getLocalizedString)("core.summary.actionDescription", actionName, desc)}`;
});
});
}
function getLifecycleDescription(log, lifecycle) {
const n = lifecycle.driverDefs.length;
return getDriverDescription(log, lifecycle).map((descriptions) => {
return (0, localizeUtils_1.getLocalizedString)("core.summary.lifecycleDescription", lifecycle.name, n, `${os_1.EOL}${descriptions.join(os_1.EOL)}`);
});
}
function initLifecycleState(lifecycle) {
return {
name: lifecycle.name,
status: "notExecuted",
actionStates: initActionStates(lifecycle),
};
}
function updateLifecycleState(state, execResult) {
if (execResult.result.isOk()) {
state.status = "succeeded";
}
else {
state.status = "failed";
}
updateActionStates(state.actionStates, execResult);
}
function initActionStates(lifecycle) {
return lifecycle.driverDefs.map((driverDef) => {
return {
name: getActionName(driverDef),
status: "notExecuted",
summaries: [],
};
});
}
function updateActionStates(actionStates, executionResult) {
const { result, summaries } = executionResult;
if (result.isOk()) {
actionStates.forEach((actionState, i) => {
actionState.status = "succeeded";
if (summaries[i]) {
actionState.summaries = summaries[i];
}
});
}
else if (result.isErr()) {
const e = result.error;
if (e.kind === "Failure") {
// just ignore Failure, because we can leave action states as "notExecuted"
}
else if (e.kind === "PartialSuccess") {
const executedActionNum = summaries.length;
actionStates.forEach((actionState, i) => {
if (i < executedActionNum - 1) {
actionState.status = "succeeded";
}
else if (i == executedActionNum - 1) {
actionState.status = "failed";
}
if (summaries[i]) {
actionState.summaries = summaries[i];
}
});
}
}
}
function stringifyLifecycleState(lifecycleState) {
const result = [];
if (lifecycleState.status === "notExecuted") {
result.push((0, localizeUtils_1.getLocalizedString)("core.summary.lifecycleNotExecuted", constant_1.SummaryConstant.NotExecuted, lifecycleState.name));
}
else if (lifecycleState.status === "succeeded") {
result.push((0, localizeUtils_1.getLocalizedString)("core.summary.lifecycleSucceeded", constant_1.SummaryConstant.Succeeded, lifecycleState.name));
}
else if (lifecycleState.status === "failed") {
result.push((0, localizeUtils_1.getLocalizedString)("core.summary.lifecycleFailed", constant_1.SummaryConstant.Failed, lifecycleState.name));
}
for (const actionState of lifecycleState.actionStates) {
if (actionState.status === "notExecuted") {
result.push((0, localizeUtils_1.getLocalizedString)("core.summary.actionNotExecuted", `${indent}${constant_1.SummaryConstant.NotExecuted} ${actionState.name}`));
}
else if (actionState.status === "failed") {
result.push((0, localizeUtils_1.getLocalizedString)("core.summary.actionFailed", `${indent}${constant_1.SummaryConstant.Failed} ${actionState.name}`));
}
else if (actionState.status === "succeeded") {
result.push((0, localizeUtils_1.getLocalizedString)("core.summary.actionSucceeded", `${indent}${constant_1.SummaryConstant.Succeeded} ${actionState.name}`));
}
for (const summary of actionState.summaries) {
if (actionState.status === "notExecuted") {
result.push(`${indent}${indent}${constant_1.SummaryConstant.NotExecuted} ${summary}`);
}
else {
result.push(`${indent}${indent}${summary}`);
}
}
}
return result;
}
class SummaryReporter {
constructor(lifecycles, log) {
this.lifecycles = lifecycles;
this.lifecycleStates = lifecycles.map((lifecycle) => initLifecycleState(lifecycle));
this.log = log;
}
// This method returns a Result, because it could fail due to driver resolution failure.
getLifecycleDescriptions() {
return (0, teamsfx_api_1.combine)(this.lifecycles.map((lifecycle) => getLifecycleDescription(this.log, lifecycle))).map((descriptions) => descriptions.join(os_1.EOL));
}
updateLifecycleState(index, execResult) {
updateLifecycleState(this.lifecycleStates[index], execResult);
}
getLifecycleSummary(createdEnvFile = undefined) {
const summaries = this.lifecycleStates.map((lifecycleState) => {
return stringifyLifecycleState(lifecycleState);
});
const flattened = lodash_1.default.flatten(summaries);
return `Summary:${os_1.EOL}${createdEnvFile
? // eslint-disable-next-line @typescript-eslint/restrict-plus-operands
` ${(0, localizeUtils_1.getLocalizedString)("core.summary.createdEnvFile")} ` + createdEnvFile + os_1.EOL + os_1.EOL
: ""}${flattened.join(os_1.EOL)}`;
}
}
exports.SummaryReporter = SummaryReporter;
//# sourceMappingURL=summary.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
import { FxError, Result, Void } from "@microsoft/teamsfx-api";
import { DriverContext } from "./driver/interface/commonArgs";
declare class DeployUtils {
askForDeployConsentV3(ctx: DriverContext): Promise<Result<Void, FxError>>;
}
export declare const deployUtils: DeployUtils;
export {};
//# sourceMappingURL=deployUtils.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"deployUtils.d.ts","sourceRoot":"","sources":["../../src/component/deployUtils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAO,OAAO,EAAM,MAAM,EAAa,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAGnF,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAE9D,cAAM,WAAW;IACT,qBAAqB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;CAUhF;AACD,eAAO,MAAM,WAAW,aAAoB,CAAC"}
+23
View File
@@ -0,0 +1,23 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.deployUtils = void 0;
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const localizeUtils_1 = require("../common/localizeUtils");
const constants_1 = require("./constants");
class DeployUtils {
async askForDeployConsentV3(ctx) {
var _a;
const msg = (0, localizeUtils_1.getLocalizedString)("core.deploy.confirmEnvNoticeV3", process.env.TEAMSFX_ENV);
const deployOption = (0, localizeUtils_1.getLocalizedString)("core.option.deploy");
const result = await ((_a = ctx.ui) === null || _a === void 0 ? void 0 : _a.showMessage("warn", msg, true, deployOption));
const choice = (result === null || result === void 0 ? void 0 : result.isOk()) ? result.value : undefined;
if (choice === deployOption) {
return (0, teamsfx_api_1.ok)(teamsfx_api_1.Void);
}
return (0, teamsfx_api_1.err)(new teamsfx_api_1.UserError(constants_1.SolutionSource, "UserCancel", "UserCancel"));
}
}
exports.deployUtils = new DeployUtils();
//# sourceMappingURL=deployUtils.js.map
@@ -0,0 +1 @@
{"version":3,"file":"deployUtils.js","sourceRoot":"","sources":["../../src/component/deployUtils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,wDAAmF;AACnF,2DAA6D;AAC7D,2CAA6C;AAG7C,MAAM,WAAW;IACf,KAAK,CAAC,qBAAqB,CAAC,GAAkB;;QAC5C,MAAM,GAAG,GAAG,IAAA,kCAAkB,EAAC,gCAAgC,EAAE,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC1F,MAAM,YAAY,GAAG,IAAA,kCAAkB,EAAC,oBAAoB,CAAC,CAAC;QAC9D,MAAM,MAAM,GAAG,MAAM,CAAA,MAAA,GAAG,CAAC,EAAE,0CAAE,WAAW,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,YAAY,CAAC,CAAA,CAAC;QAC1E,MAAM,MAAM,GAAG,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,EAAE,EAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;QACzD,IAAI,MAAM,KAAK,YAAY,EAAE;YAC3B,OAAO,IAAA,gBAAE,EAAC,kBAAI,CAAC,CAAC;SACjB;QACD,OAAO,IAAA,iBAAG,EAAC,IAAI,uBAAS,CAAC,0BAAc,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAC;IACxE,CAAC;CACF;AACY,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC"}
@@ -0,0 +1,7 @@
import { DepsChecker, DepsType } from "./depsChecker";
import { DepsLogger } from "./depsLogger";
import { DepsTelemetry } from "./depsTelemetry";
export declare class CheckerFactory {
static createChecker(type: DepsType, logger: DepsLogger, telemetry: DepsTelemetry): DepsChecker;
}
//# sourceMappingURL=checkerFactory.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"checkerFactory.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/checkerFactory.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAOhD,qBAAa,cAAc;WACX,aAAa,CACzB,IAAI,EAAE,QAAQ,EACd,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,aAAa,GACvB,WAAW;CAkBf"}
@@ -0,0 +1,33 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckerFactory = void 0;
const depsChecker_1 = require("./depsChecker");
const dotnetChecker_1 = require("./internal/dotnetChecker");
const funcToolChecker_1 = require("./internal/funcToolChecker");
const nodeChecker_1 = require("./internal/nodeChecker");
const testToolChecker_1 = require("./internal/testToolChecker");
const vxTestAppChecker_1 = require("./internal/vxTestAppChecker");
class CheckerFactory {
static createChecker(type, logger, telemetry) {
switch (type) {
case depsChecker_1.DepsType.ProjectNode:
return new nodeChecker_1.ProjectNodeChecker(logger, telemetry);
case depsChecker_1.DepsType.LtsNode:
return new nodeChecker_1.LtsNodeChecker(logger, telemetry);
case depsChecker_1.DepsType.Dotnet:
return new dotnetChecker_1.DotnetChecker(logger, telemetry);
case depsChecker_1.DepsType.FuncCoreTools:
return new funcToolChecker_1.FuncToolChecker(logger, telemetry);
case depsChecker_1.DepsType.VxTestApp:
return new vxTestAppChecker_1.VxTestAppChecker(logger, telemetry);
case depsChecker_1.DepsType.TestTool:
return new testToolChecker_1.TestToolChecker();
default:
throw Error("dependency type is undefined");
}
}
}
exports.CheckerFactory = CheckerFactory;
//# sourceMappingURL=checkerFactory.js.map
@@ -0,0 +1 @@
{"version":3,"file":"checkerFactory.js","sourceRoot":"","sources":["../../../src/component/deps-checker/checkerFactory.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,+CAAsD;AAGtD,4DAAyD;AACzD,gEAA6D;AAC7D,wDAA4E;AAC5E,gEAA6D;AAC7D,kEAA+D;AAE/D,MAAa,cAAc;IAClB,MAAM,CAAC,aAAa,CACzB,IAAc,EACd,MAAkB,EAClB,SAAwB;QAExB,QAAQ,IAAI,EAAE;YACZ,KAAK,sBAAQ,CAAC,WAAW;gBACvB,OAAO,IAAI,gCAAkB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YACnD,KAAK,sBAAQ,CAAC,OAAO;gBACnB,OAAO,IAAI,4BAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAC/C,KAAK,sBAAQ,CAAC,MAAM;gBAClB,OAAO,IAAI,6BAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAC9C,KAAK,sBAAQ,CAAC,aAAa;gBACzB,OAAO,IAAI,iCAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YAChD,KAAK,sBAAQ,CAAC,SAAS;gBACrB,OAAO,IAAI,mCAAgB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;YACjD,KAAK,sBAAQ,CAAC,QAAQ;gBACpB,OAAO,IAAI,iCAAe,EAAE,CAAC;YAC/B;gBACE,MAAM,KAAK,CAAC,8BAA8B,CAAC,CAAC;SAC/C;IACH,CAAC;CACF;AAvBD,wCAuBC"}
@@ -0,0 +1,11 @@
export declare const v3DefaultHelpLink = "https://aka.ms/teamsfx-actions/devtool-install";
export declare const functionDepsVersionsLink = "https://aka.ms/functions-node-versions";
export declare const nodeNotFoundHelpLink = "https://aka.ms/teamsfx-node";
export declare const nodeInstallationLink = "https://nodejs.org";
export declare const dotnetDefaultHelpLink = "https://aka.ms/teamsfx-actions/devtool-install";
export declare const dotnetExplanationHelpLink = "https://aka.ms/teamsfx-actions/devtool-install";
export declare const dotnetFailToInstallHelpLink = "https://aka.ms/teamsfx-actions/devtool-install";
export declare const v3NodeNotFoundHelpLink = "https://aka.ms/teamsfx-node";
export declare const v3NodeNotSupportedHelpLink = "https://aka.ms/teamsfx-node";
export declare const v3NodeNotLtsHelpLink = "https://aka.ms/teamsfx-node";
//# sourceMappingURL=helpLink.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"helpLink.d.ts","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/helpLink.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,iBAAiB,mDAAmD,CAAC;AAElF,eAAO,MAAM,wBAAwB,2CAA2C,CAAC;AAGjF,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAClE,eAAO,MAAM,oBAAoB,uBAAuB,CAAC;AAEzD,eAAO,MAAM,qBAAqB,mDAAmD,CAAC;AACtF,eAAO,MAAM,yBAAyB,mDAAwB,CAAC;AAC/D,eAAO,MAAM,2BAA2B,mDAAwB,CAAC;AAEjE,eAAO,MAAM,sBAAsB,gCAAgC,CAAC;AACpE,eAAO,MAAM,0BAA0B,gCAAgC,CAAC;AACxE,eAAO,MAAM,oBAAoB,gCAAgC,CAAC"}
@@ -0,0 +1,17 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.v3NodeNotLtsHelpLink = exports.v3NodeNotSupportedHelpLink = exports.v3NodeNotFoundHelpLink = exports.dotnetFailToInstallHelpLink = exports.dotnetExplanationHelpLink = exports.dotnetDefaultHelpLink = exports.nodeInstallationLink = exports.nodeNotFoundHelpLink = exports.functionDepsVersionsLink = exports.v3DefaultHelpLink = void 0;
exports.v3DefaultHelpLink = "https://aka.ms/teamsfx-actions/devtool-install";
exports.functionDepsVersionsLink = "https://aka.ms/functions-node-versions";
// TODO: remove this link after clean the useless code.
exports.nodeNotFoundHelpLink = `https://aka.ms/teamsfx-node`;
exports.nodeInstallationLink = "https://nodejs.org";
exports.dotnetDefaultHelpLink = "https://aka.ms/teamsfx-actions/devtool-install";
exports.dotnetExplanationHelpLink = exports.dotnetDefaultHelpLink;
exports.dotnetFailToInstallHelpLink = exports.dotnetDefaultHelpLink;
exports.v3NodeNotFoundHelpLink = "https://aka.ms/teamsfx-node";
exports.v3NodeNotSupportedHelpLink = "https://aka.ms/teamsfx-node";
exports.v3NodeNotLtsHelpLink = "https://aka.ms/teamsfx-node";
//# sourceMappingURL=helpLink.js.map
@@ -0,0 +1 @@
{"version":3,"file":"helpLink.js","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/helpLink.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAErB,QAAA,iBAAiB,GAAG,gDAAgD,CAAC;AAErE,QAAA,wBAAwB,GAAG,wCAAwC,CAAC;AAEjF,uDAAuD;AAC1C,QAAA,oBAAoB,GAAG,6BAA6B,CAAC;AACrD,QAAA,oBAAoB,GAAG,oBAAoB,CAAC;AAE5C,QAAA,qBAAqB,GAAG,gDAAgD,CAAC;AACzE,QAAA,yBAAyB,GAAG,6BAAqB,CAAC;AAClD,QAAA,2BAA2B,GAAG,6BAAqB,CAAC;AAEpD,QAAA,sBAAsB,GAAG,6BAA6B,CAAC;AACvD,QAAA,0BAA0B,GAAG,6BAA6B,CAAC;AAC3D,QAAA,oBAAoB,GAAG,6BAA6B,CAAC"}
@@ -0,0 +1,4 @@
export * from "./helpLink";
export * from "./message";
export * from "./telemetry";
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/index.ts"],"names":[],"mappings":"AAIA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./helpLink"), exports);
tslib_1.__exportStar(require("./message"), exports);
tslib_1.__exportStar(require("./telemetry"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAEb,qDAA2B;AAC3B,oDAA0B;AAC1B,sDAA4B"}
@@ -0,0 +1,22 @@
export declare const Messages: {
needInstallNpm: () => string;
failToValidateFuncCoreTool: () => string;
portableFuncNodeNotMatched: (nodeVersion: string, funcVersion: string) => string;
symlinkDirAlreadyExist: (linkFilePath: string) => string;
invalidFuncVersion: (version: string) => string;
noSentinelFile: () => string;
funcVersionNotMatch: (funcVersion: string, expectedFuncVersion: string) => string;
downloadDotnet: () => string;
finishInstallDotnet: () => string;
useGlobalDotnet: () => string;
dotnetInstallStderr: () => string;
dotnetInstallErrorCode: () => string;
dotnetNotFound: () => string;
testToolVersionNotMatch: (version: string, expectedVersion: string) => string;
failToValidateTestTool: (errorMessage: string) => string;
failToValidateVxTestAppInstallOptions: () => string;
failToValidateVxTestApp: () => string;
failToDownloadFromUrl: () => string;
linuxDepsNotFound: () => string;
};
//# sourceMappingURL=message.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/message.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,QAAQ;;;8CAGuB,MAAM,eAAe,MAAM;2CAI9B,MAAM;kCAEf,MAAM;;uCAGD,MAAM,uBAAuB,MAAM;;;;;;;uCAYnC,MAAM,mBAAmB,MAAM;2CAE3B,MAAM;;;;;CAU9C,CAAC"}
@@ -0,0 +1,31 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.Messages = void 0;
const localizeUtils_1 = require("../../../common/localizeUtils");
exports.Messages = {
needInstallNpm: () => (0, localizeUtils_1.getLocalizedString)("depChecker.needInstallNpm"),
failToValidateFuncCoreTool: () => (0, localizeUtils_1.getLocalizedString)("depChecker.failToValidateFuncCoreTool"),
portableFuncNodeNotMatched: (nodeVersion, funcVersion) => (0, localizeUtils_1.getLocalizedString)("depChecker.portableFuncNodeNotMatched")
.replace("@NodeVersion", nodeVersion)
.replace("@FuncVersion", funcVersion),
symlinkDirAlreadyExist: (linkFilePath) => (0, localizeUtils_1.getLocalizedString)("depChecker.symlinkDirAlreadyExist", linkFilePath),
invalidFuncVersion: (version) => (0, localizeUtils_1.getLocalizedString)("depChecker.invalidFuncVersion", version),
noSentinelFile: () => (0, localizeUtils_1.getLocalizedString)("depChecker.noSentinelFile"),
funcVersionNotMatch: (funcVersion, expectedFuncVersion) => (0, localizeUtils_1.getLocalizedString)("depChecker.funcVersionNotMatch", funcVersion, expectedFuncVersion),
downloadDotnet: () => (0, localizeUtils_1.getLocalizedString)("depChecker.downloadDotnet"),
finishInstallDotnet: () => (0, localizeUtils_1.getLocalizedString)("depChecker.finishInstallDotnet"),
useGlobalDotnet: () => (0, localizeUtils_1.getLocalizedString)("depChecker.useGlobalDotnet"),
dotnetInstallStderr: () => (0, localizeUtils_1.getLocalizedString)("depChecker.dotnetInstallStderr"),
dotnetInstallErrorCode: () => (0, localizeUtils_1.getLocalizedString)("depChecker.dotnetInstallErrorCode"),
dotnetNotFound: () => (0, localizeUtils_1.getLocalizedString)("depChecker.dotnetNotFound"),
// depsNotFound: () => getLocalizedString("depChecker.depsNotFound"),
testToolVersionNotMatch: (version, expectedVersion) => (0, localizeUtils_1.getLocalizedString)("depChecker.testToolVersionNotMatch", version, expectedVersion),
failToValidateTestTool: (errorMessage) => (0, localizeUtils_1.getLocalizedString)("depChecker.failedToValidateTestTool", errorMessage),
failToValidateVxTestAppInstallOptions: () => (0, localizeUtils_1.getLocalizedString)("depChecker.failToValidateVxTestAppInstallOptions"),
failToValidateVxTestApp: () => (0, localizeUtils_1.getLocalizedString)("depChecker.failToValidateVxTestApp"),
failToDownloadFromUrl: () => (0, localizeUtils_1.getLocalizedString)("depChecker.failToDownloadFromUrl"),
linuxDepsNotFound: () => (0, localizeUtils_1.getLocalizedString)("depChecker.linuxDepsNotFound"),
};
//# sourceMappingURL=message.js.map
@@ -0,0 +1 @@
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/message.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,iEAAqF;AAGxE,QAAA,QAAQ,GAAG;IACtB,cAAc,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,2BAA2B,CAAC;IACrE,0BAA0B,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,uCAAuC,CAAC;IAC7F,0BAA0B,EAAE,CAAC,WAAmB,EAAE,WAAmB,EAAE,EAAE,CACvE,IAAA,kCAAkB,EAAC,uCAAuC,CAAC;SACxD,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC;SACpC,OAAO,CAAC,cAAc,EAAE,WAAW,CAAC;IACzC,sBAAsB,EAAE,CAAC,YAAoB,EAAE,EAAE,CAC/C,IAAA,kCAAkB,EAAC,mCAAmC,EAAE,YAAY,CAAC;IACvE,kBAAkB,EAAE,CAAC,OAAe,EAAE,EAAE,CACtC,IAAA,kCAAkB,EAAC,+BAA+B,EAAE,OAAO,CAAC;IAC9D,cAAc,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,2BAA2B,CAAC;IACrE,mBAAmB,EAAE,CAAC,WAAmB,EAAE,mBAA2B,EAAE,EAAE,CACxE,IAAA,kCAAkB,EAAC,gCAAgC,EAAE,WAAW,EAAE,mBAAmB,CAAC;IAExF,cAAc,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,2BAA2B,CAAC;IACrE,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,gCAAgC,CAAC;IAC/E,eAAe,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,4BAA4B,CAAC;IACvE,mBAAmB,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,gCAAgC,CAAC;IAC/E,sBAAsB,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,mCAAmC,CAAC;IAErF,cAAc,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,2BAA2B,CAAC;IACrE,qEAAqE;IAErE,uBAAuB,EAAE,CAAC,OAAe,EAAE,eAAuB,EAAE,EAAE,CACpE,IAAA,kCAAkB,EAAC,oCAAoC,EAAE,OAAO,EAAE,eAAe,CAAC;IACpF,sBAAsB,EAAE,CAAC,YAAoB,EAAE,EAAE,CAC/C,IAAA,kCAAkB,EAAC,qCAAqC,EAAE,YAAY,CAAC;IAEzE,qCAAqC,EAAE,GAAG,EAAE,CAC1C,IAAA,kCAAkB,EAAC,kDAAkD,CAAC;IACxE,uBAAuB,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,oCAAoC,CAAC;IAEvF,qBAAqB,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,kCAAkC,CAAC;IAEnF,iBAAiB,EAAE,GAAG,EAAE,CAAC,IAAA,kCAAkB,EAAC,8BAA8B,CAAC;CAC5E,CAAC"}
@@ -0,0 +1,48 @@
export declare enum DepsCheckerEvent {
nodeVersion = "node-version",
nodeNotFound = "node-not-found",
nodeNotSupportedForProject = "node-not-supported-for-project",
nodeNotLts = "node-not-lts",
dotnetCheckSkipped = "dotnet-check-skipped",
dotnetAlreadyInstalled = "dotnet-already-installed",
dotnetInstallCompleted = "dotnet-install-completed",
dotnetInstallError = "dotnet-install-error",
dotnetInstallScriptCompleted = "dotnet-install-script-completed",
dotnetInstallScriptError = "dotnet-install-script-error",
dotnetValidationError = "dotnet-validation-error",
dotnetSearchDotnetSdks = "dotnet-search-dotnet-sdks"
}
export declare enum TelemtryMessages {
failedToExecDotnetScript = "failed to exec dotnet script.",
failedToValidateDotnet = "failed to validate dotnet.",
failedToSearchDotnetSdks = "failed to search dotnet sdks."
}
export declare enum TelemetryProperties {
SymlinkFuncVersion = "symlink-func-version",
SelectedPortableFuncVersion = "selected-portable-func-version",
HistoryFuncVersion = "history-func-version",
VersioningFuncVersions = "versioning-func-versions",
GlobalFuncVersion = "global-func-version",
InstalledFuncVersion = "installed-func-version",
SymlinkFuncVersionError = "symlink-func-version-error",
HistoryFuncVersionError = "history-func-version-error",
VersioningFuncVersionError = "versioning-func-version-error",
GlobalFuncVersionError = "global-func-version-error",
InstallFuncError = "install-func-error",
InstalledTestToolVersion = "installed-test-tool-version",
InstallTestToolError = "install-test-tool-error",
InstallTestToolReleaseType = "install-test-tool-release-type",
SymlinkTestToolVersion = "symlink-test-tool-version",
SymlinkTestToolVersionError = "symlink-test-tool-version-error",
SelectedPortableTestToolVersion = "selected-test-tool-version",
VersioningTestToolVersionError = "versioning-test-tool-version-error",
GlobalTestToolVersion = "global-test-tool-version",
GlobalTestToolVersionError = "global-test-tool-version-error",
TestToolLastUpdateTimestamp = "test-tool-last-update-timestamp",
TestToolUpdatePreviousVersion = "test-tool-update-previous-version",
TestToolUpdateError = "test-tool-update-error"
}
export declare enum TelemetryMessurement {
completionTime = "completion-time"
}
//# sourceMappingURL=telemetry.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/telemetry.ts"],"names":[],"mappings":"AAGA,oBAAY,gBAAgB;IAC1B,WAAW,iBAAiB;IAC5B,YAAY,mBAAmB;IAC/B,0BAA0B,mCAAmC;IAC7D,UAAU,iBAAiB;IAE3B,kBAAkB,yBAAyB;IAC3C,sBAAsB,6BAA6B;IACnD,sBAAsB,6BAA6B;IACnD,kBAAkB,yBAAyB;IAC3C,4BAA4B,oCAAoC;IAChE,wBAAwB,gCAAgC;IACxD,qBAAqB,4BAA4B;IACjD,sBAAsB,8BAA8B;CACrD;AAED,oBAAY,gBAAgB;IAC1B,wBAAwB,kCAAkC;IAC1D,sBAAsB,+BAA+B;IACrD,wBAAwB,kCAAkC;CAC3D;AAED,oBAAY,mBAAmB;IAC7B,kBAAkB,yBAAyB;IAC3C,2BAA2B,mCAAmC;IAC9D,kBAAkB,yBAAyB;IAC3C,sBAAsB,6BAA6B;IACnD,iBAAiB,wBAAwB;IACzC,oBAAoB,2BAA2B;IAC/C,uBAAuB,+BAA+B;IACtD,uBAAuB,+BAA+B;IACtD,0BAA0B,kCAAkC;IAC5D,sBAAsB,8BAA8B;IACpD,gBAAgB,uBAAuB;IAEvC,wBAAwB,gCAAgC;IACxD,oBAAoB,4BAA4B;IAChD,0BAA0B,mCAAmC;IAC7D,sBAAsB,8BAA8B;IACpD,2BAA2B,oCAAoC;IAC/D,+BAA+B,+BAA+B;IAC9D,8BAA8B,uCAAuC;IACrE,qBAAqB,6BAA6B;IAClD,0BAA0B,mCAAmC;IAC7D,2BAA2B,oCAAoC;IAC/D,6BAA6B,sCAAsC;IACnE,mBAAmB,2BAA2B;CAC/C;AAED,oBAAY,oBAAoB;IAC9B,cAAc,oBAAoB;CACnC"}
@@ -0,0 +1,57 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TelemetryMessurement = exports.TelemetryProperties = exports.TelemtryMessages = exports.DepsCheckerEvent = void 0;
var DepsCheckerEvent;
(function (DepsCheckerEvent) {
DepsCheckerEvent["nodeVersion"] = "node-version";
DepsCheckerEvent["nodeNotFound"] = "node-not-found";
DepsCheckerEvent["nodeNotSupportedForProject"] = "node-not-supported-for-project";
DepsCheckerEvent["nodeNotLts"] = "node-not-lts";
DepsCheckerEvent["dotnetCheckSkipped"] = "dotnet-check-skipped";
DepsCheckerEvent["dotnetAlreadyInstalled"] = "dotnet-already-installed";
DepsCheckerEvent["dotnetInstallCompleted"] = "dotnet-install-completed";
DepsCheckerEvent["dotnetInstallError"] = "dotnet-install-error";
DepsCheckerEvent["dotnetInstallScriptCompleted"] = "dotnet-install-script-completed";
DepsCheckerEvent["dotnetInstallScriptError"] = "dotnet-install-script-error";
DepsCheckerEvent["dotnetValidationError"] = "dotnet-validation-error";
DepsCheckerEvent["dotnetSearchDotnetSdks"] = "dotnet-search-dotnet-sdks";
})(DepsCheckerEvent = exports.DepsCheckerEvent || (exports.DepsCheckerEvent = {}));
var TelemtryMessages;
(function (TelemtryMessages) {
TelemtryMessages["failedToExecDotnetScript"] = "failed to exec dotnet script.";
TelemtryMessages["failedToValidateDotnet"] = "failed to validate dotnet.";
TelemtryMessages["failedToSearchDotnetSdks"] = "failed to search dotnet sdks.";
})(TelemtryMessages = exports.TelemtryMessages || (exports.TelemtryMessages = {}));
var TelemetryProperties;
(function (TelemetryProperties) {
TelemetryProperties["SymlinkFuncVersion"] = "symlink-func-version";
TelemetryProperties["SelectedPortableFuncVersion"] = "selected-portable-func-version";
TelemetryProperties["HistoryFuncVersion"] = "history-func-version";
TelemetryProperties["VersioningFuncVersions"] = "versioning-func-versions";
TelemetryProperties["GlobalFuncVersion"] = "global-func-version";
TelemetryProperties["InstalledFuncVersion"] = "installed-func-version";
TelemetryProperties["SymlinkFuncVersionError"] = "symlink-func-version-error";
TelemetryProperties["HistoryFuncVersionError"] = "history-func-version-error";
TelemetryProperties["VersioningFuncVersionError"] = "versioning-func-version-error";
TelemetryProperties["GlobalFuncVersionError"] = "global-func-version-error";
TelemetryProperties["InstallFuncError"] = "install-func-error";
TelemetryProperties["InstalledTestToolVersion"] = "installed-test-tool-version";
TelemetryProperties["InstallTestToolError"] = "install-test-tool-error";
TelemetryProperties["InstallTestToolReleaseType"] = "install-test-tool-release-type";
TelemetryProperties["SymlinkTestToolVersion"] = "symlink-test-tool-version";
TelemetryProperties["SymlinkTestToolVersionError"] = "symlink-test-tool-version-error";
TelemetryProperties["SelectedPortableTestToolVersion"] = "selected-test-tool-version";
TelemetryProperties["VersioningTestToolVersionError"] = "versioning-test-tool-version-error";
TelemetryProperties["GlobalTestToolVersion"] = "global-test-tool-version";
TelemetryProperties["GlobalTestToolVersionError"] = "global-test-tool-version-error";
TelemetryProperties["TestToolLastUpdateTimestamp"] = "test-tool-last-update-timestamp";
TelemetryProperties["TestToolUpdatePreviousVersion"] = "test-tool-update-previous-version";
TelemetryProperties["TestToolUpdateError"] = "test-tool-update-error";
})(TelemetryProperties = exports.TelemetryProperties || (exports.TelemetryProperties = {}));
var TelemetryMessurement;
(function (TelemetryMessurement) {
TelemetryMessurement["completionTime"] = "completion-time";
})(TelemetryMessurement = exports.TelemetryMessurement || (exports.TelemetryMessurement = {}));
//# sourceMappingURL=telemetry.js.map
@@ -0,0 +1 @@
{"version":3,"file":"telemetry.js","sourceRoot":"","sources":["../../../../src/component/deps-checker/constant/telemetry.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,IAAY,gBAcX;AAdD,WAAY,gBAAgB;IAC1B,gDAA4B,CAAA;IAC5B,mDAA+B,CAAA;IAC/B,iFAA6D,CAAA;IAC7D,+CAA2B,CAAA;IAE3B,+DAA2C,CAAA;IAC3C,uEAAmD,CAAA;IACnD,uEAAmD,CAAA;IACnD,+DAA2C,CAAA;IAC3C,oFAAgE,CAAA;IAChE,4EAAwD,CAAA;IACxD,qEAAiD,CAAA;IACjD,wEAAoD,CAAA;AACtD,CAAC,EAdW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAc3B;AAED,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,8EAA0D,CAAA;IAC1D,yEAAqD,CAAA;IACrD,8EAA0D,CAAA;AAC5D,CAAC,EAJW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAI3B;AAED,IAAY,mBAyBX;AAzBD,WAAY,mBAAmB;IAC7B,kEAA2C,CAAA;IAC3C,qFAA8D,CAAA;IAC9D,kEAA2C,CAAA;IAC3C,0EAAmD,CAAA;IACnD,gEAAyC,CAAA;IACzC,sEAA+C,CAAA;IAC/C,6EAAsD,CAAA;IACtD,6EAAsD,CAAA;IACtD,mFAA4D,CAAA;IAC5D,2EAAoD,CAAA;IACpD,8DAAuC,CAAA;IAEvC,+EAAwD,CAAA;IACxD,uEAAgD,CAAA;IAChD,oFAA6D,CAAA;IAC7D,2EAAoD,CAAA;IACpD,sFAA+D,CAAA;IAC/D,qFAA8D,CAAA;IAC9D,4FAAqE,CAAA;IACrE,yEAAkD,CAAA;IAClD,oFAA6D,CAAA;IAC7D,sFAA+D,CAAA;IAC/D,0FAAmE,CAAA;IACnE,qEAA8C,CAAA;AAChD,CAAC,EAzBW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAyB9B;AAED,IAAY,oBAEX;AAFD,WAAY,oBAAoB;IAC9B,0DAAkC,CAAA;AACpC,CAAC,EAFW,oBAAoB,GAApB,4BAAoB,KAApB,4BAAoB,QAE/B"}
@@ -0,0 +1,17 @@
import { LogProvider } from "@microsoft/teamsfx-api";
import { DepsLogger } from "./depsLogger";
export declare class CoreDepsLoggerAdapter implements DepsLogger {
private detailLogLines;
private logProvider;
constructor(logProvider: LogProvider);
debug(message: string): void;
info(message: string): void;
warning(message: string): void;
error(message: string): void;
appendLine(message: string): void;
append(message: string): void;
cleanup(): void;
printDetailLog(): void;
private addToDetailCache;
}
//# sourceMappingURL=coreDepsLoggerAdapter.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"coreDepsLoggerAdapter.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/coreDepsLoggerAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAY,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,qBAAsB,YAAW,UAAU;IACtD,OAAO,CAAC,cAAc,CAAgB;IACtC,OAAO,CAAC,WAAW,CAAc;gBAEd,WAAW,EAAE,WAAW;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK3B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK9B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK5B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIjC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI7B,OAAO,IAAI,IAAI;IAIf,cAAc,IAAI,IAAI;IAI7B,OAAO,CAAC,gBAAgB;CAIzB"}
@@ -0,0 +1,47 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreDepsLoggerAdapter = void 0;
const tslib_1 = require("tslib");
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const os_1 = tslib_1.__importDefault(require("os"));
class CoreDepsLoggerAdapter {
constructor(logProvider) {
this.detailLogLines = [];
this.logProvider = logProvider;
}
debug(message) {
this.addToDetailCache(teamsfx_api_1.LogLevel.Debug, message);
}
info(message) {
this.addToDetailCache(teamsfx_api_1.LogLevel.Info, message);
this.logProvider.info(message);
}
warning(message) {
this.addToDetailCache(teamsfx_api_1.LogLevel.Warning, message);
this.logProvider.warning(message);
}
error(message) {
this.addToDetailCache(teamsfx_api_1.LogLevel.Error, message);
this.logProvider.error(message);
}
appendLine(message) {
this.logProvider.log(teamsfx_api_1.LogLevel.Info, message);
}
append(message) {
this.logProvider.log(teamsfx_api_1.LogLevel.Info, message);
}
cleanup() {
this.detailLogLines = [];
}
printDetailLog() {
this.logProvider.error(this.detailLogLines.join(os_1.default.EOL));
}
addToDetailCache(level, message) {
const line = `${String(teamsfx_api_1.LogLevel[level])} ${new Date().toISOString()}: ${message}`;
this.detailLogLines.push(line);
}
}
exports.CoreDepsLoggerAdapter = CoreDepsLoggerAdapter;
//# sourceMappingURL=coreDepsLoggerAdapter.js.map
@@ -0,0 +1 @@
{"version":3,"file":"coreDepsLoggerAdapter.js","sourceRoot":"","sources":["../../../src/component/deps-checker/coreDepsLoggerAdapter.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,wDAA+D;AAC/D,oDAAoB;AAGpB,MAAa,qBAAqB;IAIhC,YAAmB,WAAwB;QAHnC,mBAAc,GAAa,EAAE,CAAC;QAIpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEM,KAAK,CAAC,OAAe;QAC1B,IAAI,CAAC,gBAAgB,CAAC,sBAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAEM,IAAI,CAAC,OAAe;QACzB,IAAI,CAAC,gBAAgB,CAAC,sBAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC9C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAEM,OAAO,CAAC,OAAe;QAC5B,IAAI,CAAC,gBAAgB,CAAC,sBAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAEM,KAAK,CAAC,OAAe;QAC1B,IAAI,CAAC,gBAAgB,CAAC,sBAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC/C,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IAEM,UAAU,CAAC,OAAe;QAC/B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,sBAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEM,MAAM,CAAC,OAAe;QAC3B,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,sBAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;IAC3B,CAAC;IAEM,cAAc;QACnB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,YAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3D,CAAC;IAEO,gBAAgB,CAAC,KAAe,EAAE,OAAe;QACvD,MAAM,IAAI,GAAG,GAAG,MAAM,CAAC,sBAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,OAAO,EAAE,CAAC;QAClF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;CACF;AA/CD,sDA+CC"}
@@ -0,0 +1,16 @@
import { DepsTelemetry } from "./depsTelemetry";
import { TelemetryReporter } from "@microsoft/teamsfx-api";
import { DepsCheckerEvent } from "./constant";
export declare class CoreDepsTelemetryAdapter implements DepsTelemetry {
private readonly _telemetryComponentType;
private readonly _telemetryReporter;
constructor(telemetryReporter: TelemetryReporter);
sendEvent(eventName: DepsCheckerEvent, properties?: {
[key: string]: string;
}, timecost?: number): void;
sendEventWithDuration(eventName: DepsCheckerEvent, action: () => Promise<void>): Promise<void>;
sendUserErrorEvent(eventName: DepsCheckerEvent, errorMessage: string): void;
sendSystemErrorEvent(eventName: DepsCheckerEvent, errorMessage: string, errorStack: string): void;
private addCommonProps;
}
//# sourceMappingURL=coreDepsTelemetryAdapter.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"coreDepsTelemetryAdapter.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/coreDepsTelemetryAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAe,iBAAiB,EAAa,MAAM,wBAAwB,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAwB,MAAM,YAAY,CAAC;AAIpE,qBAAa,wBAAyB,YAAW,aAAa;IAC5D,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA2B;IACnE,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAoB;gBAE3C,iBAAiB,EAAE,iBAAiB;IAIzC,SAAS,CACd,SAAS,EAAE,gBAAgB,EAC3B,UAAU,GAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAO,EAC1C,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAWM,qBAAqB,CAChC,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC1B,OAAO,CAAC,IAAI,CAAC;IAQT,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAU3E,oBAAoB,CACzB,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,IAAI;IAeP,OAAO,CAAC,cAAc;CAMvB"}
@@ -0,0 +1,53 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.CoreDepsTelemetryAdapter = void 0;
const tslib_1 = require("tslib");
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const os_1 = tslib_1.__importDefault(require("os"));
const constant_1 = require("./constant");
const telemetry_1 = require("../../common/telemetry");
const common_1 = require("../utils/depsChecker/common");
class CoreDepsTelemetryAdapter {
constructor(telemetryReporter) {
this._telemetryComponentType = "core:debug:envchecker";
this._telemetryReporter = telemetryReporter;
}
sendEvent(eventName, properties = {}, timecost) {
this.addCommonProps(properties);
const measurements = {};
if (timecost) {
measurements[constant_1.TelemetryMessurement.completionTime] = timecost;
}
this._telemetryReporter.sendTelemetryEvent(eventName, properties, measurements);
}
async sendEventWithDuration(eventName, action) {
const start = performance.now();
await action();
// use seconds instead of milliseconds
const timecost = Number(((performance.now() - start) / 1000).toFixed(2));
this.sendEvent(eventName, {}, timecost);
}
sendUserErrorEvent(eventName, errorMessage) {
const properties = {};
const error = new teamsfx_api_1.UserError(this._telemetryComponentType, eventName, errorMessage);
telemetry_1.telemetryUtils.fillInErrorProperties(properties, error);
this._telemetryReporter.sendTelemetryErrorEvent(eventName, Object.assign(Object.assign({}, this.addCommonProps()), properties));
}
sendSystemErrorEvent(eventName, errorMessage, errorStack) {
const properties = {};
const error = new teamsfx_api_1.SystemError(this._telemetryComponentType, eventName, `errorMsg=${errorMessage},errorStack=${errorStack}`);
error.stack = errorStack;
telemetry_1.telemetryUtils.fillInErrorProperties(properties, error);
this._telemetryReporter.sendTelemetryErrorEvent(eventName, Object.assign(Object.assign({}, this.addCommonProps()), properties));
}
addCommonProps(properties = {}) {
properties[common_1.TelemetryMeasurement.OSArch] = os_1.default.arch();
properties[common_1.TelemetryMeasurement.OSRelease] = os_1.default.release();
properties[telemetry_1.TelemetryProperty.Component] = this._telemetryComponentType;
return properties;
}
}
exports.CoreDepsTelemetryAdapter = CoreDepsTelemetryAdapter;
//# sourceMappingURL=coreDepsTelemetryAdapter.js.map
@@ -0,0 +1 @@
{"version":3,"file":"coreDepsTelemetryAdapter.js","sourceRoot":"","sources":["../../../src/component/deps-checker/coreDepsTelemetryAdapter.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAGlC,wDAAmF;AACnF,oDAAoB;AACpB,yCAAoE;AACpE,sDAA2E;AAC3E,wDAAmE;AAEnE,MAAa,wBAAwB;IAInC,YAAY,iBAAoC;QAH/B,4BAAuB,GAAG,uBAAuB,CAAC;QAIjE,IAAI,CAAC,kBAAkB,GAAG,iBAAiB,CAAC;IAC9C,CAAC;IAEM,SAAS,CACd,SAA2B,EAC3B,aAAwC,EAAE,EAC1C,QAAiB;QAEjB,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QAChC,MAAM,YAAY,GAA4B,EAAE,CAAC;QAEjD,IAAI,QAAQ,EAAE;YACZ,YAAY,CAAC,+BAAoB,CAAC,cAAc,CAAC,GAAG,QAAQ,CAAC;SAC9D;QAED,IAAI,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAChC,SAA2B,EAC3B,MAA2B;QAE3B,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;QAChC,MAAM,MAAM,EAAE,CAAC;QACf,sCAAsC;QACtC,MAAM,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAEM,kBAAkB,CAAC,SAA2B,EAAE,YAAoB;QACzE,MAAM,UAAU,GAA8B,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,uBAAS,CAAC,IAAI,CAAC,uBAAuB,EAAE,SAAS,EAAE,YAAY,CAAC,CAAC;QACnF,0BAAc,CAAC,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,SAAS,kCACpD,IAAI,CAAC,cAAc,EAAE,GACrB,UAAU,EACb,CAAC;IACL,CAAC;IAEM,oBAAoB,CACzB,SAA2B,EAC3B,YAAoB,EACpB,UAAkB;QAElB,MAAM,UAAU,GAA8B,EAAE,CAAC;QACjD,MAAM,KAAK,GAAG,IAAI,yBAAW,CAC3B,IAAI,CAAC,uBAAuB,EAC5B,SAAS,EACT,YAAY,YAAY,eAAe,UAAU,EAAE,CACpD,CAAC;QACF,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC;QACzB,0BAAc,CAAC,qBAAqB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACxD,IAAI,CAAC,kBAAkB,CAAC,uBAAuB,CAAC,SAAS,kCACpD,IAAI,CAAC,cAAc,EAAE,GACrB,UAAU,EACb,CAAC;IACL,CAAC;IAEO,cAAc,CAAC,aAAwC,EAAE;QAC/D,UAAU,CAAC,6BAAoB,CAAC,MAAM,CAAC,GAAG,YAAE,CAAC,IAAI,EAAE,CAAC;QACpD,UAAU,CAAC,6BAAoB,CAAC,SAAS,CAAC,GAAG,YAAE,CAAC,OAAO,EAAE,CAAC;QAC1D,UAAU,CAAC,6BAAiB,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,uBAAuB,CAAC;QACvE,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AArED,4DAqEC"}
@@ -0,0 +1,58 @@
import { UserError } from "@microsoft/teamsfx-api";
export interface DepsChecker {
getInstallationInfo(installOptions?: InstallOptions): Promise<DependencyStatus>;
resolve(installOptions?: InstallOptions): Promise<DependencyStatus>;
}
export declare type DependencyStatus = {
name: string;
type: DepsType;
isInstalled: boolean;
command: string;
details: {
isLinuxSupported: boolean;
supportedVersions: string[];
installVersion?: string;
binFolders?: string[];
};
telemetryProperties?: {
[key: string]: string;
};
error?: UserError;
};
export interface DepsInfo {
name: string;
isLinuxSupported: boolean;
installVersion?: string;
supportedVersions: string[];
binFolders?: string[];
details: Map<string, string>;
}
export declare enum DepsType {
LtsNode = "lts-node",
ProjectNode = "project-node",
Dotnet = "dotnet",
FuncCoreTools = "func-core-tools",
TestTool = "test-tool",
VxTestApp = "vx-test-app"
}
export interface BaseInstallOptions {
projectPath?: string;
version?: string;
}
export interface FuncInstallOptions {
symlinkDir?: string;
projectPath: string;
version: string;
}
export interface TestToolInstallOptions {
releaseType: TestToolReleaseType;
symlinkDir?: string;
projectPath: string;
versionRange: string;
}
export declare enum TestToolReleaseType {
Npm = "npm",
Binary = "binary"
}
export declare type InstallOptions = BaseInstallOptions | FuncInstallOptions | TestToolInstallOptions;
//# sourceMappingURL=depsChecker.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"depsChecker.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/depsChecker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,mBAAmB,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAEhF,OAAO,CAAC,cAAc,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CACrE;AAED,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE;QACP,gBAAgB,EAAE,OAAO,CAAC;QAC1B,iBAAiB,EAAE,MAAM,EAAE,CAAC;QAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;KACvB,CAAC;IACF,mBAAmB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAChD,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,oBAAY,QAAQ;IAClB,OAAO,aAAa;IACpB,WAAW,iBAAiB;IAC5B,MAAM,WAAW;IACjB,aAAa,oBAAoB;IACjC,QAAQ,cAAc;IACtB,SAAS,gBAAgB;CAC1B;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,mBAAmB,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,oBAAY,mBAAmB;IAC7B,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,oBAAY,cAAc,GAAG,kBAAkB,GAAG,kBAAkB,GAAG,sBAAsB,CAAC"}
@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TestToolReleaseType = exports.DepsType = void 0;
var DepsType;
(function (DepsType) {
DepsType["LtsNode"] = "lts-node";
DepsType["ProjectNode"] = "project-node";
DepsType["Dotnet"] = "dotnet";
DepsType["FuncCoreTools"] = "func-core-tools";
DepsType["TestTool"] = "test-tool";
DepsType["VxTestApp"] = "vx-test-app";
})(DepsType = exports.DepsType || (exports.DepsType = {}));
var TestToolReleaseType;
(function (TestToolReleaseType) {
TestToolReleaseType["Npm"] = "npm";
TestToolReleaseType["Binary"] = "binary";
})(TestToolReleaseType = exports.TestToolReleaseType || (exports.TestToolReleaseType = {}));
//# sourceMappingURL=depsChecker.js.map
@@ -0,0 +1 @@
{"version":3,"file":"depsChecker.js","sourceRoot":"","sources":["../../../src/component/deps-checker/depsChecker.ts"],"names":[],"mappings":";;;AAkCA,IAAY,QAOX;AAPD,WAAY,QAAQ;IAClB,gCAAoB,CAAA;IACpB,wCAA4B,CAAA;IAC5B,6BAAiB,CAAA;IACjB,6CAAiC,CAAA;IACjC,kCAAsB,CAAA;IACtB,qCAAyB,CAAA;AAC3B,CAAC,EAPW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAOnB;AAoBD,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,kCAAW,CAAA;IACX,wCAAiB,CAAA;AACnB,CAAC,EAHW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAG9B"}
@@ -0,0 +1,21 @@
export interface DepsLogger {
debug(message: string): void;
info(message: string): void;
warning(message: string): void;
error(message: string): void;
append(message: string): void;
appendLine(message: string): void;
printDetailLog(): void;
cleanup(): void;
}
export declare class EmptyLogger implements DepsLogger {
append(message: string): void;
appendLine(message: string): void;
cleanup(): void;
debug(message: string): void;
error(message: string): void;
info(message: string): void;
printDetailLog(): void;
warning(message: string): void;
}
//# sourceMappingURL=depsLogger.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"depsLogger.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/depsLogger.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE/B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAElC,cAAc,IAAI,IAAI,CAAC;IAEvB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,qBAAa,WAAY,YAAW,UAAU;IAC5C,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAE7B,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAEjC,OAAO,IAAI,IAAI;IAEf,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAE5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAE5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAE3B,cAAc,IAAI,IAAI;IAEtB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAC/B"}
@@ -0,0 +1,17 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyLogger = void 0;
class EmptyLogger {
append(message) { }
appendLine(message) { }
cleanup() { }
debug(message) { }
error(message) { }
info(message) { }
printDetailLog() { }
warning(message) { }
}
exports.EmptyLogger = EmptyLogger;
//# sourceMappingURL=depsLogger.js.map
@@ -0,0 +1 @@
{"version":3,"file":"depsLogger.js","sourceRoot":"","sources":["../../../src/component/deps-checker/depsLogger.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAoBlC,MAAa,WAAW;IACtB,MAAM,CAAC,OAAe,IAAS,CAAC;IAEhC,UAAU,CAAC,OAAe,IAAS,CAAC;IAEpC,OAAO,KAAU,CAAC;IAElB,KAAK,CAAC,OAAe,IAAS,CAAC;IAE/B,KAAK,CAAC,OAAe,IAAS,CAAC;IAE/B,IAAI,CAAC,OAAe,IAAS,CAAC;IAE9B,cAAc,KAAU,CAAC;IAEzB,OAAO,CAAC,OAAe,IAAS,CAAC;CAClC;AAhBD,kCAgBC"}
@@ -0,0 +1,32 @@
import { DepsLogger } from "./depsLogger";
import { DepsTelemetry } from "./depsTelemetry";
import { DependencyStatus, DepsType, InstallOptions } from "./depsChecker";
export declare type DepsOptions = {
fastFail?: boolean;
doctor?: boolean;
};
export declare class DepsManager {
private static readonly depsOrders;
private readonly logger;
private readonly emptyLogger;
private readonly telemetry;
constructor(logger: DepsLogger, telemetry: DepsTelemetry);
/**
* Ensure dependencies installed.
* Installation Orders:
* Node, Dotnet, FuncCoreTools, Ngrok
* @param dependencies Dependency types. If it is empty, do nothing.
* @param options If fastFail is false, it will continue even if one of the dependencies fails to install. Default value is true.
*/
ensureDependencies(dependencies: DepsType[], { fastFail, doctor }: DepsOptions): Promise<DependencyStatus[]>;
ensureDependency(depsType: DepsType, doctor?: boolean, options?: InstallOptions): Promise<DependencyStatus>;
/**
* @deprecated
* Get status without installOptions. Only used in legacy code.
*/
getStatus(depsTypes: DepsType[]): Promise<DependencyStatus[]>;
getStatusWithInstallOptions(depsType: DepsType, options: InstallOptions): Promise<DependencyStatus>;
private resolve;
static sortBySequence(dependencies: DepsType[]): DepsType[];
}
//# sourceMappingURL=depsManager.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"depsManager.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/depsManager.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAe,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAGxF,oBAAY,WAAW,GAAG;IACxB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAIhC;IAEF,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAa;IACpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAgB;gBAE9B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa;IAaxD;;;;;;OAMG;IACU,kBAAkB,CAC7B,YAAY,EAAE,QAAQ,EAAE,EACxB,EAAE,QAAe,EAAE,MAAc,EAAE,EAAE,WAAW,GAC/C,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAmBjB,gBAAgB,CAC3B,QAAQ,EAAE,QAAQ,EAClB,MAAM,UAAQ,EACd,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,gBAAgB,CAAC;IAI5B;;;OAGG;IACU,SAAS,CAAC,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAW7D,2BAA2B,CACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,cAAc,GACtB,OAAO,CAAC,gBAAgB,CAAC;YAId,OAAO;WAmBP,cAAc,CAAC,YAAY,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE;CAKnE"}
@@ -0,0 +1,85 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DepsManager = void 0;
const depsLogger_1 = require("./depsLogger");
const depsChecker_1 = require("./depsChecker");
const checkerFactory_1 = require("./checkerFactory");
class DepsManager {
constructor(logger, telemetry) {
if (!logger) {
throw Error("Logger is undefined.");
}
if (!telemetry) {
throw Error("Logger is undefined.");
}
this.logger = logger;
this.telemetry = telemetry;
this.emptyLogger = new depsLogger_1.EmptyLogger();
}
/**
* Ensure dependencies installed.
* Installation Orders:
* Node, Dotnet, FuncCoreTools, Ngrok
* @param dependencies Dependency types. If it is empty, do nothing.
* @param options If fastFail is false, it will continue even if one of the dependencies fails to install. Default value is true.
*/
async ensureDependencies(dependencies, { fastFail = true, doctor = false }) {
if (!dependencies || dependencies.length == 0) {
return [];
}
const orderedDeps = DepsManager.sortBySequence(dependencies);
const result = [];
let shouldInstall = true;
for (const type of orderedDeps) {
const status = await this.resolve(type, shouldInstall, doctor);
result.push(status);
if (fastFail && !status.isInstalled) {
shouldInstall = false;
}
}
return result;
}
async ensureDependency(depsType, doctor = false, options) {
return await this.resolve(depsType, true, doctor, options);
}
/**
* @deprecated
* Get status without installOptions. Only used in legacy code.
*/
async getStatus(depsTypes) {
if (!depsTypes || depsTypes.length == 0) {
return [];
}
const result = [];
for (const dep of depsTypes) {
result.push(await this.resolve(dep, false));
}
return result;
}
async getStatusWithInstallOptions(depsType, options) {
return await this.resolve(depsType, false, undefined, options);
}
async resolve(depsType, shouldInstall, doctor = false, installOptions) {
const checker = checkerFactory_1.CheckerFactory.createChecker(depsType, doctor ? this.emptyLogger : this.logger, this.telemetry);
if (shouldInstall) {
return await checker.resolve(installOptions);
}
else {
return await checker.getInstallationInfo(installOptions);
}
}
static sortBySequence(dependencies) {
return dependencies
.filter((value) => value != null)
.sort((a, b) => DepsManager.depsOrders.indexOf(a) - DepsManager.depsOrders.indexOf(b));
}
}
exports.DepsManager = DepsManager;
DepsManager.depsOrders = [
depsChecker_1.DepsType.Dotnet,
depsChecker_1.DepsType.FuncCoreTools,
depsChecker_1.DepsType.VxTestApp,
];
//# sourceMappingURL=depsManager.js.map
@@ -0,0 +1 @@
{"version":3,"file":"depsManager.js","sourceRoot":"","sources":["../../../src/component/deps-checker/depsManager.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,18 @@
import { DepsCheckerEvent } from "./constant/telemetry";
export interface DepsTelemetry {
sendEvent(eventName: DepsCheckerEvent, properties?: {
[p: string]: string;
}, timecost?: number): void;
sendEventWithDuration(eventName: DepsCheckerEvent, action: () => Promise<void>): Promise<void>;
sendUserErrorEvent(eventName: DepsCheckerEvent, errorMessage: string): void;
sendSystemErrorEvent(eventName: DepsCheckerEvent, errorMessage: string, errorStack: string): void;
}
export declare class EmptyTelemetry implements DepsTelemetry {
sendEvent(eventName: DepsCheckerEvent, properties?: {
[p: string]: string;
}, timecost?: number): void;
sendEventWithDuration(eventName: DepsCheckerEvent, action: () => Promise<void>): Promise<void>;
sendUserErrorEvent(eventName: DepsCheckerEvent, errorMessage: string): void;
sendSystemErrorEvent(eventName: DepsCheckerEvent, errorMessage: string, errorStack: string): void;
}
//# sourceMappingURL=depsTelemetry.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"depsTelemetry.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/depsTelemetry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,MAAM,WAAW,aAAa;IAC5B,SAAS,CACP,SAAS,EAAE,gBAAgB,EAC3B,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EACpC,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,CAAC;IAER,qBAAqB,CAAC,SAAS,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/F,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5E,oBAAoB,CAAC,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CACnG;AAED,qBAAa,cAAe,YAAW,aAAa;IAClD,SAAS,CACP,SAAS,EAAE,gBAAgB,EAC3B,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EACpC,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IACD,qBAAqB,CACzB,SAAS,EAAE,gBAAgB,EAC3B,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC1B,OAAO,CAAC,IAAI,CAAC;IAGhB,kBAAkB,CAAC,SAAS,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;IAC3E,oBAAoB,CAClB,SAAS,EAAE,gBAAgB,EAC3B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GACjB,IAAI;CACR"}
@@ -0,0 +1,15 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.EmptyTelemetry = void 0;
class EmptyTelemetry {
sendEvent(eventName, properties, timecost) { }
async sendEventWithDuration(eventName, action) {
return await action();
}
sendUserErrorEvent(eventName, errorMessage) { }
sendSystemErrorEvent(eventName, errorMessage, errorStack) { }
}
exports.EmptyTelemetry = EmptyTelemetry;
//# sourceMappingURL=depsTelemetry.js.map
@@ -0,0 +1 @@
{"version":3,"file":"depsTelemetry.js","sourceRoot":"","sources":["../../../src/component/deps-checker/depsTelemetry.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAkBlC,MAAa,cAAc;IACzB,SAAS,CACP,SAA2B,EAC3B,UAAoC,EACpC,QAAiB,IACV,CAAC;IACV,KAAK,CAAC,qBAAqB,CACzB,SAA2B,EAC3B,MAA2B;QAE3B,OAAO,MAAM,MAAM,EAAE,CAAC;IACxB,CAAC;IACD,kBAAkB,CAAC,SAA2B,EAAE,YAAoB,IAAS,CAAC;IAC9E,oBAAoB,CAClB,SAA2B,EAC3B,YAAoB,EACpB,UAAkB,IACX,CAAC;CACX;AAlBD,wCAkBC"}
@@ -0,0 +1,10 @@
export * from "./checkerFactory";
export * from "./depsChecker";
export * from "./depsLogger";
export * from "./depsManager";
export * from "./depsTelemetry";
export * from "./constant";
export * from "./util";
export * from "./coreDepsLoggerAdapter";
export * from "./coreDepsTelemetryAdapter";
//# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/component/deps-checker/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC"}
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./checkerFactory"), exports);
tslib_1.__exportStar(require("./depsChecker"), exports);
tslib_1.__exportStar(require("./depsLogger"), exports);
tslib_1.__exportStar(require("./depsManager"), exports);
tslib_1.__exportStar(require("./depsTelemetry"), exports);
tslib_1.__exportStar(require("./constant"), exports);
tslib_1.__exportStar(require("./util"), exports);
tslib_1.__exportStar(require("./coreDepsLoggerAdapter"), exports);
tslib_1.__exportStar(require("./coreDepsTelemetryAdapter"), exports);
//# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/component/deps-checker/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;AAEb,2DAAiC;AACjC,wDAA8B;AAC9B,uDAA6B;AAC7B,wDAA8B;AAC9B,0DAAgC;AAChC,qDAA2B;AAC3B,iDAAuB;AACvB,kEAAwC;AACxC,qEAA2C"}
@@ -0,0 +1,49 @@
import { UserError } from "@microsoft/teamsfx-api";
import { DependencyStatus, DepsChecker } from "../depsChecker";
import { DepsLogger } from "../depsLogger";
import { DepsTelemetry } from "../depsTelemetry";
export declare enum DotnetVersion {
v21 = "2.1",
v31 = "3.1",
v50 = "5.0",
v60 = "6.0"
}
export declare class DotnetChecker implements DepsChecker {
private static encoding;
private static timeout;
private static maxBuffer;
private readonly _logger;
private readonly _telemetry;
constructor(logger: DepsLogger, telemetry: DepsTelemetry);
getDepsInfo(isInstalled: boolean, error?: UserError): Promise<DependencyStatus>;
getInstallationInfo(): Promise<DependencyStatus>;
resolve(): Promise<DependencyStatus>;
install(): Promise<void>;
command(): Promise<string>;
static escapeFilePath(path: string): string;
private static getDotnetConfigPath;
private getDotnetExecPathFromConfig;
private handleInstall;
private static persistDotnetExecPath;
private handleLinuxDependency;
private static cleanup;
private runDotnetInstallScript;
private isDotnetInstalledCorrectly;
private isDotnetVersionsInstalled;
private static arrayIntersection;
private static isPrivateInstall;
private getGlobalDotnetSdks;
private searchDotnetSdks;
private static isFullSdkVersion;
private static getDotnetExecPathFromDotnetInstallationDir;
private getDotnetInstallScriptPath;
getResourceDir(): string;
private getDotnetInstallScriptName;
private static getDefaultInstallPath;
private getInstallCommand;
private validate;
private validateWithHelloWorld;
private tryAcquireGlobalDotnetSdk;
private static parseDotnetVersion;
}
//# sourceMappingURL=dotnetChecker.d.ts.map
@@ -0,0 +1 @@
{"version":3,"file":"dotnetChecker.d.ts","sourceRoot":"","sources":["../../../../src/component/deps-checker/internal/dotnetChecker.ts"],"names":[],"mappings":"AAGA,OAAO,EAAoB,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAarE,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAY,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAOjD,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,GAAG,QAAQ;CACZ;AAOD,qBAAa,aAAc,YAAW,WAAW;IAC/C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAW;IAClC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAiB;IACvC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAc;IAEtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;gBAE/B,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa;IAK3C,WAAW,CAAC,WAAW,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAiB/E,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC;IA6BhD,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC;IAuBpC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAwCxB,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC;WAKzB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYlD,OAAO,CAAC,MAAM,CAAC,mBAAmB;YAIpB,2BAA2B;YAgB3B,aAAa;mBAyBN,qBAAqB;YAc5B,qBAAqB;mBAId,OAAO;YAMd,sBAAsB;YAgEtB,0BAA0B;IAsBxC,OAAO,CAAC,yBAAyB;IAejC,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAIhC,OAAO,CAAC,MAAM,CAAC,gBAAgB;YAOjB,mBAAmB;YAKnB,gBAAgB;IA+C9B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B,OAAO,CAAC,MAAM,CAAC,0CAA0C;IAIzD,OAAO,CAAC,0BAA0B;IAI3B,cAAc,IAAI,MAAM;IAI/B,OAAO,CAAC,0BAA0B;IAIlC,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAIpC,OAAO,CAAC,iBAAiB;YA+BX,QAAQ;YAUR,sBAAsB;YAkDtB,yBAAyB;IAsBvC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAQlC"}
@@ -0,0 +1,413 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
Object.defineProperty(exports, "__esModule", { value: true });
exports.DotnetChecker = exports.DotnetVersion = void 0;
const tslib_1 = require("tslib");
const teamsfx_api_1 = require("@microsoft/teamsfx-api");
const child_process = tslib_1.__importStar(require("child_process"));
const fs = tslib_1.__importStar(require("fs-extra"));
const os = tslib_1.__importStar(require("os"));
const path = tslib_1.__importStar(require("path"));
const perf_hooks_1 = require("perf_hooks");
const util = tslib_1.__importStar(require("util"));
const localizeUtils_1 = require("../../../common/localizeUtils");
const error_1 = require("../../../error");
const folder_1 = require("../../../folder");
const helpLink_1 = require("../constant/helpLink");
const message_1 = require("../constant/message");
const telemetry_1 = require("../constant/telemetry");
const depsChecker_1 = require("../depsChecker");
const cpUtils_1 = require("../util/cpUtils");
const progressIndicator_1 = require("../util/progressIndicator");
const system_1 = require("../util/system");
const execFile = util.promisify(child_process.execFile);
var DotnetVersion;
(function (DotnetVersion) {
DotnetVersion["v21"] = "2.1";
DotnetVersion["v31"] = "3.1";
DotnetVersion["v50"] = "5.0";
DotnetVersion["v60"] = "6.0";
})(DotnetVersion = exports.DotnetVersion || (exports.DotnetVersion = {}));
const DotnetCoreSDKName = ".NET Core SDK";
const installVersion = (0, system_1.isMacOS)() && (0, system_1.isArm64)() ? DotnetVersion.v60 : DotnetVersion.v31;
const supportedVersions = [DotnetVersion.v31, DotnetVersion.v50, DotnetVersion.v60];
const installedNameWithVersion = `${DotnetCoreSDKName} (v${DotnetVersion.v31})`;
class DotnetChecker {
constructor(logger, telemetry) {
this._logger = logger;
this._telemetry = telemetry;
}
async getDepsInfo(isInstalled, error) {
const execPath = await this.getDotnetExecPathFromConfig();
return {
name: DotnetCoreSDKName,
type: depsChecker_1.DepsType.Dotnet,
isInstalled: isInstalled,
command: await this.command(),
details: {
isLinuxSupported: false,
installVersion: `${installVersion}`,
supportedVersions: supportedVersions,
binFolders: execPath ? [execPath] : undefined,
},
error: error,
};
}
async getInstallationInfo() {
const configPath = DotnetChecker.getDotnetConfigPath();
this._logger.debug(`[start] read dotnet path from '${configPath}'`);
const dotnetPath = await this.getDotnetExecPathFromConfig();
this._logger.debug(`[end] read dotnet path from '${configPath}', dotnetPath = '${dotnetPath || ""}'`);
this._logger.debug(`[start] check dotnet version`);
if (dotnetPath !== null && (await this.isDotnetInstalledCorrectly())) {
// filter out global sdk
if (dotnetPath.includes(`.${teamsfx_api_1.ConfigFolderName}`)) {
this._telemetry.sendEvent(telemetry_1.DepsCheckerEvent.dotnetInstallCompleted);
}
return await this.getDepsInfo(true);
}
this._logger.debug(`[end] check dotnet version`);
if ((await this.tryAcquireGlobalDotnetSdk()) && (await this.validate())) {
this._telemetry.sendEvent(telemetry_1.DepsCheckerEvent.dotnetAlreadyInstalled);
this._logger.info(`${message_1.Messages.useGlobalDotnet()} '${(await this.getDotnetExecPathFromConfig()) || ""}'`);
return await this.getDepsInfo(true);
}
return await this.getDepsInfo(false);
}
async resolve() {
try {
let installationInfo = await this.getInstallationInfo();
if (!installationInfo.isInstalled) {
await this.install();
installationInfo = await this.getInstallationInfo();
}
return installationInfo;
}
catch (error) {
this._logger.printDetailLog();
this._logger.error(`${error.message}, error = '${error.toString()}'`);
if (error instanceof teamsfx_api_1.UserError) {
return await this.getDepsInfo(false, error);
}
return await this.getDepsInfo(false, new error_1.DepsCheckerError(error.message, helpLink_1.dotnetFailToInstallHelpLink));
}
finally {
this._logger.cleanup();
}
}
async install() {
if ((0, system_1.isLinux)()) {
throw new error_1.InstallSoftwareError(installedNameWithVersion, helpLink_1.dotnetExplanationHelpLink);
}
this._logger.debug(`[start] cleanup bin/dotnet and config`);
await DotnetChecker.cleanup();
this._logger.debug(`[end] cleanup bin/dotnet and config`);
const installDir = DotnetChecker.getDefaultInstallPath();
this._logger.debug(`[start] install dotnet ${installVersion}`);
this._logger.debug(message_1.Messages.dotnetNotFound()
.replace("@NameVersion", installedNameWithVersion)
.replace("@HelpLink", helpLink_1.dotnetExplanationHelpLink));
this._logger.info(message_1.Messages.downloadDotnet()
.replace("@NameVersion", installedNameWithVersion)
.replace("@InstallDir", installDir));
// TODO add progress log
await (0, progressIndicator_1.runWithProgressIndicator)(async () => {
await this.handleInstall(installVersion, installDir);
}, this._logger);
this._logger.debug(`[end] install dotnet ${installVersion}`);
this._logger.debug(`[start] validate dotnet version`);
if (!(await this.validate())) {
this._telemetry.sendEvent(telemetry_1.DepsCheckerEvent.dotnetInstallError);
throw new error_1.DepsCheckerError((0, localizeUtils_1.getLocalizedString)("error.common.InstallSoftwareError", installedNameWithVersion), helpLink_1.dotnetFailToInstallHelpLink);
}
this._telemetry.sendEvent(telemetry_1.DepsCheckerEvent.dotnetInstallCompleted);
}
async command() {
const execPath = await this.getDotnetExecPathFromConfig();
return execPath || "dotnet";
}
static escapeFilePath(path) {
if ((0, system_1.isWindows)()) {
// Need to escape apostrophes with two apostrophes
const dotnetInstallDirEscaped = path.replace(/'/g, `''`);
// Surround with single quotes instead of double quotes (see https://github.com/dotnet/cli/issues/11521)
return `'${dotnetInstallDirEscaped}'`;
}
else {
return `"${path}"`;
}
}
static getDotnetConfigPath() {
return path.join(os.homedir(), `.${teamsfx_api_1.ConfigFolderName}`, "dotnet.json");
}
async getDotnetExecPathFromConfig() {
try {
const config = await fs.readJson(DotnetChecker.getDotnetConfigPath(), {
encoding: DotnetChecker.encoding,
});
if (typeof config.dotnetExecutablePath === "string") {
return config.dotnetExecutablePath;
}
this._logger.debug(`invalid dotnet config file format, config: '${JSON.stringify(config)}' `);
}
catch (error) {
this._logger.debug(`get dotnet path failed, error: '${error.toString()}'`);
}
return null;
}
// Do not print info level log in this method because it runs concurrently with the progress bar
async handleInstall(version, installDir) {
try {
if ((0, system_1.isLinux)()) {
await this.handleLinuxDependency();
}
// NOTE: we don't need to handle directory creation since dotnet-install script will handle it.
await this.runDotnetInstallScript(version, installDir);
this._logger.debug(`[start] write dotnet path to config`);
const dotnetExecPath = DotnetChecker.getDotnetExecPathFromDotnetInstallationDir(installDir);
await DotnetChecker.persistDotnetExecPath(dotnetExecPath);
this._logger.debug(`[end] write dotnet path to config`);
this._logger.info(message_1.Messages.finishInstallDotnet().replace("@NameVersion", installedNameWithVersion));
}
catch (error) {
this._logger.error(`${(0, localizeUtils_1.getLocalizedString)("error.common.InstallSoftwareError", installedNameWithVersion)}, error = '${error.toString()}'`);
}
}
static async persistDotnetExecPath(dotnetExecPath) {
const configPath = DotnetChecker.getDotnetConfigPath();
await fs.ensureFile(configPath);
await fs.writeJson(configPath, { dotnetExecutablePath: dotnetExecPath }, {
encoding: DotnetChecker.encoding,
spaces: 4,
EOL: os.EOL,
});
}
async handleLinuxDependency() {
// do nothing
}
static async cleanup() {
await fs.remove(DotnetChecker.getDotnetConfigPath());
await fs.emptyDir(DotnetChecker.getDefaultInstallPath());
}
// from: https://github.com/dotnet/vscode-dotnet-runtime/blob/main/vscode-dotnet-runtime-library/src/Acquisition/AcquisitionInvoker.ts
async runDotnetInstallScript(version, installDir) {
const command = this.getInstallCommand(version, installDir);
const cwd = this.getResourceDir();
const options = {
cwd: cwd,
maxBuffer: DotnetChecker.maxBuffer,
timeout: DotnetChecker.timeout,
killSignal: "SIGKILL",
shell: false,
};
const start = perf_hooks_1.performance.now();
try {
fs.chmodSync(this.getDotnetInstallScriptPath(), "755");
const { stdout, stderr } = await execFile(command[0], command.slice(1), options);
this._logger.debug(`Finished running dotnet-install script, command = '${command.join(" ")}', options = '${JSON.stringify(options)}', stdout = '${stdout}', stderr = '${stderr}'`);
const timecost = Number(((perf_hooks_1.performance.now() - start) / 1000).toFixed(2));
if (stderr && stderr.length > 0) {
const errorMessage = `${(0, localizeUtils_1.getLocalizedString)("error.common.InstallSoftwareError", installedNameWithVersion)} ${message_1.Messages.dotnetInstallStderr()} stdout = '${stdout}', stderr = '${stderr}', timecost = '${timecost}s'`;
this._telemetry.sendSystemErrorEvent(telemetry_1.DepsCheckerEvent.dotnetInstallScriptError, telemetry_1.TelemtryMessages.failedToExecDotnetScript, errorMessage);
this._logger.error(errorMessage);
}
else {
this._telemetry.sendEvent(telemetry_1.DepsCheckerEvent.dotnetInstallScriptCompleted, {}, timecost);
}
}
catch (error) {
const timecost = Number(((perf_hooks_1.performance.now() - start) / 1000).toFixed(2));
const errorMessage = `${(0, localizeUtils_1.getLocalizedString)("error.common.InstallSoftwareError", installedNameWithVersion)} ${message_1.Messages.dotnetInstallErrorCode()}, ` +
`command = '${command.join(" ")}', options = '${JSON.stringify(options
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
)}', error = '${error}', stdout = '${error.stdout}', stderr = '${
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
error.stderr}', timecost = '${timecost}s'`;
this._telemetry.sendSystemErrorEvent(telemetry_1.DepsCheckerEvent.dotnetInstallScriptError, telemetry_1.TelemtryMessages.failedToExecDotnetScript, errorMessage);
// swallow the exception since later validate will find out the errors anyway
this._logger.error(errorMessage);
}
}
async isDotnetInstalledCorrectly() {
try {
const dotnetExecPath = await this.getDotnetExecPathFromConfig();
const dotnetSdks = await this.searchDotnetSdks(dotnetExecPath);
const installedVersions = dotnetSdks
.map((sdk) => DotnetChecker.parseDotnetVersion(sdk.version))
.filter((version) => version !== null);
return this.isDotnetVersionsInstalled(installedVersions);
}
catch (error) {
const errorMessage = `validate private install failed, error = '${error.toString()}'`;
this._telemetry.sendSystemErrorEvent(telemetry_1.DepsCheckerEvent.dotnetValidationError, telemetry_1.TelemtryMessages.failedToValidateDotnet, errorMessage);
this._logger.debug(errorMessage);
return false;
}
}
isDotnetVersionsInstalled(installedVersions) {
try {
const validVersions = DotnetChecker.arrayIntersection(installedVersions, supportedVersions);
// return validVersions.length > 0;
return Promise.resolve(validVersions.length > 0);
}
catch (error) {
this._logger.error(`failed to check .NET, installedVersions = '${installedVersions.toString()}', supportedVersions = '${supportedVersions.toString()}', error = '${error.toString()}'`);
return Promise.resolve(false);
}
}
static arrayIntersection(lhs, rhs) {
return lhs.filter((value) => rhs.includes(value));
}
static isPrivateInstall(sdk) {
const privateInstallPath = DotnetChecker.getDotnetExecPathFromDotnetInstallationDir(DotnetChecker.getDefaultInstallPath());
return path.dirname(privateInstallPath) == path.dirname(sdk.path) && sdk.version !== null;
}
async getGlobalDotnetSdks() {
const globalSdks = await this.searchDotnetSdks("dotnet");
return globalSdks.filter((sdk) => !DotnetChecker.isPrivateInstall(sdk));
}
async searchDotnetSdks(dotnetExecPath) {
if (!dotnetExecPath) {
return [];
}
const sdks = [];
try {
// shell = false to prevent shell escape issues in dotnetExecPath
const dotnetListSdksOutput = await cpUtils_1.cpUtils.executeCommand(undefined, this._logger, { shell: false }, dotnetExecPath, "--list-sdks");
// dotnet --list-sdks sample output:
// > 5.0.200 [C:\Program Files\dotnet\sdk]
// > 3.1.200 [C:\Program Files\dotnet\sdk]
const regex = /(?<version>\d+\.\d+\.\d+)\s+\[(?<installPath>[^\]]+)\]/;
// NOTE(aochengwang):
// for default installation, we expect our dotnet should be installVersion.
// for user specified dotnet path, check that installVersion exists in any dotnet installation from dotnet --list-sdks.
dotnetListSdksOutput.split(/\r?\n/).forEach((line) => {
const match = regex.exec(line.trim());
if (match && match.groups) {
const path = match.groups.installPath;
const version = match.groups.version;
if (DotnetChecker.isFullSdkVersion(version) && path) {
sdks.push({ version: version, path: path });
}
}
});
}
catch (error) {
const errorMessage = `Failed to search dotnet sdk by dotnetPath = '${dotnetExecPath}', error = '${error.toString()}'`;
this._logger.debug(errorMessage);
this._telemetry.sendSystemErrorEvent(telemetry_1.DepsCheckerEvent.dotnetSearchDotnetSdks, telemetry_1.TelemtryMessages.failedToSearchDotnetSdks, errorMessage);
}
return sdks;
}
static isFullSdkVersion(version) {
const regex = /(?<major_version>\d+)\.(?<minor_version>\d+)\.(?<patch_version>\d+)/gm;
const match = regex.exec(version);
return match !== null && match.length > 0;
}
static getDotnetExecPathFromDotnetInstallationDir(installDir) {
return path.join(installDir, (0, system_1.isWindows)() ? "dotnet.exe" : "dotnet");
}
getDotnetInstallScriptPath() {
return path.join(this.getResourceDir(), this.getDotnetInstallScriptName());
}
getResourceDir() {
return path.resolve(path.join((0, folder_1.getResourceFolder)(), "deps-checker"));
}
getDotnetInstallScriptName() {
return (0, system_1.isWindows)() ? "dotnet-install.ps1" : "dotnet-install.sh";
}
static getDefaultInstallPath() {
return path.join(os.homedir(), `.${teamsfx_api_1.ConfigFolderName}`, "bin", "dotnet");
}
getInstallCommand(version, dotnetInstallDir) {
if ((0, system_1.isWindows)()) {
const command = [
DotnetChecker.escapeFilePath(this.getDotnetInstallScriptPath()),
"-InstallDir",
DotnetChecker.escapeFilePath(dotnetInstallDir),
"-Channel",
version,
];
return [
"powershell.exe",
"-NoProfile",
"-ExecutionPolicy",
"unrestricted",
"-Command",
`& { [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; & ${command.join(" ")} }`,
];
}
else {
return [
"bash",
this.getDotnetInstallScriptPath(),
"-InstallDir",
dotnetInstallDir,
"-Channel",
version,
];
}
}
async validate() {
const isInstallationValid = (await this.isDotnetInstalledCorrectly()) && (await this.validateWithHelloWorld());
if (!isInstallationValid) {
this._telemetry.sendEvent(telemetry_1.DepsCheckerEvent.dotnetValidationError);
await DotnetChecker.cleanup();
}
return isInstallationValid;
}
async validateWithHelloWorld() {
const dotnetPath = await this.getDotnetExecPathFromConfig();
if (!dotnetPath) {
return false;
}
const samplePath = path.join(os.homedir(), `.${teamsfx_api_1.ConfigFolderName}`, "dotnetSample");
try {
await fs.remove(samplePath);
await cpUtils_1.cpUtils.executeCommand(undefined, this._logger, { shell: false }, dotnetPath, "new", "console", "--output", `${samplePath}`, "--force");
await cpUtils_1.cpUtils.executeCommand(undefined, this._logger, { shell: false }, dotnetPath, "run", "--project", `${samplePath}`, "--force");
return true;
}
catch (error) {
this._telemetry.sendSystemErrorEvent(telemetry_1.DepsCheckerEvent.dotnetValidationError, telemetry_1.TelemtryMessages.failedToValidateDotnet, error);
this._logger.debug(`Failed to run hello world, dotnetPath = ${dotnetPath}, error = ${error.toString()}`);
}
finally {
await fs.remove(samplePath);
}
return false;
}
async tryAcquireGlobalDotnetSdk() {
try {
const sdks = await this.getGlobalDotnetSdks();
if (!sdks || sdks.length == 0) {
return false;
}
// todo: by far, use first valid dotnet sdk
// todo: write dotnetExecPath into user settings instead of into .fx/dotnet.json
const selectedSdk = sdks[0];
const dotnetExecPath = DotnetChecker.getDotnetExecPathFromDotnetInstallationDir(path.resolve(selectedSdk.path, ".."));
await DotnetChecker.persistDotnetExecPath(dotnetExecPath);
return true;
}
catch (error) {
this._logger.debug(`Failed to acquire global dotnet sdk, error = '${error.toString()}'`);
return false;
}
}
static parseDotnetVersion(output) {
var _a, _b;
const regex = /(?<major_version>\d+)\.(?<minor_version>\d+)\.(?<patch_version>\d+)/gm;
const match = regex.exec(output);
if (!match) {
return null;
}
return (((_a = match.groups) === null || _a === void 0 ? void 0 : _a.major_version) || "") + "." + (((_b = match.groups) === null || _b === void 0 ? void 0 : _b.minor_version) || "");
}
}
exports.DotnetChecker = DotnetChecker;
DotnetChecker.encoding = "utf-8";
DotnetChecker.timeout = 5 * 60 * 1000; // same as vscode-dotnet-runtime
DotnetChecker.maxBuffer = 500 * 1024;
//# sourceMappingURL=dotnetChecker.js.map
File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More