diff --git a/bin/setup.js b/bin/setup.js new file mode 100755 index 0000000..d14e124 --- /dev/null +++ b/bin/setup.js @@ -0,0 +1,16 @@ +#!/usr/bin/env node +const path = require('path') +const fs = require('fs') + +const dir = __dirname +const root = path.resolve(dir, '..') + +const exists = fs.existsSync(path.resolve(root, './src')) +if (!exists) { + console.log('src already removed - skipping') + process.exit(0) +} + +const { spawn } = require('child_process') + +spawn('npm run build && rm -rf ./src', { cwd: root, shell: true, stdio: 'inherit' }) diff --git a/package.json b/package.json index a7c46d1..b10da60 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "url": "https://github.com/MichalLytek" }, "scripts": { + "build": "tsc --build", "test": "jest --verbose --coverage", "test:ci": "jest --verbose --coverage --ci --forceExit --detectOpenHandles --runInBand", "test:watch": "jest --watch", @@ -17,7 +18,7 @@ "verify": "npm run check && npm run lint", "package": "gulp package", "docs": "npm run --prefix website start", - "postinstall": "node ./dist/postinstall || exit 0" + "postinstall": "npm run build && node ./dist/postinstall || exit 0" }, "peerDependencies": { "class-validator": ">=0.13.0", @@ -127,5 +128,6 @@ "engines": { "node": ">= 14.5.0" }, - "private": true + "private": true, + "bin": "./bin/setup.js" } diff --git a/tsconfig.json b/tsconfig.json index 542c4c4..0a8debe 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,7 +13,7 @@ "declaration": true, /* Generates corresponding '.d.ts' file. */ "sourceMap": true, /* Generates corresponding '.map' file. */ // "outFile": "./", /* Concatenate and emit output to single file. */ - "outDir": "./build", /* Redirect output structure to the directory. */ + "outDir": "./dist", /* Redirect output structure to the directory. */ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ "removeComments": false, /* Do not emit comments to output. */ // "noEmit": true, /* Do not emit outputs. */ @@ -60,8 +60,7 @@ "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */ }, "include": [ - "./src", - "./tests" + "./src" ], "exclude": [ "./examples/apollo-client"