From b67e9b1b86a1e3b0457f4737636319b3f019fbbe Mon Sep 17 00:00:00 2001 From: Austen Collins Date: Mon, 7 Sep 2015 10:10:42 -0700 Subject: [PATCH 1/4] new: create lib and lambdas folder when new project is created --- lib/commands/new.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/commands/new.js b/lib/commands/new.js index 8005935d9..dfb8f4fa2 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,8 @@ 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')), utils.writeFile(path.join(project.rootPath, 'admin.env'), adminEnv), utils.writeFile(path.join(project.rootPath, 'jaws-cf.json'), JSON.stringify(cfTemplate, null, 2)), ]); From 08bee7d14e449169ec04ee7962aa042c600905c0 Mon Sep 17 00:00:00 2001 From: Austen Collins Date: Mon, 7 Sep 2015 10:36:53 -0700 Subject: [PATCH 2/4] generate: show success message --- lib/commands/generate.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/commands/generate.js b/lib/commands/generate.js index f2d5e514b..c77efc52c 100644 --- a/lib/commands/generate.js +++ b/lib/commands/generate.js @@ -45,7 +45,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 +56,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 +67,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 +78,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 { @@ -214,5 +214,9 @@ 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" folder.'); + }); }; From ea52e5d064f3d421f62d4176b5ad8b077899d417 Mon Sep 17 00:00:00 2001 From: Austen Collins Date: Mon, 7 Sep 2015 11:52:02 -0700 Subject: [PATCH 3/4] sync --- lib/commands/generate.js | 2 +- lib/commands/new.js | 1 + tests/all.js | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/commands/generate.js b/lib/commands/generate.js index c77efc52c..3767c3958 100644 --- a/lib/commands/generate.js +++ b/lib/commands/generate.js @@ -217,6 +217,6 @@ module.exports.generate = function(isLambda, isApi, functionName, resourceName, .then(_createSkeleton) .then(function() { // Success message - console.log('Successfully created new folders and files in your "back" folder.'); + console.log('Successfully created new folders and files in your "back/lambdas" folder.'); }); }; diff --git a/lib/commands/new.js b/lib/commands/new.js index dfb8f4fa2..94626e828 100644 --- a/lib/commands/new.js +++ b/lib/commands/new.js @@ -267,6 +267,7 @@ function _createProjectDirectory() { 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..28207a73f 100644 --- a/tests/all.js +++ b/tests/all.js @@ -14,10 +14,10 @@ describe('AllTests', function() { }); //require tests vs inline so we can run sequentially - require('./cli/tag'); - require('./cli/install'); - require('./cli/env'); - require('./cli/generate'); + //require('./cli/tag'); + //require('./cli/install'); + //require('./cli/env'); + //require('./cli/generate'); /** * Tests below create AWS Resources From 970cde5db406ed8be2976f3376dfd62da3467b09 Mon Sep 17 00:00:00 2001 From: Austen Collins Date: Mon, 7 Sep 2015 13:03:10 -0700 Subject: [PATCH 4/4] generate: remind users to do npm install, if necessary --- lib/commands/generate.js | 14 ++++++++++++-- tests/all.js | 10 +++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/commands/generate.js b/lib/commands/generate.js index 3767c3958..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 }; /** @@ -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; @@ -218,5 +223,10 @@ module.exports.generate = function(isLambda, isApi, functionName, resourceName, .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/tests/all.js b/tests/all.js index 28207a73f..2ec03cd6c 100644 --- a/tests/all.js +++ b/tests/all.js @@ -14,15 +14,15 @@ describe('AllTests', function() { }); //require tests vs inline so we can run sequentially - //require('./cli/tag'); - //require('./cli/install'); - //require('./cli/env'); - //require('./cli/generate'); + require('./cli/tag'); + require('./cli/install'); + require('./cli/env'); + require('./cli/generate'); /** * Tests below create AWS Resources */ - require('./cli/deploy_lambda'); + //require('./cli/deploy_lambda'); //require('./cli/deploy_api'); //require('./cli/new'); //Must be run last });