Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(build): use programmatic API's instead of CLI #8

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <lenon@athenna.io>",
Expand Down
35 changes: 25 additions & 10 deletions src/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
14 changes: 14 additions & 0 deletions src/tsc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @athenna/tsconfig
*
* (c) João Lenon <lenon@athenna.io>
*
* 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')
}