Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(fx-core): scaffold question and generator refactor #13106

Open
wants to merge 120 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 74 commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
f2b786c
refactor: create question
jayzhang Nov 21, 2024
97f5a5f
Merge branch 'dev' of https://github.com/OfficeDev/TeamsFx into huaji…
jayzhang Nov 25, 2024
a6c55f8
feat: improve question model api
jayzhang Nov 26, 2024
3b55151
feat: up
jayzhang Nov 26, 2024
952b9a9
Merge branch 'dev' of https://github.com/OfficeDev/TeamsFx into huaji…
jayzhang Nov 28, 2024
f7aa205
Merge branch 'dev' of https://github.com/OfficeDev/teams-toolkit into…
jayzhang Dec 2, 2024
cb8b960
feat: up
jayzhang Dec 2, 2024
da61e4f
feat: up
jayzhang Dec 2, 2024
de022e2
feat: up
jayzhang Dec 4, 2024
80e718d
feat: up
jayzhang Dec 4, 2024
d887e1d
feat: up
jayzhang Dec 5, 2024
ab3e5ea
feat: scaffold question demo
tecton Dec 11, 2024
744b7b3
fix: question layout
tecton Dec 16, 2024
3026e28
feat: merge dev
jayzhang Jan 3, 2025
7ef1767
feat: merge dev
jayzhang Jan 3, 2025
6e34232
feat: merge dev
jayzhang Jan 9, 2025
8226bee
refactor: adjust
jayzhang Jan 9, 2025
7425c10
refactor: clean up scaffold question tree
jayzhang Jan 10, 2025
d5fb766
feat: merge
jayzhang Jan 10, 2025
2c154f0
refactor: improve tree
jayzhang Jan 10, 2025
86db0a1
refactor: clean up tree
jayzhang Jan 13, 2025
a91a858
refactor: clean
jayzhang Jan 14, 2025
78fd52a
refactor: split question model
jayzhang Jan 17, 2025
783f496
refactor: vs question
jayzhang Jan 17, 2025
78b0ad7
refactor: apply new scaffold question
jayzhang Jan 18, 2025
8bdd221
refactor: add template metadata
tecton Jan 23, 2025
8132659
Merge branch 'dev' into nintan/refactor
tecton Jan 23, 2025
c77b07c
fix: bug after merging codes
tecton Jan 23, 2025
c8fe8f2
refactor: default generator read from template metadata
tecton Jan 23, 2025
db36d6c
feat: up
jayzhang Jan 24, 2025
74f98b8
Merge branch 'nintan/refactor' of https://github.com/OfficeDev/TeamsF…
jayzhang Jan 24, 2025
6b6c9a2
feat: up
jayzhang Jan 24, 2025
15a1d04
feat: up
jayzhang Jan 24, 2025
654c6e3
feat: add template link
jayzhang Jan 24, 2025
d475300
Merge branch 'dev' of https://github.com/OfficeDev/TeamsFx into ninta…
jayzhang Jan 24, 2025
9945e31
feat: restore cli options
jayzhang Jan 24, 2025
e52abc1
refactor: format
jayzhang Jan 24, 2025
bb3d70f
refactor: create from tdp question node
jayzhang Jan 24, 2025
47cf3bf
refactor: create from tdp question node
jayzhang Jan 24, 2025
c906893
refactor: create from tdp integration
jayzhang Jan 24, 2025
01b0da4
refactor: create from tdp integration
jayzhang Jan 24, 2025
f05dfa8
refactor: unused import
jayzhang Jan 24, 2025
70f23cc
refactor: ssr tab generagor
jayzhang Jan 24, 2025
bfccc57
fix: ut
jayzhang Jan 25, 2025
d0ee33a
fix: ut
jayzhang Jan 26, 2025
46e06be
fix: ut
jayzhang Jan 26, 2025
b888ee1
fix: ut
jayzhang Jan 26, 2025
9ddeba5
fix: ut
jayzhang Jan 26, 2025
793202c
fix: ut
jayzhang Jan 26, 2025
b31a4cf
fix: ut
jayzhang Jan 26, 2025
8da329a
fix: ut
jayzhang Jan 26, 2025
28ced6c
fix: ut
jayzhang Jan 26, 2025
06cd41e
fix: ut
jayzhang Jan 27, 2025
3dfa242
fix: ut
jayzhang Jan 27, 2025
7e13c28
fix: ut
jayzhang Jan 31, 2025
5972178
fix: ut
jayzhang Feb 3, 2025
0cee753
fix: ut
jayzhang Feb 3, 2025
059ff67
fix: ut
jayzhang Feb 3, 2025
80c2210
fix: remove unused function
jayzhang Feb 3, 2025
741a559
fix: ut
jayzhang Feb 3, 2025
59114f8
fix: ut
jayzhang Feb 3, 2025
397e11b
fix: ut
jayzhang Feb 3, 2025
4660f4a
fix: ut
jayzhang Feb 4, 2025
2987bc8
fix: ut
jayzhang Feb 4, 2025
ba55a1d
fix: ut
jayzhang Feb 4, 2025
01aec79
fix: ut
jayzhang Feb 4, 2025
e0bf771
fix: ut
jayzhang Feb 4, 2025
d593454
fix: ut
jayzhang Feb 4, 2025
b34aba8
fix: ut
jayzhang Feb 4, 2025
d4084ba
fix: ut
jayzhang Feb 4, 2025
323fda5
fix: ut
jayzhang Feb 4, 2025
b9ec301
refactor: use new template name
jayzhang Feb 6, 2025
0c1e2ee
refactor: merge dev
jayzhang Feb 6, 2025
c9a66bc
refactor: spfx generator refer new constants
jayzhang Feb 6, 2025
aa84368
fix: language option and add copilot template list
jayzhang Feb 6, 2025
ebe0008
fix: language option and add copilot template list
jayzhang Feb 6, 2025
9192d0e
fix: assign template for da:no plugin and da:import existing api spec
jayzhang Feb 6, 2025
dc008b7
refactor: cleanup code (#13133)
yuqizhou77 Feb 6, 2025
001f6bb
refactor: clean and reorganize template metadata
tecton Feb 7, 2025
d564737
docs: comments
jayzhang Feb 7, 2025
35623e9
feat: merge
jayzhang Feb 7, 2025
166bc75
feat: merge dev
jayzhang Feb 7, 2025
f716d54
refactor: remove unused file
jayzhang Feb 7, 2025
9ca048a
fix: trigger onDisSelection for preset answer
jayzhang Feb 7, 2025
41765a5
fix: move ai-assistant-bot into vs folder
jayzhang Feb 7, 2025
d6e19c9
fix: apiKey option label
jayzhang Feb 7, 2025
68fc6ce
docs: comments
jayzhang Feb 7, 2025
fb5086a
refactor: restore da capability node
jayzhang Feb 7, 2025
c669008
fix: question model option names and template metadata
tecton Feb 7, 2025
3954797
fix: revert translate files changes
tecton Feb 7, 2025
a789349
fix: comment
tecton Feb 7, 2025
616fcf0
fix: ut
tecton Feb 8, 2025
6d37eee
feat: cli non-interactive project-type
jayzhang Feb 8, 2025
ca9d04f
refactor: unused import
jayzhang Feb 8, 2025
0373fde
test: cli ut
jayzhang Feb 8, 2025
169f788
fix: option open link
tecton Feb 8, 2025
ba277d3
Merge branch 'nintan/refactor' of https://github.com/OfficeDev/TeamsF…
tecton Feb 8, 2025
58a26c8
fix: create from tdp question model
jayzhang Feb 10, 2025
c1b0aed
Merge branch 'nintan/refactor' of https://github.com/OfficeDev/TeamsF…
jayzhang Feb 10, 2025
4946e7b
refactor: clean up imports
jayzhang Feb 11, 2025
ee421c1
fix: support cli donet project scaffold
jayzhang Feb 11, 2025
6b71b12
fix: support cli donet project scaffold ut
jayzhang Feb 11, 2025
aef3f6a
fix: create from tdp e2e
jayzhang Feb 11, 2025
6aa6721
fix: add python templates
tecton Feb 11, 2025
8d7517d
Merge branch 'nintan/refactor' of https://github.com/OfficeDev/TeamsF…
tecton Feb 11, 2025
2a6af72
fix: default language in question model
jayzhang Feb 11, 2025
5b7e664
Merge branch 'nintan/refactor' of https://github.com/OfficeDev/TeamsF…
jayzhang Feb 11, 2025
8b31690
test: fix ut
jayzhang Feb 11, 2025
6e54936
test: e2e test debug
jayzhang Feb 11, 2025
4678f2f
fix: scaffold failure
jayzhang Feb 12, 2025
e8671e5
feat: merge dev
jayzhang Feb 12, 2025
378b368
fix: bot me scaffold
jayzhang Feb 12, 2025
6d43f65
fix: error
jayzhang Feb 12, 2025
7f4492e
fix: create tdp template from cli non-interactive mode
jayzhang Feb 12, 2025
141c96d
test: ut
jayzhang Feb 12, 2025
b331f44
test: ut
jayzhang Feb 12, 2025
d74b0e0
test: ut
jayzhang Feb 12, 2025
5a10855
fix: vs only templates
jayzhang Feb 12, 2025
11ce65f
fix: revert launch.json for cli
jayzhang Feb 12, 2025
a63de3d
fix: ut
jayzhang Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/api/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export enum VsCodeEnv {

export enum Stage {
create = "create",
createTdp = "createTdp",
build = "build",
debug = "debug",
provision = "provision",
Expand Down
5 changes: 5 additions & 0 deletions packages/api/src/qm/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ export interface SingleSelectQuestion extends UserInputQuestion {
* whether to skip validation against allowed list in non-interactive mode, default false
*/
skipValidation?: boolean;

/**
* callback function which is triggered when the value is selected
*/
onDidSelection?: (itemOrId: string | OptionItem, inputs: Inputs) => Promise<void> | void;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions packages/api/src/qm/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,11 @@ export interface InputResult<T> {
* answer value
*/
result?: T;

/**
* resolved option list
*/
options?: StaticOptions;
jayzhang marked this conversation as resolved.
Show resolved Hide resolved
}

export type ConfirmResult = InputResult<boolean>;
Expand Down
14 changes: 9 additions & 5 deletions packages/cli/src/userInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,12 +274,12 @@ class CLIUserInteraction implements UserInteraction {
if (config.options.length === 1 && config.skipSingleOption) {
const answer = (config.options as StaticOptions)[0];
if (config.returnObject) {
return ok({ type: "skip", result: answer });
return ok({ type: "skip", result: answer, options: config.options as StaticOptions });
} else {
if (typeof answer === "string") {
return ok({ type: "skip", result: answer });
return ok({ type: "skip", result: answer, options: config.options as StaticOptions });
} else {
return ok({ type: "skip", result: answer.id });
return ok({ type: "skip", result: answer.id, options: config.options as StaticOptions });
}
}
}
Expand Down Expand Up @@ -310,9 +310,13 @@ class CLIUserInteraction implements UserInteraction {
return ok({ type: "success", result: answer });
} else {
if (typeof answer === "string") {
return ok({ type: "success", result: answer });
return ok({ type: "success", result: answer, options: config.options as StaticOptions });
} else {
return ok({ type: "success", result: answer.id });
return ok({
type: "success",
result: answer.id,
options: config.options as StaticOptions,
});
}
}
} else {
Expand Down
14 changes: 14 additions & 0 deletions packages/cli/tests/unit/ui2.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SingleSelectConfig,
UserError,
err,
ok,
} from "@microsoft/teamsfx-api";
import { SelectSubscriptionError, UnhandledError } from "@microsoft/teamsfx-core";
import { assert } from "chai";
Expand Down Expand Up @@ -184,6 +185,19 @@ describe("UserInteraction(CLI) 2", () => {
assert.isTrue(result.error instanceof SelectSubscriptionError);
}
});
it("happy return options", async () => {
const config: SingleSelectConfig = {
name: "test",
title: "test",
options: ["a", "b"],
};
sandbox.stub(UI, "singleSelect").resolves(ok("a"));
const result = await UI.selectOption(config);
assert.isTrue(result.isOk());
if (result.isOk()) {
assert.deepEqual(result.value.options, ["a", "b"]);
}
});
});

describe("inputText", () => {
Expand Down
11 changes: 0 additions & 11 deletions packages/fx-core/src/component/coordinator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,17 +206,6 @@ class Coordinator {

context.projectPath = projectPath;

if (inputs.teamsAppFromTdp) {
const res = await developerPortalScaffoldUtils.updateFilesForTdp(
context,
inputs.teamsAppFromTdp,
inputs
);
if (res.isErr()) {
return err(res.error);
}
}

const trimRes = await manifestUtils.trimManifestShortName(projectPath);
if (trimRes.isErr()) return err(trimRes.error);

Expand Down
67 changes: 67 additions & 0 deletions packages/fx-core/src/component/generator/TdpGenerator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

/**
* @author [email protected]
*/

import { Context, err, FxError, GeneratorResult, Inputs, ok, Result } from "@microsoft/teamsfx-api";
import { InputValidationError } from "../../error";
import { ProgrammingLanguage, QuestionNames } from "../../question/constants";
import { developerPortalScaffoldUtils } from "../developerPortalScaffoldUtils";
import { ActionContext } from "../middleware/actionExecutionMW";
import { DefaultTemplateGenerator } from "./templates/templateGenerator";
import { TemplateInfo } from "./templates/templateInfo";

/**
* TdpGenerator is used to generate code from TDP app definition.
*/
export class TdpGenerator extends DefaultTemplateGenerator {
componentName = "tdp-generator";

// activation condition
public activate(context: Context, inputs: Inputs): boolean {
return inputs.teamsAppFromTdp !== undefined;
}

public async getTemplateInfos(
context: Context,
inputs: Inputs,
destinationPath: string,
actionContext?: ActionContext
): Promise<Result<TemplateInfo[], FxError>> {
const templateName = inputs[QuestionNames.TemplateName];
if (!templateName) {
return err(
new InputValidationError("teamsAppFromTdp", "Invalid App Definition", "TdpGenerator")
);
}
const language = inputs[QuestionNames.ProgrammingLanguage] as ProgrammingLanguage;
return Promise.resolve(
ok([
{
templateName: templateName,
language: language,
replaceMap: {},
},
])
);
}

async post(
context: Context,
inputs: Inputs,
destinationPath: string,
actionContext?: ActionContext
): Promise<Result<GeneratorResult, FxError>> {
const res = await developerPortalScaffoldUtils.updateFilesForTdp(
context,
inputs.teamsAppFromTdp,
inputs
);
if (res.isErr()) {
return err(res.error);
}
return ok({});
}
}
Loading
Loading