@@ -12,6 +12,7 @@ import slash from 'slash';
1212import aws4 from 'aws4' ;
1313import axios from 'axios' ;
1414import chalk from 'chalk' ;
15+ import { exec } from 'child_process' ;
1516
1617const log = console . log ;
1718const error = console . error ;
@@ -30,6 +31,9 @@ function parseArgumentsIntoOptions() {
3031 return yargs . option ( 'force' , {
3132 type : 'boolean' ,
3233 description : 'CAUTION: This will override the version if it already exists in the database!'
34+ } ) . option ( 'keep' , {
35+ type : 'boolean' ,
36+ description : 'Prevents removal of the tar.gz file.'
3337 } ) ;
3438 } , publish )
3539 . command ( 'logout' , 'Remove all credentials' , ( yargs ) => {
@@ -69,15 +73,26 @@ function determineCategory(appInfo) {
6973 return Array . isArray ( appInfo . category ) ? appInfo . category : [ appInfo . category ] ;
7074}
7175
76+ function pruneDev ( ) {
77+ return new Promise ( ( resolve ) => {
78+ log ( gray ( 'Pruning development dependencies' ) ) ;
79+ exec ( 'npm prune --production' , ( err , stdout , stderr ) => {
80+ log ( gray ( 'Finished pruning development dependencies' ) ) ;
81+ resolve ( ) ;
82+ } ) ;
83+ } ) ;
84+ }
85+
7286function createTar ( appInfo , argv ) {
7387 log ( gray ( 'Process for creating the tar.gz file' ) ) ;
74- return new Promise ( ( resolve , reject ) => {
88+ return new Promise ( async ( resolve , reject ) => {
7589 let version = `v${ appInfo . version } ` ;
7690 if ( argv . latest ) {
7791 version = 'latest' ;
7892 }
7993 const tarFile = `${ appInfo . id } -${ version } .tar.gz` ;
8094 log ( gray ( `Filename determined: '${ tarFile } '` ) ) ;
95+ await pruneDev ( ) ;
8196 tar . c ( {
8297 gzip : true ,
8398 file : tarFile ,
@@ -421,6 +436,10 @@ async function publish(argv) {
421436 if ( errors ) {
422437 log ( red ( 'Failed to push an asset to the S3 storage. Failed to publish the app. Please contact the HCS admin' ) ) ;
423438 } else {
439+ if ( ! argv . keep ) {
440+ log ( gray ( 'Cleaning up' ) ) ;
441+ fs . unlinkSync ( `./${ tar . filename } ` ) ;
442+ }
424443 log ( green ( 'Successfully published the app to the Homey Community Store.' ) ) ;
425444 }
426445 } else {
0 commit comments