@@ -19,8 +19,11 @@ async function createFile(fullPath, content) {
1919 return writeFile ( fullPath , content , { flag : 'wx' } ) ;
2020}
2121
22- const javaScriptDeps = { } ;
23- const typescriptDeps = { '@twilio-labs/serverless-runtime-types' : versions . serverlessRuntimeTypes } ;
22+ const javaScriptDeps = { twilio : versions . twilio } ;
23+ const typescriptDeps = {
24+ '@twilio-labs/serverless-runtime-types' : versions . serverlessRuntimeTypes ,
25+ ...javaScriptDeps ,
26+ } ;
2427const javaScriptDevDeps = { 'twilio-run' : versions . twilioRun } ;
2528const typescriptDevDeps = {
2629 'twilio-run' : versions . twilioRun ,
@@ -38,47 +41,59 @@ function createPackageJSON(pathName, name, projectType = 'javascript') {
3841 if ( projectType === 'typescript' ) {
3942 scripts . test = 'tsc --noEmit' ;
4043 scripts . build = 'tsc && npm run build:copy-assets' ;
41- scripts [ 'build:copy-assets' ] = 'copyfiles src/assets/* src/assets/**/* --up 2 --exclude **/*.ts dist/assets/' ;
44+ scripts [ 'build:copy-assets' ] =
45+ 'copyfiles src/assets/* src/assets/**/* --up 2 --exclude **/*.ts dist/assets/' ;
4246 scripts . prestart = 'npm run build' ;
4347 scripts . predeploy = 'npm run build' ;
44- scripts . start += ' --functions-folder dist/functions --assets-folder dist/assets' ;
45- scripts . deploy += ' --functions-folder dist/functions --assets-folder dist/assets' ;
48+ scripts . start +=
49+ ' --functions-folder dist/functions --assets-folder dist/assets' ;
50+ scripts . deploy +=
51+ ' --functions-folder dist/functions --assets-folder dist/assets' ;
4652 }
4753 const packageJSON = JSON . stringify (
4854 {
4955 name,
5056 version : '0.0.0' ,
5157 private : true ,
5258 scripts,
53- dependencies : projectType === 'typescript' ? typescriptDeps : javaScriptDeps ,
54- devDependencies : projectType === 'typescript' ? typescriptDevDeps : javaScriptDevDeps ,
59+ dependencies :
60+ projectType === 'typescript' ? typescriptDeps : javaScriptDeps ,
61+ devDependencies :
62+ projectType === 'typescript' ? typescriptDevDeps : javaScriptDevDeps ,
5563 engines : { node : versions . node } ,
5664 } ,
5765 null ,
58- 2 ,
66+ 2
5967 ) ;
6068 return createFile ( fullPath , packageJSON ) ;
6169}
6270
6371function copyRecursively ( src , dest ) {
64- return readdir ( src ) . then ( ( children ) => {
72+ return readdir ( src ) . then ( children => {
6573 return Promise . all (
66- children . map ( ( child ) =>
67- stat ( path . join ( src , child ) ) . then ( ( stats ) => {
74+ children . map ( child =>
75+ stat ( path . join ( src , child ) ) . then ( stats => {
6876 if ( stats . isDirectory ( ) ) {
6977 return mkdir ( path . join ( dest , child ) ) . then ( ( ) =>
70- copyRecursively ( path . join ( src , child ) , path . join ( dest , child ) ) ,
78+ copyRecursively ( path . join ( src , child ) , path . join ( dest , child ) )
7179 ) ;
7280 }
73- return copyFile ( path . join ( src , child ) , path . join ( dest , child ) , COPYFILE_EXCL ) ;
74- } ) ,
75- ) ,
81+ return copyFile (
82+ path . join ( src , child ) ,
83+ path . join ( dest , child ) ,
84+ COPYFILE_EXCL
85+ ) ;
86+ } )
87+ )
7688 ) ;
7789 } ) ;
7890}
7991
8092function createExampleFromTemplates ( pathName , projectType = 'javascript' ) {
81- return copyRecursively ( path . join ( __dirname , '..' , '..' , 'templates' , projectType ) , pathName ) ;
93+ return copyRecursively (
94+ path . join ( __dirname , '..' , '..' , 'templates' , projectType ) ,
95+ pathName
96+ ) ;
8297}
8398
8499function createEnvFile ( pathName , { accountSid, authToken } ) {
@@ -111,8 +126,8 @@ function createTsconfigFile(pathName) {
111126 } ,
112127 } ,
113128 null ,
114- 2 ,
115- ) ,
129+ 2
130+ )
116131 ) ;
117132}
118133
0 commit comments