Skip to content

Commit b91e539

Browse files
authored
add release file (#8)
1 parent 7aa645d commit b91e539

File tree

9 files changed

+64
-33
lines changed

9 files changed

+64
-33
lines changed

.eslintignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
dist/
1+
**/dist/**
2+
**/node_modules/**

.eslintrc.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@ module.exports = {
44
ecmaVersion: 2020,
55
sourceType: 'module',
66
},
7-
extends: [
8-
'plugin:@typescript-eslint/recommended',
9-
'plugin:jsdoc/recommended',
10-
// Make sure this is always the last configuration in the extends array.
11-
'plugin:prettier/recommended',
12-
],
7+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
8+
plugins: ['@typescript-eslint/eslint-plugin'],
139
rules: {
1410
'@typescript-eslint/no-unused-vars': 'error',
1511
'@typescript-eslint/explicit-module-boundary-types': 'error',
16-
'@typescript-eslint/no-non-null-assertion': 'error',
12+
'@typescript-eslint/no-non-null-assertion': 'off',
1713
'@typescript-eslint/no-explicit-any': 'off',
18-
'@typescript-eslint/ban-ts-comment': 'off',
14+
'@typescript-eslint/ban-ts-comment': 'error',
1915
},
2016
overrides: [
2117
{
2218
files: ['**/__tests__/**/*'],
23-
rules: {
24-
'jsdoc/require-jsdoc': 'off',
25-
},
2619
},
2720
],
2821
};

.github/workflows/release.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: 'publish to NPM'
2+
on:
3+
push:
4+
tags: ['*']
5+
6+
jobs:
7+
publish:
8+
runs-on: 'ubuntu-latest'
9+
steps:
10+
- uses: actions/checkout@v1
11+
- uses: actions/setup-node@v1
12+
with:
13+
node-version: 14
14+
- run: yarn install
15+
- run: yarn build
16+
17+
- id: 'publish'
18+
uses: JS-DevTools/npm-publish@v1
19+
with:
20+
token: ${{ secrets.NPM_AUTH_TOKEN }}
21+
22+
- if: steps.publish.outputs.type != 'none'
23+
run: |
24+
echo "Version changed: ${{ steps.publish.outputs.old-version }} => ${{ steps.publish.outputs.version }}"

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ and this project adheres to
1010

1111
### TBA
1212

13+
## [v1.0.0] - 2022-10-05
14+
15+
### Added
16+
17+
- Public release
18+
1319
## [v0.1.0] - 2022-10-05
1420

