Skip to content

Commit

Permalink
fix: use release script
Browse files Browse the repository at this point in the history
  • Loading branch information
agoldis committed Mar 10, 2023
1 parent 361d37f commit 8f29211
Show file tree
Hide file tree
Showing 4 changed files with 165 additions and 18 deletions.
27 changes: 26 additions & 1 deletion .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Add `cypress-cloud/plugin` to `cypress.config.{js|ts|mjs}`
```js
// cypress.config.js
const { defineConfig } = require("cypress");
const cloudPlugin = require("cypress-cloud/plugin");
const { cloudPlugin } = require("cypress-cloud/plugin");
module.exports = defineConfig({
e2e: {
setupNodeEvents(on, config) {
Expand Down Expand Up @@ -136,3 +136,28 @@ npm run test
```

> Please note, we use `esbuild` for building and `swc` for testing. In addition, jest has built-in module aliases, but eslint does not. Beware of importing aliases in non-testing code.
## Releasing

### Beta channel

```sh
cd packages/cypress-cloud
npm run release -- --preRelease=beta && npm run release:npm -- -t beta
```

### Latest channel

```sh
cd packages/cypress-cloud
npm run release && npm run release:npm -- -t latest
```

### Localhost

```sh
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
npm adduser --registry http://localhost:4873
npm login --registry http://localhost:4873
npm publish --registry http://localhost:4873 --tag beta
```
68 changes: 66 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 20 additions & 15 deletions packages/cypress-cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cypress-cloud",
"version": "1.4.2-beta.0",
"main": ".",
"version": "1.4.2-beta.5",
"main": "./dist",
"author": "Currents Software Inc",
"homepage": "https://github.com/currents-dev/cypress-cloud",
"bugs": {
Expand All @@ -16,8 +16,7 @@
"cypress",
"sorry-cypress",
"ci",
"test",
"automation",
"e2e",
"cypress-cloud"
],
"scripts": {
Expand All @@ -26,6 +25,7 @@
"test": "jest",
"test:watch": "jest --watch",
"release": "release-it",
"release:npm": "./publish.js",
"dev": "tsup --watch",
"build": "tsup --dts"
},
Expand Down Expand Up @@ -60,6 +60,7 @@
"commander": "^9.4.1",
"common-path-prefix": "^3.0.0",
"cy2": "^3.4.2",
"cypress-cloud": "^1.4.2-beta.13",
"debug": "^4.3.4",
"getos": "^3.2.1",
"globby": "^11.1.0",
Expand All @@ -76,9 +77,7 @@
"cypress-cloud": "./bin/cli.js"
},
"files": [
"dist/*",
"LICENSE.md",
"README.md"
"dist"
],
"tsup": {
"entry": [
Expand All @@ -97,21 +96,27 @@
"target": "node14"
},
"exports": {
".": "./",
"./plugin": "./plugin",
"./support": "./support",
".": "./dist",
"./plugin": {
"import": "./dist/plugin/index.js",
"require": "./dist/plugin/index.js",
"types": "./dist/plugin/index.d.ts"
},
"./support": {
"import": "./dist/support/index.js",
"require": "./dist/support/index.js",
"types": "./dist/support/index.d.ts"
},
"./package.json": "./package.json"
},
"release-it": {
"hooks": {
"before:init": "npm run rm && npm run build",
"before:npm:release": "cp package.json dist/package.json && cp README.md dist/README.md && cp LICENSE.md dist/LICENSE.md && cd dist"
},
"github": {
"release": true,
"releaseName": "v${version}"
},
"npm": {},
"npm": {
"publish": false
},
"git": {
"requireCleanWorkingDir": false,
"commitMessage": "chore: release v${version}",
Expand Down
53 changes: 53 additions & 0 deletions packages/cypress-cloud/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env node

const { execSync } = require("child_process");
const fs = require("fs");
const pkg = require("./package.json");

const { Command, Option } = require("@commander-js/extra-typings");

const program = new Command()
.name("publish")
.option("-t, --tag <beta | latest>", "npm dist-tag to publish to");

program.parse(process.argv);
const options = program.opts();

console.log(options);
if (!options.tag) {
console.log("No tag supplied: beta or latest");
process.exit(1);
}

const newPkg = {
...pkg,
main: "./index.js",
files: ["*"],
exports: {
".": "./",
"./plugin": {
import: "./plugin/index.js",
require: "./plugin/index.js",
types: "./plugin/index.d.ts",
},
"./support": {
import: "./support/index.js",
require: "./support/index.js",
types: "./support/index.d.ts",
},
"./package.json": "./package.json",
},
};
fs.copyFileSync("./LICENSE.md", "./dist/LICENSE.md");
fs.writeFileSync(
"./dist/package.json",
JSON.stringify(newPkg, null, 2),
"utf-8"
);
execSync(
`npm pack --dry-run && npm publish --registry http://localhost:4873 --tag ${options.tag}`,
{
cwd: "./dist",
stdio: "inherit",
}
);

0 comments on commit 8f29211

Please sign in to comment.