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

fix: apim parameter is not string #1450

Merged
merged 2 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
70 changes: 38 additions & 32 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
QTreeNode,
Inputs,
Platform,
Colors
Colors,
} from "@microsoft/teamsfx-api";

import { ConfigNotFoundError, ReadFileError } from "./error";
Expand Down Expand Up @@ -96,7 +96,7 @@ export function toYargsOptions(data: Question): Options {
// if (choices && choices.length > 0 && data.default === undefined) {
// data.default = choices[0];
// }

const defaultValue = data.default;
if (defaultValue && defaultValue instanceof Array && defaultValue.length > 0) {
data.default = defaultValue.map((item) => item.toLocaleLowerCase());
Expand All @@ -110,7 +110,8 @@ export function toYargsOptions(data: Question): Options {
choices: choices,
hidden: !!(data as any).hide,
global: false,
}
type: "string",
};
}
return {
array: data.type === "multiSelect",
Expand All @@ -119,6 +120,7 @@ export function toYargsOptions(data: Question): Options {
choices: choices,
hidden: !!(data as any).hide,
global: false,
type: "string",
};
}

Expand Down Expand Up @@ -230,52 +232,56 @@ export function getTeamsAppId(rootfolder: string | undefined): any {
return undefined;
}

export function getSystemInputs(projectPath?: string):Inputs{
const systemInputs:Inputs = {
export function getSystemInputs(projectPath?: string): Inputs {
const systemInputs: Inputs = {
platform: Platform.CLI,
projectPath: projectPath,
correlationId: uuid.v4()
correlationId: uuid.v4(),
};
return systemInputs;
}

export function argsToInputs(params: { [_: string]: Options }, args: { [argName: string]: string|string[] }):Inputs{
export function argsToInputs(
params: { [_: string]: Options },
args: { [argName: string]: string | string[] }
): Inputs {
const inputs = getSystemInputs();
for (const name in params) {
if (name.endsWith("folder") && args[name]) {
inputs[name] = path.resolve(args[name] as string);
}
else {
} else {
inputs[name] = args[name];
}
}
const rootFolder = path.resolve(inputs["folder"] as string || "./");
const rootFolder = path.resolve((inputs["folder"] as string) || "./");
delete inputs["folder"];
inputs.projectPath = rootFolder;
return inputs;
}

export function getColorizedString(message: Array<{content: string, color: Colors}>): string {
export function getColorizedString(message: Array<{ content: string; color: Colors }>): string {
// Color support is automatically detected by chalk
const colorizedMessage = message.map(item => {
switch(item.color) {
case Colors.BRIGHT_WHITE:
return chalk.whiteBright(item.content);
case Colors.WHITE:
return chalk.white(item.content);
case Colors.BRIGHT_MAGENTA:
return chalk.magentaBright(item.content);
case Colors.BRIGHT_GREEN:
return chalk.greenBright(item.content);
case Colors.BRIGHT_RED:
return chalk.redBright(item.content);
case Colors.BRIGHT_YELLOW:
return chalk.yellowBright(item.content);
case Colors.BRIGHT_CYAN:
return chalk.cyanBright.underline(item.content);
default:
return item.content;
}
}).join("");
const colorizedMessage = message
.map((item) => {
switch (item.color) {
case Colors.BRIGHT_WHITE:
return chalk.whiteBright(item.content);
case Colors.WHITE:
return chalk.white(item.content);
case Colors.BRIGHT_MAGENTA:
return chalk.magentaBright(item.content);
case Colors.BRIGHT_GREEN:
return chalk.greenBright(item.content);
case Colors.BRIGHT_RED:
return chalk.redBright(item.content);
case Colors.BRIGHT_YELLOW:
return chalk.yellowBright(item.content);
case Colors.BRIGHT_CYAN:
return chalk.cyanBright.underline(item.content);
default:
return item.content;
}
})
.join("");
return colorizedMessage;
}
}
3 changes: 1 addition & 2 deletions packages/cli/tests/e2e/smoke/AzureAppHappyPath.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ describe("Azure App Happy Path", function () {

// provision
await execAsyncWithRetry(
`teamsfx provision --sql-admin-name Abc123321 --sql-password Cab232332 --sql-confirm-password Cab232332`
+ ` --sql-skip-adding-user false`,
`teamsfx provision --sql-admin-name Abc123321 --sql-password Cab232332 --sql-confirm-password Cab232332`,
{
cwd: projectPath,
env: process.env,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe("Provision to Azure with SQL", function () {

// provision
await execAsyncWithRetry(
`teamsfx provision --subscription ${subscription} --sql-admin-name Abc123321 --sql-password Cab232332 --sql-confirm-password Cab232332 --sql-skip-adding-user false`,
`teamsfx provision --subscription ${subscription} --sql-admin-name Abc123321 --sql-password Cab232332 --sql-confirm-password Cab232332`,
{
cwd: projectPath,
env: process.env,
Expand Down