Skip to content

Commit a851d79

Browse files
authored
feat: improved DX for unified-desktop-gui (#18099)
- Moves graphql-codegen config to the root, which will serve all packages needing it - Adds gulpfile for coordinating scripts related to dev environment in launchpad app - yarn dev from the root runs yarn gulp dev, which: Runs autobarrel for rolling up the @packages/graphql files Cleans the dist & cache for .vite Starts the a codegen watcher for Nexus Starts the graphql-codegen --watch & highlights output Starts vite servers for launchpad & app Starts electron watch.js
1 parent 8bda0a9 commit a851d79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+1257
-425
lines changed

autobarrel.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"prefix": "/* eslint-disable padding-line-between-statements */",
3+
"paths": [
4+
"packages/graphql/src/**/*"
5+
]
6+
}

circle.yml

+3
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ commands:
389389
type: string
390390
steps:
391391
- restore_cached_workspace
392+
- run: yarn gulp graphqlCodegen
392393
- run: yarn workspace @packages/launchpad cypress:run --browser <<parameters.browser>>
393394
- store_test_results:
394395
path: /tmp/cypress
@@ -1001,6 +1002,8 @@ jobs:
10011002
- run: yarn test-scripts
10021003
# make sure our snapshots are compared correctly
10031004
- run: yarn test-mocha-snapshot
1005+
# Get the codegen output
1006+
- run: yarn gulp buildProd
10041007
# make sure packages with TypeScript can be transpiled to JS
10051008
- run: yarn lerna run build-prod --stream
10061009
# run unit tests from each individual package

cli/lib/cli.js

+1
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,7 @@ module.exports = {
397397
debug('opening Cypress')
398398
require('./exec/open')
399399
.start(util.parseOpts(opts))
400+
.then(util.exit)
400401
.catch(util.logErrorExit1)
401402
})
402403

cli/lib/exec/spawn.js

