Skip to content

Commit

Permalink
pw_web_ui: Replace '@Pigweed' and 'pigweed' imports with 'pigweedjs'
Browse files Browse the repository at this point in the history
Changing package name from pigweed to pigweedjs caused a few protos
to not be included in final bundle. This fixes the bug and adds
a test to check if the bundle imports some outside module, which
happens when rollup fails to find the right module when creating
the bundle.

Change-Id: I0987ca74e91b1b355779bf382ea8b567e62eda18
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/103400
Commit-Queue: Asad Memon <asadmemon@google.com>
Reviewed-by: Anthony DiGirolamo <tonymd@google.com>
  • Loading branch information
asadm authored and CQ Bot Account committed Jul 25, 2022
1 parent e9bb8a0 commit 41af1d8
Show file tree
Hide file tree
Showing 30 changed files with 64 additions and 57 deletions.
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {pathsToModuleNameMapper} from "ts-jest";
import type {InitialOptionsTsJest} from 'ts-jest/dist/types';

const paths = {
"@pigweed/pw_*": [
"pigweedjs/pw_*": [
"./pw_*/ts"
],
"pigweed/protos/*": [
"pigweedjs/protos/*": [
"./dist/protos/*"
]
}
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pigweedjs",
"version": "0.0.2",
"version": "0.0.3",
"description": "An open source collection of embedded-targeted libraries",
"author": "The Pigweed Authors",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion pw_protobuf_compiler/ts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ protoc(protos, outDir).then(() => {
makeProtoCollection(
path.join(outDir, 'descriptor.bin'),
outDir,
'pigweed/protos'
'pigweedjs/protos'
);
});
2 changes: 1 addition & 1 deletion pw_protobuf_compiler/ts/ts_proto_collection.template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {
ProtoCollection as Base,
ModuleMap,
} from '@pigweed/pw_protobuf_compiler';
} from 'pigweedjs/pw_protobuf_compiler';
import {FileDescriptorSet} from 'google-protobuf/google/protobuf/descriptor_pb';
import * as base64 from 'base64-js';

Expand Down
4 changes: 2 additions & 2 deletions pw_protobuf_compiler/ts/ts_proto_collection_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@

/* eslint-env browser */

import {Message} from 'pigweed/protos/pw_protobuf_compiler/pw_protobuf_compiler_protos/nested/more_nesting/test_pb';
import {Message} from 'pigweedjs/protos/pw_protobuf_compiler/pw_protobuf_compiler_protos/nested/more_nesting/test_pb';

import {ProtoCollection} from 'pigweed/protos/collection';
import {ProtoCollection} from 'pigweedjs/protos/collection';

describe('ProtoCollection', () => {
it('getMessageType returns message', () => {
Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/ts/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.

import {Status} from '@pigweed/pw_status';
import {Status} from 'pigweedjs/pw_status';
import {Message} from 'google-protobuf';

import WaitQueue from "./queue";
Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/ts/call_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/* eslint-env browser */

import {SomeMessage} from 'pigweed/protos/pw_rpc/ts/test2_pb';
import {SomeMessage} from 'pigweedjs/protos/pw_rpc/ts/test2_pb';

import {Call} from './call';
import {Channel, Method, Service} from './descriptors';
Expand Down
6 changes: 3 additions & 3 deletions pw_rpc/ts/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

/** Provides a pw_rpc client for TypeScript. */

import {ProtoCollection} from '@pigweed/pw_protobuf_compiler';
import {Status} from '@pigweed/pw_status';
import {ProtoCollection} from 'pigweedjs/pw_protobuf_compiler';
import {Status} from 'pigweedjs/pw_status';
import {Message} from 'google-protobuf';
import {
PacketType,
RpcPacket,
} from 'pigweed/protos/pw_rpc/internal/packet_pb';
} from 'pigweedjs/protos/pw_rpc/internal/packet_pb';

import {Channel, Service} from './descriptors';
import {MethodStub, methodStubFactory} from './method';
Expand Down
10 changes: 5 additions & 5 deletions pw_rpc/ts/client_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@

/* eslint-env browser */

import {Status} from '@pigweed/pw_status';
import {MessageCreator} from '@pigweed/pw_protobuf_compiler';
import {Status} from 'pigweedjs/pw_status';
import {MessageCreator} from 'pigweedjs/pw_protobuf_compiler';
import {Message} from 'google-protobuf';
import {
PacketType,
RpcPacket,
} from 'pigweed/protos/pw_rpc/internal/packet_pb';
import {ProtoCollection} from 'pigweed/protos/collection';
} from 'pigweedjs/protos/pw_rpc/internal/packet_pb';
import {ProtoCollection} from 'pigweedjs/protos/collection';
import {
Request,
Response,
} from 'pigweed/protos/pw_rpc/ts/test_pb';
} from 'pigweedjs/protos/pw_rpc/ts/test_pb';

import {Client} from './client';
import {Channel, Method} from './descriptors';
Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/ts/descriptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.

import {ProtoCollection} from '@pigweed/pw_protobuf_compiler';
import {ProtoCollection} from 'pigweedjs/pw_protobuf_compiler';
import {
MethodDescriptorProto,
ServiceDescriptorProto,
Expand Down
4 changes: 2 additions & 2 deletions pw_rpc/ts/descriptors_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

/* eslint-env browser */

import {ProtoCollection} from 'pigweed/protos/collection';
import {ProtoCollection} from 'pigweedjs/protos/collection';
import {
Request,
Response,
} from 'pigweed/protos/pw_rpc/ts/test_pb';
} from 'pigweedjs/protos/pw_rpc/ts/test_pb';

import * as descriptors from './descriptors';

Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/ts/method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// License for the specific language governing permissions and limitations under
// the License.

import {Status} from '@pigweed/pw_status';
import {Status} from 'pigweedjs/pw_status';
import {Message} from 'google-protobuf';

import {
Expand Down
4 changes: 2 additions & 2 deletions pw_rpc/ts/packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

import {Message} from 'google-protobuf';
import {MethodDescriptorProto} from 'google-protobuf/google/protobuf/descriptor_pb';
import * as packetPb from 'pigweed/protos/pw_rpc/internal/packet_pb';
import {Status} from '@pigweed/pw_status';
import * as packetPb from 'pigweedjs/protos/pw_rpc/internal/packet_pb';
import {Status} from 'pigweedjs/pw_status';

// Channel, Service, Method
type idSet = [number, number, number];
Expand Down
4 changes: 2 additions & 2 deletions pw_rpc/ts/packets_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import {
PacketType,
RpcPacket,
} from 'pigweed/protos/pw_rpc/internal/packet_pb';
import {Status} from '@pigweed/pw_status';
} from 'pigweedjs/protos/pw_rpc/internal/packet_pb';
import {Status} from 'pigweedjs/pw_status';

import * as packets from './packets';

Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/ts/rpc_classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// the License.

import {Message} from 'google-protobuf';
import {Status} from '@pigweed/pw_status';
import {Status} from 'pigweedjs/pw_status';

import {Call} from './call';
import {Channel, Method, Service} from './descriptors';
Expand Down
2 changes: 1 addition & 1 deletion pw_tokenizer/ts/detokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/** Decodes and detokenizes strings from binary or Base64 input. */
import {Buffer} from 'buffer';
import {Frame} from '@pigweed/pw_hdlc';
import {Frame} from 'pigweedjs/pw_hdlc';
import {TokenDatabase} from './token_database';
import {PrintfDecoder} from './printf_decoder';

Expand Down
2 changes: 1 addition & 1 deletion pw_tokenizer/ts/detokenizer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/* eslint-env browser */

import {Frame, Encoder, Decoder} from '@pigweed/pw_hdlc';
import {Frame, Encoder, Decoder} from 'pigweedjs/pw_hdlc';
import {Detokenizer} from './detokenizer';

const CSV = `
Expand Down
6 changes: 3 additions & 3 deletions pw_transfer/ts/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import {
BidirectionalStreamingCall,
BidirectionalStreamingMethodStub,
ServiceClient,
} from '@pigweed/pw_rpc';
import {Status} from '@pigweed/pw_status';
import {Chunk} from 'pigweed/protos/pw_transfer/transfer_pb';
} from 'pigweedjs/pw_rpc';
import {Status} from 'pigweedjs/pw_status';
import {Chunk} from 'pigweedjs/protos/pw_transfer/transfer_pb';

import {
ReadTransfer,
Expand Down
6 changes: 3 additions & 3 deletions pw_transfer/ts/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import {
BidirectionalStreamingCall,
BidirectionalStreamingMethodStub,
ServiceClient,
} from '@pigweed/pw_rpc';
import {Status} from '@pigweed/pw_status';
import {Chunk} from 'pigweed/protos/pw_transfer/transfer_pb';
} from 'pigweedjs/pw_rpc';
import {Status} from 'pigweedjs/pw_status';
import {Chunk} from 'pigweedjs/protos/pw_transfer/transfer_pb';

export class ProgressStats {
constructor(
Expand Down
10 changes: 5 additions & 5 deletions pw_transfer/ts/transfer_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import {
decode,
MethodStub,
ServiceClient,
} from '@pigweed/pw_rpc';
import {Status} from '@pigweed/pw_status';
} from 'pigweedjs/pw_rpc';
import {Status} from 'pigweedjs/pw_status';
import {
PacketType,
RpcPacket,
} from 'pigweed/protos/pw_rpc/internal/packet_pb';
import {ProtoCollection} from 'pigweed/protos/collection';
import {Chunk} from 'pigweed/protos/pw_transfer/transfer_pb';
} from 'pigweedjs/protos/pw_rpc/internal/packet_pb';
import {ProtoCollection} from 'pigweedjs/protos/collection';
import {Chunk} from 'pigweedjs/protos/pw_transfer/transfer_pb';

import {Manager} from './client';
import {ProgressStats} from './transfer';
Expand Down
6 changes: 3 additions & 3 deletions pw_web_ui/src/frontend/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ import {
} from '@material-ui/core';
import {ToggleButtonGroup, ToggleButton} from '@material-ui/lab';
import {WebSerialTransport} from '../transport/web_serial_transport';
import {Decoder, Frame, Encoder} from '@pigweed/pw_hdlc';
import {Decoder, Frame, Encoder} from 'pigweedjs/pw_hdlc';
import {SerialLog} from './serial_log';
import {Log} from './log';
import * as React from 'react';
import {useState, useRef} from 'react';
import {Channel, Client, UnaryMethodStub} from '@pigweed/pw_rpc';
import {Status} from '@pigweed/pw_status';
import {Channel, Client, UnaryMethodStub} from 'pigweedjs/pw_rpc';
import {Status} from 'pigweedjs/pw_status';
import {ProtoCollection} from 'web_proto_collection/generated/ts_proto_collection';

const RPC_ADDRESS = 82;
Expand Down
4 changes: 2 additions & 2 deletions pw_web_ui/src/frontend/log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import {makeStyles, Paper, Box} from '@material-ui/core';
import * as React from 'react';
import {default as AnsiUp} from 'ansi_up';
import * as Parser from 'html-react-parser';
import {Frame} from '@pigweed/pw_hdlc';
import {Detokenizer} from '@pigweed/pw_tokenizer';
import {Frame} from 'pigweedjs/pw_hdlc';
import {Detokenizer} from 'pigweedjs/pw_tokenizer';

type Props = {
lines: string[];
Expand Down
4 changes: 2 additions & 2 deletions pw_web_ui/src/frontend/rpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
/* eslint-env browser */
import {makeStyles, Box} from '@material-ui/core';
import * as React from 'react';
import {Status} from '@pigweed/pw_status';
import {Status} from 'pigweedjs/pw_status';
import {Message} from 'google-protobuf';
import {Call} from '@pigweed/pw_rpc';
import {Call} from 'pigweedjs/pw_rpc';

type Props = {
calls: Call[];
Expand Down
2 changes: 1 addition & 1 deletion pw_web_ui/src/frontend/serial_log.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* eslint-env browser */
import {makeStyles, Paper, Box} from '@material-ui/core';
import * as React from 'react';
import {FrameStatus, Frame} from '@pigweed/pw_hdlc';
import {FrameStatus, Frame} from 'pigweedjs/pw_hdlc';

type Props = {
frames: Frame[];
Expand Down
7 changes: 7 additions & 0 deletions ts/index_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from "../dist/index.umd";

import {ProtoCollection} from "../dist/protos/collection.umd";
import * as fs from "fs";

describe('Pigweed Bundle', () => {

Expand Down Expand Up @@ -66,4 +67,10 @@ describe('Pigweed Bundle', () => {
expect(WebSerial.WebSerialTransport).toBeDefined();
});

it('is not referring to any outside Pigweed modules', () => {
const requireString = "require('pigweedjs";
const file = fs.readFileSync(require.resolve("../dist/index.umd"));
expect(file.indexOf(requireString)).toBe(-1)
});

});
2 changes: 1 addition & 1 deletion ts/transport/serial_mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

/* eslint-env browser */
import {Subject} from 'rxjs';
import type {SerialConnectionEvent, SerialPort, Serial, SerialPortRequestOptions, SerialOptions} from "pigweed/types/serial"
import type {SerialConnectionEvent, SerialPort, Serial, SerialPortRequestOptions, SerialOptions} from "pigweedjs/types/serial"
/**
* AsyncQueue is a queue that allows values to be dequeued
* before they are enqueued, returning a promise that resolves
Expand Down
2 changes: 1 addition & 1 deletion ts/transport/web_serial_transport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/* eslint-env browser */
import {BehaviorSubject, Observable, Subject, Subscription} from 'rxjs';
import DeviceTransport from './device_transport';
import type {SerialPort, Serial, SerialOptions, Navigator, SerialPortFilter} from "pigweed/types/serial"
import type {SerialPort, Serial, SerialOptions, Navigator, SerialPortFilter} from "pigweedjs/types/serial"

const DEFAULT_SERIAL_OPTIONS: SerialOptions & {baudRate: number} = {
// Some versions of chrome use `baudrate` (linux)
Expand Down
2 changes: 1 addition & 1 deletion ts/transport/web_serial_transport_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {last, take} from 'rxjs/operators';

import {SerialMock} from './serial_mock';
import {WebSerialTransport, DeviceLockedError} from './web_serial_transport';
import type {Serial} from "pigweed/types/serial"
import type {Serial} from "pigweedjs/types/serial"

describe('WebSerialTransport', () => {
let serialMock: SerialMock;
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"declaration": true,
"allowJs": true,
"paths": {
"@pigweed/pw_*": [
"pigweedjs/pw_*": [
"./pw_*/ts"
],
"pigweed/protos/*": [
"pigweedjs/protos/*": [
"./dist/protos/*"
],
"pigweed/types/*": [
"pigweedjs/types/*": [
"./ts/types/*"
]
}
Expand Down

0 comments on commit 41af1d8

Please sign in to comment.