Skip to content

Commit 13ad366

Browse files
chore(workspace): add publish scripts and docs
1 parent 05b2090 commit 13ad366

File tree

11 files changed

+1335
-132
lines changed

11 files changed

+1335
-132
lines changed

.commitlintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": ["@commitlint/config-angular"],
2+
"extends": ["@commitlint/config-conventional"],
33
"rules": {}
44
}

.verdaccio/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ packages:
1919
proxy: npmjs
2020

2121
# log settings
22-
logs:
22+
log:
2323
type: stdout
2424
format: pretty
2525
level: warn

package-lock.json

Lines changed: 1143 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
"repository": "https://github.com/prestodb/presto-js-client",
1212
"scripts": {
1313
"build": "nx build",
14-
"build:presto-client": "nx build presto-client",
1514
"commit": "cz",
1615
"format": "nx format",
1716
"format:check": "nx format:check",
18-
"format:write": "nx format:write",
1917
"lint": "nx lint",
18+
"local-registry": "nx local-registry",
2019
"nx": "nx",
2120
"prepare": "husky install",
2221
"presto:up": "docker compose -f ./docker-compose/presto/docker-compose.yml -p presto up",
23-
"publish": "nx publish",
22+
"publish": "nx version",
23+
"publish:local": "nx version-local",
2424
"serve": "nx serve",
2525
"test": "nx test"
2626
},
@@ -42,8 +42,9 @@
4242
"tslib": "^2.3.0"
4343
},
4444
"devDependencies": {
45-
"@commitlint/cli": "~17.0.0",
46-
"@commitlint/config-angular": "~17.0.0",
45+
"@commitlint/cli": "~17.7.0",
46+
"@commitlint/config-conventional": "~17.7.0",
47+
"@jscutlery/semver": "~3.1.0",
4748
"@nestjs/schematics": "^10.0.1",
4849
"@nestjs/testing": "^10.0.2",
4950
"@nx/eslint-plugin": "16.8.1",

presto-client/.swcrc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
{
2+
"exclude": [
3+
"jest.config.ts",
4+
".*\\.spec.tsx?$",
5+
".*\\.test.tsx?$",
6+
"./src/jest-setup.ts$",
7+
"./**/jest-setup.ts$",
8+
".*.js$"
9+
],
210
"jsc": {
3-
"target": "es2017",
11+
"externalHelpers": true,
12+
"keepClassNames": true,
13+
"loose": true,
414
"parser": {
5-
"syntax": "typescript",
615
"decorators": true,
7-
"dynamicImport": true
16+
"dynamicImport": true,
17+
"syntax": "typescript"
818
},
19+
"target": "es2017",
920
"transform": {
1021
"decoratorMetadata": true,
1122
"legacyDecorator": true
12-
},
13-
"keepClassNames": true,
14-
"externalHelpers": true,
15-
"loose": true
23+
}
1624
},
1725
"module": {
18-
"type": "es6"
26+
"type": "commonjs"
1927
},
20-
"sourceMaps": true,
21-
"exclude": [
22-
"jest.config.ts",
23-
".*\\.spec.tsx?$",
24-
".*\\.test.tsx?$",
25-
"./src/jest-setup.ts$",
26-
"./**/jest-setup.ts$",
27-
".*.js$"
28-
]
28+
"sourceMaps": true
2929
}

presto-client/CHANGELOG.md

Whitespace-only changes.

presto-client/README.md

