Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
chore: change onMessage to be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
SSen committed Aug 13, 2020
1 parent cf787f4 commit 13c5cd5
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .packages.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'@ssen/*':
version: 2.1.0
version: 2.1.1
tag: latest
module: commonjs
rocket-punch:
version: 2.1.0
version: 2.1.1
tag: latest
module: commonjs
packageJson:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.1.1] - 2020-08-13

### Fixed
- Change `onMessage` to be optional

## [2.1.0] - 2020-08-13

### Added
Expand Down Expand Up @@ -76,6 +81,7 @@ Release
### Added
- Rewrite paths by TypeScript compiler transformer API on build (e.g. `import A from '../a'` to `import A from 'a'`)

[2.1.1]: https://github.com/rocket-hangar/rocket-punch/compare/v2.1.0...v2.1.1
[2.1.0]: https://github.com/rocket-hangar/rocket-punch/compare/v2.0.0...v2.1.0
[2.0.0]: https://github.com/rocket-hangar/rocket-punch/compare/v1.3.1...v2.0.0
[1.3.1]: https://github.com/rocket-hangar/rocket-punch/compare/v1.1.0...v1.3.1
Expand Down
3 changes: 2 additions & 1 deletion src/rocket-punch/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import process from 'process';
import { PackageJson } from 'type-fest';
import ts from 'typescript';
import { readPackages } from './entry/readPackages';
import { buildMessageHandler } from './message-handlers/build';
import { computePackageJson } from './package-json/computePackageJson';
import { getRootDependencies } from './package-json/getRootDependencies';
import { getSharedPackageJson } from './package-json/getSharedPackageJson';
Expand All @@ -30,7 +31,7 @@ export async function build({
transformCompilerHost,
transformCompilerOptions,
emitCustomTransformers,
onMessage,
onMessage = buildMessageHandler,
}: BuildParams) {
// ---------------------------------------------
// set env
Expand Down
3 changes: 2 additions & 1 deletion src/rocket-punch/doctor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import depcheck from 'depcheck';
import path from 'path';
import process from 'process';
import { readPackages } from './entry/readPackages';
import { doctorMessageHandler } from './message-handlers/doctor';
import { DoctorParams } from './params';
import { PackageInfo } from './types';

Expand All @@ -11,7 +12,7 @@ export async function doctor({
entry,
sourceRoot = 'src',
tsconfig = 'tsconfig.json',
onMessage,
onMessage = doctorMessageHandler,
}: DoctorParams) {
const internalPackages: Map<string, PackageInfo> = await readPackages({ cwd, sourceRoot, entry });

Expand Down
8 changes: 4 additions & 4 deletions src/rocket-punch/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export interface BuildParams extends CommonParams {
*/
emitCustomTransformers?: (packageName: string) => () => ts.CustomTransformers | undefined;

onMessage: (message: BuildMessages) => Promise<void>;
onMessage?: (message: BuildMessages) => Promise<void>;
}

export interface PublishParams extends Pick<CommonParams, 'cwd' | 'entry' | 'dist' | 'sourceRoot'> {
Expand Down Expand Up @@ -187,13 +187,13 @@ export interface PublishParams extends Pick<CommonParams, 'cwd' | 'entry' | 'dis
*/
registry?: string;

onMessage: (message: PublishMessages) => Promise<void>;
onMessage?: (message: PublishMessages) => Promise<void>;
}

export interface ViewParams extends Pick<CommonParams, 'cwd' | 'entry' | 'sourceRoot'> {
onMessage: (message: ViewMessages) => Promise<void>;
onMessage?: (message: ViewMessages) => Promise<void>;
}

export interface DoctorParams extends Pick<CommonParams, 'cwd' | 'entry' | 'tsconfig' | 'sourceRoot'> {
onMessage: (message: DoctorMessages) => Promise<void>;
onMessage?: (message: DoctorMessages) => Promise<void>;
}
3 changes: 2 additions & 1 deletion src/rocket-punch/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { AvailablePublishOption, getPublishOptions, selectPublishOptions } from
import path from 'path';
import process from 'process';
import { readPackages } from './entry/readPackages';
import { publishMessageHandler } from './message-handlers/publish';
import { PublishParams } from './params';
import { PackageInfo, PublishOption } from './types';

Expand All @@ -15,7 +16,7 @@ export async function publish({
access,
entry,
registry,
onMessage,
onMessage = publishMessageHandler,
}: PublishParams) {
const packages: Map<string, PackageInfo> = await readPackages({
cwd,
Expand Down
8 changes: 7 additions & 1 deletion src/rocket-punch/view.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import getPackageJson, { FullMetadata } from 'package-json';
import process from 'process';
import { readPackages } from './entry/readPackages';
import { viewMessageHandler } from './message-handlers/view';
import { ViewParams } from './params';
import { PackageInfo } from './types';

export async function view({ cwd = process.cwd(), sourceRoot = 'src', entry, onMessage }: ViewParams) {
export async function view({
cwd = process.cwd(),
sourceRoot = 'src',
entry,
onMessage = viewMessageHandler,
}: ViewParams) {
const internalPackages: Map<string, PackageInfo> = await readPackages({ cwd, sourceRoot, entry });

const originMetadatas: (FullMetadata | undefined)[] = await Promise.all(
Expand Down

0 comments on commit 13c5cd5

Please sign in to comment.