From da6c889f5431d1baa41e3d933e83c377fa04aaf0 Mon Sep 17 00:00:00 2001 From: Tan Le Date: Tue, 23 Apr 2024 10:53:23 +0700 Subject: [PATCH] chore: publish pure ts package to npm --- .eslintrc.js | 6 +++++- .gitignore | 3 ++- package.json | 6 +++++- metacraft.config.js => src/embed/index.ts | 0 src/package.json | 15 +++++++++++---- src/{utils.ts => utils/index.ts} | 0 tsconfig.json | 16 ++++++++++------ yarn.lock | 14 +++++++++++++- 8 files changed, 46 insertions(+), 14 deletions(-) rename metacraft.config.js => src/embed/index.ts (100%) rename src/{utils.ts => utils/index.ts} (100%) diff --git a/.eslintrc.js b/.eslintrc.js index 391c89e..a4613eb 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,4 +1,8 @@ +/** @type {import('eslint').Linter.Config} */ module.exports = { extends: ['@metacraft/eslint-config'], - ignorePatterns: ['**/metacraft/'], + ignorePatterns: ['**/metacraft/', '**/dist/'], + env: { + node: true, + }, }; diff --git a/.gitignore b/.gitignore index 3f7e92c..d95244b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ node_modules # dist -**/metacraft \ No newline at end of file +**/metacraft +**/dist \ No newline at end of file diff --git a/package.json b/package.json index 5a20e6c..8e07043 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,10 @@ ], "scripts": { "test": "jest --passWithNoTests", - "lint": "eslint . --ext .ts" + "lint": "eslint . --ext .ts", + "clean": "rimraf src/dist", + "build": "yarn clean && tsc", + "publish": "cd src && npm publish --access public && cd .." }, "author": "", "license": "MIT", @@ -23,6 +26,7 @@ "eslint": "^8.0.0", "jest": "^29.7.0", "prettier": "^3.2.5", + "rimraf": "^5.0.5", "typescript": "5.3.3" } } diff --git a/metacraft.config.js b/src/embed/index.ts similarity index 100% rename from metacraft.config.js rename to src/embed/index.ts diff --git a/src/package.json b/src/package.json index 496079d..cebec3e 100644 --- a/src/package.json +++ b/src/package.json @@ -1,10 +1,17 @@ { "name": "@metacraft/crab", - "version": "0.0.1", - "description": "", - "main": "index.js", - "author": "", + "version": "0.0.2", + "description": "A universal messaging library for cross-platform applications", + "author": "https://metacraft.studio", "license": "MIT", + "files": [ + "core", + "chrome", + "web", + "mobile", + "embed", + "utils" + ], "devDependencies": { "@types/chrome": "^0.0.266" } diff --git a/src/utils.ts b/src/utils/index.ts similarity index 100% rename from src/utils.ts rename to src/utils/index.ts diff --git a/tsconfig.json b/tsconfig.json index 4fcecc3..0ea97b6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,14 @@ { - "extends": "@metacraft/tsconfig/application.json", + "extends": "@metacraft/tsconfig/base.json", + "include": ["src"], + "exclude": ["src/dist"], "compilerOptions": { - "baseUrl": "src", - "paths": { - "core": ["./core"], - "core/*": ["./core/*"] - } + "target": "es2018", + "moduleResolution": "node", // don't have to import actual filenames, can import extensionless files + "declaration": true, // generate .d.ts files + "sourceMap": true, // generate source map + "outDir": "src/dist", // output compiled js, d.ts, and source map to dist folder + "strict": true, + "esModuleInterop": true } } diff --git a/yarn.lock b/yarn.lock index 2cd6ded..5c550f2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2910,6 +2910,7 @@ __metadata: eslint: "npm:^8.0.0" jest: "npm:^29.7.0" prettier: "npm:^3.2.5" + rimraf: "npm:^5.0.5" typescript: "npm:5.3.3" languageName: unknown linkType: soft @@ -3896,7 +3897,7 @@ __metadata: languageName: node linkType: hard -"glob@npm:^10.2.2, glob@npm:^10.3.10": +"glob@npm:^10.2.2, glob@npm:^10.3.10, glob@npm:^10.3.7": version: 10.3.12 resolution: "glob@npm:10.3.12" dependencies: @@ -6099,6 +6100,17 @@ __metadata: languageName: node linkType: hard +"rimraf@npm:^5.0.5": + version: 5.0.5 + resolution: "rimraf@npm:5.0.5" + dependencies: + glob: "npm:^10.3.7" + bin: + rimraf: dist/esm/bin.mjs + checksum: 10c0/d50dbe724f33835decd88395b25ed35995077c60a50ae78ded06e0185418914e555817aad1b4243edbff2254548c2f6ad6f70cc850040bebb4da9e8cc016f586 + languageName: node + linkType: hard + "run-parallel@npm:^1.1.9": version: 1.2.0 resolution: "run-parallel@npm:1.2.0"