mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
commit
2aef28e4e7
@ -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.');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -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)),
|
||||
]);
|
||||
|
||||
@ -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
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user