@hexonet/semantic-release-whmcs 5.0.28 → 5.0.30

Sign up to get free protection for your applications and to get access to all the features.
package/HISTORY.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## [5.0.30](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-whmcs/compare/v5.0.29...v5.0.30) (2024-09-26)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **deps:** bump puppeteer from 23.4.0 to 23.4.1 ([41f653d](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-whmcs/commit/41f653d009c07e66a0629bbc5618a6547393db9d))
7
+
8
+ ## [5.0.29](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-whmcs/compare/v5.0.28...v5.0.29) (2024-09-23)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **deps:** bump debug from 4.3.6 to 4.3.7 ([a76c9c6](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-whmcs/commit/a76c9c65e60d19c2369c711a7168cdb651b2a45c))
14
+ * **deps:** bump puppeteer from 23.3.0 to 23.4.0 ([7e62d3d](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-whmcs/commit/7e62d3d4d05c3b939fd9157dde7fa7b48f10717d))
15
+
1
16
  ## [5.0.28](https://github.com/centralnicgroup-opensource/rtldev-middleware-semantic-release-whmcs/compare/v5.0.27...v5.0.28) (2024-09-05)
2
17
 
3
18
 
@@ -3,14 +3,11 @@ import debugConfig from "debug";
3
3
  import { fileURLToPath } from "node:url";
4
4
  const debug = debugConfig("semantic-release:whmcs");
5
5
  const __filename = fileURLToPath(import.meta.url);
6
+
6
7
  /**
7
- * A method to publish the module update on whmcs market place
8
+ * A method to publish the module update on WHMCS marketplace
8
9
  */
9
10
  export default async (pluginConfig, context) => {
10
- // if (!context.logger) {
11
- // context.logger = console;
12
- // }
13
-
14
11
  const sep = "+++++++++++++++++++++++++++++++++++++++++++++++++++";
15
12
  const out = `\n${sep}\n${__filename}\n${sep}\n`;
16
13
 
@@ -27,55 +24,51 @@ export default async (pluginConfig, context) => {
27
24
  if (!result) {
28
25
  return result;
29
26
  }
27
+
30
28
  const { page, navOpts, gotoOpts, selectorOpts, productid, urlbase } = püppi.config;
31
29
 
32
- // strip markdown links from notes as not allowed to keep
33
30
  try {
34
- // navigate to product administration
31
+ // Navigate to product administration
35
32
  const url = `${urlbase}/product/${productid}/edit#versions`;
36
33
  await page.goto(url, gotoOpts);
37
- debug("product page loaded at %s", url);
38
- // open versions tab (instead of doing it via url)
39
- // let selector = '#nav-tabs li a[href="#versions"]';
40
- // await page.waitForSelector(selector, selectorOpts);
41
- // await page.click(selector);
34
+ debug("Product page loaded at %s", url);
35
+
36
+ // Fetch all version rows
37
+ const rows = await page.$$("tr"); // Get all rows in the table
42
38
 
43
- // delete version
44
- // xpath improvements / changes with v16.1.0
45
- // -> https://github.com/puppeteer/puppeteer/pull/8730
46
- // https://github.com/puppeteer/puppeteer/blob/d1681ec06b7c3db4b51c20b17b3339f852efbd4d/test/src/queryhandler.spec.ts
47
- let elements = [];
48
- do {
49
- const xpath = `xpath/.//td[contains(., "Version ${version}")]/following-sibling::td/a[contains(@class, "btn-styled-red")]`;
50
- await page.waitForSelector(xpath, selectorOpts);
51
- debug("XPath found.");
52
- const nav = page.waitForNavigation(navOpts);
53
- elements = await page.$$(xpath);
54
- if (elements.length) {
55
- debug("Delete Button - click.");
56
- await elements[0].hover();
57
- await elements[0].click();
58
- debug("Delete Button - clicked.");
59
- await nav;
60
- debug("Navigation finished.");
61
- // confirm deletion
62
- const selector = "button.btn-styled-red";
63
- await page.waitForSelector(selector, selectorOpts);
64
- debug("deletion confirmation button available");
65
- debug("click confirmation button");
66
- await page.clickAndNavigate(selector);
67
- debug("clicked confirmation button");
68
- await nav;
69
- debug("WHMCS Marketplace deleting product version succeeded.");
39
+ let deleteButton = null;
40
+
41
+ // Loop through rows to find the one containing the specified version
42
+ for (const row of rows) {
43
+ const textContent = await row.evaluate((el) => el.textContent);
44
+ if (textContent.includes(`Version ${version}`)) {
45
+ // Found the correct row, now look for the delete button
46
+ deleteButton = await row.$("a.btn-styled-red");
47
+ break; // Exit the loop once found
70
48
  }
71
- } while (elements.length);
72
- } catch (error) {
73
- // while loop and having all versions deleted
74
- if (!/waiting for selector `.\/\//i.test(error.message)) {
75
- debug("Deleting product version failed.", error.message);
76
- await page.browser().close();
49
+ }
50
+
51
+ if (!deleteButton) {
52
+ debug(`Delete button for version ${version} not found.`);
77
53
  return false;
78
54
  }
55
+
56
+ // Click the delete button and wait for navigation
57
+ debug("Clicking the delete button.");
58
+ await Promise.all([deleteButton.click(), page.waitForNavigation(navOpts)]);
59
+
60
+ // Confirm deletion by clicking the confirmation button
61
+ const confirmSelector = "button.btn-styled-red";
62
+ await page.waitForSelector(confirmSelector, selectorOpts);
63
+ debug("Deletion confirmation button available.");
64
+
65
+ await Promise.all([page.click(confirmSelector), page.waitForNavigation(navOpts)]);
66
+
67
+ debug("Clicked confirmation button. WHMCS Marketplace product version deleted successfully.");
68
+ } catch (error) {
69
+ debug("Deleting product version failed.", error.message);
70
+ await page.browser().close();
71
+ return false;
79
72
  }
80
73
 
81
74
  await page.browser().close();
package/lib/puppet.js CHANGED
@@ -10,14 +10,14 @@ export default async (context) => {
10
10
  // logger: logger,
11
11
  gotoOpts: {
12
12
  waitUntil: ["load", "domcontentloaded"],
13
- timeout: 240000,
13
+ timeout: 60 * 1000 * 10,
14
14
  },
15
15
  navOpts: {
16
16
  waitUntil: ["networkidle0"],
17
- timeout: 240000,
17
+ timeout: 60 * 1000 * 5,
18
18
  },
19
19
  selectorOpts: {
20
- timeout: 60000,
20
+ timeout: 60 * 1000 * 5,
21
21
  },
22
22
  logger: context.logger,
23
23
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hexonet/semantic-release-whmcs",
3
3
  "description": "`semantic-release` plugin for auto-publishing on WHMCS marketplace",
4
- "version": "5.0.28",
4
+ "version": "5.0.30",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "publishConfig": {
@@ -87,7 +87,7 @@
87
87
  "aggregate-error": "^5.0.0",
88
88
  "debug": "^4.3.4",
89
89
  "github-api": "^3.4.0",
90
- "puppeteer": "^23.1.0",
90
+ "puppeteer": ">=23.4.0",
91
91
  "yargs": "^17.7.1"
92
92
  }
93
93
  }