Added a version script

It automaticly update the version number without importing package.json

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
Florian Bouillon 2021-06-22 21:40:28 +02:00
parent f858bd5c79
commit 96bc9149c9
Signed by: Florian Bouillon
GPG Key ID: 50BD648F12C86AB6
5 changed files with 230 additions and 225 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ coverage
# Dist files
dist
src/version.json

View File

@ -42,7 +42,8 @@
"unfetch": "^4.2.0"
},
"scripts": {
"build": "yarn build:cjs && yarn build:browser && yarn build:es2015",
"prebuild": "node scripts/export-version-number.js",
"build": "yarn prebuild && yarn build:cjs && yarn build:browser && yarn build:es2015",
"build:cjs": "tsc --project tsconfig.json",
"build:es2015": "tsc --project tsconfig.es2015.json",
"build:browser": "wp --config webpack.config.js",

View File

@ -0,0 +1,4 @@
const { version } = require('../package.json')
const fs = require('fs')
fs.writeFileSync('./src/version.json', JSON.stringify({version}))

View File

@ -1,4 +1,5 @@
import TCGdex from './tcgdex'
import { version } from './version.json'
export default class Request {
@ -14,7 +15,7 @@ export default class Request {
const unfetch = TCGdex.fetch
const resp = await unfetch(url, {
headers: {
'user-agent': `@tcgdex/javascript-sdk/${TCGdex.VERSION}`
'user-agent': `@tcgdex/javascript-sdk/${version}`
}
})
if (resp.status !== 200) {

View File

@ -8,8 +8,6 @@ export default class TCGdex {
public static fetch: typeof fetch
public static readonly VERSION = '2.2.0'
/**
* @deprecated to change the lang use `this.lang`
*/