diff --git a/npm/create-cypress-tests/package.json b/npm/create-cypress-tests/package.json index e3f1aab33b..5901324bfb 100644 --- a/npm/create-cypress-tests/package.json +++ b/npm/create-cypress-tests/package.json @@ -5,9 +5,10 @@ "private": false, "main": "index.js", "scripts": { - "build": "yarn prepare-example && tsc -p ./tsconfig.json && node scripts/example copy-to ./dist/initial-template && yarn copy \"./src/**/*.template.js\" \"./dist/src\"", + "build": "yarn prepare-example && tsc -p ./tsconfig.json && node scripts/example copy-to ./dist/initial-template && yarn prepare-copy-templates", "build-prod": "yarn build", "prepare-example": "node scripts/example copy-to ./initial-template", + "prepare-copy-templates": "node scripts/copy-templates copy-to ./dist/src", "test": "cross-env TS_NODE_PROJECT=./tsconfig.test.json mocha --config .mocharc.json './src/**/*.test.ts'", "test:watch": "yarn test -w" }, @@ -20,6 +21,7 @@ "chalk": "4.1.0", "cli-highlight": "2.1.10", "commander": "6.1.0", + "fast-glob": "3.2.7", "find-up": "5.0.0", "fs-extra": "^9.0.1", "glob": "^7.1.6", diff --git a/npm/create-cypress-tests/scripts/copy-templates.js b/npm/create-cypress-tests/scripts/copy-templates.js new file mode 100644 index 0000000000..832a816c05 --- /dev/null +++ b/npm/create-cypress-tests/scripts/copy-templates.js @@ -0,0 +1,40 @@ +const fg = require('fast-glob') +const fs = require('fs-extra') +const chalk = require('chalk') +const path = require('path') +const program = require('commander') + +program +.command('copy-to [destination]') +.description('copy ./src/**/*.template.js into destination') +.action(async (destination) => { + const srcPath = path.resolve(__dirname, '..', 'src') + const destinationPath = path.resolve(process.cwd(), destination) + + const templates = await fg('**/*.template.js', { + cwd: srcPath, + onlyFiles: true, + unique: true, + }) + + const srcOuput = './src/' + let destinationOuput = destination.replace('/\\/g', '/') + + if (!destinationOuput.endsWith('/')) { + destinationOuput += '/' + } + + const relOutput = (template, forSource) => { + return `${forSource ? srcOuput : destinationOuput}${template}` + } + + const result = await Promise.all(templates.map(async (template) => { + await fs.copy(path.join(srcPath, template), path.join(destinationPath, template)) + + return () => console.log(`✅ ${relOutput(template, true)} successfully copied to ${chalk.cyan(relOutput(template, false))}`) + })) + + result.forEach((r) => r()) +}) + +program.parse(process.argv) diff --git a/npm/design-system/package.json b/npm/design-system/package.json index 1d12359032..9b28636e77 100644 --- a/npm/design-system/package.json +++ b/npm/design-system/package.json @@ -4,7 +4,7 @@ "description": "Styles, standards, and components used throughout Cypress", "main": "dist/index.js", "scripts": { - "build": "rimraf dist && yarn rollup -c rollup.config.js", + "build": "rimraf dist && rollup -c rollup.config.js", "build-prod": "yarn build", "build-storybook": "build-storybook", "build-style-types": "tsm \"src/css/derived/*.scss\" --nameFormat none --exportType default", diff --git a/npm/react/package.json b/npm/react/package.json index 13286330c9..64d814ac2b 100644 --- a/npm/react/package.json +++ b/npm/react/package.json @@ -4,7 +4,7 @@ "description": "Test React components using Cypress", "main": "dist/cypress-react.cjs.js", "scripts": { - "build": "rimraf dist && yarn transpile-plugins && yarn rollup -c rollup.config.js", + "build": "rimraf dist && yarn transpile-plugins && rollup -c rollup.config.js", "build-prod": "yarn build", "cy:open": "node ../../scripts/cypress.js open-ct", "cy:open:debug": "node --inspect-brk ../../scripts/start.js --component-testing --run-project ${PWD}", diff --git a/npm/vue/package.json b/npm/vue/package.json index 361463018b..3d9809a6df 100644 --- a/npm/vue/package.json +++ b/npm/vue/package.json @@ -4,7 +4,7 @@ "description": "Browser-based Component Testing for Vue.js with Cypress.io ✌️🌲", "main": "dist/cypress-vue.cjs.js", "scripts": { - "build": "rimraf dist && yarn rollup -c rollup.config.js", + "build": "rimraf dist && rollup -c rollup.config.js", "build-prod": "yarn build", "cy:open": "node ../../scripts/cypress.js open-ct --project ${PWD}", "cy:run": "node ../../scripts/cypress.js run-ct --project ${PWD}", diff --git a/package.json b/package.json index 0ab261ea3a..b4cf8665b1 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "check-node-version": "node scripts/check-node-version.js", "check-terminal": "node scripts/check-terminal.js", "clean": "lerna run clean --parallel", - "check-ts": "yarn gulp checkTs", + "check-ts": "gulp checkTs", "clean-deps": "find . -depth -name node_modules -type d -exec rm -rf {} \\;", "clean-untracked-files": "git clean -d -f", "precypress:open": "yarn ensure-deps", @@ -30,14 +30,14 @@ "precypress:run:debug": "yarn ensure-deps", "cypress:run:debug": "node ./scripts/debug.js cypress:run", "cypress:verify": "cypress verify --dev", - "dev": "yarn gulp dev", + "dev": "gulp dev", "gulp:debug": "node --inspect-brk ./node_modules/.bin/gulp", "dev-debug": "node ./scripts/debug.js dev", "docker": "./scripts/run-docker-local.sh", "effective:circle:config": "circleci config process circle.yml | sed /^#/d", "ensure-deps": "./scripts/ensure-dependencies.sh", "get-next-version": "node scripts/get-next-version.js", - "postinstall": "yarn-deduplicate --strategy=highest && patch-package && yarn gulp postinstall && ./scripts/run-if-not-ci.sh yarn build", + "postinstall": "yarn-deduplicate --strategy=highest && patch-package && gulp postinstall && ./scripts/run-if-not-ci.sh yarn build", "jscodeshift": "jscodeshift -t ./node_modules/js-codemod/transforms/arrow-function-arguments.js", "lint": "eslint --ext .js,.jsx,.ts,.tsx,.json .", "lint-changed": "lint-changed", diff --git a/packages/app/package.json b/packages/app/package.json index cfd976ec98..4b76c8e73e 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -11,7 +11,7 @@ "cypress:launch": "cross-env TZ=America/New_York node ../../scripts/cypress open --project ${PWD}", "cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open-ct --project ${PWD}", "cypress:run": "cross-env TZ=America/New_York node ../../scripts/cypress run-ct --project ${PWD}", - "dev": "yarn gulp dev --project ${PWD}", + "dev": "gulp dev --project ${PWD}", "start": "echo \"run 'yarn dev' from the root\" && exit 1", "watch": "echo \"run 'yarn dev' from the root\" && exit 1", "vite:dev": "vite", diff --git a/packages/data-context/package.json b/packages/data-context/package.json index f6d9309744..4c3dd17c99 100644 --- a/packages/data-context/package.json +++ b/packages/data-context/package.json @@ -7,14 +7,15 @@ "scripts": { "build-prod": "tsc || echo 'built, with errors'", "check-ts": "tsc --noEmit", - "clean-deps": "rm -rf node_modules", - "clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", + "clean-deps": "rimraf node_modules", + "clean": "rimraf ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", "test-unit": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --config ./test/.mocharc.js --exit", "test-integration": "mocha -r @packages/ts/register test/integration/**/*.spec.ts --config ./test/.mocharc.js --exit" }, "dependencies": {}, "devDependencies": { "@packages/ts": "0.0.0-development", - "mocha": "7.0.1" + "mocha": "7.0.1", + "rimraf": "3.0.2" } } diff --git a/packages/desktop-gui/package.json b/packages/desktop-gui/package.json index 83a27dd462..2a3c5c0914 100644 --- a/packages/desktop-gui/package.json +++ b/packages/desktop-gui/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "webpack", "build-prod": "cross-env NODE_ENV=production yarn build", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open --project .", "cypress:open:ct": "cross-env TZ=America/New_York node ../../scripts/cypress open-ct --project .", "cypress:run": "cross-env TZ=America/New_York node ../../scripts/cypress run --project .", @@ -52,6 +52,7 @@ "react-popper": "2.2.5", "react-select": "3.1.0", "react-transition-group": "4.4.1", + "rimraf": "3.0.2", "webpack": "4.44.2", "webpack-cli": "3.3.2" }, diff --git a/packages/driver/package.json b/packages/driver/package.json index a8afd991a9..90d8128d8b 100644 --- a/packages/driver/package.json +++ b/packages/driver/package.json @@ -3,7 +3,7 @@ "version": "0.0.0-development", "private": true, "scripts": { - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open", "cypress:run": "node ../../scripts/cypress run", "postinstall": "patch-package", @@ -69,6 +69,7 @@ "react-16.0.0": "npm:react@16.0.0", "react-dom-15.6.1": "npm:react-dom@15.6.1", "react-dom-16.0.0": "npm:react-dom@16.0.0", + "rimraf": "3.0.2", "rollup-plugin-node-builtins": "^2.1.2", "setimmediate": "1.0.5", "sinon": "8.1.1", diff --git a/packages/electron/package.json b/packages/electron/package.json index b0ab8fa8dd..72bda4ca5c 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "node ./bin/cypress-electron --install", "build-prod": "yarn build", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "postinstall": "echo '@packages/electron needs: yarn build'", "start": "./bin/cypress-electron", "test": "yarn test-unit", @@ -26,7 +26,8 @@ "devDependencies": { "electron": "13.2.0", "execa": "4.1.0", - "mocha": "3.5.3" + "mocha": "3.5.3", + "rimraf": "3.0.2" }, "files": [ "dist", diff --git a/packages/example/package.json b/packages/example/package.json index d9fe37f507..2275117c0e 100644 --- a/packages/example/package.json +++ b/packages/example/package.json @@ -6,7 +6,7 @@ "types": "index.d.ts", "scripts": { "postinstall": "echo '@packages/example needs: yarn build'", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "test": "yarn test-unit", "test-e2e": "cypress run", "test-debug": "yarn test-unit --inspect-brk=5566", @@ -35,6 +35,7 @@ "gulp-rev-all": "2.0.2", "mocha": "2.5.3", "resolve-pkg": "2.0.0", + "rimraf": "3.0.2", "shelljs": "0.8.4" } } diff --git a/packages/extension/package.json b/packages/extension/package.json index 41b50e8fb6..0f348daef9 100644 --- a/packages/extension/package.json +++ b/packages/extension/package.json @@ -7,7 +7,7 @@ "build": "gulp build", "build-prod": "yarn build", "clean": "gulp clean", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "postinstall": "echo '@packages/extension needs: yarn build'", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", diff --git a/packages/frontend-shared/package.json b/packages/frontend-shared/package.json index a5d015b36d..f332bd2f21 100644 --- a/packages/frontend-shared/package.json +++ b/packages/frontend-shared/package.json @@ -5,8 +5,8 @@ "scripts": { "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "tsc --noEmit", - "clean-deps": "rm -rf node_modules", - "clean": "rm -f src/*.js src/**/*.js" + "clean-deps": "rimraf node_modules", + "clean": "rimraf src/*.js src/**/*.js" }, "dependencies": {}, "devDependencies": { @@ -20,6 +20,7 @@ "classnames": "2.3.1", "graphql": "^15.5.1", "graphql-tag": "^2.12.5", + "rimraf": "3.0.2", "vite-plugin-icons": "0.6.3", "vue": "3.2.6", "vue-i18n": "9.2.0-beta.1", diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 5609de379f..221aae2b0a 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -7,8 +7,8 @@ "scripts": { "build-prod": "tsc || echo 'built, with errors'", "check-ts": "tsc --noEmit", - "clean-deps": "rm -rf node_modules", - "clean": "rm -f ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", + "clean-deps": "rimraf node_modules", + "clean": "rimraf ./src/*.js ./src/**/*.js ./src/**/**/*.js ./test/**/*.js || echo 'cleaned'", "postinstall": "echo '@packages/graphql needs: yarn build'", "test-unit": "mocha -r @packages/ts/register test/unit/**/*.spec.ts --config ./test/.mocharc.js --exit", "test-integration": "mocha -r @packages/ts/register test/integration/**/*.spec.ts --config ./test/.mocharc.js --exit" @@ -32,6 +32,7 @@ "@types/dedent": "^0.7.0", "chai": "^4.2.0", "mocha": "^8.1.3", + "rimraf": "3.0.2", "snap-shot-it": "7.9.3" }, "files": [ diff --git a/packages/https-proxy/package.json b/packages/https-proxy/package.json index 63982c5dc8..1faa73fdb8 100644 --- a/packages/https-proxy/package.json +++ b/packages/https-proxy/package.json @@ -4,7 +4,7 @@ "private": true, "main": "index.js", "scripts": { - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "https": "node https.js", "regenerate:certs": "cd ./test/helpers/certs && ./regenerate-certs.sh", "start": "node index.js", @@ -19,6 +19,7 @@ "fs-extra": "8.1.0", "lodash": "4.17.21", "node-forge": "0.10.0", + "rimraf": "3.0.2", "semaphore": "1.1.0" }, "devDependencies": { diff --git a/packages/launcher/package.json b/packages/launcher/package.json index e340669d19..47180ad265 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -6,7 +6,7 @@ "scripts": { "build-prod": "tsc --project .", "clean": "node scripts/clean.js || true", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "clean-js": "yarn clean", "size": "t=\"cypress-v0.0.0.tgz\"; yarn pack --filename \"${t}\"; wc -c \"cli/${t}\"; tar tvf \"${t}\"; rm \"${t}\";", "test": "yarn test-unit", @@ -29,6 +29,7 @@ "chai-as-promised": "7.1.1", "cross-env": "6.0.3", "mocha": "3.5.3", + "rimraf": "3.0.2", "shelljs": "0.8.3", "sinon": "^10.0.0", "sinon-chai": "3.4.0", diff --git a/packages/launchpad/package.json b/packages/launchpad/package.json index 184fdf5159..6758d56d5c 100644 --- a/packages/launchpad/package.json +++ b/packages/launchpad/package.json @@ -12,7 +12,7 @@ "cypress:launch": "cross-env TZ=America/New_York node ../../scripts/cypress open --project ${PWD}", "cypress:open": "cross-env TZ=America/New_York node ../../scripts/cypress open-ct --project ${PWD}", "cypress:run": "cross-env TZ=America/New_York node ../../scripts/cypress run-ct --project ${PWD}", - "dev": "yarn gulp dev --project ${PWD}", + "dev": "gulp dev --project ${PWD}", "start": "echo 'run yarn dev from the root' && exit 1", "watch": "echo 'run yarn dev from the root' && exit 1" }, diff --git a/packages/net-stubbing/package.json b/packages/net-stubbing/package.json index a52eabc79c..89c6dd52da 100644 --- a/packages/net-stubbing/package.json +++ b/packages/net-stubbing/package.json @@ -5,7 +5,7 @@ "main": "./lib/server", "scripts": { "build-prod": "tsc --project .", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "test": "mocha -r @packages/ts/register --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json --exit test/unit/*" }, "dependencies": { @@ -21,7 +21,8 @@ "@types/mocha": "7.0.2", "bin-up": "1.2.0", "chai": "4.2.0", - "mocha": "7.1.2" + "mocha": "7.1.2", + "rimraf": "3.0.2" }, "files": [ "lib" diff --git a/packages/network/package.json b/packages/network/package.json index 636e9ac90e..b66a409b45 100644 --- a/packages/network/package.json +++ b/packages/network/package.json @@ -5,8 +5,8 @@ "main": "index.js", "scripts": { "build-prod": "tsc --project .", - "clean": "rm lib/*.js || echo 'cleaned'", - "clean-deps": "rm -rf node_modules", + "clean": "rimraf lib/*.js || echo 'cleaned'", + "clean-deps": "rimraf node_modules", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", @@ -32,6 +32,7 @@ "@types/concat-stream": "1.6.0", "express": "4.17.1", "mocha": "6.2.2", + "rimraf": "3.0.2", "sinon": "7.3.1", "sinon-chai": "3.3.0", "typescript": "^4.2.3" diff --git a/packages/proxy/package.json b/packages/proxy/package.json index 1513046429..dc58a185fa 100644 --- a/packages/proxy/package.json +++ b/packages/proxy/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "build-prod": "tsc --project .", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "run-mocha": "mocha -r @packages/ts/register -r test/pretest.ts --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", "test": "yarn run-mocha \"test/integration/*.spec.ts\" \"test/unit/**/*.spec.ts\"", "test-integration": "yarn run-mocha \"test/integration/*.spec.ts\"", @@ -31,6 +31,7 @@ "@types/express": "4.17.2", "@types/supertest": "2.0.10", "express": "4.17.1", + "rimraf": "3.0.2", "supertest": "6.0.1", "typescript": "^4.2.3" }, diff --git a/packages/reporter/package.json b/packages/reporter/package.json index 12d51141bf..4615030dc0 100644 --- a/packages/reporter/package.json +++ b/packages/reporter/package.json @@ -5,7 +5,7 @@ "browser": "src/main.tsx", "scripts": { "build-for-tests": "webpack", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open --project .", "cypress:run": "node ../../scripts/cypress run --project .", "watch": "yarn build-for-tests --watch --progress" @@ -33,6 +33,7 @@ "prop-types": "15.7.2", "react": "16.8.6", "react-dom": "16.8.6", + "rimraf": "3.0.2", "sinon": "7.5.0", "webpack": "4.35.3", "webpack-cli": "3.3.2" diff --git a/packages/resolve-dist/package.json b/packages/resolve-dist/package.json index 31c04088ec..413f6d83f0 100644 --- a/packages/resolve-dist/package.json +++ b/packages/resolve-dist/package.json @@ -5,8 +5,8 @@ "main": "index.js", "scripts": { "build-prod": "tsc --project .", - "clean": "rm lib/*.js || echo 'cleaned'", - "clean-deps": "rm -rf node_modules", + "clean": "rimraf lib/*.js || echo 'cleaned'", + "clean-deps": "rimraf node_modules", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", "test-unit": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json", @@ -16,7 +16,8 @@ "fs-extra": "8.1.0" }, "devDependencies": { - "@packages/ts": "0.0.0-development" + "@packages/ts": "0.0.0-development", + "rimraf": "3.0.2" }, "files": [ "lib" diff --git a/packages/rewriter/package.json b/packages/rewriter/package.json index 1016985fe8..dba83191f2 100644 --- a/packages/rewriter/package.json +++ b/packages/rewriter/package.json @@ -6,7 +6,7 @@ "scripts": { "build-prod": "tsc --project .", "build-test": "yarn build-prod --noEmit", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "test": "mocha --reporter mocha-multi-reporters --reporter-options configFile=../../mocha-reporter-config.json" }, "dependencies": { @@ -24,6 +24,7 @@ "@types/parse5-html-rewriting-stream": "5.1.1", "fs-extra": "9.0.0", "nock": "12.0.3", + "rimraf": "3.0.2", "sinon": "9.0.2", "sinon-chai": "3.5.0", "snap-shot-it": "7.9.3" diff --git a/packages/runner-ct/package.json b/packages/runner-ct/package.json index 385fe38d90..a0f2e33a5f 100644 --- a/packages/runner-ct/package.json +++ b/packages/runner-ct/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "webpack", "build-prod": "cross-env NODE_ENV=production yarn build && tsc", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "cypress:open": "ts-node ../../scripts/cypress.js open-ct --project ${PWD}", "cypress:run": "ts-node ../../scripts/cypress.js run-ct --project ${PWD}", "postinstall": "echo '@packages/runner needs: yarn build'", @@ -52,6 +52,7 @@ "react-devtools-inline": "^4.10.1", "react-dom": "16.8.6", "react-split-pane": "^0.1.92", + "rimraf": "3.0.2", "sass-loader": "^10.0.3", "sockjs-client": "^1.5.0", "strip-ansi": "6.0.0", diff --git a/packages/runner/package.json b/packages/runner/package.json index 1f6d0be0c3..cc753bc837 100644 --- a/packages/runner/package.json +++ b/packages/runner/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "webpack", "build-prod": "cross-env NODE_ENV=production yarn build", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open", "cypress:run": "node ../../scripts/cypress run", "postinstall": "echo '@packages/runner needs: yarn build'", @@ -55,6 +55,7 @@ "prop-types": "15.7.2", "react": "16.8.6", "react-dom": "16.8.6", + "rimraf": "3.0.2", "sinon": "7.5.0", "sinon-chai": "3.3.0", "snap-shot-core": "10.2.1", diff --git a/packages/server/package.json b/packages/server/package.json index 454f55780d..72e71cee05 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -6,7 +6,7 @@ "scripts": { "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "tsc --noEmit", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "codecov": "codecov", "dev": "node index.js", "docker": "cd ../.. && WORKING_DIR=/packages/server ./scripts/run-docker-local.sh", @@ -179,6 +179,7 @@ "proxyquire": "2.1.3", "react": "16.8.6", "repl.history": "0.1.4", + "rimraf": "3.0.2", "sinon": "5.1.1", "snap-shot-it": "7.9.3", "ssestream": "1.0.1", diff --git a/packages/socket/package.json b/packages/socket/package.json index 1d99403c3b..c797c774ae 100644 --- a/packages/socket/package.json +++ b/packages/socket/package.json @@ -7,7 +7,7 @@ "scripts": { "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "tsc --noEmit", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "postinstall": "patch-package", "test": "yarn test-unit", "test-debug": "yarn test-unit --inspect-brk=5566", @@ -23,7 +23,8 @@ "chai": "3.5.0", "cross-env": "6.0.3", "mocha": "3.5.3", - "resolve-pkg": "2.0.0" + "resolve-pkg": "2.0.0", + "rimraf": "3.0.2" }, "files": [ "lib", diff --git a/packages/ts/package.json b/packages/ts/package.json index 3c44cf9cf1..08dcb9956d 100644 --- a/packages/ts/package.json +++ b/packages/ts/package.json @@ -4,7 +4,7 @@ "private": true, "main": "index.js", "scripts": { - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "postinstall": "patch-package", "test": "yarn test-unit", "test-unit": "node test", @@ -14,6 +14,7 @@ "debug": "4.3.2" }, "devDependencies": { + "rimraf": "3.0.2", "ts-node": "5.0.1" }, "files": [ diff --git a/packages/types/package.json b/packages/types/package.json index 9eced90b6c..e69b871e71 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -7,10 +7,11 @@ "scripts": { "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "tsc --noEmit", - "clean": "rm -f src/*.js src/**/*.js" + "clean": "rimraf src/*.js src/**/*.js" }, "dependencies": {}, "devDependencies": { + "rimraf": "3.0.2", "typescript": "^4.2.3" }, "files": [ diff --git a/packages/ui-components/package.json b/packages/ui-components/package.json index 56bb5a0f91..016d6e41bf 100644 --- a/packages/ui-components/package.json +++ b/packages/ui-components/package.json @@ -7,7 +7,7 @@ "build-for-tests": "webpack", "check-deps": "node ../../scripts/check-deps.js --verbose", "check-deps-pre": "npm run check-deps -- --prescript", - "clean-deps": "rm -rf node_modules", + "clean-deps": "rimraf node_modules", "cypress:open": "node ../../scripts/cypress open --project .", "cypress:run": "node ../../scripts/cypress run --project .", "pretest": "npm run check-deps-pre", @@ -36,7 +36,8 @@ "prop-types": "15.7.2", "react": "16.8.6", "react-dom": "16.8.6", + "rimraf": "3.0.2", "webpack": "4.41.6", "webpack-cli": "3.3.11" } -} \ No newline at end of file +} diff --git a/scripts/gulp/tasks/gulpVite.ts b/scripts/gulp/tasks/gulpVite.ts index 36fb6fd64c..7fa9ab6567 100644 --- a/scripts/gulp/tasks/gulpVite.ts +++ b/scripts/gulp/tasks/gulpVite.ts @@ -8,13 +8,13 @@ const CYPRESS_VITE_APP_PORT = getenv.int('CYPRESS_VITE_APP_PORT', 3333) const CYPRESS_VITE_LAUNCHPAD_PORT = getenv.int('CYPRESS_VITE_LAUNCHPAD_PORT', 3001) export function viteApp () { - return viteDev('vite-app', `yarn vite --port ${CYPRESS_VITE_APP_PORT} --base /__vite__/`, { + return viteDev('vite-app', `vite --port ${CYPRESS_VITE_APP_PORT} --base /__vite__/`, { cwd: monorepoPaths.pkgApp, }) } export function viteLaunchpad () { - return viteDev('vite-launchpad', `yarn vite --port ${CYPRESS_VITE_LAUNCHPAD_PORT}`, { + return viteDev('vite-launchpad', `vite --port ${CYPRESS_VITE_LAUNCHPAD_PORT}`, { cwd: monorepoPaths.pkgLaunchpad, }) } diff --git a/scripts/gulp/utils/childProcessUtils.ts b/scripts/gulp/utils/childProcessUtils.ts index 782f36a186..ea3d56f1c4 100644 --- a/scripts/gulp/utils/childProcessUtils.ts +++ b/scripts/gulp/utils/childProcessUtils.ts @@ -46,7 +46,13 @@ export async function spawned ( spawningApps.add(prefix) const [executable, ...rest] = command.split(' ') - const cp = spawn(executable, rest, { + let useExecutable = executable + + if (process.platform === 'win32' && !useExecutable.endsWith('.cmd')) { + useExecutable = `${executable}.cmd` + } + + const cp = spawn(useExecutable, rest, { stdio: 'pipe', env: { FORCE_COLOR: '1', @@ -91,12 +97,38 @@ export async function spawned ( return new Promise((resolve, reject) => { if (waitForExit) { - cp.once('exit', () => { - resolve(cp) + if (process.platform === 'win32') { + cp.on('exit', (code, signal) => { + console.log(`Exit code: ${code} => ${signal}`) + resolve(cp) + }) + } else { + cp.once('exit', (code, signal) => { + console.log(`Exit code: ${code} => ${signal}`) + resolve(cp) + }) + } + + cp.once('error', (e) => { + console.log(`error executing ${command}`, e) + reject(e) + }) + } else { + if (process.platform === 'win32') { + cp.on('exit', (code, signal) => { + console.log(`Exit code: ${code} => ${signal}`) + }) + } else { + cp.once('exit', (code, signal) => { + console.log(`Exit code: ${code} => ${signal}`) + }) + } + + cp.once('error', (e) => { + console.log(`error executing ${command}`, e) + reject(e) }) - cp.once('error', reject) - } else { cp.stdout?.once('data', () => { spawningApps.delete(prefix) resolve(cp) diff --git a/scripts/gulp/utils/nexusTypegenUtil.ts b/scripts/gulp/utils/nexusTypegenUtil.ts index 574de7d33e..c781cdac73 100644 --- a/scripts/gulp/utils/nexusTypegenUtil.ts +++ b/scripts/gulp/utils/nexusTypegenUtil.ts @@ -22,16 +22,38 @@ function prefixTypegen (s: string) { return `${chalk.cyan('nexusTypegen')}: ${s}` } +async function windowsTouch (filename: string, time: Date) { + // `fs.utimesSync` is used here to prevent existing file contents from being overwritten. + // It also updates the last modification timestamp of the file, which is consistent with what POSIX touch does. + try { + fs.utimesSync(filename, time, time) + } catch (e) { + fs.closeSync(fs.openSync(filename, 'w')) + } +} + export async function nexusTypegen (cfg: NexusTypegenCfg) { const dfd = pDefer() if (cfg.outputPath) { await fs.ensureDir(path.join(monorepoPaths.pkgGraphql, 'src/gen')) - execSync(`touch ${path.join(monorepoPaths.pkgGraphql, 'src/gen/cloud-source-types.gen.ts')}`) - execSync(`touch ${cfg.outputPath}`) + + const pkgGraphql = path.join(monorepoPaths.pkgGraphql, 'src/gen/cloud-source-types.gen.ts') + + // on windows there is no `touch` equivalent command + if (process.platform === 'win32') { + const time = new Date() + + await windowsTouch(pkgGraphql, time) + await windowsTouch(cfg.outputPath, time) + } else { + execSync(`touch ${pkgGraphql}`) + execSync(`touch ${cfg.outputPath}`) + } } - const out = spawn('node', ['-r', '@packages/ts/register', cfg.filePath], { + const nodeCmd = `node${process.platform === 'win32' ? '.cmd' : ''}` + const out = spawn(nodeCmd, ['-r', '@packages/ts/register', cfg.filePath], { cwd: cfg.cwd, env: { ...process.env, diff --git a/yarn.lock b/yarn.lock index 3b4e44a4ef..f6614368d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -20015,6 +20015,17 @@ fast-glob@3.1.1: merge2 "^1.3.0" micromatch "^4.0.2" +fast-glob@3.2.7, fast-glob@^3.0.3, fast-glob@^3.1.1, fast-glob@^3.2.4, fast-glob@^3.2.5, fast-glob@^3.2.6, fast-glob@^3.2.7: + version "3.2.7" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" + integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + fast-glob@^2.0.2, fast-glob@^2.2.6: version "2.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.7.tgz#6953857c3afa475fff92ee6015d52da70a4cd39d" @@ -20027,17 +20038,6 @@ fast-glob@^2.0.2, fast-glob@^2.2.6: merge2 "^1.2.3" micromatch "^3.1.10" -fast-glob@^3.0.3, fast-glob@^3.1.1, fast-glob@^3.2.4, fast-glob@^3.2.5, fast-glob@^3.2.6, fast-glob@^3.2.7: - version "3.2.7" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" - integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - fast-json-parse@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/fast-json-parse/-/fast-json-parse-1.0.3.tgz#43e5c61ee4efa9265633046b770fb682a7577c4d"