Use a temp directory to install the compat test fixtures
This is a way to run `npm install` on the compat test fixtures without the node_modules at the root of the repo interfering with the node's module resolution (and that of parcel/webpack/etc). It's hacky because ideally we'd just put each test in its own docker container for simplicity. We tried that in the private repo, but the complexity is not worth the benefit.
This commit is contained in:
parent
024b1896c6
commit
e856ee54ff
9 changed files with 680 additions and 663 deletions
6
.github/actions/yarn-nm-install/action.yml
vendored
6
.github/actions/yarn-nm-install/action.yml
vendored
|
@ -53,6 +53,6 @@ runs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: yarn workspace playground run playwright install --with-deps
|
run: yarn workspace playground run playwright install --with-deps
|
||||||
|
|
||||||
- name: Update browserlist
|
# - name: Update browserlist
|
||||||
shell: bash
|
# shell: bash
|
||||||
run: npx browserslist@latest --update-db
|
# run: npx browserslist@latest --update-db
|
||||||
|
|
|
@ -29,17 +29,10 @@
|
||||||
"web-vitals": "^1.0.1"
|
"web-vitals": "^1.0.1"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": ["react-app", "react-app/jest"]
|
||||||
"react-app",
|
|
||||||
"react-app/jest"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [">0.2%", "not dead", "not op_mini all"],
|
||||||
">0.2%",
|
|
||||||
"not dead",
|
|
||||||
"not op_mini all"
|
|
||||||
],
|
|
||||||
"development": [
|
"development": [
|
||||||
"last 1 chrome version",
|
"last 1 chrome version",
|
||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/// <reference types="next" />
|
/// <reference types="next" />
|
||||||
/// <reference types="next/image-types/global" />
|
/// <reference types="next/image-types/global" />
|
||||||
|
/// <reference types="next/navigation-types/compat/navigation" />
|
||||||
|
|
||||||
// NOTE: This file should not be edited
|
// NOTE: This file should not be edited
|
||||||
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
// see https://nextjs.org/docs/basic-features/typescript for more information.
|
||||||
|
|
|
@ -17,12 +17,19 @@
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"jsx": "preserve"
|
"jsx": "preserve",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"strictNullChecks": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"next-env.d.ts",
|
"next-env.d.ts",
|
||||||
"**/*.ts",
|
"**/*.ts",
|
||||||
"**/*.tsx"
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
"node_modules"
|
"node_modules"
|
||||||
|
|
|
@ -11,12 +11,9 @@
|
||||||
"@theatre/core": "0.0.1-COMPAT.1",
|
"@theatre/core": "0.0.1-COMPAT.1",
|
||||||
"@theatre/r3f": "0.0.1-COMPAT.1",
|
"@theatre/r3f": "0.0.1-COMPAT.1",
|
||||||
"@theatre/studio": "0.0.1-COMPAT.1",
|
"@theatre/studio": "0.0.1-COMPAT.1",
|
||||||
"parcel": "^2.5.0",
|
"parcel": "^2.9.3",
|
||||||
"react": "^18.1.0",
|
"react": "^18.1.0",
|
||||||
"react-dom": "^18.1.0",
|
"react-dom": "^18.1.0",
|
||||||
"serve": "14.2.0"
|
"serve": "14.2.0"
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"buffer": "^5.7.1"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
"node-cleanup": "^2.1.2",
|
"node-cleanup": "^2.1.2",
|
||||||
"playwright": "^1.29.1",
|
"playwright": "^1.29.1",
|
||||||
"prettier": "^2.6.2",
|
"prettier": "^2.6.2",
|
||||||
"verdaccio": "^5.10.2",
|
"verdaccio": "^5.26.1",
|
||||||
"verdaccio-auth-memory": "^10.2.0",
|
"verdaccio-auth-memory": "^10.2.2",
|
||||||
"verdaccio-memory": "^10.2.0",
|
"verdaccio-memory": "^10.3.2",
|
||||||
"zx": "^7.1.1"
|
"zx": "^7.1.1"
|
||||||
},
|
},
|
||||||
"version": "0.0.1-COMPAT.1"
|
"version": "0.0.1-COMPAT.1"
|
||||||
|
|
|
@ -7,7 +7,6 @@ import path from 'path'
|
||||||
import {globby, argv, YAML, $, fs, cd, os, within} from 'zx'
|
import {globby, argv, YAML, $, fs, cd, os, within} from 'zx'
|
||||||
import onCleanup from 'node-cleanup'
|
import onCleanup from 'node-cleanup'
|
||||||
import * as verdaccioPackage from 'verdaccio'
|
import * as verdaccioPackage from 'verdaccio'
|
||||||
import {chromium, devices} from 'playwright'
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} pkg
|
* @param {string} pkg
|
||||||
|
@ -55,6 +54,8 @@ const tempVersion =
|
||||||
: // a random integer between 1 and 50000
|
: // a random integer between 1 and 50000
|
||||||
(Math.floor(Math.random() * 50000) + 1).toString())
|
(Math.floor(Math.random() * 50000) + 1).toString())
|
||||||
|
|
||||||
|
const keepAlive = !!argv['keep-alive']
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This script starts verdaccio and publishes all the packages in the monorepo to it, then
|
* This script starts verdaccio and publishes all the packages in the monorepo to it, then
|
||||||
* it runs `npm install` on all the test packages, and finally it closes verdaccio.
|
* it runs `npm install` on all the test packages, and finally it closes verdaccio.
|
||||||
|
@ -83,8 +84,15 @@ export async function installFixtures() {
|
||||||
console.log('Running `$ npm install` on test packages')
|
console.log('Running `$ npm install` on test packages')
|
||||||
await runNpmInstallOnTestPackages()
|
await runNpmInstallOnTestPackages()
|
||||||
console.log('All fixtures installed successfully')
|
console.log('All fixtures installed successfully')
|
||||||
await verdaccioServer.close()
|
if (keepAlive) {
|
||||||
|
console.log('Keeping verdaccio alive. Press Ctrl+C to exit.')
|
||||||
|
// wait for ctrl+c
|
||||||
|
await new Promise((resolve) => {})
|
||||||
|
} else {
|
||||||
|
console.log('Closing verdaccio. Use --keep-alive to keep it running.')
|
||||||
restoreTestPackageJsons()
|
restoreTestPackageJsons()
|
||||||
|
await verdaccioServer.close()
|
||||||
|
}
|
||||||
console.log('Done')
|
console.log('Done')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,18 +100,39 @@ async function runNpmInstallOnTestPackages() {
|
||||||
const packagePaths = await getCompatibilityTestSetups()
|
const packagePaths = await getCompatibilityTestSetups()
|
||||||
|
|
||||||
for (const pathToPackageDir of packagePaths) {
|
for (const pathToPackageDir of packagePaths) {
|
||||||
cd(pathToPackageDir)
|
await fs.remove(path.join(pathToPackageDir, 'node_modules'))
|
||||||
|
await fs.remove(path.join(pathToPackageDir, 'package-lock.json'))
|
||||||
|
cd(path.join(pathToPackageDir, '../'))
|
||||||
|
const tempPath = fs.mkdtempSync(
|
||||||
|
path.join(os.tmpdir(), 'theatre-compat-test-'),
|
||||||
|
)
|
||||||
|
await fs.copy(pathToPackageDir, tempPath)
|
||||||
|
|
||||||
|
cd(path.join(tempPath))
|
||||||
try {
|
try {
|
||||||
console.log('Running npm install on ' + pathToPackageDir + '...')
|
console.log('Running npm install on ' + pathToPackageDir + '...')
|
||||||
await $`npm install --registry ${config.VERDACCIO_URL} --loglevel ${
|
await $`npm install --registry ${config.VERDACCIO_URL} --loglevel ${
|
||||||
verbose ? 'warn' : 'error'
|
verbose ? 'warn' : 'error'
|
||||||
} --fund false`
|
} --fund false`
|
||||||
|
|
||||||
|
console.log('npm install finished successfully in' + tempPath)
|
||||||
|
|
||||||
|
await fs.move(
|
||||||
|
path.join(tempPath, 'node_modules'),
|
||||||
|
path.join(pathToPackageDir, 'node_modules'),
|
||||||
|
)
|
||||||
|
await fs.move(
|
||||||
|
path.join(tempPath, 'package-lock.json'),
|
||||||
|
path.join(pathToPackageDir, 'package-lock.json'),
|
||||||
|
)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to install dependencies for ${pathToPackageDir}
|
console.error(`Failed to install dependencies for ${pathToPackageDir}
|
||||||
Try running \`npm install\` in that directory manually via:
|
Try running \`npm install\` in that directory manually via:
|
||||||
cd ${pathToPackageDir}
|
cd ${pathToPackageDir}
|
||||||
npm install --registry ${config.VERDACCIO_URL}
|
npm install --registry ${config.VERDACCIO_URL}
|
||||||
Original error: ${error}`)
|
Original error: ${error}`)
|
||||||
|
} finally {
|
||||||
|
await fs.remove(tempPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,6 +216,10 @@ const startVerdaccio = (port) => {
|
||||||
config.logs.level = 'warn'
|
config.logs.level = 'warn'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const cache = path.join(__dirname, '../.verdaccio-cache')
|
||||||
|
|
||||||
|
config.self_path = cache
|
||||||
|
|
||||||
const onReady = (webServer) => {
|
const onReady = (webServer) => {
|
||||||
webServer.listen(port, () => {
|
webServer.listen(port, () => {
|
||||||
resolved = true
|
resolved = true
|
||||||
|
@ -194,14 +227,7 @@ const startVerdaccio = (port) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
startVerdaccioServer(
|
startVerdaccioServer(config, 6000, cache, '1.0.0', 'verdaccio', onReady)
|
||||||
config,
|
|
||||||
6000,
|
|
||||||
undefined,
|
|
||||||
'1.0.0',
|
|
||||||
'verdaccio',
|
|
||||||
onReady,
|
|
||||||
)
|
|
||||||
}),
|
}),
|
||||||
new Promise((_, rej) => {
|
new Promise((_, rej) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
store:
|
store:
|
||||||
memory:
|
memory:
|
||||||
limit: 1000
|
limit: 10000
|
||||||
auth:
|
auth:
|
||||||
auth-memory:
|
auth-memory:
|
||||||
users:
|
users:
|
||||||
|
|
Loading…
Reference in a new issue