@datacamp/learn-vm-scripts 1.1.0 → 1.2.0
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 -0
- package/dist/local.cjs +44 -59
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -92815,6 +92815,8 @@ async function loginToDatabricks({
|
|
|
92815
92815
|
// src/resetChrome.ts
|
|
92816
92816
|
var import_node_child_process = require("node:child_process");
|
|
92817
92817
|
var import_promises3 = require("node:fs/promises");
|
|
92818
|
+
|
|
92819
|
+
// src/retryWithExponentialBackoff.ts
|
|
92818
92820
|
var retryWithExponentialBackoff = async ({
|
|
92819
92821
|
fn,
|
|
92820
92822
|
maxRetries,
|
|
@@ -92835,6 +92837,8 @@ var retryWithExponentialBackoff = async ({
|
|
|
92835
92837
|
}
|
|
92836
92838
|
throw new Error("Max retries exceeded");
|
|
92837
92839
|
};
|
|
92840
|
+
|
|
92841
|
+
// src/resetChrome.ts
|
|
92838
92842
|
var resetChrome = async ({ userDataDir }) => {
|
|
92839
92843
|
try {
|
|
92840
92844
|
const stdout = (0, import_node_child_process.execSync)("taskkill /IM chrome.exe /F");
|
|
@@ -92892,6 +92896,45 @@ async function loginToSnowflake({
|
|
|
92892
92896
|
await notNowButton?.click();
|
|
92893
92897
|
}
|
|
92894
92898
|
|
|
92899
|
+
// src/fabricLogin.ts
|
|
92900
|
+
async function loginToFabric({
|
|
92901
|
+
url,
|
|
92902
|
+
page,
|
|
92903
|
+
username,
|
|
92904
|
+
password
|
|
92905
|
+
}) {
|
|
92906
|
+
log("Navigating to Fabric login page...");
|
|
92907
|
+
await page.goto(ensureHttps(url));
|
|
92908
|
+
log("Entering email...");
|
|
92909
|
+
await page.waitForSelector('input[id="email"]');
|
|
92910
|
+
await setInput({
|
|
92911
|
+
page,
|
|
92912
|
+
querySelector: 'input[id="email"]',
|
|
92913
|
+
value: username
|
|
92914
|
+
});
|
|
92915
|
+
await page.waitForSelector("button#submitBtn[onclick]");
|
|
92916
|
+
await retryWithExponentialBackoff({
|
|
92917
|
+
fn: () => page.click("button#submitBtn[onclick]"),
|
|
92918
|
+
initialDelay: 100,
|
|
92919
|
+
maxRetries: 10
|
|
92920
|
+
});
|
|
92921
|
+
log("Entering password...");
|
|
92922
|
+
await page.waitForSelector('input[type="password"]');
|
|
92923
|
+
await setInput({
|
|
92924
|
+
page,
|
|
92925
|
+
querySelector: 'input[type="password"]',
|
|
92926
|
+
value: password
|
|
92927
|
+
});
|
|
92928
|
+
await page.waitForSelector('input[type="submit"]');
|
|
92929
|
+
await Promise.all([
|
|
92930
|
+
page.waitForNavigation(),
|
|
92931
|
+
page.click('input[type="submit"]')
|
|
92932
|
+
]);
|
|
92933
|
+
log("Making sure user stays signed in...");
|
|
92934
|
+
await page.waitForSelector('input[type="submit"]');
|
|
92935
|
+
await page.click('input[type="submit"]');
|
|
92936
|
+
}
|
|
92937
|
+
|
|
92895
92938
|
// src/startInputWatcher.ts
|
|
92896
92939
|
var Input = objectType({
|
|
92897
92940
|
cloudProvider: enumType(["aws", "azure", "snowflake"]),
|
|
@@ -92910,6 +92953,10 @@ var handleInput = async ({ line, page }) => {
|
|
|
92910
92953
|
await loginToDatabricks({ url, page, password, username });
|
|
92911
92954
|
break;
|
|
92912
92955
|
}
|
|
92956
|
+
if (url.includes("app.fabric.microsoft.com")) {
|
|
92957
|
+
await loginToFabric({ url, page, password, username });
|
|
92958
|
+
break;
|
|
92959
|
+
}
|
|
92913
92960
|
await loginToAzure({ url, username, page, password });
|
|
92914
92961
|
break;
|
|
92915
92962
|
case "aws":
|
package/dist/local.cjs
CHANGED
|
@@ -85624,7 +85624,6 @@ async function setupPuppeteerPage({
|
|
|
85624
85624
|
}
|
|
85625
85625
|
|
|
85626
85626
|
// src/utils.ts
|
|
85627
|
-
var AZURE_LOGIN_URL = "https://portal.azure.com/";
|
|
85628
85627
|
function ensureHttps(url) {
|
|
85629
85628
|
const hasProtocol = /^(http|https):\/\//i.test(url);
|
|
85630
85629
|
if (!hasProtocol) {
|
|
@@ -85652,79 +85651,65 @@ var log = (message) => {
|
|
|
85652
85651
|
console.log(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}`);
|
|
85653
85652
|
};
|
|
85654
85653
|
|
|
85655
|
-
// src/
|
|
85656
|
-
var
|
|
85657
|
-
|
|
85658
|
-
|
|
85659
|
-
|
|
85660
|
-
|
|
85661
|
-
|
|
85662
|
-
|
|
85654
|
+
// src/retryWithExponentialBackoff.ts
|
|
85655
|
+
var retryWithExponentialBackoff = async ({
|
|
85656
|
+
fn,
|
|
85657
|
+
maxRetries,
|
|
85658
|
+
initialDelay
|
|
85659
|
+
}) => {
|
|
85660
|
+
let retries = 0;
|
|
85661
|
+
while (retries < maxRetries) {
|
|
85662
|
+
try {
|
|
85663
|
+
await fn();
|
|
85664
|
+
return;
|
|
85665
|
+
} catch (e) {
|
|
85666
|
+
console.error(`Error in exponential backoff iteration ${retries}:`, e);
|
|
85667
|
+
await new Promise(
|
|
85668
|
+
(resolve5) => setTimeout(resolve5, 2 ** retries * initialDelay)
|
|
85669
|
+
);
|
|
85670
|
+
retries++;
|
|
85671
|
+
}
|
|
85672
|
+
}
|
|
85673
|
+
throw new Error("Max retries exceeded");
|
|
85663
85674
|
};
|
|
85664
|
-
|
|
85675
|
+
|
|
85676
|
+
// src/fabricLogin.ts
|
|
85677
|
+
async function loginToFabric({
|
|
85665
85678
|
url,
|
|
85666
|
-
username,
|
|
85667
85679
|
page,
|
|
85668
|
-
|
|
85669
|
-
|
|
85680
|
+
username,
|
|
85681
|
+
password
|
|
85670
85682
|
}) {
|
|
85671
|
-
log("Navigating to
|
|
85672
|
-
await
|
|
85683
|
+
log("Navigating to Fabric login page...");
|
|
85684
|
+
await page.goto(ensureHttps(url));
|
|
85673
85685
|
log("Entering email...");
|
|
85674
|
-
|
|
85675
|
-
await page.waitForSelector(usernameQuerySelector);
|
|
85686
|
+
await page.waitForSelector('input[id="email"]');
|
|
85676
85687
|
await setInput({
|
|
85677
85688
|
page,
|
|
85678
|
-
querySelector:
|
|
85689
|
+
querySelector: 'input[id="email"]',
|
|
85679
85690
|
value: username
|
|
85680
85691
|
});
|
|
85681
|
-
await
|
|
85682
|
-
|
|
85683
|
-
page.click(
|
|
85684
|
-
|
|
85685
|
-
|
|
85692
|
+
await page.waitForSelector("button#submitBtn[onclick]");
|
|
85693
|
+
await retryWithExponentialBackoff({
|
|
85694
|
+
fn: () => page.click("button#submitBtn[onclick]"),
|
|
85695
|
+
initialDelay: 100,
|
|
85696
|
+
maxRetries: 10
|
|
85697
|
+
});
|
|
85686
85698
|
log("Entering password...");
|
|
85687
|
-
|
|
85688
|
-
await page.waitForSelector(passwordQuerySelector, { visible: true });
|
|
85699
|
+
await page.waitForSelector('input[type="password"]');
|
|
85689
85700
|
await setInput({
|
|
85690
85701
|
page,
|
|
85691
|
-
querySelector:
|
|
85702
|
+
querySelector: 'input[type="password"]',
|
|
85692
85703
|
value: password
|
|
85693
85704
|
});
|
|
85705
|
+
await page.waitForSelector('input[type="submit"]');
|
|
85694
85706
|
await Promise.all([
|
|
85695
85707
|
page.waitForNavigation(),
|
|
85696
85708
|
page.click('input[type="submit"]')
|
|
85697
85709
|
]);
|
|
85698
|
-
log("
|
|
85699
|
-
|
|
85700
|
-
await page.
|
|
85701
|
-
await page.click('[type="submit"]');
|
|
85702
|
-
if (skipOnboarding) {
|
|
85703
|
-
log("Skipping onboarding...");
|
|
85704
|
-
void closeOnboardingPopups(page).catch((error) => {
|
|
85705
|
-
console.error("Error in onboarding of Azure login: ", error);
|
|
85706
|
-
});
|
|
85707
|
-
}
|
|
85708
|
-
log("Logged in to Azure successfully");
|
|
85709
|
-
}
|
|
85710
|
-
|
|
85711
|
-
// src/fabricLogin.ts
|
|
85712
|
-
async function loginToFabric({
|
|
85713
|
-
url,
|
|
85714
|
-
page,
|
|
85715
|
-
username,
|
|
85716
|
-
password
|
|
85717
|
-
}) {
|
|
85718
|
-
await loginToAzure({
|
|
85719
|
-
url: AZURE_LOGIN_URL,
|
|
85720
|
-
username,
|
|
85721
|
-
page,
|
|
85722
|
-
password,
|
|
85723
|
-
skipOnboarding: false
|
|
85724
|
-
});
|
|
85725
|
-
log("Navigating to Fabric login page...");
|
|
85726
|
-
await page.goto(ensureHttps(url));
|
|
85727
|
-
log("Logged in to Fabric successfully");
|
|
85710
|
+
log("Making sure user stays signed in...");
|
|
85711
|
+
await page.waitForSelector('input[type="submit"]');
|
|
85712
|
+
await page.click('input[type="submit"]');
|
|
85728
85713
|
}
|
|
85729
85714
|
|
|
85730
85715
|
// src/local.ts
|
|
@@ -85736,9 +85721,9 @@ var main = async () => {
|
|
|
85736
85721
|
userDataDir
|
|
85737
85722
|
});
|
|
85738
85723
|
await loginToFabric({
|
|
85739
|
-
url: "https://app.fabric.microsoft.com/groups/
|
|
85740
|
-
username: "student-
|
|
85741
|
-
password: "
|
|
85724
|
+
url: "https://app.fabric.microsoft.com/groups/e6ee3b8e-9bea-4387-acb8-c6f6e6c01ad3/list?ctid=348b43ee-8752-46f9-808c-350eaafe29b6&experience=data-engineering",
|
|
85725
|
+
username: "student-f0ef13a1-ea92-4bb2-b6cf-781f7d222c8c@datacamplearn.onmicrosoft.com",
|
|
85726
|
+
password: "s98BSHz@JYUEOyO9P@5s",
|
|
85742
85727
|
page
|
|
85743
85728
|
});
|
|
85744
85729
|
};
|
package/package.json
CHANGED