Skip to content

Commit

Permalink
feat(dx): generate types upon building for npm
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Sep 12, 2022
1 parent 07b8d32 commit 4563b6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .stacks/src/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ export async function buildFunctionLibrary() {
}
}

export async function generateTypes() {
consola.info('Building your functions library for production use & npm/CDN distribution...')

try {
await runNpmScript(NpmScript.GenerateTypes)
consola.success('Your library types were generated.')
}
catch (error) {
consola.error('There was an error generating your types')
consola.error(error)
}
}

export async function startBuildProcess(options: any) {
if (options.components || options === 'components') {
await buildComponentLibraries()
Expand All @@ -117,8 +130,9 @@ export async function startBuildProcess(options: any) {
else if (options.npm || options === 'npm') {
await buildComponentLibraries()
await buildFunctionLibrary()
await generateTypes()

consola.success('All your libraries were built successfully to be distributed on npm.')
consola.success('All your libraries and its types were built successfully to be distributed on npm.')
}

else {
Expand Down
1 change: 1 addition & 0 deletions .stacks/src/types/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@ export const enum NpmScript {
Test = 'test',
TestTypes = 'test:types',
TestCoverage = 'test:coverage',
GenerateTypes = 'generate:types',
}

0 comments on commit 4563b6d

Please sign in to comment.