From 6f696e07a5ff70304d1f1f92c64143ecc3d1629f Mon Sep 17 00:00:00 2001 From: ngo275 Date: Mon, 21 Oct 2024 09:41:45 +0700 Subject: [PATCH] Fixed build config --- README.md | 14 +++++++++++-- package.json | 8 ++++--- rollup.config.js | 54 ++++++++++++++++++++++++++++-------------------- tsconfig.json | 11 +++++++--- yarn.lock | 20 ++++++++++++++++-- 5 files changed, 75 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d81374a..126a805 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## What is this? -This library is a TypeScript library for retrieving public data from the App Store. For example, you can get app details, ratings, reviews, similar apps, and privacy information of other apps. +This library is a TypeScript library for retrieving public data from the App Store. For example, you can get app details, ratings, reviews, similar apps, and privacy information. Note that it is different from App Connect API, which focuses on providing API about your app, such as app sales, ratings, reviews, etc. @@ -52,6 +52,17 @@ const appData = await client.app({ id: "6446901002" }); // Or use app ID (bundle ID) const appData = await client.app({ appId: "com.burbn.barcelona" }); + +console.log(appData); + +// { +// id: '6446901002', +// appId: 'com.burbn.barcelona', +// title: 'Threads', +// url: 'https://apps.apple.com/us/app/threads/id6446901002?uo=4', +// description: 'Say more with Threads — Instagram’s text-based conversation app.\n' + +// ... +// } ``` ### Get Apps by Developer @@ -80,7 +91,6 @@ const topFreeApps = await client.list({ You can get privacy details by ID. You must provide the ID. ```typescript -// Use app ID const privacy = await client.privacy({ id: "6446901002" }); ``` diff --git a/package.json b/package.json index b069f05..9b6d2cc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "app-store-client", "description": "A TypeScript client for the Apple App Store API", - "version": "1.0.0", + "version": "1.0.1", "license": "MIT", "author": "Shu", "main": "dist/index.cjs.js", @@ -12,13 +12,14 @@ "build": "rollup -c --bundleConfigAsCjs", "start": "node dist/index.js", "test": "jest", - "prepare": "husky" + "prepare": "husky", + "prepublishOnly": "yarn build" }, "lint-staged": { "**/*": "prettier --write --ignore-unknown" }, "files": [ - "dist/**/*" + "dist" ], "devDependencies": { "@eslint/js": "^9.12.0", @@ -35,6 +36,7 @@ "lint-staged": "^15.2.10", "prettier": "^3.3.3", "rollup": "^4.24.0", + "rollup-plugin-dts": "^6.1.1", "rollup-plugin-terser": "^7.0.2", "ts-jest": "^29.2.5", "tslib": "^2.8.0", diff --git a/rollup.config.js b/rollup.config.js index f8d82e0..a2ad722 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,25 +1,35 @@ import typescript from "@rollup/plugin-typescript"; import { terser } from "rollup-plugin-terser"; +import { dts } from "rollup-plugin-dts"; -export default { - input: "src/index.ts", - output: [ - { - file: "dist/index.cjs.js", - format: "cjs", - sourcemap: true, - }, - { - file: "dist/index.esm.js", - format: "es", - sourcemap: true, - }, - ], - plugins: [ - typescript({ - tsconfig: "./tsconfig.json", - }), - terser(), // Minifies the output bundle - ], - external: ["memoizee", "xml2js", "util", "cheerio", "axios"], -}; +export default [ + { + input: "src/index.ts", + output: [ + { + file: "dist/index.cjs.js", + format: "cjs", + sourcemap: true, + }, + { + file: "dist/index.esm.js", + format: "es", + sourcemap: true, + }, + ], + plugins: [ + typescript({ + tsconfig: "./tsconfig.json", + declaration: true, + declarationDir: "./dist", + }), + terser(), // Minifies the output bundle + ], + external: ["memoizee", "xml2js", "util", "cheerio", "axios"], + }, + { + input: "./dist/index.d.ts", + output: [{ file: "dist/index.d.ts", format: "es" }], + plugins: [dts()], + }, +]; diff --git a/tsconfig.json b/tsconfig.json index c017ac4..575ac18 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,11 +1,16 @@ { "compilerOptions": { "target": "ES2020", - "module": "NodeNext", + "module": "ESNext", + "moduleResolution": "node", "outDir": "./dist", "strict": true, - "esModuleInterop": true + "esModuleInterop": true, + "declaration": true, + "declarationDir": "./dist", + "sourceMap": true, + "rootDir": "./src" }, "include": ["src/**/*.ts"], - "exclude": ["node_modules"] + "exclude": ["node_modules", "**/*.test.ts"] } diff --git a/yarn.lock b/yarn.lock index 3a000c9..2f041d3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10,7 +10,7 @@ "@jridgewell/gen-mapping" "^0.3.5" "@jridgewell/trace-mapping" "^0.3.24" -"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.25.7": +"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.24.2", "@babel/code-frame@^7.25.7": version "7.25.7" resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.25.7.tgz#438f2c524071531d643c6f0188e1e28f130cebc7" integrity sha512-0xZJFNE5XMpENsgfHYTw8FbX4kv53mFLn2i3XPoq69LyhYSCBJtitaHx9QnsVTrsogI4Z3+HtEfZ2/GFPOtf5g== @@ -607,7 +607,7 @@ "@jridgewell/gen-mapping" "^0.3.5" "@jridgewell/trace-mapping" "^0.3.25" -"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14": +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.14", "@jridgewell/sourcemap-codec@^1.5.0": version "1.5.0" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== @@ -2746,6 +2746,13 @@ lru-queue@^0.1.0: dependencies: es5-ext "~0.10.2" +magic-string@^0.30.10: + version "0.30.12" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.12.tgz#9eb11c9d072b9bcb4940a5b2c2e1a217e4ee1a60" + integrity sha512-Ea8I3sQMVXr8JhN4z+H/d8zwo+tYDgHE9+5G4Wnrwhs0gaK9fXTKx0Tw5Xwsd/bCPTTZNRAdpyzvoeORe9LYpw== + dependencies: + "@jridgewell/sourcemap-codec" "^1.5.0" + make-dir@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-4.0.0.tgz#c3c2307a771277cd9638305f915c29ae741b614e" @@ -3173,6 +3180,15 @@ rfdc@^1.4.1: resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.4.1.tgz#778f76c4fb731d93414e8f925fbecf64cce7f6ca" integrity sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA== +rollup-plugin-dts@^6.1.1: + version "6.1.1" + resolved "https://registry.yarnpkg.com/rollup-plugin-dts/-/rollup-plugin-dts-6.1.1.tgz#46b33f4d1d7f4e66f1171ced9b282ac11a15a254" + integrity sha512-aSHRcJ6KG2IHIioYlvAOcEq6U99sVtqDDKVhnwt70rW6tsz3tv5OSjEiWcgzfsHdLyGXZ/3b/7b/+Za3Y6r1XA== + dependencies: + magic-string "^0.30.10" + optionalDependencies: + "@babel/code-frame" "^7.24.2" + rollup-plugin-terser@^7.0.2: version "7.0.2" resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"