Skip to content
This repository has been archived by the owner on Nov 22, 2022. It is now read-only.

Commit

Permalink
Expose CLI to build code on command (#2)
Browse files Browse the repository at this point in the history
* Amends

* Bin

* Update

* Test

* Shell cmd

* Updatye package.json

* Run build

* Test

* Update

* Post-install

* Update

* Test

* Force build in pkg

* Remove building tests

* Delete src after build
  • Loading branch information
varbrad authored Oct 7, 2022
1 parent 02900be commit 852add4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
16 changes: 16 additions & 0 deletions bin/setup.js
Original file line number Diff line number Diff line change
@@ -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' })
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -127,5 +128,6 @@
"engines": {
"node": ">= 14.5.0"
},
"private": true
"private": true,
"bin": "./bin/setup.js"
}
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -60,8 +60,7 @@
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */
},
"include": [
"./src",
"./tests"
"./src"
],
"exclude": [
"./examples/apollo-client"
Expand Down

0 comments on commit 852add4

Please sign in to comment.