Lines changed: 94 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,103 @@ This library was generated with [Nx](https://nx.dev).
44

55
## Building
66

7-
Run `npm run build presto-client` to build the library.
7+
To build the library using [SWC](https://swc.rs), run the following command:
8+
9+
```bash
10+
npm run build presto-client
11+
```
812

913
## Linting
1014

11-
Run `npm run lint presto-client` to run the linter on the library.
15+
To lint the library using [ESLint](https://eslint.org), run the following command:
16+
17+
```bash
18+
npm run lint presto-client
19+
```
20+
21+
## Publishing
22+
23+
### Locally
24+
25+
To publish a new version to a private local registry, follow these steps:
26+
27+
#### Steps
28+
29+
1. Start by cleaning your workspace using the following command:
30+
31+
```bash
32+
git stash
33+
```
34+
35+
2. Start a private local registry using [Verdaccio](https://verdaccio.org):
36+
37+
```bash
38+
npm run local-registry presto-js-client
39+
```
40+
41+
3. In another terminal, publish the new version by running the following command:
42+
43+
```bash
44+
npm run publish:local presto-client
45+
```
46+
47+
If you're publishing a Pre-release version, run instead:
48+
49+
```bash
50+
npm run publish:local presto-client -- --releaseAs=premajor|preminor|prepatch --preid=beta
51+
```
52+
53+
Check the [semver options](https://github.com/jscutlery/semver#available-options) for all available options.
54+
55+
4. If the output of the previous command is successful, check that:
56+
57+
- A new local git tag was generated.
58+
- `presto-client/CHANGELOG.md` file was updated.
59+
- `presto-client/package.json` file was updated.
60+
61+
5. Visit http://localhost:4873 and ensure that `@prestodb/presto-js-client` was pushed successfully to the private local registry, including the git tag, `CHANGELOG.md`, and `package.json` files reviewed above.
62+
63+
6. Now you can run `npm i @prestodb/presto-js-client` in any other project locally to test the released version before releasing it to NPM.
64+
65+
### NPM
66+
67+
To publish a new version to NPM, follow these steps:
68+
69+
#### Pre-requisites
70+
71+
- Have a valid `NPM_TOKEN` with write permissions to [prestodb NPM organization](https://www.npmjs.com/settings/prestodb/packages).
72+
- Install [GitHub CLI](https://cli.github.com/) on your machine.
73+
74+
#### Steps
75+
76+
1. Start by cleaning your workspace using the following command:
77+
78+
```bash
79+
git stash
80+
```
81+
82+
2. Publish a new version by running the following command:
83+
84+
```bash
85+
npm run publish presto-client
86+
```
87+
88+
If you're publishing a Pre-release version, run instead:
89+
90+
```bash
91+
npm run publish presto-client -- --releaseAs=premajor|preminor|prepatch --preid=beta
92+
```
93+
94+
Check the [semver options](https://github.com/jscutlery/semver#available-options) for all available options.
95+
96+
3. As part of the previous command, a draft GitHub release is also created. Go to [GitHub Releases](https://github.com/prestodb/presto-js-client/releases), review and edit it if necessary, and then click "Publish release" to make it public.
97+
98+
\*If you published the package as a Pre-release version, please also mark the GitHub release as a "Pre-release."
1299

13100
## Testing
14101

15-
Run `npm run test presto-client` to execute the unit tests via [Jest](https://jestjs.io).
102+
To test the library using [Jest](https://jestjs.io), run the following command:
103+
104+
```bash
105+
npm run test presto-client
106+
```

presto-client/project.json

Lines changed: 46 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,68 @@
66
"targets": {
77
"build": {
88
"executor": "@nx/js:swc",
9-
"outputs": ["{options.outputPath}"],
109
"options": {
11-
"outputPath": "dist/presto-client",
10+
"assets": ["presto-client/*.md"],
1211
"main": "presto-client/src/index.ts",
13-
"tsConfig": "presto-client/tsconfig.lib.json",
14-
"assets": ["presto-client/*.md"]
12+
"outputPath": "dist/presto-client",
13+
"tsConfig": "presto-client/tsconfig.lib.json"
14+
},
15+
"outputs": ["{options.outputPath}"]
16+
},
17+
"github": {
18+
"executor": "@jscutlery/semver:github",
19+
"options": {
20+
"draft": true,
21+
"generateNotes": true,
22+
"notes": "${notes}",
23+
"tag": "${tag}"
1524
}
1625
},
1726
"lint": {
1827
"executor": "@nx/linter:eslint",
19-
"outputs": ["{options.outputFile}"],
2028
"options": {
2129
"lintFilePatterns": ["presto-client/**/*.ts", "presto-client/package.json"]
22-
}
30+
},
31+
"outputs": ["{options.outputFile}"]
2332
},
24-
"publish": {
25-
"command": "node tools/scripts/publish.mjs presto-client {args.ver} {args.tag}",
26-
"dependsOn": ["build", "lint", "test"]
33+
"npm": {
34+
"command": "node tools/scripts/npm.mjs presto-client ${version} ${tag}"
2735
},
2836
"test": {
29-
"executor": "@nx/jest:jest",
30-
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
31-
"options": {
32-
"jestConfig": "presto-client/jest.config.ts",
33-
"passWithNoTests": true
34-
},
3537
"configurations": {
3638
"ci": {
3739
"ci": true,
3840
"codeCoverage": true
3941
}
42+
},
43+
"executor": "@nx/jest:jest",
44+
"options": {
45+
"jestConfig": "presto-client/jest.config.ts",
46+
"passWithNoTests": true
47+
},
48+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"]
49+
},
50+
"version": {
51+
"dependsOn": ["build", "lint", "test"],
52+
"executor": "@jscutlery/semver:version",
53+
"options": {
54+
"commitMessageFormat": "chore({projectName}): release ${version}",
55+
"postTargets": ["presto-client:github", "presto-client:npm"],
56+
"preset": "conventional",
57+
"push": true,
58+
"skipCommitTypes": ["build", "ci", "chore", "docs", "style", "test"]
59+
}
60+
},
61+
"version-local": {
62+
"dependsOn": ["build", "lint", "test"],
63+
"executor": "@jscutlery/semver:version",
64+
"options": {
65+
"commitMessageFormat": "chore({projectName}): release ${version}",
66+
"postTargets": ["presto-client:npm"],
67+
"preset": "conventional",
68+
"push": false,
69+
"skipCommit": true,
70+
"skipCommitTypes": ["build", "ci", "chore", "docs", "style", "test"]
4071
}
4172
}
4273
},

presto-client/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"compilerOptions": {
33
"forceConsistentCasingInFileNames": true,
4-
"module": "esnext",
4+
"module": "CommonJS",
5+
"noFallthroughCasesInSwitch": true,
56
"noImplicitOverride": true,
67
"noImplicitReturns": true,
7-
"noFallthroughCasesInSwitch": true,
88
"noPropertyAccessFromIndexSignature": true,
9-
"strict": true
9+
"strict": true,
10+
"target": "ESNext"
1011
},
1112
"extends": "../tsconfig.base.json",
1213
"files": [],

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"local-registry": {
66
"executor": "@nx/js:verdaccio",
77
"options": {
8-
"port": 4873,
98
"config": ".verdaccio/config.yml",
9+
"port": 4873,
1010
"storage": "tmp/local-registry/storage"
1111
}
1212
}

0 commit comments

Comments
 (0)