-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ecf76f4
commit 33fe41b
Showing
6 changed files
with
479 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ yarn-error.log | |
.DS_STORE | ||
|
||
build-docs | ||
dist-docs | ||
|
||
# xopera | ||
*.opera | ||
|
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,93 @@ | ||
import * as files from '#files' | ||
import {sleep} from '#utils' | ||
import dayjs from '#utils/day' | ||
import console from 'console' | ||
import * as path from 'path' | ||
import puppeteer, {Browser, PDFOptions} from 'puppeteer' | ||
|
||
type Job = { | ||
url: string | ||
name: string | ||
} | ||
|
||
const jobs: Job[] = [ | ||
{ | ||
url: 'https://vintner.opentosca.org/variability4tosca/specification', | ||
name: 'variability4tosca-01-motivation', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/variability4tosca/specification', | ||
name: 'variability4tosca-02-specification', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/variability4tosca/testing', | ||
name: 'variability4tosca-03-testing', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/variability4tosca/feature-ide', | ||
name: 'variability4tosca-04-feature-ide', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/queries4tosca/getting-started', | ||
name: 'queries4tosca-01-getting-started', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/queries4tosca/specification', | ||
name: 'queries4tosca-02-specification', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/sofdcar/profile', | ||
name: 'tosca-sofdcar-profile-01-profile', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/sofdcar/guides/zone', | ||
name: 'tosca-sofdcar-profile-02-guides-zone', | ||
}, | ||
{ | ||
url: 'https://vintner.opentosca.org/sofdcar/guides/location', | ||
name: 'tosca-sofdcar-profile-03-guides-location', | ||
}, | ||
] | ||
|
||
let browser: Browser | ||
const dist = path.join(__dirname, '..', '..', '..', 'dist-docs') | ||
|
||
async function run(job: Job) { | ||
console.log('Processing', job.url) | ||
|
||
const page = await browser.newPage() | ||
|
||
await page.emulateMediaType('screen') | ||
await page.setViewport({width: 1920, height: 1080}) | ||
|
||
await page.goto(job.url, {waitUntil: 'networkidle2'}) | ||
|
||
await sleep(1000) | ||
|
||
await page.addStyleTag({ | ||
content: ` | ||
.md-header, .md-footer { | ||
display: none !important; | ||
}`, | ||
}) | ||
|
||
const config: PDFOptions = { | ||
path: path.join(dist, job.name + '-' + dayjs().format('YYYY-MM-DD') + '.pdf'), | ||
format: 'A4', | ||
scale: 0.7, | ||
preferCSSPageSize: true, | ||
} | ||
|
||
await page.pdf(config) | ||
} | ||
|
||
async function main() { | ||
files.removeDirectory(dist) | ||
files.createDirectory(dist) | ||
|
||
browser = await puppeteer.launch({headless: 'new'}) | ||
await Promise.all(jobs.map(run)) | ||
await browser.close() | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
@page { | ||
size: A4; | ||
margin: 8mm; | ||
} |
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 |
---|---|---|
|
@@ -77,6 +77,7 @@ | |
"pkg": "^5.8.1", | ||
"postinstall-postinstall": "^2.1.0", | ||
"prettier": "^2.8.7", | ||
"puppeteer": "^20.7.3", | ||
"semver": "^7.5.2", | ||
"sync-directory": "^6.0.4", | ||
"ts-node": "^10.9.1", | ||
|
@@ -124,6 +125,7 @@ | |
"docs:record": "yarn docs:record:home && yarn docs:record:getting-started", | ||
"docs:record:home": "cd docs/cmds/casts && bash record.sh home", | ||
"docs:record:getting-started": "cd docs/cmds/casts && bash record.sh getting-started", | ||
"docs:export": "bash docs/cmds/command.sh export", | ||
"examples:xopera": "bash examples/xopera-motivation/demo.sh", | ||
"examples:unfurl": "bash examples/unfurl-motivation/demo.sh", | ||
"licenses:check": "license-checker --production --summary --onlyAllow \"MIT;Apache-2.0;Python-2.0;BSD-2-Clause;BSD-3-Clause;ISC;CC-BY-3.0;CC0-1.0;PSF;0BSD;BlueOak-1.0.0\" --excludePackages [email protected]", | ||
|
Oops, something went wrong.