1521
### Added

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
{
22
"name": "postmessage-communicator",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "[![Release](https://img.shields.io/github/v/release/wayfair-incubator/oss-template?display_name=tag)](CHANGELOG.md) [![Lint](https://github.com/wayfair-incubator/oss-template/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/wayfair-incubator/oss-template/actions/workflows/lint.yml) [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.0-4baaaa.svg)](CODE_OF_CONDUCT.md) [![Maintainer](https://img.shields.io/badge/Maintainer-Wayfair-7F187F)](https://wayfair.github.io)",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
77
"files": ["/dist"],
88
"scripts": {
9-
"test": "echo \"Error: no test specified\" && exit 1"
9+
"build": "yarn tsc",
10+
"lint": "eslint src/**/*.ts",
11+
"format": "prettier --write src/**/*.ts",
12+
"format:check": "prettier --check src/**/*.ts"
1013
},
1114
"repository": {
1215
"type": "git",

src/classes/ClientCommunicator.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ interface InitPayload {
1111
}
1212

1313
export class ClientCommunicator extends Communicator {
14-
init(payload: InitPayload) {
14+
init(payload: InitPayload): void {
1515
this.post({type: ClientEvent.LoginWithToken, payload});
1616
}
17-
refreshWithToken(token: string) {
17+
refreshWithToken(token: string): void {
1818
this.post({type: ClientEvent.RefreshWithToken, payload: token});
1919
}
2020
}

src/classes/Communicator.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {ClientEvent} from './ClientCommunicator';
33

44
type EventType = VendorEvent | ClientEvent | string;
55

6+
type CallBack = (e: MessageEvent) => void;
7+
68
interface CommunicatorEvent {
79
type: EventType;
810
payload?: any;
@@ -16,11 +18,11 @@ export class Communicator {
1618
this.origin = origin;
1719
}
1820

19-
updateConfig(target: Window) {
21+
updateConfig(target: Window): void {
2022
this.target = target;
2123
}
2224

23-
subscribe(eventType: EventType, cb: (e: MessageEvent) => void) {
25+
subscribe(eventType: EventType, cb: CallBack): CallBack {
2426
const msg = (e: MessageEvent) => {
2527
if (e.origin !== this.origin || e.data.type !== eventType) {
2628
return;
@@ -31,11 +33,11 @@ export class Communicator {
3133
return msg;
3234
}
3335

34-
unsubscribe(cb: (e: MessageEvent) => void) {
36+
unsubscribe(cb: CallBack): void {
3537
window.removeEventListener('message', cb);
3638
}
3739

38-
post({type, payload = ''}: CommunicatorEvent) {
40+
post({type, payload = ''}: CommunicatorEvent): void {
3941
this.target.postMessage({type, payload}, this.origin);
4042
}
4143
}

src/classes/VendorCommunicator.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export enum VendorEvent {
1212
UnauthorizedToken = 'UnauthorizedToken',
1313
}
1414

15-
interface MetaData {
15+
interface Metadata {
1616
title: string;
1717
brand: string;
1818
style: string;
@@ -27,8 +27,8 @@ interface EventPayload {
2727
customerId: string;
2828
projectId: string;
2929
versionId: number;
30-
metadata: MetaData;
31-
bom?: {};
30+
metadata: Metadata;
31+
bom?: any;
3232
}
3333

3434
export class VendorCommunicator extends Communicator {
@@ -38,39 +38,39 @@ export class VendorCommunicator extends Communicator {
3838
this.origin = origin;
3939
}
4040

41-
addToCart(payload: EventPayload) {
41+
addToCart(payload: EventPayload): void {
4242
this.post({type: VendorEvent.AddToCart, payload});
4343
}
4444

45-
appInitialized() {
45+
appInitialized(): void {
4646
this.post({type: VendorEvent.AddToCart});
4747
}
4848

49-
contactDesigner(payload: EventPayload) {
49+
contactDesigner(payload: EventPayload): void {
5050
this.post({type: VendorEvent.ContactDesigner, payload});
5151
}
5252

53-
dirtyStateChanged() {
53+
dirtyStateChanged(): void {
5454
this.post({type: VendorEvent.DirtyStateChanged});
5555
}
5656

57-
iframeLoaded() {
57+
iframeLoaded(): void {
5858
this.post({type: VendorEvent.IframeLoaded});
5959
}
6060

61-
projectSaved() {
61+
projectSaved(): void {
6262
this.post({type: VendorEvent.ProjectSaved});
6363
}
6464

65-
projectDeleted() {
65+
projectDeleted(): void {
6666
this.post({type: VendorEvent.ProjectDeleted});
6767
}
6868

69-
tokenRefreshRequested() {
69+
tokenRefreshRequested(): void {
7070
this.post({type: VendorEvent.TokenRefreshRequested});
7171
}
7272

73-
unauthorizedToken(error: string) {
73+
unauthorizedToken(error: string): void {
7474
this.post({type: VendorEvent.UnauthorizedToken, payload: error});
7575
}
7676
}

tsconfig.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
"target": "ES2019",
44
"declaration": true,
55
"module": "commonjs",
6+
"resolveJsonModule": true,
67
"outDir": "./dist",
78
"rootDir": "./src",
89
"strict": true,
910
"noImplicitAny": true,
10-
"esModuleInterop": true
11+
"esModuleInterop": true,
12+
"strictNullChecks": true,
1113
},
1214
"exclude": ["node_modules", "**/*.test.ts"],
1315
"include": ["src/**/*"]

0 commit comments

Comments
 (0)