forked from scullyio/scully
-
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.
feat(scully-plugin-puppeteer): move Puppeteer to a stand-alone (optio…
…nal) plugin (scullyio#1470) * feat(scully-plugin-puppeteer): move Puppeteer to a stand-alone (optional) plugin ISSUES CLOSED: scullyio#1462 * fix(scully-plugin-puppeteer): fix circular dependency issue by ovoinf the name in TEXT messages. ISSUES CLOSED: scullyio#1462 * refactor(scully-plugin-puppeteer): don't use a config setting anymore for the 'default' routeRenderer
- Loading branch information
1 parent
0af7c82
commit 01a57ba
Showing
38 changed files
with
314 additions
and
105 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 |
---|---|---|
|
@@ -57,3 +57,4 @@ testDocs | |
scully/tsconfig.sps-sample.json | ||
adsample.js | ||
bs.sh | ||
consoleProxy.ts |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
module.exports = { | ||
projects: ['<rootDir>/tests/jest/src', '<rootDir>/libs/platform-server'], | ||
projects: ['<rootDir>/tests/jest/src', '<rootDir>/libs/platform-server', '<rootDir>/libs/plugins/scully-plugin-puppeteer'], | ||
}; |
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 |
---|---|---|
|
@@ -21,4 +21,4 @@ | |
"scully-plugin", | ||
"plugin" | ||
] | ||
} | ||
} |
9 changes: 7 additions & 2 deletions
9
libs/plugins/scully-plugin-local-cache/src/lib/installInterceptor.ts
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"presets": [["@nrwl/web/babel", { "useBuiltIns": "usage" }]] | ||
} |
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,18 @@ | ||
{ | ||
"extends": ["../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,10 @@ | ||
# scully-plugin-puppeteer | ||
|
||
This is the Puppeteer render plugin for Scully. | ||
|
||
The interface for a renderPlugin is: | ||
```ts | ||
(route:HandledRoute) => Promise<string> | ||
``` | ||
|
||
This plugin will be called for every route that is in the `handledRoute[]` When it throws its retried for 3 times. If it fails after that, the route is skipped. |
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,15 @@ | ||
module.exports = { | ||
displayName: 'plugins-scully-plugin-puppeteer', | ||
preset: '../../../jest.preset.js', | ||
globals: { | ||
'ts-jest': { | ||
tsconfig: '<rootDir>/tsconfig.spec.json', | ||
}, | ||
}, | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]sx?$': 'ts-jest', | ||
}, | ||
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], | ||
coverageDirectory: '../../../coverage/libs/plugins/scully-plugin-puppeteer', | ||
}; |
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,27 @@ | ||
{ | ||
"name": "@scullyio/scully-plugin-puppeteer", | ||
"version": "2.0.0", | ||
"description": "Scully Puppeteer render plugin", | ||
"main": "./src/index.js", | ||
"license": "MIT", | ||
"dependencies": { | ||
"tslib": "^1.13.0" | ||
}, | ||
"peerDependencies": { | ||
"@scullyio/scully": "*", | ||
"puppeteer": "^10.2.0" | ||
}, | ||
"repository": { | ||
"type": "GIT", | ||
"url": "https://github.com/scullyio/scully/tree/main/libs/plugins/scully-plugin-puppeteer" | ||
}, | ||
"keywords": [ | ||
"angular", | ||
"scully", | ||
"seo", | ||
"scully-plugin", | ||
"puppeteer", | ||
"plugin", | ||
"render" | ||
] | ||
} |
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,11 @@ | ||
import { logOk, routeRenderer, registerPlugin } from '@scullyio/scully'; | ||
import { launchedBrowser } from './lib/launchedBrowser'; | ||
import { puppeteerRender } from './lib/plugins-scully-plugin-puppeteer'; | ||
import { launchedBrowser$ } from './lib/launchedBrowser'; | ||
|
||
registerPlugin('enterprise','getPPTLaunchedBrowser',async () => launchedBrowser$) | ||
registerPlugin('beforeAll', 'startLaunching the browser', async () => { | ||
logOk('Puppeteer is being launched') | ||
launchedBrowser(); | ||
}) | ||
registerPlugin('scullySystem', routeRenderer, puppeteerRender); |
9 changes: 3 additions & 6 deletions
9
.../src/lib/renderPlugins/launchedBrowser.ts → ...ugin-puppeteer/src/lib/launchedBrowser.ts
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
7 changes: 7 additions & 0 deletions
7
libs/plugins/scully-plugin-puppeteer/src/lib/plugins-scully-plugin-puppeteer.spec.ts
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,7 @@ | ||
import { puppeteerRender } from './plugins-scully-plugin-puppeteer'; | ||
|
||
describe('pluginsScullyPluginPuppeteer', () => { | ||
it('should work', () => { | ||
expect(puppeteerRender).toEqual(puppeteerRender) | ||
}); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../../tsconfig.base.json", | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
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,11 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "../../../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"exclude": ["**/*.spec.ts"], | ||
"include": ["**/*.ts"] | ||
} |
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,9 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": ["**/*.spec.ts", "**/*.spec.tsx", "**/*.spec.js", "**/*.spec.jsx", "**/*.d.ts"] | ||
} |
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
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
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,17 +1,11 @@ | ||
import { registerPlugin, scullySystem } from '../../pluginManagement'; | ||
import { launchedBrowser } from '../../renderPlugins/launchedBrowser'; | ||
import { HandledRoute } from '../../routerPlugins/handledRoute.interface'; | ||
import { printProgress } from '../log'; | ||
import { renderParallel } from './renderParallel'; | ||
|
||
|
||
export const renderPlugin = 'renderPlugin' as const; | ||
registerPlugin(scullySystem, renderPlugin, defaultRenderPlugin); | ||
async function defaultRenderPlugin(handledRoutes: HandledRoute[]) { | ||
/** update progress to show what's going on */ | ||
printProgress(false, 'Starting puppeteer'); | ||
/** launch the browser, its shared among renderers */ | ||
await launchedBrowser(); | ||
/** start handling each route, works in chunked parallel mode */ | ||
await renderParallel(handledRoutes); | ||
} |
Oops, something went wrong.