Skip to content
This repository has been archived by the owner on Jun 21, 2020. It is now read-only.

Commit

Permalink
Renames bxpb-runtime to @bxpb/runtime.
Browse files Browse the repository at this point in the history
Refs #1.

This updates the package name to use the new NPM scope. This improves protection against typo-squatting and clearly indicates that it is an "officially" supported package.

I opted to have the directory structure as `packages/runtime/` rather than `packages/@bxpb/runtime/` as all packages should be under `@bxpb`, so it would just be extra typing and an extra directory which serves no benefit.
  • Loading branch information
dgp1130 committed Jun 2, 2020
1 parent 22b4732 commit 5f60205
Show file tree
Hide file tree
Showing 27 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ could implemented in a Chrome extension like so:
```typescript
// service.ts

import { servePort } from 'bxpb-runtime';
import { servePort } from '@bxpb/runtime';
import { GreeterService } from './protos/greeter_bx'; // Generated service.
import { HelloRequest, HelloResponse } from './protos/greeter_pb';

Expand Down Expand Up @@ -93,7 +93,7 @@ The architecture will consist of a few packages:

* `bxpb-protoc-compiler`: A plugin for `protoc` which generates TypeScript client/service stubs
for a given protobuf service.
* `bxpb-runtime`: A runtime to be included that performs the real work of communicating between
* `@bxpb/runtime`: A runtime to be included that performs the real work of communicating between
the client and service in a generic fashion.
* This will include client and service stubs, rather than splitting them across multiple
packages. This is to keep the number of packages down as much as possible.
2 changes: 1 addition & 1 deletion examples/greeter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"url": "https://github.com/dgp1130/bxpb/issues"
},
"dependencies": {
"bxpb-runtime": "^0.0.0",
"@bxpb/runtime": "^0.0.0",
"google-protobuf": "^3.12.0",
"tslib": "^2.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# BXPB Packages

This contains all the packages for BXPB.
This contains all the packages for BXPB. All of these are under the `@bxpb` scope.

* [bxpb-protoc-plugin](bxpb-protoc-plugin/) - The compiler plugin which generates BXPB TypeScript
definitions for protocol buffer source files.
* [bxpb-runtime](bxpb-runtime/) - The runtime for clients and services of BXPB.
* [@bxpb/runtime](runtime/) - The runtime for clients and services of BXPB.
4 changes: 2 additions & 2 deletions packages/bxpb-protoc-plugin/src/generators/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function* generateClientFiles(file: string, fileDescriptor: FileDescripto
/** Returns the generated JavaScript source as a string. */
function generateClientJs(filePath: path.ParsedPath, fileDescriptor: FileDescriptorProto): string {
return `
import { ProtoClient, rpc } from 'bxpb-runtime/dist/client.js';
import { ProtoClient, rpc } from '@bxpb/runtime/dist/client.js';
import * as descriptors from './${filePath.name}_bxdescriptors.js';
${fileDescriptor.getServiceList().map((service) => {
Expand Down Expand Up @@ -66,7 +66,7 @@ export class ${serviceName}Client extends ProtoClient {
/** Returns the generated TypeScript definitions as a string. */
function generateClientDts(filePath: path.ParsedPath, fileDescriptor: FileDescriptorProto): string {
return `
import { ProtoClient } from 'bxpb-runtime/dist/client';
import { ProtoClient } from '@bxpb/runtime/dist/client';
import protos from './${filePath.name}_pb';
import * as descriptors from './${filePath.name}_bxdescriptors';
Expand Down
12 changes: 6 additions & 6 deletions packages/bxpb-protoc-plugin/src/generators/clients_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('clients', ()=> {

expect(jsFile.getName()).toBe('foo_bxclients.js');
expect(jsFile.getContent()).toBe(`
import { ProtoClient, rpc } from 'bxpb-runtime/dist/client.js';
import { ProtoClient, rpc } from '@bxpb/runtime/dist/client.js';
import * as descriptors from './foo_bxdescriptors.js';
/** Client for calling {@link descriptors.FooService}. */
Expand All @@ -38,7 +38,7 @@ export class FooClient extends ProtoClient {

expect(dtsFile.getName()).toBe('foo_bxclients.d.ts');
expect(dtsFile.getContent()).toBe(`
import { ProtoClient } from 'bxpb-runtime/dist/client';
import { ProtoClient } from '@bxpb/runtime/dist/client';
import protos from './foo_pb';
import * as descriptors from './foo_bxdescriptors';
Expand Down Expand Up @@ -80,7 +80,7 @@ export class FooClient extends ProtoClient {
generateClientFiles('foo.proto', fileDescriptor));

expect(jsFile.getContent()).toBe(`
import { ProtoClient, rpc } from 'bxpb-runtime/dist/client.js';
import { ProtoClient, rpc } from '@bxpb/runtime/dist/client.js';
import * as descriptors from './foo_bxdescriptors.js';
/** Client for calling {@link descriptors.FooService}. */
Expand All @@ -101,7 +101,7 @@ export class BarClient extends ProtoClient {
`.trim());

expect(dtsFile.getContent()).toBe(`
import { ProtoClient } from 'bxpb-runtime/dist/client';
import { ProtoClient } from '@bxpb/runtime/dist/client';
import protos from './foo_pb';
import * as descriptors from './foo_bxdescriptors';
Expand Down Expand Up @@ -144,7 +144,7 @@ export class BarClient extends ProtoClient {
generateClientFiles('foo.proto', fileDescriptor));

expect(jsFile.getContent()).toBe(`
import { ProtoClient, rpc } from 'bxpb-runtime/dist/client.js';
import { ProtoClient, rpc } from '@bxpb/runtime/dist/client.js';
import * as descriptors from './foo_bxdescriptors.js';
/** Client for calling {@link descriptors.FooService}. */
Expand All @@ -162,7 +162,7 @@ export class FooClient extends ProtoClient {
`.trim());

expect(dtsFile.getContent()).toBe(`
import { ProtoClient } from 'bxpb-runtime/dist/client';
import { ProtoClient } from '@bxpb/runtime/dist/client';
import protos from './foo_pb';
import * as descriptors from './foo_bxdescriptors';
Expand Down
2 changes: 1 addition & 1 deletion packages/bxpb-protoc-plugin/src/generators/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const ${serviceName}Service = Object.freeze({
function generateDescriptorDts(filePath: path.ParsedPath, descriptor: FileDescriptorProto): string {
return `
import { Message } from 'google-protobuf';
import { MethodDescriptor, ServiceDescriptor } from 'bxpb-runtime/dist/descriptors';
import { MethodDescriptor, ServiceDescriptor } from '@bxpb/runtime/dist/descriptors';
import protos from './${filePath.name}_pb';
${descriptor.getServiceList().map((service) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const FooService = Object.freeze({
expect(dtsFile.getName()).toBe('foo_bxdescriptors.d.ts');
expect(dtsFile.getContent()).toBe(`
import { Message } from 'google-protobuf';
import { MethodDescriptor, ServiceDescriptor } from 'bxpb-runtime/dist/descriptors';
import { MethodDescriptor, ServiceDescriptor } from '@bxpb/runtime/dist/descriptors';
import protos from './foo_pb';
/** Interface of \`Foo\`'s service descriptor. */
Expand Down Expand Up @@ -129,7 +129,7 @@ export const BarService = Object.freeze({

expect(dtsFile.getContent()).toBe(`
import { Message } from 'google-protobuf';
import { MethodDescriptor, ServiceDescriptor } from 'bxpb-runtime/dist/descriptors';
import { MethodDescriptor, ServiceDescriptor } from '@bxpb/runtime/dist/descriptors';
import protos from './foo_pb';
/** Interface of \`Foo\`'s service descriptor. */
Expand Down Expand Up @@ -213,7 +213,7 @@ export const FooService = Object.freeze({

expect(dtsFile.getContent()).toBe(`
import { Message } from 'google-protobuf';
import { MethodDescriptor, ServiceDescriptor } from 'bxpb-runtime/dist/descriptors';
import { MethodDescriptor, ServiceDescriptor } from '@bxpb/runtime/dist/descriptors';
import protos from './foo_pb';
/** Interface of \`Foo\`'s service descriptor. */
Expand Down Expand Up @@ -293,7 +293,7 @@ export const FooService = Object.freeze({

expect(dtsFile.getContent()).toBe(`
import { Message } from 'google-protobuf';
import { MethodDescriptor, ServiceDescriptor } from 'bxpb-runtime/dist/descriptors';
import { MethodDescriptor, ServiceDescriptor } from '@bxpb/runtime/dist/descriptors';
import protos from './foo_pb';
/** Interface of \`Foo\`'s service descriptor. */
Expand Down
4 changes: 2 additions & 2 deletions packages/bxpb-protoc-plugin/src/generators/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function generateServiceJs(filePath: path.ParsedPath, descriptor: FileDescriptor
});

return `
import { serve } from 'bxpb-runtime/dist/service.js';
import { serve } from '@bxpb/runtime/dist/service.js';
import * as descriptors from './${filePath.name}_bxdescriptors.js';
${serviceNames.map((serviceName) => `
Expand All @@ -69,7 +69,7 @@ function generateServiceDts(filePath: path.ParsedPath, descriptor: FileDescripto
});

return `
import { Transport, ServiceImplementation } from 'bxpb-runtime/dist/service';
import { Transport, ServiceImplementation } from '@bxpb/runtime/dist/service';
import * as descriptors from './${filePath.name}_bxdescriptors';
${serviceNames.map((serviceName) => `
Expand Down
8 changes: 4 additions & 4 deletions packages/bxpb-protoc-plugin/src/generators/services_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('services', () => {

expect(jsFile.getName()).toBe('foo_bxservices.js');
expect(jsFile.getContent()).toBe(`
import { serve } from 'bxpb-runtime/dist/service.js';
import { serve } from '@bxpb/runtime/dist/service.js';
import * as descriptors from './foo_bxdescriptors.js';
/**
Expand All @@ -31,7 +31,7 @@ export function serveFoo(transport, serviceImpl) {

expect(dtsFile.getName()).toBe('foo_bxservices.d.ts');
expect(dtsFile.getContent()).toBe(`
import { Transport, ServiceImplementation } from 'bxpb-runtime/dist/service';
import { Transport, ServiceImplementation } from '@bxpb/runtime/dist/service';
import * as descriptors from './foo_bxdescriptors';
/**
Expand All @@ -54,7 +54,7 @@ export function serveFoo(transport: Transport, serviceImpl: ServiceImplementatio
'foo.proto', fileDescriptor));

expect(jsFile.getContent()).toBe(`
import { serve } from 'bxpb-runtime/dist/service.js';
import { serve } from '@bxpb/runtime/dist/service.js';
import * as descriptors from './foo_bxdescriptors.js';
/**
Expand All @@ -75,7 +75,7 @@ export function serveBar(transport, serviceImpl) {
`.trim());

expect(dtsFile.getContent()).toBe(`
import { Transport, ServiceImplementation } from 'bxpb-runtime/dist/service';
import { Transport, ServiceImplementation } from '@bxpb/runtime/dist/service';
import * as descriptors from './foo_bxdescriptors';
/**
Expand Down
18 changes: 9 additions & 9 deletions packages/bxpb-runtime/README.md → packages/runtime/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# `bxpb-runtime`
# `@bxpb/runtime`

Implements the runtime for clients and services using `bxpb`.

Expand All @@ -7,7 +7,7 @@ Implements the runtime for clients and services using `bxpb`.
Services should use `serve()` to listen to a message passing API and run a service on it.

```typescript
import { serve } from 'bxpb-runtime/service';
import { serve } from '@bxpb/runtime/service';
import { GreeterService } from 'protos/greeter_bx';
import { HelloRequest, HelloResponse } from 'protos/greeter_pb';

Expand All @@ -24,7 +24,7 @@ serve(chrome.runtime.onMessage, MyProtoService, {
Clients should extend `ProtoClient` for a given service they want to call.

```typescript
import { ProtoClient } from 'bxpb-runtime/client';
import { ProtoClient } from '@bxpb/runtime/client';
import { GreeterService } from 'protos/greeter_bx';
import { HelloRequest, HelloResponse } from 'protos/greeter_pb';

Expand Down Expand Up @@ -54,7 +54,7 @@ Client classes are typically generated by `bxpb-protoc-plugin` and not hand-writ
To build this package, run from the repository root:

```shell
npm run -- lerna run build --stream --scope bxpb-runtime --include-dependencies
npm run -- lerna run build --stream --scope @bxpb/runtime --include-dependencies
```

Output files are stored in the `dist/` directory.
Expand All @@ -64,21 +64,21 @@ Output files are stored in the `dist/` directory.
Build and run unit tests with this command (run from the repository root):

```shell
npm run -- lerna run build --stream --scope bxpb-runtime --include-dependencies &&
npm run -- lerna run test --stream --scope bxpb-runtime
npm run -- lerna run build --stream --scope @bxpb/runtime --include-dependencies &&
npm run -- lerna run test --stream --scope @bxpb/runtime
```

You can debug tests by running:

```shell
npm run -- lerna run build --stream --scope bxpb-runtime --include-dependencies &&
npm run -- lerna run test:debug --stream --scope bxpb-runtime
npm run -- lerna run build --stream --scope @bxpb/runtime --include-dependencies &&
npm run -- lerna run test:debug --stream --scope @bxpb/runtime
```

This will start Karma on port 9876, open a browser to http://localhost:9876/debug.html to start
debugging. Sourcemaps should work out of the box and are available under the `/base` directory in
DevTools.

Karma will live reload and incorpate any changes from the package without requiring a restart.
However this only works for changes within `bxpb-runtime`. If any dependent packages are modified,
However this only works for changes within `@bxpb/runtime`. If any dependent packages are modified,
this will likely require a full rebuild.
File renamed without changes.

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

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "bxpb-runtime",
"name": "@bxpb/runtime",
"version": "0.0.0",
"description": "Runtime library for browser extension protocol buffers.",
"keywords": [
Expand All @@ -13,7 +13,7 @@
"services"
],
"author": "Doug Parker <[email protected]>",
"homepage": "https://github.com/dgp1130/bxpb/packages/bxpb-runtime/",
"homepage": "https://github.com/dgp1130/bxpb/packages/runtime/",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5f60205

Please sign in to comment.