@datacamp/learn-vm-scripts 1.8.3 → 1.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +47 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -366663,12 +366663,16 @@ var setInput = ({
|
|
|
366663
366663
|
|
|
366664
366664
|
// src/azureLogin.ts
|
|
366665
366665
|
var closeOnboardingPopups = async (page) => {
|
|
366666
|
-
|
|
366667
|
-
|
|
366668
|
-
|
|
366669
|
-
|
|
366670
|
-
|
|
366671
|
-
|
|
366666
|
+
try {
|
|
366667
|
+
const welcomeSurveyCloseButton = 'span.fxs-welcomesurvey-close-icon[role="button"]';
|
|
366668
|
+
await page.waitForSelector(welcomeSurveyCloseButton);
|
|
366669
|
+
await page.click(welcomeSurveyCloseButton);
|
|
366670
|
+
const popupButton = "button.fxs-teaching-bubble-close";
|
|
366671
|
+
await page.waitForSelector(popupButton);
|
|
366672
|
+
await page.click(popupButton);
|
|
366673
|
+
} catch {
|
|
366674
|
+
log("Onboarding popups not found or not clickable");
|
|
366675
|
+
}
|
|
366672
366676
|
};
|
|
366673
366677
|
var closeSideNavigation = async (page) => {
|
|
366674
366678
|
try {
|
|
@@ -366717,7 +366721,7 @@ async function loginToAzure({
|
|
|
366717
366721
|
log("Password entered successfully");
|
|
366718
366722
|
log("Ensuring user stays signed in ...");
|
|
366719
366723
|
await page.waitForSelector('[type="submit"]');
|
|
366720
|
-
await page.click('[type="submit"]');
|
|
366724
|
+
await Promise.all([page.waitForNavigation(), page.click('[type="submit"]')]);
|
|
366721
366725
|
if (skipOnboarding) {
|
|
366722
366726
|
log("Skipping onboarding...");
|
|
366723
366727
|
void closeOnboardingPopups(page).catch((error) => {
|
|
@@ -366725,7 +366729,6 @@ async function loginToAzure({
|
|
|
366725
366729
|
});
|
|
366726
366730
|
}
|
|
366727
366731
|
if (url.includes("m365.cloud.microsoft/chat")) {
|
|
366728
|
-
await page.waitForNavigation({ waitUntil: "networkidle0" });
|
|
366729
366732
|
void closeSideNavigation(page).catch((error) => {
|
|
366730
366733
|
console.error(
|
|
366731
366734
|
"Error closing side navigation for Microsoft 365 copilot chat: ",
|
|
@@ -367071,9 +367074,10 @@ var handleInput = async ({ line, page }) => {
|
|
|
367071
367074
|
default:
|
|
367072
367075
|
return unreachable(input);
|
|
367073
367076
|
}
|
|
367074
|
-
|
|
367077
|
+
return true;
|
|
367075
367078
|
} catch (error) {
|
|
367076
367079
|
console.error(`Error: "${error.message}" on input ${line}`);
|
|
367080
|
+
return false;
|
|
367077
367081
|
}
|
|
367078
367082
|
};
|
|
367079
367083
|
var createFileIfNotExists = async (filePath) => {
|
|
@@ -367092,6 +367096,9 @@ var startInputWatcher = async ({
|
|
|
367092
367096
|
}) => {
|
|
367093
367097
|
const outputFileHandle = await fs.open(outputFilePath, "a");
|
|
367094
367098
|
let lastInput = void 0;
|
|
367099
|
+
let lastInputSucceeded = void 0;
|
|
367100
|
+
let processingPromise = void 0;
|
|
367101
|
+
let numberOfRuns = 0;
|
|
367095
367102
|
await createFileIfNotExists(inputFilePath);
|
|
367096
367103
|
let page = await setupPuppeteerPage({
|
|
367097
367104
|
executablePath,
|
|
@@ -367105,8 +367112,9 @@ var startInputWatcher = async ({
|
|
|
367105
367112
|
log("No input");
|
|
367106
367113
|
return;
|
|
367107
367114
|
}
|
|
367108
|
-
if (lastInput != null && newInput === lastInput) {
|
|
367115
|
+
if (lastInput != null && newInput === lastInput && lastInputSucceeded === true) {
|
|
367109
367116
|
log("Input already processed");
|
|
367117
|
+
log("Script ran successfully");
|
|
367110
367118
|
await outputFileHandle.appendFile(`Done: ${newInput}`);
|
|
367111
367119
|
return;
|
|
367112
367120
|
}
|
|
@@ -367119,19 +367127,44 @@ var startInputWatcher = async ({
|
|
|
367119
367127
|
});
|
|
367120
367128
|
}
|
|
367121
367129
|
log("New input, processing");
|
|
367122
|
-
await handleInput({ line: newInput, page });
|
|
367130
|
+
const success = await handleInput({ line: newInput, page });
|
|
367131
|
+
lastInput = newInput;
|
|
367132
|
+
if (success) {
|
|
367133
|
+
log("Script ran successfully");
|
|
367134
|
+
lastInputSucceeded = true;
|
|
367135
|
+
} else {
|
|
367136
|
+
log("Script ran unsuccessfully");
|
|
367137
|
+
lastInputSucceeded = false;
|
|
367138
|
+
}
|
|
367123
367139
|
await outputFileHandle.appendFile(`Done: ${newInput}`);
|
|
367124
367140
|
log("Done processing input");
|
|
367125
|
-
lastInput = newInput;
|
|
367126
367141
|
};
|
|
367127
|
-
|
|
367142
|
+
const run = async () => {
|
|
367143
|
+
numberOfRuns++;
|
|
367144
|
+
const runId = numberOfRuns;
|
|
367145
|
+
if (processingPromise != null) {
|
|
367146
|
+
log(`WARNING: Parallel execution detected!`);
|
|
367147
|
+
await processingPromise;
|
|
367148
|
+
if (runId !== numberOfRuns) {
|
|
367149
|
+
log(`WARNING: Run ${runId} was cancelled`);
|
|
367150
|
+
return;
|
|
367151
|
+
}
|
|
367152
|
+
}
|
|
367153
|
+
try {
|
|
367154
|
+
processingPromise = checkInputFile();
|
|
367155
|
+
await processingPromise;
|
|
367156
|
+
} finally {
|
|
367157
|
+
processingPromise = void 0;
|
|
367158
|
+
}
|
|
367159
|
+
};
|
|
367160
|
+
await run();
|
|
367128
367161
|
log("Waiting for input");
|
|
367129
367162
|
for await (const event of fs.watch(inputFilePath)) {
|
|
367130
367163
|
if (event.eventType !== "change") {
|
|
367131
367164
|
continue;
|
|
367132
367165
|
}
|
|
367133
367166
|
log("Input file changed");
|
|
367134
|
-
await
|
|
367167
|
+
await run();
|
|
367135
367168
|
}
|
|
367136
367169
|
};
|
|
367137
367170
|
|
package/package.json
CHANGED