forked from reg-viz/reg-suit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace browser from Electron to Puppeteer
- Loading branch information
Showing
9 changed files
with
162 additions
and
1,832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ lib/ | |
dist/ | ||
public/css/ | ||
screenshot/ | ||
landing-page/ | ||
.reg/ |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,46 @@ | ||
const Nightmare = require("nightmare"); | ||
const nightmare = Nightmare({ show: false, width: 1200, height: 300, webPreferences: { | ||
nodeIntegration: true, | ||
preload: `${__dirname}/preload.js`, | ||
}}); | ||
|
||
const mkdirp = require("mkdirp"); | ||
mkdirp.sync(`${__dirname}/screenshot`); | ||
const Puppeteer = require('puppeteer'); | ||
|
||
async function main() { | ||
try { | ||
mkdirp.sync(`${__dirname}/screenshot`); | ||
|
||
const browser = await Puppeteer.launch({ | ||
args: ["--no-sandbox", "--disable-setuid-sandbox"], | ||
headless: true, | ||
}); | ||
const page = await browser.newPage(); | ||
await page.goto(`file://${__dirname}/landing-page/public/index.html`); | ||
|
||
await page.setViewport({ | ||
width: 1440, | ||
height: 600, | ||
}); | ||
await page.waitFor(500); | ||
await page.screenshot({ path: `${__dirname}/screenshot/index_desktop.png`, fullPage: true }); | ||
|
||
nightmare | ||
.goto(`file://${__dirname}/dist/index.html`) | ||
.wait(500) | ||
.evaluate(() => win.setSize(1200, 3300)) | ||
.wait(100) | ||
.screenshot(`${__dirname}/screenshot/index.png`) | ||
.evaluate(() => win.setSize(900, 3500)) | ||
.wait(100) | ||
.screenshot(`${__dirname}/screenshot/index_mid.png`) | ||
.evaluate(() => win.setSize(700, 3500)) | ||
.wait(100) | ||
.screenshot(`${__dirname}/screenshot/index_sp.png`) | ||
.end() | ||
.then(() => { | ||
console.log("Captured screenshot") | ||
}) | ||
.catch(x => { | ||
console.error(x); | ||
await page.setViewport({ | ||
width: 1044, | ||
height: 768, | ||
}); | ||
await page.waitFor(500); | ||
await page.screenshot({ path: `${__dirname}/screenshot/index_tablet.png`, fullPage: true }); | ||
|
||
await page.setViewport({ | ||
width: 375, | ||
height: 767, | ||
}); | ||
await page.waitFor(500); | ||
await page.screenshot({ path: `${__dirname}/screenshot/index_mobile.png`, fullPage: true }); | ||
|
||
await page.close(); | ||
await new Promise(res => setTimeout(res, 50)); | ||
await browser.close(); | ||
process.exit(0); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
}) | ||
; | ||
} | ||
} | ||
|
||
main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
VERSION=$1 | ||
DIR=landing-page | ||
|
||
if [ -e "$DIR" ]; then | ||
cd $DIR | ||
git fetch origin | ||
git checkout refs/tags/$VERSION | ||
else | ||
git clone https://github.com/reg-viz/reg-suit-lp.git -b $VERSION $DIR --depth 1 | ||
cd $DIR | ||
fi | ||
|
||
yarn install --frozen-lockfile | ||
|
||
yarn build | ||
|
Oops, something went wrong.