Skip to content

Commit

Permalink
Merge branch 'main' into long/fork-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
LongOddCode committed Mar 29, 2024
2 parents 654c223 + 172bf0e commit bf8c72e
Show file tree
Hide file tree
Showing 48 changed files with 520 additions and 431 deletions.
4 changes: 2 additions & 2 deletions packages/cli/tests/unit/telemetry/cliTelemetry.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ describe("Telemetry", function () {
if (eventName === "UserError") {
expect(properties[TelemetryProperty.ErrorType]).equals(TelemetryErrorType.UserError);
expect(properties[TelemetryProperty.ErrorCode]).equals("ut.user");
expect(properties[TelemetryProperty.ErrorMessage]).equals("UserError");
// expect(properties[TelemetryProperty.ErrorMessage]).equals("UserError");
} else {
expect(properties[TelemetryProperty.ErrorType]).equals(TelemetryErrorType.SystemError);
expect(properties[TelemetryProperty.ErrorCode]).equals("ut.system");
expect(properties[TelemetryProperty.ErrorMessage]).equals("SystemError");
// expect(properties[TelemetryProperty.ErrorMessage]).equals("SystemError");
}
});
const reporter = new CliTelemetryReporter("real", "real", "real", "real");
Expand Down
22 changes: 11 additions & 11 deletions packages/fx-core/resource/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -376,36 +376,36 @@
"core.createProjectQuestion.officeXMLAddin.bar.detail": "Creating Project.",
"core.createProjectQuestion.officeXMLAddin.mainEntry.title": "Office Add-in",
"core.createProjectQuestion.officeXMLAddin.mainEntry.detail": "Create integration with Outlook, Word, Excel, or PowerPoint",
"core.createProjectQuestion.officeXMLAddin.create.title": "Select to create an Outlook, Word, Excel, or PowerPoint Add-in",
"core.createProjectQuestion.officeXMLAddin.create.title": "Select to Create an Outlook, Word, Excel, or PowerPoint Add-in",
"core.createProjectQuestion.officeXMLAddin.word.title": "Word Add-in",
"core.createProjectQuestion.officeXMLAddin.word.detail": "Create an add-in that can run in Word across multiple platforms",
"core.createProjectQuestion.officeXMLAddin.word.sso.title": "Add-in with Single Sign On",
"core.createProjectQuestion.officeXMLAddin.word.sso.detail": "Create a Word add-in with Single Sign On capabilities",
"core.createProjectQuestion.officeXMLAddin.word.react.title": "Add-in with React framework",
"core.createProjectQuestion.officeXMLAddin.word.react.title": "Add-in with React Framework",
"core.createProjectQuestion.officeXMLAddin.word.react.detail": "Create a Word add-in with React framework",
"core.createProjectQuestion.officeXMLAddin.word.create.title": "Create a Word Add-in",
"core.createProjectQuestion.officeXMLAddin.excel.title": "Excel Add-in",
"core.createProjectQuestion.officeXMLAddin.excel.detail": "Extend Excel functionality and access Excel data on multiple platforms",
"core.createProjectQuestion.officeXMLAddin.excel.sso.title": "Add-in with Single Sign On",
"core.createProjectQuestion.officeXMLAddin.excel.sso.detail": "Create an Excel add-in with Single Sign On capabilities",
"core.createProjectQuestion.officeXMLAddin.excel.react.title": "Add-in with React framework",
"core.createProjectQuestion.officeXMLAddin.excel.react.title": "Add-in with React Framework",
"core.createProjectQuestion.officeXMLAddin.excel.react.detail": "Create an Excel add-in with React framework",
"core.createProjectQuestion.officeXMLAddin.excel.cf.shared.title": "Excel Custom Functions using a Shared Runtime",
"core.createProjectQuestion.officeXMLAddin.excel.cf.shared.title": "Excel Custom Functions Using a Shared Runtime",
"core.createProjectQuestion.officeXMLAddin.excel.cf.shared.detail": "Create an Excel add-in leveraging Custom Functions using a Shared Runtime",
"core.createProjectQuestion.officeXMLAddin.excel.cf.js.title": "Excel Custom Functions using a JavaScript-only Runtime",
"core.createProjectQuestion.officeXMLAddin.excel.cf.js.title": "Excel Custom Functions Using a JavaScript-only Runtime",
"core.createProjectQuestion.officeXMLAddin.excel.cf.js.detail": "Create an Excel add-in leveraging Custom Functions using a JavaScript-only Runtime",
"core.createProjectQuestion.officeXMLAddin.excel.create.title": "Create an Excel Add-in",
"core.createProjectQuestion.officeXMLAddin.powerpoint.title": "PowerPoint Add-in",
"core.createProjectQuestion.officeXMLAddin.powerpoint.detail": "Build engaging solutions for presentations across platform",
"core.createProjectQuestion.officeXMLAddin.powerpoint.sso.title": "Create a PowerPoint add-in with Single Sign On capabilities",
"core.createProjectQuestion.officeXMLAddin.powerpoint.sso.title": "Add-in with Single Sign On",
"core.createProjectQuestion.officeXMLAddin.powerpoint.sso.detail": "PowerPoint add-in with Single Sign On capabilities",
"core.createProjectQuestion.officeXMLAddin.powerpoint.react.title": "Add-in with React framework",
"core.createProjectQuestion.officeXMLAddin.powerpoint.react.title": "Add-in with React Framework",
"core.createProjectQuestion.officeXMLAddin.powerpoint.react.detail": "Create a PowerPoint add-in with React framework",
"core.createProjectQuestion.officeXMLAddin.powerpoint.create.title": "Create a PowerPoint Add-in",
"core.createProjectQuestion.officeXMLAddin.taskpane.title": "Add-in with Basic Taskpane",
"core.createProjectQuestion.officeXMLAddin.taskpane.detail": "Customize the Ribbon with a button and embed content in the Taskpane",
"core.createProjectQuestion.officeXMLAddin.manifestOnly.title": "Add-in project containing the manifest only",
"core.createProjectQuestion.officeXMLAddin.manifestOnly.detail": "Create a simple add-in project with a manifest file only",
"core.createProjectQuestion.officeXMLAddin.taskpane.title": "Add-in with Basic Task Pane",
"core.createProjectQuestion.officeXMLAddin.taskpane.detail": "Customize the Ribbon with a button and create a dashboard in the Task Pane",
"core.createProjectQuestion.officeXMLAddin.manifestOnly.title": "Add-in Project With only Manifest File",
"core.createProjectQuestion.officeXMLAddin.manifestOnly.detail": "Create an add-in project that includes only the manifest file",
"core.aiAssistantBotOption.label": "AI Assistant Bot",
"core.aiAssistantBotOption.detail": "A custom AI assistant bot in Teams using Teams AI library and OpenAI Assistants API",
"core.aiBotOption.label": "AI Chat Bot",
Expand Down
18 changes: 10 additions & 8 deletions packages/fx-core/src/common/featureFlags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export function isOfficeXMLAddinEnabled(): boolean {
return isFeatureFlagEnabled(FeatureFlagName.OfficeXMLAddin, false);
}

