chore: DX improvements in unify workflow (#18444)

This commit is contained in:
Tim Griesser
2021-10-11 18:29:01 -04:00
committed by GitHub
parent 9a19ad81bd
commit 7f6a64d789
30 changed files with 328 additions and 101 deletions
+2 -10
View File
@@ -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',
+2 -1
View File
@@ -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
+31 -16
View File
@@ -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()
}
+2 -1
View File
@@ -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({})
}