Skip to content

Commit

Permalink
[Admin] Update script to bypass user prompt when run from GitHub Acti…
Browse files Browse the repository at this point in the history
…on (#2060)

* [Admin] Update script to bypass user prompt when run from GitHub Action

* Updates based on feedback
  • Loading branch information
ElizabethSamuel-MSFT authored Sep 16, 2024
1 parent e0e36c3 commit 2e88f23
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 15 deletions.
9 changes: 8 additions & 1 deletion generate-docs/GenerateDocs.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash

while getopts b: flag
do
case "${flag}" in
b) bypassPrompt=${OPTARG};;
esac
done

if [ -e "build-log.txt" ]; then
rm build-log.txt
fi
Expand Down Expand Up @@ -35,7 +42,7 @@ npm install
pushd scripts
npm install
npm run build
node preprocessor.js
node preprocessor.js $bypassPrompt
popd


Expand Down
39 changes: 25 additions & 14 deletions generate-docs/scripts/preprocessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@ import * as path from "path";
import * as fsx from 'fs-extra';

tryCatch(async () => {
// ----
// Display prompts
// ----
console.log('\n\n');
const args = process.argv.slice(2);
let sourceChoice;

console.log('\n');
const sourceChoice = await promptFromList({
message: `What is the source of the Office-js TypeScript definition files that should be used to generate the docs?`,
choices: [
{ name: "DefinitelyTyped (optimized rebuild)", value: "DT" },
{ name: "DefinitelyTyped (full rebuild)", value: "DT+" },
{ name: "CDN (if available)", value: "CDN" },
{ name: "Local files [generate-docs\\script-inputs\\*.d.ts]", value: "Local" }
]
});
// Bypass the prompt - for use with the GitHub Action.
if (args.length > 0 && args[0] !== null && args[0].trim().length > 0) {
console.log("Bypassing source choice prompt.");
sourceChoice = args[0].trim();
} else {
// ----
// Display prompts
// ----
console.log('\n\n');

console.log('\n');
sourceChoice = await promptFromList({
message: `What is the source of the Office-js TypeScript definition files that should be used to generate the docs?`,
choices: [
{ name: "DefinitelyTyped (optimized rebuild)", value: "DT" },
{ name: "DefinitelyTyped (full rebuild)", value: "DT+" },
{ name: "CDN (if available)", value: "CDN" },
{ name: "Local files [generate-docs\\script-inputs\\*.d.ts]", value: "Local" }
]
});
}


let urlToCopyOfficeJsFrom = "";
Expand Down Expand Up @@ -48,6 +57,8 @@ tryCatch(async () => {
// to avoid being redirected to the EDOG environment on corpnet.
// If we ever want to generate not just public d.ts but also "office-with-first-party.d.ts",
// replace the filename.
default:
throw new Error(`Invalid prompt selection: ${sourceChoice}`);
}

console.log("\nStarting preprocessor script...\n");
Expand Down

0 comments on commit 2e88f23

Please sign in to comment.