Skip to content

Commit

Permalink
Update to nx 12 6 (scullyio#1417)
Browse files Browse the repository at this point in the history
* chore: remove and ignore migrations files
* chore: change jest settings to be compatible with jest 27
* chore: clean up
* chore(scully): update to puppeteer 10
  • Loading branch information
Jefiozie authored Aug 9, 2021
1 parent 532427e commit b4dfe9e
Show file tree
Hide file tree
Showing 32 changed files with 16,907 additions and 18,652 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ libs/scully/.vscode/settings.json
tools/autoVersion.js
tools/autoVersion.js.map
test_for_zoneJS.ts

migrations.*
7 changes: 1 addition & 6 deletions apps/sample-blog/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// const nxPreset = require('@nrwl/jest/preset');
const jestPreset = require('../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../tests/jest/src'],
preset: '../../jest.config.js',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
7 changes: 1 addition & 6 deletions apps/scully-docs/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
// const nxPreset = require('@nrwl/jest/preset');
const jestPreset = require('../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../tests/jest/src'],
preset: '../../jest.config.js',
preset: '../../jest.preset.js',
setupFilesAfterEnv: ['../../tests/jest/src/setup-jest.ts'],
coverageDirectory: '../../coverage/apps/scully-docs',
transform: {
Expand Down
29 changes: 0 additions & 29 deletions apps/scully-docs/src/main.playground.ts

This file was deleted.

17 changes: 1 addition & 16 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
module.exports = {
projects: [
// '<rootDir>/libs/scully',
// '<rootDir>/libs/ng-lib',
// '<rootDir>/apps/sample-blog',
// '<rootDir>/apps/scully-docs',
// '<rootDir>/libs/plugins/extra',
'<rootDir>/libs/plugins/from-data',
// '<rootDir>/libs/plugins/scully-plugin-local-cache',
// '<rootDir>/libs/plugins/base-href-rewrite',
// '<rootDir>/libs/plugins/scully-plugin-flash-prevention',
// '<rootDir>/libs/plugins/logrocket',
// '<rootDir>/libs/plugins/sentry',
// '<rootDir>/libs/plugins/google-analytics',
// '<rootDir>/libs/plugins/docs-link-update',
// '<rootDir>/libs/plugins/scully-plugin-remove-scripts',
// '<rootDir>/libs/plugins/scully-plugin-critical-css',
// '<rootDir>/libs/plugins/scully-plugin-copy-to-clipboard',
'<rootDir>/tests/jest/src'
],
};
24 changes: 3 additions & 21 deletions jest.preset.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
const nxPreset = require('@nrwl/jest/preset');

module.exports = {
roots: ['tests/jest/src'],
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
setupFilesAfterEnv: ['./tests/jest/src/setup-jest.ts'],
moduleNameMapper: {
'@app/(.*)': '<rootDir>/apps/sample-blog/src/app/$1',
'@assets/(.*)': '<rootDir>/apps/sample-blog/src/assets/$1',
'@env': '<rootDir>/apps/sample-blog/src/environments/environment',
'@src/(.*)': '<rootDir>/apps/sample-blog/src/$1',
'@scullyio/ng-lib': '<rootDir>/dist/libs/ng-lib',
},
globals: {
'ts-jest': {
tsconfig: './tsconfig.spec.json',
stringifyContentPathRegex: '\\.html$',
astTransformers: {
// before: ['jest-preset-angular/build/InlineFilesTransformer', 'jest-preset-angular/build/StripStylesTransformer'],
},
},
},
...nxPreset
};
6 changes: 2 additions & 4 deletions libs/plugins/base-href-rewrite/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
6 changes: 2 additions & 4 deletions libs/plugins/docs-link-update/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
12 changes: 8 additions & 4 deletions libs/plugins/extra/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
testEnvironment: 'jsdom',
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
coverageDirectory: '../../../coverage/libs/plugins/extra',
displayName: 'plugins-extra',
Expand Down
14 changes: 9 additions & 5 deletions libs/plugins/from-data/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
// const nxPreset = require('@nrwl/jest/preset');
const jestPreset = require('../../../jest.preset');


module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
},
},
testEnvironment: 'jsdom',

setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
6 changes: 2 additions & 4 deletions libs/plugins/google-analytics/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
6 changes: 2 additions & 4 deletions libs/plugins/logrocket/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
6 changes: 2 additions & 4 deletions libs/plugins/scully-plugin-copy-to-clipboard/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
globals: {
'ts-jest': {
Expand Down
6 changes: 2 additions & 4 deletions libs/plugins/scully-plugin-critical-css/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
globals: {
'ts-jest': {
Expand Down
6 changes: 2 additions & 4 deletions libs/plugins/scully-plugin-flash-prevention/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
11 changes: 4 additions & 7 deletions libs/plugins/scully-plugin-local-cache/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@

module.exports = {
displayName: 'local-cache',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.spec.json',
},
},
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'html'],
coverageDirectory: '../../../coverage/libs/plugins/scully-plugin-local-cache',
displayName: 'local-cache',
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-prototype-builtins */
import { Request } from 'puppeteer';
import { HTTPRequest as Request } from 'puppeteer';
import { config } from './config';
import { generateId } from './generateId';
import { del, get } from './ldb';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export async function handlePuppeteerResponse(resp: HTTPResponse) {
try {
const responseHeaders = resp.headers();
const id = generateId();
if (responseHeaders['from-scully-cache']) {
if (responseHeaders['from-scully-cache']==='true') {
/** no need to reprocess */
return;
}
Expand All @@ -37,7 +37,7 @@ export async function handlePuppeteerResponse(resp: HTTPResponse) {
requestHeaders: headers,
TTL,
response: {
headers: { ...responseHeaders, 'from-scully-cache': true },
headers: { ...responseHeaders, 'from-scully-cache': 'true' },
contentType: resp.headers()['content-type'] || headers['content-type'] || 'umh',
status: resp.status(),
body,
Expand Down
8 changes: 4 additions & 4 deletions libs/plugins/scully-plugin-remove-scripts/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
preset: '../../../jest.preset.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
8 changes: 4 additions & 4 deletions libs/plugins/sentry/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// const nxPreset = require('@nrwl/jest/preset');

const jestPreset = require('../../../jest.preset');

module.exports = {
...jestPreset,
roots: ['../../../tests/jest/src'],
preset: '../../../jest.config.js',
preset: '../../../jest.preset.js',
preset: '../../../jest.preset.js',
preset: '../../../jest.preset.js',
setupFilesAfterEnv: ['../../../tests/jest/src/setup-jest.ts'],
transform: {
'^.+\\.[tj]sx?$': 'ts-jest',
Expand Down
8 changes: 4 additions & 4 deletions libs/scully/src/lib/renderPlugins/launchedBrowser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Browser, launch, LaunchOptions } from 'puppeteer';
import { Browser, launch, LaunchOptions, BrowserLaunchArgumentOptions } from 'puppeteer';
import { BehaviorSubject, from, interval, merge, Observable, of, timer } from 'rxjs';
import { catchError, delayWhen, filter, shareReplay, switchMap, take, throttleTime } from 'rxjs/operators';
import { captureException } from '../utils/captureMessage';
Expand Down Expand Up @@ -53,7 +53,7 @@ export const reLaunch = (reason?: string): Promise<Browser> => {
* Function that creates an observable with the puppeteer browser inside
* @param options
*/
function obsBrowser(options: LaunchOptions = scullyConfig.puppeteerLaunchOptions || {}): Observable<Browser> {
function obsBrowser(options: any = scullyConfig.puppeteerLaunchOptions || {}): Observable<Browser> {
if (showBrowser) {
options.headless = false;
}
Expand Down Expand Up @@ -143,7 +143,7 @@ function launchPuppeteerWithRetry(options, failedLaunches = 0): Promise<Browser>
/** use a 1 minute timeout to detect a stalled launch of puppeteer */
timeout(Math.max(/** serverTimeout,*/ 60 * 1000)),
launch(options).then((b) => {
return b;
return b as unknown as Browser;
}),
])
.catch((e) => {
Expand Down Expand Up @@ -171,5 +171,5 @@ https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md
=================================================================================================
`);
process.exit(15);
});
}) as unknown as Promise<Browser>;
}
16 changes: 0 additions & 16 deletions migrations.failed..json

This file was deleted.

Loading

0 comments on commit b4dfe9e

Please sign in to comment.