Skip to content

Commit

Permalink
Merge branch 'dev' into supkasar-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
supkasar committed Mar 13, 2024
2 parents a46643b + e7482a0 commit 6d198fe
Show file tree
Hide file tree
Showing 827 changed files with 31,883 additions and 1,947 deletions.
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
/templates/scripts @hund030 @eriolchan @huimiu
/templates/constraints/yml/actions @hund030 @eriolchan @huimiu

/templates/**/api-plugin-from-scratch @hund030 @eriolchan @huimiu
/templates/**/copilot-plugin-from-scratch @hund030 @eriolchan @huimiu
/templates/**/copilot-plugin-from-scratch-api-key @hund030 @eriolchan @huimiu
/templates/**/dashboard-tab @hund030 @eriolchan @huimiu
Expand All @@ -124,6 +125,7 @@
/templates/**/office-addin @jayzhang @nliu-ms
/templates/**/copilot-plugin-existing-api @yuqizhou77 @Alive-Fish @jayzhang
/templates/**/copilot-plugin-existing-api-api-key @yuqizhou77 @Alive-Fish @jayzhang
/templates/**/api-plugin-existing-api @yuqizhou77 @Alive-Fish @jayzhang
/templates/**/spfx-tab @HuihuiWu-Microsoft @yuqizhou77 @nliu-ms @jayzhang
/templates/**/spfx-tab-import @HuihuiWu-Microsoft @yuqizhou77 @nliu-ms @jayzhang

Expand All @@ -139,6 +141,10 @@
/templates/**/m365-message-extension @kimizhu @swatDong @kuojianlu
/templates/**/ai-bot @kimizhu @swatDong @kuojianlu
/templates/**/ai-assistant-bot @kimizhu @swatDong @kuojianlu
/templates/**/custom-copilot-basic @kimizhu @swatDong @kuojianlu @XiaofuHuang
/templates/python/custom-copilot-basic @frankqianms @adashen
/templates/**/custom-copilot-assistant-new @kimizhu @swatDong @kuojianlu @XiaofuHuang
/templates/**/custom-copilot-assistant-assistants-api @kimizhu @swatDong @kuojianlu @XiaofuHuang

/packages/fx-core/.eslintignore @LongOddCode @wenytang-ms
/packages/fx-core/.eslintrc.js @LongOddCode @wenytang-ms
Expand Down
32 changes: 29 additions & 3 deletions .github/actions/create-milestone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ class CreateMilestone extends Action {
for (const sprint of sprints) {
await checkAndCreateMilestone(sprint, existingMilestones);
}

const existingOpenMilestones = await getExistingMilestones('CY', 'open');
safeLog(`found ${existingMilestones.length} existing open milestones`);
for (const openMilestone of existingOpenMilestones) {
await checkAndCloseMilestone(openMilestone);
}
}

