mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-08 15:59:46 -05:00
chore: DX improvements in unify workflow (#18444)
This commit is contained in:
@@ -60,6 +60,8 @@ gulp.task(
|
||||
gulp.task(
|
||||
'dev',
|
||||
gulp.series(
|
||||
makePathMap,
|
||||
|
||||
'codegen',
|
||||
|
||||
killExistingCypress,
|
||||
@@ -77,16 +79,6 @@ gulp.task(
|
||||
),
|
||||
)
|
||||
|
||||
gulp.task(
|
||||
'dev:no-watch',
|
||||
gulp.series(
|
||||
async function setNoWatch () {
|
||||
setGulpGlobal('shouldWatch', false)
|
||||
},
|
||||
'dev',
|
||||
),
|
||||
)
|
||||
|
||||
gulp.task('dev:clean', gulp.series(
|
||||
// Clean any vite assets
|
||||
'viteClean',
|
||||
|
||||
@@ -5,6 +5,7 @@ export const monorepoPaths = {
|
||||
root: path.join(__dirname, '../..'),
|
||||
pkgDir: path.join(__dirname, '../../packages'),
|
||||
pkgApp: path.join(__dirname, '../../packages/app'),
|
||||
pkgDataContext: path.join(__dirname, '../../packages/data-context'),
|
||||
pkgDesktopGui: path.join(__dirname, '../../packages/desktop-gui'),
|
||||
pkgDriver: path.join(__dirname, '../../packages/driver'),
|
||||
pkgElectron: path.join(__dirname, '../../packages/electron'),
|
||||
@@ -31,4 +32,4 @@ export const monorepoPaths = {
|
||||
pkgTypes: path.join(__dirname, '../../packages/types'),
|
||||
pkgUiComponents: path.join(__dirname, '../../packages/ui-components'),
|
||||
pkgWebConfig: path.join(__dirname, '../../packages/web-config')
|
||||
}
|
||||
} as const
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
import chokidar from 'chokidar'
|
||||
import path from 'path'
|
||||
import pDefer from 'p-defer'
|
||||
import fs from 'fs-extra'
|
||||
import { DevActions } from '@packages/data-context/src/actions/DevActions'
|
||||
|
||||
import { monorepoPaths } from '../monorepoPaths'
|
||||
import { ENV_VARS, getGulpGlobal } from '../gulpConstants'
|
||||
@@ -125,6 +127,16 @@ export async function startCypressWatch () {
|
||||
})
|
||||
}
|
||||
|
||||
// Ensure that the directory we're using to touch the file for update exists
|
||||
fs.ensureDirSync(path.dirname(DevActions.CY_STATE_PATH))
|
||||
|
||||
function signalRestart () {
|
||||
fs.writeFile(DevActions.CY_STATE_PATH, JSON.stringify(new Date().toString()))
|
||||
}
|
||||
|
||||
/**
|
||||
* We touch a file within
|
||||
*/
|
||||
async function restartServer () {
|
||||
if (isRestarting) {
|
||||
return
|
||||
@@ -150,24 +162,27 @@ export async function startCypressWatch () {
|
||||
isRestarting = false
|
||||
}
|
||||
|
||||
if (getGulpGlobal('shouldWatch')) {
|
||||
const watcher = chokidar.watch([
|
||||
'packages/{graphql,data-context}/src/**/*.{js,ts}',
|
||||
'packages/server/lib/**/*.{js,ts}',
|
||||
], {
|
||||
cwd: monorepoPaths.root,
|
||||
ignored: /\.gen\.ts/,
|
||||
ignoreInitial: true,
|
||||
})
|
||||
const watcher = chokidar.watch([
|
||||
'packages/{graphql,data-context}/src/**/*.{js,ts}',
|
||||
'packages/server/lib/**/*.{js,ts}',
|
||||
], {
|
||||
cwd: monorepoPaths.root,
|
||||
ignored: /\.gen\.ts/,
|
||||
ignoreInitial: true,
|
||||
})
|
||||
|
||||
watcher.on('add', restartServer)
|
||||
watcher.on('change', restartServer)
|
||||
watcher.on('add', signalRestart)
|
||||
watcher.on('change', signalRestart)
|
||||
|
||||
process.on('beforeExit', () => {
|
||||
isClosing = true
|
||||
watcher.close()
|
||||
})
|
||||
}
|
||||
process.on('beforeExit', () => {
|
||||
isClosing = true
|
||||
watcher.close()
|
||||
})
|
||||
|
||||
const restartWatcher = chokidar.watch(DevActions.CY_TRIGGER_UPDATE)
|
||||
|
||||
restartWatcher.on('add', restartServer)
|
||||
restartWatcher.on('change', restartServer)
|
||||
|
||||
await startCypressWithListeners()
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ export async function runWebpack (cfg: RunWebpackCfg) {
|
||||
line.includes('Compiled successfully') ||
|
||||
line.includes('Compiled with warnings') ||
|
||||
line.includes('Failed to compile') ||
|
||||
line.includes('Built at: ')
|
||||
line.includes('Built at: ') ||
|
||||
line.includes('Live Reload listening')
|
||||
) {
|
||||
dfd.resolve({})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user