+21-9
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ module.exports = {
102102
const electronArgs = []
103103
const node11WindowsFix = isPlatform('win32')
104104

105+
let startScriptPath
106+
105107
if (options.dev) {
108+
executable = 'node'
106109
// if we're in dev then reset
107110
// the launch cmd to be 'npm run dev'
108-
executable = 'node'
109-
electronArgs.unshift(
110-
path.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'),
111-
)
111+
startScriptPath = path.resolve(__dirname, '..', '..', '..', 'scripts', 'start.js'),
112112

113113
debug('in dev mode the args became %o', args)
114114
}
@@ -141,9 +141,7 @@ module.exports = {
141141

142142
if (stdioOptions.env.ELECTRON_RUN_AS_NODE) {
143143
// Since we are running electron as node, we need to add an entry point file.
144-
const serverEntryPoint = path.join(state.getBinaryPkgPath(path.dirname(executable)), '..', 'index.js')
145-
146-
args = [serverEntryPoint, ...args]
144+
startScriptPath = path.join(state.getBinaryPkgPath(path.dirname(executable)), '..', 'index.js')
147145
} else {
148146
// Start arguments with "--" so Electron knows these are OUR
149147
// arguments and does not try to sanitize them. Otherwise on Windows
@@ -152,9 +150,23 @@ module.exports = {
152150
args = [...electronArgs, '--', ...args]
153151
}
154152

155-
debug('spawning Cypress with executable: %s', executable)
156153
debug('spawn args %o %o', args, _.omit(stdioOptions, 'env'))
157-
const child = cp.spawn(executable, args, stdioOptions)
154+
let child
155+
156+
if (process.env.CYPRESS_INTERNAL_DEV_WATCH) {
157+
debug('spawning Cypress as fork: %s', startScriptPath)
158+
child = cp.fork(startScriptPath, args, stdioOptions)
159+
process.on('message', (msg) => {
160+
child.send(msg)
161+
})
162+
} else {
163+
debug('spawning Cypress with executable: %s', executable)
164+
if (startScriptPath) {
165+
args.unshift(startScriptPath)
166+
}
167+
168+
child = cp.spawn(executable, args, stdioOptions)
169+
}
158170

159171
function resolveOn (event) {
160172
return function (code, signal) {

graphql-codegen.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
overwrite: true
2+
schema: './packages/graphql/schema.graphql'
3+
generates:
4+
'./packages/app/src/generated/graphql.ts':
5+
documents: './packages/app/src/**/*.vue'
6+
config:
7+
immutableTypes: true
8+
useTypeImports: true
9+
preResolveTypes: true
10+
onlyOperationTypes: true
11+
avoidOptionals: true
12+
enumsAsTypes: true
13+
plugins:
14+
- add:
15+
content: '/* eslint-disable */'
16+
- 'typescript':
17+
- 'typescript-operations'
18+
- 'typed-document-node'
19+
'./packages/launchpad/src/generated/graphql.ts':
20+
documents: './packages/launchpad/src/**/*.vue'
21+
config:
22+
immutableTypes: true
23+
useTypeImports: true
24+
preResolveTypes: true
25+
onlyOperationTypes: true
26+
avoidOptionals: true
27+
enumsAsTypes: true
28+
plugins:
29+
- add:
30+
content: '/* eslint-disable */'
31+
- 'typescript':
32+
- 'typescript-operations'
33+
- 'typed-document-node'
34+
'./packages/graphql/src/testing/testUnionType.ts':
35+
plugins:
36+
- add:
37+
content: '/* eslint-disable */'
38+
- 'packages/graphql/script/codegen-mount.js'

gulpfile.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require('@packages/ts/register')
2+
require('./scripts/gulp/gulpfile')

package.json

+20-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"description": "Cypress.io end to end testing tool",
55
"private": true,
66
"scripts": {
7+
"prebinary-build": "yarn gulp buildProd",
78
"binary-build": "node ./scripts/binary.js build",
89
"binary-deploy": "node ./scripts/binary.js deploy",
910
"binary-deploy-linux": "./scripts/build-linux-binary.sh",
@@ -13,6 +14,7 @@
1314
"binary-upload": "node ./scripts/binary.js upload",
1415
"binary-zip": "node ./scripts/binary.js zip",
1516
"build": "lerna run build --stream --no-bail --ignore create-cypress-tests && lerna run build --stream --scope create-cypress-tests",
17+
"prebuild-prod": "yarn gulp buildProd",
1618
"build-prod": "lerna run build-prod --stream --ignore create-cypress-tests && lerna run build-prod --stream --scope create-cypress-tests",
1719
"bump": "node ./scripts/binary.js bump",
1820
"check-node-version": "node scripts/check-node-version.js",
@@ -29,14 +31,14 @@
2931
"precypress:run:debug": "yarn ensure-deps",
3032
"cypress:run:debug": "node ./scripts/debug.js cypress:run",
3133
"cypress:verify": "cypress verify --dev",
32-
"dev": "node ./scripts/start.js",
33-
"dev:watch": "node ./scripts/watch.js",
34+
"dev": "yarn gulp dev",
35+
"gulp:debug": "node --inspect-brk ./node_modules/.bin/gulp",
3436
"dev-debug": "node ./scripts/debug.js dev",
3537
"docker": "./scripts/run-docker-local.sh",
3638
"effective:circle:config": "circleci config process circle.yml | sed /^#/d",
3739
"ensure-deps": "./scripts/ensure-dependencies.sh",
3840
"get-next-version": "node scripts/get-next-version.js",
39-
"postinstall": "yarn-deduplicate --strategy=highest && patch-package && ./scripts/run-if-not-ci.sh yarn build",
41+
"postinstall": "yarn-deduplicate --strategy=highest && patch-package && yarn gulp postinstall && ./scripts/run-if-not-ci.sh yarn build",
4042
"jscodeshift": "jscodeshift -t ./node_modules/js-codemod/transforms/arrow-function-arguments.js",
4143
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.json .",
4244
"lint-changed": "lint-changed",
@@ -81,6 +83,12 @@
8183
"@cypress/request": "2.88.6",
8284
"@cypress/request-promise": "4.2.6",
8385
"@fellow/eslint-plugin-coffee": "0.4.13",
86+
"@graphql-codegen/add": "^2.0.2",
87+
"@graphql-codegen/cli": "^1.21.6",
88+
"@graphql-codegen/plugin-helpers": "^2.1.1",
89+
"@graphql-codegen/typed-document-node": "^1.18.9",
90+
"@graphql-codegen/typescript": "^1.22.4",
91+
"@graphql-codegen/typescript-operations": "^1.18.3",
8492
"@percy/cli": "1.0.0-beta.48",
8593
"@percy/cypress": "^3.1.0",
8694
"@semantic-release/changelog": "5.0.1",
@@ -89,10 +97,13 @@
8997
"@types/chai-enzyme": "0.6.7",
9098
"@types/classnames": "2.2.9",
9199
"@types/debug": "4.1.5",
100+
"@types/detect-port": "^1.3.1",
92101
"@types/enzyme-adapter-react-16": "1.0.5",
93102
"@types/execa": "0.9.0",
94103
"@types/fs-extra": "^8.0.1",
104+
"@types/getenv": "^1.0.0",
95105
"@types/glob": "7.1.1",
106+
"@types/gulp": "^4.0.9",
96107
"@types/lodash": "4.14.168",
97108
"@types/markdown-it": "0.0.9",
98109
"@types/mini-css-extract-plugin": "1.4.2",
@@ -104,11 +115,13 @@
104115
"@types/react-dom": "16.9.8",
105116
"@types/request-promise": "4.1.45",
106117
"@types/sinon-chai": "3.2.3",
118+
"@types/through2": "^2.0.36",
107119
"@typescript-eslint/eslint-plugin": "4.18.0",
108120
"@typescript-eslint/parser": "4.18.0",
109121
"ansi-styles": "3.2.1",
110122
"arg": "4.1.2",
111123
"ascii-table": "0.0.9",
124+
"autobarrel": "^1.1.0",
112125
"aws-sdk": "2.447.0",
113126
"babel-eslint": "10.1.0",
114127
"bluebird": "3.5.3",
@@ -123,6 +136,7 @@
123136
"conventional-recommended-bump": "6.1.0",
124137
"debug": "4.3.2",
125138
"del": "3.0.0",
139+
"detect-port": "^1.3.0",
126140
"electron-builder": "22.9.1",
127141
"electron-notarize": "1.0.0",
128142
"enzyme-adapter-react-16": "1.12.1",
@@ -137,6 +151,7 @@
137151
"filesize": "4.1.2",
138152
"find-package-json": "1.2.0",
139153
"fs-extra": "8.1.0",
154+
"getenv": "^1.0.0",
140155
"gift": "0.10.2",
141156
"glob": "7.1.6",
142157
"globby": "10.0.1",
@@ -170,6 +185,7 @@
170185
"mocha-multi-reporters": "1.1.7",
171186
"mock-fs": "4.9.0",
172187
"odiff-bin": "2.1.0",
188+
"p-defer": "^3.0.0",
173189
"parse-github-repo-url": "1.4.1",
174190
"patch-package": "6.2.2",
175191
"plist": "3.0.1",
@@ -193,6 +209,7 @@
193209
"term-to-html": "1.2.0",
194210
"terminal-banner": "1.1.0",
195211
"through": "2.3.8",
212+
"through2": "^4.0.2",
196213
"ts-node": "8.3.0",
197214
"typescript": "^4.2.3",
198215
"yarn-deduplicate": "3.1.0"

packages/app/graphql-codegen.yml

-23
This file was deleted.

packages/app/package.json

+6-19
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,21 @@
33
"version": "0.0.0-development",
44
"private": true,
55
"scripts": {
6-
"prebuild": "yarn codegen",
7-
"build": "vite build",
86
"types": "vue-tsc --noEmit",
9-
"build-prod": "cross-env NODE_ENV=production yarn build",
7+
"build-prod": "cross-env NODE_ENV=production vite build",
8+
"clean": "rm -rf dist && rm -rf ./node_modules/.vite && echo 'cleaned'",
109
"clean-deps": "rm -rf node_modules",
11-
"test": "echo ok",
10+
"test": "echo 'ok'",
1211
"cypress:launch": "cross-env TZ=America/New_York node ../../scripts/cypress open --project ${PWD}",
1312
"cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open-ct --project ${PWD}",
1413
"cypress:run": "cross-env TZ=America/New_York node ../../scripts/cypress run-ct --project ${PWD}",
15-
"dev": "NODE_ENV=development LAUNCHPAD=1 node ../../scripts/cypress open",
16-
"postinstall": "yarn codegen && echo '@packages/launchpad needs: yarn build'",
17-
"start": "vite --port 3333 --base /__vite__/",
18-
"watch": "concurrently \"yarn start\" \"yarn codegen --watch\"",
19-
"codegen": "graphql-codegen --config ${PWD}/graphql-codegen.yml"
14+
"dev": "yarn gulp dev --project ${PWD}",
15+
"start": "echo \"run 'yarn dev' from the root\" && exit 1",
16+
"watch": "echo \"run 'yarn dev' from the root\" && exit 1"
2017
},
2118
"dependencies": {},
2219
"devDependencies": {
2320
"@cypress/vue": "0.0.0-development",
24-
"@graphql-codegen/add": "^2.0.2",
25-
"@graphql-codegen/cli": "^1.21.6",
26-
"@graphql-codegen/typed-document-node": "^1.18.9",
27-
"@graphql-codegen/typescript": "^1.22.4",
28-
"@graphql-codegen/typescript-operations": "^1.18.3",
2921
"@graphql-typed-document-node/core": "^3.1.0",
3022
"@headlessui/vue": "1.4.0",
3123
"@iconify/json": "1.1.368",
@@ -37,9 +29,6 @@
3729
"@urql/vue": "0.4.3",
3830
"@vitejs/plugin-vue": "1.2.4",
3931
"@vitejs/plugin-vue-jsx": "1.1.6",
40-
"@vue/compiler-core": "3.2.6",
41-
"@vue/compiler-dom": "3.2.6",
42-
"@vue/compiler-sfc": "3.2.6",
4332
"@vueuse/core": "5.2.0",
4433
"bluebird": "3.5.3",
4534
"classnames": "2.3.1",
@@ -67,8 +56,6 @@
6756
"files": [
6857
"dist",
6958
"lib",
70-
"script",
71-
"graphql-codegen.yml",
7259
"src"
7360
]
7461
}

packages/electron/lib/electron.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ module.exports = {
156156
return process.exit(code)
157157
})
158158

159-
if (process.argv.includes('--devWatch')) {
159+
if (process.env.CYPRESS_INTERNAL_DEV_WATCH) {
160160
spawned.on('exit', () => {
161161
process.exit(0)
162162
})

packages/graphql/package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"main": "index.js",
66
"browser": "src/index.ts",
77
"scripts": {
8-
"build": "node script/build-schema.js",
98
"types": "tsc --noEmit",
10-
"build-prod": "yarn build && tsc",
9+
"build-prod": "yarn gulp nexusCodegen && tsc",
1110
"clean-deps": "rm -rf node_modules",
1211
"clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'",
1312
"postinstall": "echo '@packages/graphql needs: yarn build'",

packages/graphql/script/build-schema.js

-8
This file was deleted.
File renamed without changes.

packages/graphql/src/actions/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* eslint-disable padding-line-between-statements */
2+
// created by autobarrel, do not modify directly
3+
4+
export * from './BaseActions'
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
export * from './browserConstants'
2-
3-
export * from './wizardConstants'
1+
/* eslint-disable padding-line-between-statements */
2+
// created by autobarrel, do not modify directly
43

4+
export * from './browserConstants'
55
export * from './projectConstants'
6-
76
export * from './runConstants'
7+
export * from './wizardConstants'

packages/graphql/src/context/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/* eslint-disable padding-line-between-statements */
2+
// created by autobarrel, do not modify directly
3+
4+
export * from './BaseContext'
+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
/* eslint-disable padding-line-between-statements */
2+
// created by autobarrel, do not modify directly
3+
4+
export * from './BrowserContract'
15
export * from './ProjectContract'

0 commit comments

Comments
 (0)