Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

package refactor #37

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// eslint-disable-next-line no-undef
module.exports = {
root: true,
ignorePatterns: ["dist", "examples", "e2e", "well-known-types"],
ignorePatterns: ["dist", "*.pb.ts", "*.pb.js"],
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
env: {
browser: true,
node: true,
},
plugins: ["@typescript-eslint"],
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"prettier",
],
extends: ["eslint:recommended", "prettier"],
overrides: [
{
files: ["*.ts"],
Expand All @@ -18,6 +22,7 @@ module.exports = {
project: ["./tsconfig.json"],
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/recommended-requiring-type-checking",
],
rules: {
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
node-version-file: ".nvmrc"
cache: "pnpm"
- run: pnpm install --frozen-lockfile
- run: pnpm package:build
- run: (cd packages/protoscript && pnpm package:build)
# run again to link bin that is now available after package:build
- run: pnpm install
- run: pnpm install --frozen-lockfile
- run: pnpm lint
- run: pnpm test:ci && pnpm codecov --token=$CODECOV_TOKEN
env:
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ jobs:
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- run: pnpm install --frozen-lockfile
- run: cp README.md LICENSE CHANGELOG.md packages/protoscript
- run: cd packages/protoscript
- run: pnpm package:build
- run: cd dist && npm publish
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
**/dist/*
!**/dist/package.json
coverage
node_modules
todo.txt
well-known-types/**/*.pb.ts
packages/well-known-types/**/*.pb.ts
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

pnpm run package:build
(cd packages/protoscript && pnpm run package:build)
pnpm run regen
pnpm run lint:fix
4 changes: 0 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,3 @@ As part of installation, husky pre-commit hooks are installed to run linters aga
### Publishing

There are CI and publishing GitHub workflows in `./github/workflows`. These are named `ci.yml` and `publish.yml`.

### Note

`protoscript` package self referencing is used by the wellknowntypes. right now works in a surprising manner: the package is built into dist, but the source package.json has the same name as the package.json that will be generated into dist. This results in self referencing using the source directory when everything is built.
34 changes: 0 additions & 34 deletions dist/package.json

This file was deleted.

4 changes: 3 additions & 1 deletion e2e/conformance/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "conformance",
"type": "module",
"scripts": {
"build": "esbuild runner.ts --bundle --platform=node --target=es2020 --outfile=dist/runner.cjs",
"conformance:build": "./bin/generate_conformance_test_runner.sh"
"conformance:build": "./bin/generate_conformance_test_runner.sh",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"protoscript": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion e2e/conformance/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function test(request: ConformanceRequest): ConformanceResponse {
} else if (request.jsonPayload) {
testMessage = TestAllTypesProto3JSON.decode(request.jsonPayload);
} else {
return { runtimeError: `${request} not supported` };
return { runtimeError: "request not supported" };
}
} catch (err) {
// > This string should be set to indicate parsing failed. The string can
Expand Down
8 changes: 8 additions & 0 deletions e2e/conformance/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"exclude": ["dist"]
}
4 changes: 4 additions & 0 deletions e2e/serialization/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"name": "test-serialization",
"type": "module",
"scripts": {
"typecheck": "tsc --noEmit"
},
"dependencies": {
"protoscript": "workspace:*"
}
Expand Down
1 change: 0 additions & 1 deletion e2e/serialization/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { describe, it } from "@jest/globals";
import { Baz, Foo, FooJSON } from "./message.pb.js";

const nestedMessage: Foo.FooBar = {
Expand Down
8 changes: 8 additions & 0 deletions e2e/serialization/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"exclude": ["dist"]
}
2 changes: 1 addition & 1 deletion e2e/treeshaking/TreeshakingTest.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { TreeshakingTest } from "./treeshaking.pb";
import { TreeshakingTest } from "./treeshaking.pb.js";

export default TreeshakingTest.initialize();
2 changes: 1 addition & 1 deletion e2e/treeshaking/TreeshakingTestJSON.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { TreeshakingTestJSON } from "./treeshaking.pb";
import { TreeshakingTestJSON } from "./treeshaking.pb.js";

export default TreeshakingTestJSON.initialize();
4 changes: 4 additions & 0 deletions e2e/treeshaking/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"name": "test-serialization",
"type": "module",
"dependencies": {
"protoscript": "workspace:*"
},
"scripts": {
"typecheck": "tsc --noEmit"
},
"devDependencies": {
"esbuild": "^0.18.16"
}
Expand Down
8 changes: 8 additions & 0 deletions e2e/treeshaking/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"exclude": ["dist"]
}
1 change: 1 addition & 0 deletions examples/closure-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "js-example",
"type": "module",
"main": "index.js",
"license": "MIT",
"scripts": {
Expand Down
Loading