Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
ci(WHMCS): auto-add new module version on marketplace
Browse files Browse the repository at this point in the history
  • Loading branch information
KaiSchwarz-cnic committed Mar 11, 2019
1 parent 753a843 commit ecce845
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
Binary file added module.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions package.json
Expand Up @@ -53,8 +53,9 @@
"@semantic-release/git": "7.0.8",
"@semantic-release/github": "5.2.10",
"conventional-changelog": "3.0.6",
"semantic-release": "^15.9.17",
"travis-deploy-once": "^5.0.9"
"puppeteer": "1.13.0",
"semantic-release": "15.13.3",
"travis-deploy-once": "5.0.11"
},
"release": {
"debug": false,
Expand Down Expand Up @@ -108,6 +109,10 @@
"path": "pkg/whmcs-ispapi-backorder.tar.gz"
}
]
},
{
"path": "@semantic-release/exec",
"cmd": "node whmcsmarketplace.js ${nextRelease.version} \"${nextRelease.notes}\""
}
]
},
Expand Down
54 changes: 54 additions & 0 deletions whmcsmarketplace.js
@@ -0,0 +1,54 @@
'use strict';

const puppeteer = require('puppeteer');
const login = process.env.WHMCSMP_LOGIN;
const password = process.env.WHMCSMP_PASSWORD;
const version = process.argv[2];
const changelog = process.argv[3];

const submitForm = async (page, selector, skipWait) => {
await page.$eval(selector, form => form.submit());
if (skipWait) {
return Promise.resolve();
}
return page.waitForNavigation({ waitUntil: 'networkidle2' });
};

(async () => {
let url = 'https://marketplace.whmcs.com/user/login';
const browser = await puppeteer.launch({
headless: true
});
const [page] = await browser.pages();
// page.on('console', msg => console.log('PAGE LOG:', msg.text()));
await page.setJavaScriptEnabled(true);
await page.goto(url, { waitUntil: ['load', 'domcontentloaded'], timeout: 10000 });
// do login
let selector = '#email';
await page.type(selector, login);
selector = '#password';
await page.type(selector, password);
await submitForm(page, 'div.login-leftcol form', true);
await page.waitFor(2000);

// add new version
url = 'https://marketplace.whmcs.com/product/3386/versions/new';
await page.goto(url, { waitUntil: ['load', 'domcontentloaded'], timeout: 10000 });
selector = '#version';
await page.type(selector, version);
selector = '#released_at';
const date = new Date();
const day = date.getDate();
const month = date.getMonth() + 1;
//tt.mm.jjjj
//but for any reason we need to provide mm.tt.jjjj when doing it though puppeteer
//tt.mm.jjjj in non-headless mode mm.tt.jjjj otherwise? lol?
await page.type(selector, `${month < 10 ? '0' : ''}${month}.${day < 10 ? '0' : ''}${day}.${date.getFullYear()}`);
selector = '#description';
await page.type(selector, changelog);
await submitForm(page, 'div.listing-edit-container form', true);
await page.waitFor(2000);

await page.close();
await browser.close();
})();

0 comments on commit ecce845

Please sign in to comment.