mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-17 04:29:57 -06:00
* chore: rename snapshots and spec files to fit vitest convention (#32405) * chore: move compiled files to dist directory to make vitest convertion easier (#32406) * chore: convert utils to vitest (#32407) * chore: convert logger to vitest * chore: convert errors spec to vitest * chore: convert cypress spec to vitest * chore: convert `exec` directory to `vitest` (#32428) * chore: cut over exec directory to vitest * Update cli/test/lib/exec/run.spec.ts * Update cli/test/lib/exec/run.spec.ts * Update cli/test/lib/exec/run.spec.ts * chore: convert the CLI and build script specs over to vitest (#32438) * chore: convert tasks directory to vitest (#32434) change way verify module is exported due to issues interpreting module (thinks its an esm) rework scripts as we cannot run an empty mocha suite chore: fix snapshots and verify requires that are internal to the cypress project fix stubbing issues with fs-extra which is also used by request-progress under the hood fix issues where xvfb was stopping prematurely * chore: remove files no longer used now that mocha tests are converted to vitest (#32455) * build binaries * chore: fix CLI tests (#32484) * chore: remove CI branch
84 lines
2.1 KiB
TypeScript
84 lines
2.1 KiB
TypeScript
import _ from 'lodash'
|
|
import path from 'path'
|
|
import shell from 'shelljs'
|
|
import fs from 'fs-extra'
|
|
|
|
// grab the current version and a few other properties
|
|
// from the root package.json
|
|
import rootPkg from '@packages/root'
|
|
|
|
const {
|
|
version,
|
|
description,
|
|
homepage,
|
|
license,
|
|
bugs,
|
|
repository,
|
|
keywords,
|
|
} = rootPkg as any
|
|
|
|
// the rest of properties should come from the package.json in CLI folder
|
|
const packageJsonSrc = path.join('package.json')
|
|
const packageJsonDest = path.join('build', 'package.json')
|
|
|
|
function getStdout (cmd: string): string {
|
|
return shell.exec(cmd).trim()
|
|
}
|
|
|
|
function preparePackageForNpmRelease (json: any, branchName?: string): any {
|
|
// modify the existing package.json
|
|
// to prepare it for releasing to npm
|
|
delete json.devDependencies
|
|
delete json['private']
|
|
// no need to include "nyc" code coverage settings
|
|
delete json.nyc
|
|
delete json.workspaces
|
|
|
|
_.extend(json, {
|
|
version,
|
|
buildInfo: {
|
|
commitBranch: branchName || process.env.CIRCLE_BRANCH || getStdout('git branch --show-current'),
|
|
commitSha: getStdout('git rev-parse HEAD'),
|
|
commitDate: new Date(getStdout('git show -s --format=%ci')).toISOString(),
|
|
stable: false,
|
|
},
|
|
description,
|
|
homepage,
|
|
license,
|
|
bugs,
|
|
repository,
|
|
keywords,
|
|
types: 'types', // typescript types
|
|
scripts: {
|
|
postinstall: 'node dist/index.js --exec install',
|
|
size: 't="$(npm pack .)"; wc -c "${t}"; tar tvf "${t}"; rm "${t}";',
|
|
},
|
|
})
|
|
|
|
return json
|
|
}
|
|
|
|
async function makeUserPackageFile (branchName?: string): Promise<any> {
|
|
const json = await fs.readJson(packageJsonSrc)
|
|
const jsonPrepared = preparePackageForNpmRelease(json, branchName)
|
|
|
|
await fs.outputJson(packageJsonDest, jsonPrepared, {
|
|
spaces: 2,
|
|
}) // returning package json object makes it easy to test
|
|
|
|
return jsonPrepared
|
|
}
|
|
|
|
export default makeUserPackageFile
|
|
|
|
if (require.main === module) {
|
|
makeUserPackageFile(process.env.BRANCH)
|
|
.catch((err: any) => {
|
|
/* eslint-disable no-console */
|
|
console.error('Could not write user package file')
|
|
console.error(err)
|
|
/* eslint-enable no-console */
|
|
process.exit(-1)
|
|
})
|
|
}
|