From 0501452fb9e2df954ee871171052ab9f01367b25 Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Tue, 2 Nov 2021 02:19:22 +1000 Subject: [PATCH] fix: support using create-cypress-tests as part of build process (#18714) Co-authored-by: Tim Griesser --- npm/create-cypress-tests/package.json | 6 +++++- npm/create-cypress-tests/src/main.ts | 2 ++ packages/data-context/package.json | 12 ++++++++++++ .../src/sources/ProjectDataSource.ts | 2 +- packages/frontend-shared/package.json | 1 - scripts/binary/build.js | 18 ++++++++++++++++-- scripts/binary/zip.js | 2 +- yarn.lock | 2 +- 8 files changed, 38 insertions(+), 7 deletions(-) diff --git a/npm/create-cypress-tests/package.json b/npm/create-cypress-tests/package.json index 5901324bfb42..07cddcdb51fa 100644 --- a/npm/create-cypress-tests/package.json +++ b/npm/create-cypress-tests/package.json @@ -3,7 +3,7 @@ "version": "0.0.0-development", "description": "Cypress smart installation wizard", "private": false, - "main": "index.js", + "main": "dist/src/main.js", "scripts": { "build": "yarn prepare-example && tsc -p ./tsconfig.json && node scripts/example copy-to ./dist/initial-template && yarn prepare-copy-templates", "build-prod": "yarn build", @@ -41,6 +41,10 @@ "snap-shot-it": "7.9.3", "typescript": "^4.2.3" }, + "files": [ + "dist", + "bin" + ], "bin": { "create-cypress-tests": "dist/src/index.js" }, diff --git a/npm/create-cypress-tests/src/main.ts b/npm/create-cypress-tests/src/main.ts index 4dd68128e8fc..818a58b94329 100644 --- a/npm/create-cypress-tests/src/main.ts +++ b/npm/create-cypress-tests/src/main.ts @@ -102,3 +102,5 @@ export async function main ({ useNpm, ignoreTs, setupComponentTesting, ignoreExa console.log(`\nHappy testing with ${chalk.green('cypress.io')} 🌲\n`) } + +export { scanFSForAvailableDependency } diff --git a/packages/data-context/package.json b/packages/data-context/package.json index 6b5f0398ec8d..4a28bfac4f42 100644 --- a/packages/data-context/package.json +++ b/packages/data-context/package.json @@ -14,10 +14,21 @@ }, "dependencies": { "@storybook/csf-tools": "^6.4.0-alpha.38", + "@urql/core": "2.3.1", + "@urql/exchange-execute": "1.1.0", + "@urql/exchange-graphcache": "4.3.3", + "chokidar": "3.5.1", "create-cypress-tests": "0.0.0-development", "cross-fetch": "^3.1.4", "dataloader": "^2.0.0", + "dedent": "^0.7.0", + "electron": "14.1.0", + "endent": "2.0.1", + "execa": "1.0.0", + "fs-extra": "8.1.0", + "getenv": "1.0.0", "globby": "^11.0.1", + "graphql": "^15.5.1", "lodash": "4.17.21", "p-defer": "^3.0.0", "wonka": "^4.0.15" @@ -26,6 +37,7 @@ "@packages/resolve-dist": "0.0.0-development", "@packages/ts": "0.0.0-development", "@packages/types": "0.0.0-development", + "@types/dedent": "^0.7.0", "mocha": "7.0.1", "rimraf": "3.0.2" }, diff --git a/packages/data-context/src/sources/ProjectDataSource.ts b/packages/data-context/src/sources/ProjectDataSource.ts index 5efed4a0fc91..d01b7efb6fb7 100644 --- a/packages/data-context/src/sources/ProjectDataSource.ts +++ b/packages/data-context/src/sources/ProjectDataSource.ts @@ -1,6 +1,6 @@ import type { CodeGenType, SpecType } from '@packages/graphql/src/gen/nxs.gen' import { FrontendFramework, FRONTEND_FRAMEWORKS, FullConfig, ResolvedFromConfig, RESOLVED_FROM, SpecFile, STORYBOOK_GLOB } from '@packages/types' -import { scanFSForAvailableDependency } from 'create-cypress-tests/src/findPackageJson' +import { scanFSForAvailableDependency } from 'create-cypress-tests' import path from 'path' import type { DataContext } from '..' diff --git a/packages/frontend-shared/package.json b/packages/frontend-shared/package.json index c507c8f5eb40..a3c46d62f2f9 100644 --- a/packages/frontend-shared/package.json +++ b/packages/frontend-shared/package.json @@ -3,7 +3,6 @@ "version": "0.0.0-development", "private": true, "scripts": { - "build-prod": "tsc || echo 'built, with type errors'", "check-ts": "vue-tsc --noEmit", "clean-deps": "rimraf node_modules", "clean": "rimraf dist ./node_modules/.vite src/*.js src/**/*.js && echo 'cleaned'", diff --git a/scripts/binary/build.js b/scripts/binary/build.js index 2990404ba0f1..697e5a8bb7f3 100644 --- a/scripts/binary/build.js +++ b/scripts/binary/build.js @@ -350,13 +350,27 @@ require('./packages/server')\ const runSmokeTests = function () { log('#runSmokeTests') - const run = function () { + const run = async function () { // make sure to use a longer timeout - on Mac the first // launch of a built application invokes gatekeeper check // which takes a couple of seconds const executablePath = meta.buildAppExecutable(platform) - return smoke.test(executablePath) + // Moving this package specifically to simulate a failing scenario for + // https://github.com/cypress-io/cypress/pull/18714 + await fse.move( + path.join(process.cwd(), 'node_modules/create-cypress-tests'), + path.join(process.cwd(), 'node_modules/_create-cypress-tests'), + ) + + try { + return await smoke.test(executablePath) + } finally { + await fse.move( + path.join(process.cwd(), 'node_modules/_create-cypress-tests'), + path.join(process.cwd(), 'node_modules/create-cypress-tests'), + ) + } } if (xvfb.isNeeded()) { diff --git a/scripts/binary/zip.js b/scripts/binary/zip.js index 712f52f8f9fe..a18fec3017d5 100644 --- a/scripts/binary/zip.js +++ b/scripts/binary/zip.js @@ -73,7 +73,7 @@ const checkZipSize = function (zipPath) { const zipSize = filesize(stats.size, { round: 0 }) console.log(`zip file size ${zipSize}`) - const MAX_ALLOWED_SIZE_MB = os.platform() === 'win32' ? 295 : 260 + const MAX_ALLOWED_SIZE_MB = os.platform() === 'win32' ? 295 : 300 const MAX_ZIP_FILE_SIZE = megaBytes(MAX_ALLOWED_SIZE_MB) if (stats.size > MAX_ZIP_FILE_SIZE) { diff --git a/yarn.lock b/yarn.lock index a2b1c3217012..ad7c45c1159d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -18619,7 +18619,7 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0, end-of-stream@^1.4.1: dependencies: once "^1.4.0" -endent@^2.0.1: +endent@2.0.1, endent@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/endent/-/endent-2.0.1.tgz#fb18383a3f37ae3213a5d9f6c4a880d1061eb4c5" integrity sha512-mADztvcC+vCk4XEZaCz6xIPO2NHQuprv5CAEjuVAu6aZwqAj7nVNlMyl1goPFYqCCpS2OJV9jwpumJLkotZrNw==