private async createClient() {
Expand Down Expand Up @@ -93,7 +99,7 @@ async function checkAndCreateMilestone(sprint: any, existingMilestones: any[]):
title: `${prefix}-${name}`,
due_on: new Date(sprint.attributes.finishDate),
path: sprint.path,
}
};
safeLog(`create milestone ${milestoneInfo.title}`);
await createMilestone(milestoneInfo);
}
Expand All @@ -118,12 +124,12 @@ async function checkAndCreateMilestone(sprint: any, existingMilestones: any[]):
due_on: string | null;
};
*/
async function getExistingMilestones(prefix: string): Promise<any[]> {
async function getExistingMilestones(prefix: string, state: "open" | "closed" | "all" = "all"): Promise<any[]> {
let resp = await kit.request('GET /repos/{owner}/{repo}/milestones', {
owner: owner,
repo: repo,
direction: 'desc',
state: 'all',
state: state,
per_page: 20,
});
const milestones = resp.data.filter(
Expand All @@ -134,3 +140,23 @@ async function getExistingMilestones(prefix: string): Promise<any[]> {
// latestInfo.due_on = new Date(milestones[latestIndex].due_on!);
}

async function checkAndCloseMilestone(milestone: any): Promise<void> {
safeLog(`check ${milestone.title} for close`);
if (milestone.open_issues === 0 && milestone.due_on) {
const dueTime = new Date(milestone.due_on);
if (dueTime < new Date()) {
await kit.request('PATCH /repos/{owner}/{repo}/milestones/{milestone_number}', {
owner: owner,
repo: repo,
milestone_number: milestone.number,
state: 'closed',
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
});
safeLog(`close dued milestones: ${milestone.title}`);
}
}

}

2 changes: 2 additions & 0 deletions .github/policies/resourceManagement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ configuration:
then:
- addReply:
reply: Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.
- addLabel:
label: needs attention
- description: "[Idle Issue Management] Remove no recent activity label from issues"
if:
- payloadType: Issues
Expand Down
24 changes: 0 additions & 24 deletions .github/workflows/lint-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,30 +43,6 @@ jobs:
}
}
npm-audit:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 14
- name: audit
run: npx lerna-audit
- name: check cache
run: |
git add .
VAR=$(git diff --cached --name-only)
if [ ! -z "$VAR" ]
then
echo $VAR
echo '======================================= Prompt Information ==============================================='
echo 'There found several moderate severity vulnerabilities in this repo, please check in the package or lock file to repo with: '
echo 'npx lerna-audit'
exit 1
fi
check-format:
if: ${{ github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion packages/adaptivecards-tools-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"adaptive-expressions": "^4.20.0",
"adaptivecards": "~2.10.0",
"adaptivecards-templating": "^2.1.0",
"markdown-it": "^12.2.0",
"markdown-it": "^12.3.2",
"react": "^17.0.2"
},
"publishConfig": {
Expand Down
8 changes: 4 additions & 4 deletions packages/adaptivecards-tools-sdk/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions packages/cli/src/commands/models/accountLoginAzure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,17 @@ export const accountLoginAzureCommand: CLICommand = {
],
examples: [
{
command: `${process.env.TEAMSFX_CLI_BIN_NAME} auth login azure --service-principal -u USERNAME -p SECRET --tenant TENANT_ID`,
command: `${process.env.TEAMSFX_CLI_BIN_NAME} auth login azure --interactive false --service-principal -u USERNAME -p SECRET --tenant TENANT_ID`,
description: "Log in with a service principal using client secret",
},
{
command: `${process.env.TEAMSFX_CLI_BIN_NAME} auth login azure --service-principal -u USERNAME -p "C:/Users/mycertfile.pem" --tenant TENANT_ID`,
command: `${process.env.TEAMSFX_CLI_BIN_NAME} auth login azure --interactive false --service-principal -u USERNAME -p "C:/Users/mycertfile.pem" --tenant TENANT_ID`,
description: "Log in with a service principal using client certificate",
},
],
telemetry: {
event: TelemetryEvent.AccountLoginAzure,
},
defaultInteractiveOption: false,
handler: async (ctx) => {
const args = ctx.optionValues;
const isSP = args["service-principal"] as boolean;
Expand Down
24 changes: 13 additions & 11 deletions packages/cli/src/commonlib/azureLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
SubscriptionInfo,
UserError,
} from "@microsoft/teamsfx-api";
import { AzureScopes, isValidProjectV3 } from "@microsoft/teamsfx-core";
import {
AzureScopes,
isValidProjectV3,
InvalidAzureSubscriptionError,
} from "@microsoft/teamsfx-core";
import * as fs from "fs-extra";
import * as path from "path";
import CLIUIInstance from "../userInteraction";
Expand All @@ -41,6 +45,7 @@ import {
import { LoginStatus, login } from "./common/login";
import CLILogProvider from "./log";
import { MemoryCache } from "./memoryCache";
import ui from "../userInteraction";

const accountName = "azure";
const scopes = ["https://management.core.windows.net/user_impersonation"];
Expand Down Expand Up @@ -538,26 +543,23 @@ async function listAll<T>(
return all;
}

import { InvalidAzureSubscriptionError } from "@microsoft/teamsfx-core";
import AzureLoginCI from "./azureLoginCI";
import AzureAccountProviderUserPassword from "./azureLoginUserPassword";

const ciEnabled = process.env.CI_ENABLED;
// todo delete ciEnabled
const azureLogin =
ciEnabled && ciEnabled === "true"
? AzureSpCrypto.checkAzureSPFile()
? AzureLoginCI
: AzureAccountProviderUserPassword
: AzureSpCrypto.checkAzureSPFile()
const azureLogin = !ui.interactive
? AzureSpCrypto.checkAzureSPFile()
? AzureLoginCI
: AzureAccountManager.getInstance();
: AzureAccountProviderUserPassword
: AzureSpCrypto.checkAzureSPFile()
? AzureLoginCI
: AzureAccountManager.getInstance();

export default azureLogin;

// todo merge with default export, this function fix bug when user already logins with service principal, and he logins interactively, default azureLogin will return azureLoginCIProvider
export function getAzureProvider() {
return ciEnabled && ciEnabled === "true"
return !ui.interactive
? AzureSpCrypto.checkAzureSPFile()
? AzureLoginCI
: AzureAccountProviderUserPassword
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commonlib/codeFlowLogin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ export class CodeFlowLogin {
})
.catch(async (error) => {
CliCodeLogInstance.necessaryLog(
LogLevel.Error,
LogLevel.Debug,
"[Login] Failed to retrieve token silently. If you encounter this problem multiple times, you can delete `" +
path.join(os.homedir(), ".fx", "account") +
"` and try again. " +
Expand Down Expand Up @@ -322,7 +322,7 @@ export class CodeFlowLogin {
}
} catch (error: any) {
CliCodeLogInstance.necessaryLog(
LogLevel.Error,
LogLevel.Debug,
"[Login] Failed to retrieve token silently. If you encounter this problem multiple times, you can delete `" +
path.join(os.homedir(), ".fx", "account") +
"` and try again. " +
Expand Down Expand Up @@ -366,7 +366,7 @@ export class CodeFlowLogin {
throw error;
} else {
CliCodeLogInstance.necessaryLog(
LogLevel.Error,
LogLevel.Debug,
"[Login] Failed to retrieve tenant token silently. If you encounter this problem multiple times, you can delete `" +
path.join(os.homedir(), ".fx", "account") +
"` and try again. " +
Expand Down Expand Up @@ -415,7 +415,7 @@ export class CodeFlowLogin {
throw error;
} else {
CliCodeLogInstance.necessaryLog(
LogLevel.Error,
LogLevel.Debug,
"[Login] Failed to retrieve tenant token silently. If you encounter this problem multiple times, you can delete `" +
path.join(os.homedir(), ".fx", "account") +
"` and try again. " +
Expand Down
9 changes: 4 additions & 5 deletions packages/cli/src/commonlib/m365Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { m365CacheName, signedIn, signedOut } from "./common/constant";
import { LoginStatus } from "./common/login";
import M365TokenProviderUserPassword from "./m365LoginUserPassword";
import { AuthSvcScopes, setRegion } from "@microsoft/teamsfx-core";
import ui from "../userInteraction";

const SERVER_PORT = 0;

Expand Down Expand Up @@ -77,7 +78,7 @@ export class M365Login extends BasicLogin implements M365TokenProvider {
if (M365Login.codeFlowInstance.account) {
const regionTokenRes = await M365Login.codeFlowInstance.getTokenByScopes(AuthSvcScopes);
if (regionTokenRes.isOk()) {
setRegion(regionTokenRes.value);
await setRegion(regionTokenRes.value);
}
} else {
needLogin = true;
Expand All @@ -87,7 +88,7 @@ export class M365Login extends BasicLogin implements M365TokenProvider {
if (needLogin == true && M365Login.codeFlowInstance.account) {
const regionTokenRes = await M365Login.codeFlowInstance.getTokenByScopes(AuthSvcScopes);
if (regionTokenRes.isOk()) {
setRegion(regionTokenRes.value);
await setRegion(regionTokenRes.value);
}
}

Expand Down Expand Up @@ -145,8 +146,6 @@ export class M365Login extends BasicLogin implements M365TokenProvider {
}
}

const ciEnabled = process.env.CI_ENABLED;
const m365Login =
ciEnabled && ciEnabled === "true" ? M365TokenProviderUserPassword : M365Login.getInstance();
const m365Login = !ui.interactive ? M365TokenProviderUserPassword : M365Login.getInstance();

export default m365Login;
7 changes: 2 additions & 5 deletions packages/cli/src/userInteraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,9 @@ import { getColorizedString } from "./utils";
type ValidationType<T> = (input: T) => string | boolean | Promise<string | boolean>;

class CLIUserInteraction implements UserInteraction {
get ciEnabled(): boolean {
return process.env.CI_ENABLED === "true";
}
private _interactive = true;
get interactive(): boolean {
if (this.ciEnabled) {
if (process.env.CI_ENABLED === "true") {
return false;
} else {
return this._interactive;
Expand Down Expand Up @@ -534,7 +531,7 @@ class CLIUserInteraction implements UserInteraction {
}

public async openUrl(link: string): Promise<Result<boolean, FxError>> {
if (!this.ciEnabled) await open(link);
if (!this.interactive) await open(link);
return ok(true);
}

Expand Down
17 changes: 11 additions & 6 deletions packages/cli/tests/unit/ui.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { logger } from "../../src/commonlib/logger";
import * as customizedPrompts from "../../src/prompts";
import UI from "../../src/userInteraction";
import { expect } from "./utils";
import mockedEnv from "mocked-env";

describe("User Interaction Tests", function () {
const sandbox = sinon.createSandbox();
Expand Down Expand Up @@ -413,17 +414,21 @@ describe("User Interaction Tests", function () {
afterEach(() => {
sandbox.restore();
});
it("Check process.env", () => {
expect(UI.ciEnabled).equals(process.env.CI_EANBLED === "true");
});
it("interactive = true", async () => {
sandbox.stub(UI, "ciEnabled").value(false);
const mockedEnvRestore = mockedEnv({
CI_ENABLED: "true",
});
UI.interactive = true;
expect(UI.interactive).equals(true);
expect(UI.interactive).equals(false);
mockedEnvRestore();
});
it("interactive = false when ciEnabled", async () => {
sandbox.stub(UI, "ciEnabled").value(true);
const mockedEnvRestore = mockedEnv({
CI_ENABLED: "false",
});
UI.interactive = false;
expect(UI.interactive).equals(false);
mockedEnvRestore();
});

it("Create Progress Bar", async () => {
Expand Down

0 comments on commit 6d198fe

Please sign in to comment.