From 0b257d6df4189083c198ba8963124a8a0ea29c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Lenon?= Date: Wed, 4 Oct 2023 15:24:22 +0100 Subject: [PATCH] fix(build): use programmatic API's instead of CLI --- package-lock.json | 4 ++-- package.json | 2 +- src/build.js | 35 +++++++++++++++++++++++++---------- src/tsc.js | 14 ++++++++++++++ 4 files changed, 42 insertions(+), 13 deletions(-) create mode 100644 src/tsc.js diff --git a/package-lock.json b/package-lock.json index 3f0e211..b43b419 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@athenna/tsconfig", - "version": "4.7.0", + "version": "4.8.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@athenna/tsconfig", - "version": "4.7.0", + "version": "4.8.0", "license": "MIT", "dependencies": { "copyfiles": "^2.4.1", diff --git a/package.json b/package.json index 0ec9082..a21d5c4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@athenna/tsconfig", - "version": "4.7.0", + "version": "4.8.0", "description": "Exports the base TypeScript configuration for Athena applications and packages.", "license": "MIT", "author": "João Lenon ", diff --git a/src/build.js b/src/build.js index a8fcdac..a9c76be 100644 --- a/src/build.js +++ b/src/build.js @@ -7,17 +7,32 @@ * file that was distributed with this source code. */ -import { sep } from 'node:path' -import { spawn } from 'node:child_process' +import copyfiles from 'copyfiles' -const bin = `${process.cwd()}${sep}node_modules${sep}.bin` +import { tsc } from './tsc.js' +import { rimraf } from 'rimraf' -const tsc = `${bin}${sep}tsc` -const rimraf = `${bin}${sep}rimraf` -const copyfiles = `${bin}${sep}copyfiles` +/** + * Delete old build folder. + */ +rimraf('build') -const options = { shell: true, stdio: 'inherit' } +/** + * Run tsc compiler. + */ +// await tsc() -spawn(`${rimraf} build`, options) -spawn(`${tsc} --project node_modules/@athenna/tsconfig/tsconfig.lib-build.json`, options) -spawn(`${copyfiles} templates configurer package.json package-lock.json LICENSE.md README.md build`, options) +/** + * Copy default files to build folder. + */ +copyfiles([ + 'templates', + 'configurer', + 'package.json', + 'package-lock.json', + 'LICENSE.md', + 'README.md', + 'build' +], '', (err) => { + if (err) throw err +}) diff --git a/src/tsc.js b/src/tsc.js new file mode 100644 index 0000000..f806cc6 --- /dev/null +++ b/src/tsc.js @@ -0,0 +1,14 @@ +/** + * @athenna/tsconfig + * + * (c) João Lenon + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +export async function tsc() { + process.argv.push('--project', 'node_modules/@athenna/tsconfig/tsconfig.lib-build.json') + + await import('typescript/lib/tsc.js') +}