export function isOfficeJSONAddinEnabled(): boolean {
return isFeatureFlagEnabled(FeatureFlagName.OfficeAddin, false);
}

export function isTeamsFxRebrandingEnabled(): boolean {
return isFeatureFlagEnabled(FeatureFlagName.TeamsFxRebranding, false);
}
Expand All @@ -78,10 +82,6 @@ export function isNewProjectTypeEnabled(): boolean {
return isFeatureFlagEnabled(FeatureFlagName.NewProjectType, true);
}

export function isOfficeJSONAddinEnabled(): boolean {
return isFeatureFlagEnabled(FeatureFlagName.OfficeAddin, false);
}

export function isApiMeSSOEnabled(): boolean {
return isFeatureFlagEnabled(FeatureFlagName.ApiMeSSO, false);
}
Expand All @@ -91,7 +91,7 @@ export function isApiMeSSOEnabled(): boolean {
// Case 1: TEAMSFX_OFFICE_ADDIN = false, TEAMSFX_OFFICE_XML_ADDIN = false
// 1.1 project-type option: `outlook-addin-type`
// 1.2 addin-host: not show but use `outlook` internally
// 1.3 capabilities options: [`jason-taskpane`, `outlook-addin-import`]
// 1.3 capabilities options: [`json-taskpane`, `outlook-addin-import`]
// 1.4 programming-language options: [`typescript`] (skip in UI)
// 1.5 office-addin-framework-type: not show question but use `default_old` internally
// 1.6 generator class: OfficeAddinGenerator
Expand All @@ -107,15 +107,17 @@ export function isApiMeSSOEnabled(): boolean {
// 2.4 programming-language options:
// if (addin-host == `outlook`) then [`typescript`] (skip in UI)
// else two options: [`typescript`, `javascript`]
// 2.5 office-addin-framework-type options: not show but use `default` internally
// 2.5 office-addin-framework-type options:
// if (word excel and powerpoint) use `default` internally
// else if (outlook) use `default_old` internally
// 2.6 generator class:
// if (addin-host == `outlook`) then OfficeAddinGenerator
// else OfficeXMLAddinGenerator
// 2.7 template link:
// if (addin-host == `outlook`) config.json.json-taskpane.default.[programming-language]
// else config[addin-host].[capabilities].default.[programming-language]
// Case 3: TEAMSFX_OFFICE_ADDIN = true AND TEAMSFX_OFFICE_XML_ADDIN = true
// 3.1 project-type option: `office-addin-type`
// 3.1 project-type option: `office-addin-type`
// 3.2 addin-host: not show but will use `wxpo` internally
// 3.3 capabilities options: [`json-taskpane`, `office-addin-import`]
// 3.4 programming-language options: [`typescript`, `javascript`]
Expand All @@ -125,7 +127,7 @@ export function isApiMeSSOEnabled(): boolean {
// case 4: TEAMSFX_OFFICE_ADDIN = true AND TEAMSFX_OFFICE_XML_ADDIN = fasle
// 4.1 project-type option: `office-addin-type`
// 4.2 addin-host: not show but will use `wxpo` internally
// 4.3 capabilities options: [`jason-taskpane`, `office-addin-import`]
// 4.3 capabilities options: [`json-taskpane`, `office-addin-import`]
// 4.4 programming-language options: [`typescript`, `javascript`]
// 4.5 office-addin-framework-type options: [`default`, `react`]
// 4.6 generator class: OfficeAddinGenerator
Expand Down
13 changes: 13 additions & 0 deletions packages/fx-core/src/common/projectTypeChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from "path";
import semver from "semver";
import { parseDocument } from "yaml";
import { MetadataV2, MetadataV3 } from "./versionMetadata";
import { isValidOfficeAddInProject } from "./projectSettingsHelper";

export enum TeamsfxConfigType {
projectSettingsJson = "projectSettings.json",
Expand Down Expand Up @@ -34,6 +35,7 @@ export interface ProjectTypeResult {
manifestVersion?: string;
dependsOnTeamsJs?: boolean;
isSPFx?: boolean;
officeAddinProjectType?: string;
lauguages: ("ts" | "js" | "csharp" | "java" | "python" | "c")[];
}

Expand Down Expand Up @@ -195,6 +197,16 @@ class ProjectTypeChecker {
}
return true;
}

findOfficeAddinProject(filePath: string, data: ProjectTypeResult): boolean {
if (isValidOfficeAddInProject(filePath)) {
data.officeAddinProjectType = "XML";
data.isTeamsFx = false;
return false;

Check warning on line 205 in packages/fx-core/src/common/projectTypeChecker.ts

View check run for this annotation

Codecov / codecov/patch

packages/fx-core/src/common/projectTypeChecker.ts#L203-L205

Added lines #L203 - L205 were not covered by tests
}
return true;

Check warning on line 207 in packages/fx-core/src/common/projectTypeChecker.ts

View check run for this annotation

Codecov / codecov/patch

packages/fx-core/src/common/projectTypeChecker.ts#L207

Added line #L207 was not covered by tests
}

async checkProjectType(projectPath: string) {
const result: ProjectTypeResult = {
isTeamsFx: false,
Expand Down Expand Up @@ -236,6 +248,7 @@ class ProjectTypeChecker {
2,
0
);
this.findOfficeAddinProject(projectPath, result);
} catch (e) {}
return result;
}
Expand Down
19 changes: 11 additions & 8 deletions packages/fx-core/src/common/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { TelemetryConstants } from "../component/constants";
import { TOOLS, globalVars } from "../core/globalVars";
import { ProjectTypeResult } from "./projectTypeChecker";
import { assign } from "lodash";
import { ProjectType } from "@microsoft/m365-spec-parser";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import ProjectType.

export enum TelemetryProperty {
TriggerFrom = "trigger-from",
Expand Down Expand Up @@ -144,6 +145,7 @@ export enum ProjectTypeProps {
TeamsManifestCapabilities = "manifest-capabilities",
TeamsJs = "teams-js",
Lauguages = "languages",
OfficeAddinProjectType = "office-addin-project-type",
}

export enum TelemetrySuccess {
Expand Down Expand Up @@ -239,8 +241,8 @@ export function fillInTelemetryPropsForFxError(
props[TelemetryConstants.properties.errorCode] =
props[TelemetryConstants.properties.errorCode] || errorCode;
props[TelemetryConstants.properties.errorType] = errorType;
props[TelemetryConstants.properties.errorMessage] = error.message;
props[TelemetryConstants.properties.errorStack] = error.stack !== undefined ? error.stack : ""; // error stack will not append in error-message any more
// props[TelemetryConstants.properties.errorMessage] = error.message; // error-message is retired
// props[TelemetryConstants.properties.errorStack] = error.stack !== undefined ? error.stack : ""; // error stack will not append in error-message any more
props[TelemetryConstants.properties.errorName] = error.name;

// append global context properties
Expand All @@ -252,12 +254,12 @@ export function fillInTelemetryPropsForFxError(
props[TelemetryConstants.properties.errorInnerCode] = error.innerError["code"];
}

if (error.innerError) {
props[TelemetryConstants.properties.innerError] = JSON.stringify(
error.innerError,
Object.getOwnPropertyNames(error.innerError)
);
}
// if (error.innerError) { // inner-error is retired
// props[TelemetryConstants.properties.innerError] = JSON.stringify(
// error.innerError,
// Object.getOwnPropertyNames(error.innerError)
// );
// }

if (error.categories) {
props[TelemetryConstants.properties.errorCat] = error.categories.join("|");
Expand All @@ -284,6 +286,7 @@ export function fillinProjectTypeProperties(
[ProjectTypeProps.Lauguages]: projectTypeRes.lauguages.join(","),
[ProjectTypeProps.TeamsManifestCapabilities]:
projectTypeRes.manifestCapabilities?.join(",") || "",
[ProjectTypeProps.OfficeAddinProjectType]: projectTypeRes.officeAddinProjectType || "",
};
assign(props, newProps);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
import { hooks } from "@feathersjs/hooks/lib";
import { Context, FxError, Inputs, Result, err, ok } from "@microsoft/teamsfx-api";
import * as childProcess from "child_process";
import _ from "lodash";
import _, { merge } from "lodash";
import { OfficeAddinManifest } from "office-addin-manifest";
import { join } from "path";
import { promisify } from "util";
import { getLocalizedString } from "../../../common/localizeUtils";
import { assembleError } from "../../../error";
import { QuestionNames } from "../../../question/questionNames";
import { ActionExecutionMW } from "../../middleware/actionExecutionMW";
import { ActionExecutionMW, ActionContext } from "../../middleware/actionExecutionMW";
import { Generator } from "../generator";
import { HelperMethods } from "../officeAddin/helperMethods";
import { getOfficeAddinTemplateConfig } from "./projectConfig";
Expand All @@ -24,6 +24,14 @@ import { convertToLangKey } from "../utils";
const COMPONENT_NAME = "office-xml-addin";
const TELEMETRY_EVENT = "generate";
const TEMPLATE_BASE = "office-xml-addin";
const TEMPLATE_COMMON_NAME = "office-xml-addin-common";
const TEMPLATE_COMMON_LANG = "common";

const enum OfficeXMLAddinTelemetryProperties {
host = "office-xml-addin-host",
project = "office-xml-addin-project",
lang = "office-xml-addin-lang",
}

/**
* project-type=office-xml-addin-type addin-host!==outlook
Expand All @@ -40,7 +48,8 @@ export class OfficeXMLAddinGenerator {
static async generate(
context: Context,
inputs: Inputs,
destinationPath: string
destinationPath: string,
actionContext?: ActionContext
): Promise<Result<undefined, FxError>> {
const host = inputs[QuestionNames.OfficeAddinHost] as string;
const capability = inputs[QuestionNames.Capabilities];
Expand All @@ -50,15 +59,21 @@ export class OfficeXMLAddinGenerator {
const langKey = convertToLangKey(lang);
const appName = inputs[QuestionNames.AppName] as string;
const projectType = inputs[QuestionNames.ProjectType];
const templteConfig = getOfficeAddinTemplateConfig(projectType, host);
const templateName = templteConfig[capability].localTemplate;
const projectLink = templteConfig[capability].framework["default"][lang];
const templateConfig = getOfficeAddinTemplateConfig(projectType, host);
const templateName = templateConfig[capability].localTemplate;
const projectLink = templateConfig[capability].framework["default"][lang];
const workingDir = process.cwd();
const progressBar = context.userInteraction.createProgressBar(
getLocalizedString("core.createProjectQuestion.officeXMLAddin.bar.title"),
1
);

merge(actionContext?.telemetryProps, {
[OfficeXMLAddinTelemetryProperties.host]: host,
[OfficeXMLAddinTelemetryProperties.project]: capability,
[OfficeXMLAddinTelemetryProperties.lang]: lang,
});

try {
process.chdir(destinationPath);
await progressBar.start();
Expand Down Expand Up @@ -87,7 +102,7 @@ export class OfficeXMLAddinGenerator {
langKey
);
if (getManifestOnlyProjectTemplateRes.isErr())
return err(getManifestOnlyProjectTemplateRes.error);
throw err(getManifestOnlyProjectTemplateRes.error);
}

// -> Common Step: Copy the README (or with manifest for manifest-only proj)
Expand All @@ -97,7 +112,7 @@ export class OfficeXMLAddinGenerator {
`${TEMPLATE_BASE}-${templateName}`,
langKey
);
if (getReadmeTemplateRes.isErr()) return err(getReadmeTemplateRes.error);
if (getReadmeTemplateRes.isErr()) throw err(getReadmeTemplateRes.error);

// -> Common Step: Modify the Manifest
await OfficeAddinManifest.modifyManifestFile(
Expand All @@ -106,6 +121,15 @@ export class OfficeXMLAddinGenerator {
`${appName}`
);

// -> Common Step: Generate OfficeXMLAddin specific `teamsapp.yml`
const generateOfficeYMLRes = await Generator.generateTemplate(
context,
destinationPath,
TEMPLATE_COMMON_NAME,
TEMPLATE_COMMON_LANG
);
if (generateOfficeYMLRes.isErr()) throw err(generateOfficeYMLRes.error);

process.chdir(workingDir);
await progressBar.end(true, true);
return ok(undefined);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const OfficeAddinProjectConfig: IOfficeAddinProjectConfig = {
localTemplate: "excel-react",
...CommonProjectConfig.react,
},
"excel-cfshared": {
"excel-custom-functions-shared": {
title: "core.createProjectQuestion.officeXMLAddin.excel.cf.shared.title",
detail: "core.createProjectQuestion.officeXMLAddin.excel.cf.shared.detail",
localTemplate: "excel-cf",
Expand All @@ -134,7 +134,7 @@ export const OfficeAddinProjectConfig: IOfficeAddinProjectConfig = {
},
},
},
"excel-cfjs": {
"excel-custom-functions-js": {
title: "core.createProjectQuestion.officeXMLAddin.excel.cf.js.title",
detail: "core.createProjectQuestion.officeXMLAddin.excel.cf.js.detail",
localTemplate: "excel-cf",
Expand Down
4 changes: 2 additions & 2 deletions packages/fx-core/src/error/script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class ScriptTimeoutError extends UserError {
const errorOptions: UserErrorOptions = {
source: "script",
name: "ScriptTimeoutError",
message: getDefaultString(key, cmd),
message: getDefaultString(key, ""), //the script content maybe contains securit data that should not be reported in telemetry
displayMessage: getLocalizedString(key, cmd),
error: error,
categories: [ErrorCategory.External],
Expand All @@ -32,7 +32,7 @@ export class ScriptExecutionError extends UserError {
const errorOptions: UserErrorOptions = {
source: "script",
name: "ScriptExecutionError",
message: getDefaultString(key, script, message),
message: getDefaultString(key, "", message), //the script content maybe contains securit data that should not be reported in telemetry
displayMessage: getLocalizedString(key, script, message),
error: error,
categories: [ErrorCategory.External],
Expand Down
Loading

0 comments on commit bf8c72e

Please sign in to comment.