Skip to content

Commit 5d1699a

Browse files
committed
Cleanup tar file after publish and added an option to keep the file if the user wants it
1 parent a5e2ab7 commit 5d1699a

3 files changed

Lines changed: 22 additions & 3 deletions

File tree

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@maxvandelaar/homey-community-store-cli",
3-
"version": "2.1.1",
3+
"version": "2.2.0",
44
"description": "CLI tool to upload apps to the Homey Community Store. Run 'hcs' to understand how to use it.",
55
"main": "src/index.js",
66
"bin": {

src/cli.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import slash from 'slash';
1212
import aws4 from 'aws4';
1313
import axios from 'axios';
1414
import chalk from 'chalk';
15+
import {exec} from 'child_process';
1516

1617
const log = console.log;
1718
const 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+
7286
function 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

Comments
 (0)