@datacamp/learn-vm-scripts 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/dist/index.cjs +14 -15
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -92641,7 +92641,7 @@ var {
92641
92641
  var puppeteer_core_default = puppeteer;
92642
92642
 
92643
92643
  // src/setup.ts
92644
- async function setupBrowser({
92644
+ async function setupPuppeteerPage({
92645
92645
  executablePath: executablePath2,
92646
92646
  userDataDir
92647
92647
  }) {
@@ -92655,10 +92655,9 @@ async function setupBrowser({
92655
92655
  });
92656
92656
  const pages = await browser.pages();
92657
92657
  if (pages[0] !== void 0) {
92658
- return { browser, page: pages[0] };
92658
+ return pages[0];
92659
92659
  }
92660
- const page = await browser.newPage();
92661
- return { browser, page };
92660
+ return browser.newPage();
92662
92661
  }
92663
92662
 
92664
92663
  // src/utils.ts
@@ -92730,7 +92729,7 @@ async function loginToAzure({
92730
92729
  log("Password entered successfully");
92731
92730
  log("Ensuring user stays signed in ...");
92732
92731
  await page.waitForSelector('[type="submit"]');
92733
- await Promise.all([page.waitForNavigation(), page.click('[type="submit"]')]);
92732
+ await page.click('[type="submit"]');
92734
92733
  log("Logged in to Azure successfully");
92735
92734
  }
92736
92735
 
@@ -92811,19 +92810,11 @@ var Input = objectType({
92811
92810
  url: stringType(),
92812
92811
  username: stringType()
92813
92812
  });
92814
- var handleInput = async ({
92815
- line,
92816
- userDataDir,
92817
- executablePath: executablePath2
92818
- }) => {
92813
+ var handleInput = async ({ line, page }) => {
92819
92814
  try {
92820
92815
  const { cloudProvider, url, password, username } = Input.parse(
92821
92816
  JSON.parse(line)
92822
92817
  );
92823
- const { browser, page } = await setupBrowser({
92824
- executablePath: executablePath2,
92825
- userDataDir
92826
- });
92827
92818
  switch (cloudProvider) {
92828
92819
  case "azure":
92829
92820
  await loginToAzure({ url, username, page, password });
@@ -92872,6 +92863,10 @@ var startInputWatcher = async ({
92872
92863
  const outputFileHandle = await fs6.open(outputFilePath, "a");
92873
92864
  let lastInput = void 0;
92874
92865
  await createFileIfNotExists(inputFilePath);
92866
+ let page = await setupPuppeteerPage({
92867
+ executablePath: executablePath2,
92868
+ userDataDir
92869
+ });
92875
92870
  const checkInputFile = async () => {
92876
92871
  const fileContent = await fs6.readFile(inputFilePath, { encoding: "utf-8" });
92877
92872
  const lines = fileContent.split(/\r?\n/);
@@ -92888,9 +92883,13 @@ var startInputWatcher = async ({
92888
92883
  if (lastInput != null) {
92889
92884
  log("Resetting Chrome");
92890
92885
  await resetChrome({ userDataDir });
92886
+ page = await setupPuppeteerPage({
92887
+ executablePath: executablePath2,
92888
+ userDataDir
92889
+ });
92891
92890
  }
92892
92891
  log("New input, processing");
92893
- await handleInput({ line: newInput, userDataDir, executablePath: executablePath2 });
92892
+ await handleInput({ line: newInput, page });
92894
92893
  await outputFileHandle.appendFile(`Done: ${newInput}`);
92895
92894
  log("Done processing input");
92896
92895
  lastInput = newInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datacamp/learn-vm-scripts",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "repository": "git@github.com:datacamp-engineering/learn-vm-scripts.git",
5
5
  "description": "Scripts used by VMs in learn.",
6
6
  "main": "./dist/index.cjs",