From 07741012c23345f005a1c512dbae4fbb914dee4c Mon Sep 17 00:00:00 2001 From: Yucel Okcu Date: Fri, 22 Jan 2021 19:53:34 +0300 Subject: [PATCH] Add update notifier --- package.json | 8 +++++--- src/index.ts | 11 +++++++++++ tsconfig.test.json => test/tsconfig.test.json | 1 + test/typescript.test.ts | 10 +++++----- tsconfig.json | 1 + 5 files changed, 23 insertions(+), 8 deletions(-) rename tsconfig.test.json => test/tsconfig.test.json (88%) diff --git a/package.json b/package.json index 86fcaac..ec76171 100644 --- a/package.json +++ b/package.json @@ -2,10 +2,10 @@ "name": "@zeplin/cli-connect-react-plugin", "version": "0.2.8", "description": "Zeplin CLI Connected Components - React Plugin", - "main": "./dist/index", + "main": "./dist/src/index", "scripts": { "test": "jest", - "copy-templates": "copyfiles -u 1 src/template/** dist/", + "copy-templates": "copyfiles -u 1 src/template/** dist/src", "build:dev": "npm run build -- --sourceMap", "build": "rimraf dist/ && npm run copy-templates && tsc", "lint": "eslint --ext .js,.ts .", @@ -31,6 +31,7 @@ "@types/node": "^13.13.5", "@types/pug": "^2.0.4", "@types/react": "^17.0.0", + "@types/update-notifier": "^5.0.0", "@typescript-eslint/eslint-plugin": "^2.31.0", "@typescript-eslint/parser": "^2.31.0", "@zeplin/cli": "^1.0.4", @@ -49,6 +50,7 @@ "fs-extra": "^9.0.1", "pug": "^2.0.4", "react-docgen": "^5.3.1", - "react-docgen-typescript": "^1.20.5" + "react-docgen-typescript": "^1.20.5", + "update-notifier": "^5.0.1" } } diff --git a/src/index.ts b/src/index.ts index b3b0cd6..837fc16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,12 +6,23 @@ import pug from "pug"; import { readFile, pathExists } from "fs-extra"; import { ComponentDoc, parse, PreparedComponentDoc, Props } from "react-docgen"; import * as docgen from "react-docgen-typescript"; +import updateNotifier from "update-notifier"; +import { name as packageName, version as packageVersion } from "../package.json"; interface ReactPluginConfig { tsDocgen?: "react-docgen" | "react-docgen-typescript"; tsConfigPath?: string; } +updateNotifier({ + pkg: { + name: packageName, + version: packageVersion + }, + updateCheckInterval: 0, + shouldNotifyInNpmScript: true +}).notify(); + export default class implements ConnectPlugin { supportedFileExtensions = [".js", ".jsx", ".ts", ".tsx"]; tsExtensions = [".ts", ".tsx"]; diff --git a/tsconfig.test.json b/test/tsconfig.test.json similarity index 88% rename from tsconfig.test.json rename to test/tsconfig.test.json index 28f70d6..2c925a9 100644 --- a/tsconfig.test.json +++ b/test/tsconfig.test.json @@ -5,6 +5,7 @@ "lib": ["es5", "es6", "dom"], "noImplicitAny": false, "esModuleInterop": true, + "resolveJsonModule": true, "sourceMap": true, "outDir": "lib", "jsx": "react" diff --git a/test/typescript.test.ts b/test/typescript.test.ts index 5cbbe83..41ad51d 100644 --- a/test/typescript.test.ts +++ b/test/typescript.test.ts @@ -74,7 +74,7 @@ describe("Connected Components React Plugin - TypeScript", () => { processor.config = { tsDocgen: "react-docgen-typescript", - tsConfigPath: "./tsconfig.test.json" + tsConfigPath: "./test/tsconfig.test.json" }; const componentCode = await processor.process( @@ -92,7 +92,7 @@ describe("Connected Components React Plugin - TypeScript", () => { processor.config = { tsDocgen: "react-docgen-typescript", - tsConfigPath: "./tsconfig.test.json" + tsConfigPath: "./test/tsconfig.test.json" }; const componentCode = await processor.process( @@ -110,7 +110,7 @@ describe("Connected Components React Plugin - TypeScript", () => { processor.config = { tsDocgen: "react-docgen-typescript", - tsConfigPath: "./tsconfig.test.json" + tsConfigPath: "./test/tsconfig.test.json" }; const componentCode = await processor.process( @@ -128,7 +128,7 @@ describe("Connected Components React Plugin - TypeScript", () => { processor.config = { tsDocgen: "react-docgen-typescript", - tsConfigPath: "./tsconfig.test.json" + tsConfigPath: "./test/tsconfig.test.json" }; const componentCode = await processor.process( @@ -146,7 +146,7 @@ describe("Connected Components React Plugin - TypeScript", () => { processor.config = { tsDocgen: "react-docgen-typescript", - tsConfigPath: "./tsconfig.test.json" + tsConfigPath: "./test/tsconfig.test.json" }; const componentCode = await processor.process( diff --git a/tsconfig.json b/tsconfig.json index 751fdb8..300b4c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "esModuleInterop": true, + "resolveJsonModule": true, "moduleResolution": "node", "baseUrl": ".", "paths": {