Skip to content
This repository was archived by the owner on Mar 8, 2020. It is now read-only.

Commit 275773c

Browse files
mbwhiteJakeeyturner
authored andcommitted
Update the composer-archive create with improved output (#1035)
* get the loopback adapter up and working * updates to unit test * Unit test updates * Update the composer archive create cli for better output
1 parent b6be6ce commit 275773c

File tree

5 files changed

+23
-16
lines changed

5 files changed

+23
-16
lines changed

packages/composer-cli/lib/cmds/archive/createCommand.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,10 @@ module.exports.handler = (argv) => {
3030

3131
argv.thePromise = Create.handler(argv)
3232
.then(() => {
33-
console.log ('Command completed successfully.');
33+
return 0;
3434
})
3535
.catch((error) => {
36-
console.log(error.stack);
37-
console.log(error+ '\nCommand failed.');
36+
throw error;
3837
});
3938

4039
return argv.thePromise;

packages/composer-cli/lib/cmds/archive/lib/create.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ const Admin = require('composer-admin');
1818
const BusinessNetworkDefinition = Admin.BusinessNetworkDefinition;
1919
const fs = require('fs');
2020
const sanitize = require('sanitize-filename');
21+
22+
// const ora = require('ora');
23+
const chalk = require('chalk');
24+
2125
/**
2226
* Composer Create Archive command
2327
*
@@ -37,23 +41,24 @@ class Create {
3741

3842
let inputDir = '';
3943

40-
console.log('Creating Business Network Archive\n');
44+
console.log(chalk.blue.bold('Creating Business Network Archive\n'));
4145
if (argv.sourceType === 'module'){
4246
// using a npm module name
4347
//
4448
let moduleName = argv.sourceName;
4549
const path = require('path');
46-
console.log('Node module search path : \n'+process.env.NODE_PATH+' \n');
50+
4751
let moduleIndexjs;
4852
try {
4953
moduleIndexjs=require.resolve(moduleName);
5054
} catch (err){
5155
if (err.code==='MODULE_NOT_FOUND'){
5256
let localName = process.cwd()+'/node_modules/'+moduleName;
53-
console.log('Not found in main node_module search path, trying current directory :'+localName);
57+
console.log(chalk.bold.yellow('Not found in main node_module search path, trying current directory'));
58+
console.log(chalk.yellow('\tCurrent Directory: ')+localName);
5459
moduleIndexjs=require.resolve(localName);
5560
}else {
56-
console.log('Unable to locate the npm module specified');
61+
console.log(chalk.blue.red('Unable to locate the npm module specified'));
5762
return Promise.reject(err);
5863
}
5964

@@ -69,12 +74,14 @@ class Create {
6974
inputDir = argv.sourceName;
7075
}
7176
}
72-
console.log('Looking for package.json of Business Network Definition in '+inputDir);
77+
console.log(chalk.blue.bold('\nLooking for package.json of Business Network Definition'));
78+
console.log(chalk.blue('\tInput directory: ')+inputDir);
7379

7480
return BusinessNetworkDefinition.fromDirectory(inputDir).then( (result)=> {
75-
console.log('\nFound:\nDescription:'+result.getDescription());
76-
console.log('Name:'+result.getName());
77-
console.log('Identifier:'+result.getIdentifier());
81+
console.log(chalk.blue.bold('\nFound:'));
82+
console.log(chalk.blue('\tDescription: ')+result.getDescription());
83+
console.log(chalk.blue('\tName: ')+result.getName());
84+
console.log(chalk.blue('\tIdentifier: ')+result.getIdentifier());
7885

7986

8087
if (!argv.archiveFile){
@@ -85,7 +92,8 @@ class Create {
8592
(result) => {
8693
//write the buffer to a file
8794
fs.writeFileSync(argv.archiveFile,result);
88-
console.log('\nWritten Business Network Definition Archive file to '+argv.archiveFile);
95+
console.log(chalk.blue.bold('\nWritten Business Network Definition Archive file to '));
96+
console.log(chalk.blue('\tOutput file: ')+argv.archiveFile);
8997
return;
9098
}
9199

packages/composer-cli/lib/cmds/archive/listCommand.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ module.exports.handler = (argv) => {
2828

2929
argv.thePromise = List.handler(argv)
3030
.then(() => {
31-
console.log ('Command completed successfully.');
31+
return 0;
3232
})
3333
.catch((error) => {
34-
console.log(error+ '\nCommand failed.');
34+
throw error;
3535
});
3636
return argv.thePromise;
3737
};

packages/composer-common/lib/businessnetworkdefinition.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class BusinessNetworkDefinition {
280280
let scriptFiles = scriptManager.getScripts();
281281
scriptFiles.forEach(function(file) {
282282
let fileIdentifier = file.identifier;
283-
let fileName = fileIdentifier.substring(fileIdentifier.lastIndexOf('/') + 1);
283+
let fileName = fsPath.parse(fileIdentifier).base;
284284
zip.folder('lib').file(fileName, file.contents);
285285
});
286286

packages/composer-rest-server/server/boot/composer-discovery.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ module.exports = function (app, callback) {
580580

581581
// Apply any required updates to the specified model schema.
582582
modelSchema = updateModelSchema(modelSchema);
583-
583+
console.log(modelSchema);
584584
// This call creates the model class from the model schema.
585585
let model = app.loopback.createModel(modelSchema);
586586

0 commit comments

Comments
 (0)