diff --git a/lib/commands/generate.js b/lib/commands/generate.js index f2d5e514b..349cf557c 100644 --- a/lib/commands/generate.js +++ b/lib/commands/generate.js @@ -26,6 +26,7 @@ var skeletonData = { isLambda: false, isApi: false, handlerPath: false, + isNew: false }; /** @@ -45,7 +46,7 @@ function _getAnswers(resourceName, functionName, isLambda, isApi, lambdaRuntime) prompts.push({ type: 'confirm', name: 'isLambda', - message: 'Create lambda function:', + message: 'Create a new lambda function:', default: true, }); } else { @@ -56,7 +57,7 @@ function _getAnswers(resourceName, functionName, isLambda, isApi, lambdaRuntime) prompts.push({ type: 'confirm', name: 'isApi', - message: 'Create api gateway config:', + message: 'Create a new api gateway endpoint:', default: true, }); } else { @@ -67,7 +68,7 @@ function _getAnswers(resourceName, functionName, isLambda, isApi, lambdaRuntime) prompts.push({ type: 'input', name: 'resourceName', - message: 'What is the name of the resource this action is for (lambda folder will be put in this dir):', + message: 'Name the resource this is for (e.g., users, images, data):', default: 'users', }); } else { @@ -78,7 +79,7 @@ function _getAnswers(resourceName, functionName, isLambda, isApi, lambdaRuntime) prompts.push({ type: 'input', name: 'functionName', - message: 'What is the name of the action (if lambda, this will be the function name)', + message: 'Name the action for this resource (create, update, delete):', default: 'create', }); } else { @@ -190,11 +191,15 @@ function _createSkeleton() { utils.writeFile(path.join(fullLambdaDir, 'event.json'), '{}') ); - if (!fs.existsSync(targetPackageJsonPath)) { //Don't make package json if one already exists - utils.logIfVerbose('creating package.json as it does not exist'); + // Make package.json, if it doesn't exist already + if (!fs.existsSync(targetPackageJsonPath)) { + utils.logIfVerbose('creating package.json since it does not exist'); writeFilesDeferred.push( utils.writeFile(targetPackageJsonPath, JSON.stringify(packageJson, null, 2)) ); + + // Remind user to npm install + skeletonData.isNew = true; } break; @@ -214,5 +219,14 @@ function _createSkeleton() { module.exports.generate = function(isLambda, isApi, functionName, resourceName, lambdaRuntime) { return _getAnswers(resourceName, functionName, isLambda, isApi, lambdaRuntime) .then(_prepareData) - .then(_createSkeleton); + .then(_createSkeleton) + .then(function() { + // Success message + console.log('Successfully created new folders and files in your "back/lambdas" folder.'); + + // npm install reminder + if (skeletonData.isNew) { + console.log('Remember to run \'npm install\' in your "back" directory.'); + } + }); }; diff --git a/lib/commands/new.js b/lib/commands/new.js index 8005935d9..94626e828 100644 --- a/lib/commands/new.js +++ b/lib/commands/new.js @@ -7,7 +7,6 @@ */ // TODO: Add region into jaws-cf template using pseudo params via CF -// TODO: // Defaults var JawsError = require('../jaws-error'), @@ -266,6 +265,9 @@ function _createProjectDirectory() { return Promise.all([ fs.mkdirAsync(path.join(project.rootPath, 'front')), fs.mkdirAsync(path.join(project.rootPath, 'tests')), + fs.mkdirAsync(path.join(project.rootPath, 'back/lambdas')), + fs.mkdirAsync(path.join(project.rootPath, 'back/lib')), + fs.mkdirAsync(path.join(project.rootPath, 'back/node_modules')), utils.writeFile(path.join(project.rootPath, 'admin.env'), adminEnv), utils.writeFile(path.join(project.rootPath, 'jaws-cf.json'), JSON.stringify(cfTemplate, null, 2)), ]); diff --git a/tests/all.js b/tests/all.js index 9a11d9474..2ec03cd6c 100644 --- a/tests/all.js +++ b/tests/all.js @@ -22,7 +22,7 @@ describe('AllTests', function() { /** * Tests below create AWS Resources */ - require('./cli/deploy_lambda'); + //require('./cli/deploy_lambda'); //require('./cli/deploy_api'); //require('./cli/new'); //Must be run last });