refactor(config): load JSON configs and emit JSON-only PCA output
This commit is contained in:
@@ -35,7 +35,7 @@ function runAz(args, options = {}) {
|
||||
async function main() {
|
||||
const usageText = `Usage: ${path.basename(process.argv[1])} [options] <app-name>
|
||||
Options:
|
||||
-c, --config <path> Write config template to file (optional)
|
||||
-c, --config <path> Write JSON config to file (optional)
|
||||
-h, --help Show this help message and exit`;
|
||||
let values;
|
||||
let positionals;
|
||||
@@ -51,7 +51,7 @@ Options:
|
||||
}));
|
||||
} catch (err) {
|
||||
console.error(`Error: ${err.message}`);
|
||||
console.log(usageText);
|
||||
console.error(usageText);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ Options:
|
||||
console.error(
|
||||
"Error: Too many positional arguments. Only one app name positional argument is allowed.",
|
||||
);
|
||||
console.log(usageText);
|
||||
console.error(usageText);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ Options:
|
||||
|
||||
if (!appName) {
|
||||
console.error("Error: Application name is required.");
|
||||
console.log(usageText);
|
||||
console.error(usageText);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -89,13 +89,12 @@ Options:
|
||||
"tsv",
|
||||
]).stdout;
|
||||
|
||||
let userConfirmation = "";
|
||||
if (appId) {
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout,
|
||||
output: process.stderr,
|
||||
});
|
||||
userConfirmation = await new Promise((resolve) => {
|
||||
const answer = await new Promise((resolve) => {
|
||||
rl.question(
|
||||
`Application '${appName}' already exists. Update it? [y/N]: `,
|
||||
(answer) => {
|
||||
@@ -105,8 +104,8 @@ Options:
|
||||
);
|
||||
});
|
||||
|
||||
if (!/^(yes|y)$/i.test(userConfirmation)) {
|
||||
console.log("Canceled.");
|
||||
if (!/^(yes|y)$/i.test(answer)) {
|
||||
console.error("Canceled.");
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
@@ -231,16 +230,14 @@ Options:
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (userConfirmation) {
|
||||
console.log(`Updated application '${appName}'`);
|
||||
} else {
|
||||
console.log(`Created application '${appName}'`);
|
||||
}
|
||||
const configTemplate = `export const config = {
|
||||
"appName": "${appName}",
|
||||
"tenantId": "${tenantId}",
|
||||
"clientId": "${appId}"
|
||||
};`;
|
||||
const configTemplate = JSON.stringify(
|
||||
{
|
||||
tenantId,
|
||||
clientId: appId,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
);
|
||||
|
||||
if (configPath) {
|
||||
const targetPath = path.resolve(configPath);
|
||||
|
||||
Reference in New Issue
Block a user