-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from serverless-stack/alpha
Adding `sst start`, a local dev environment for Lambda
- Loading branch information
Showing
180 changed files
with
7,591 additions
and
12,606 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,26 @@ | ||
# Don't ever lint node_modules | ||
node_modules | ||
|
||
# Don't lint build output (make sure it's set to your correct build folder name) | ||
dist | ||
|
||
# Don't lint nyc coverage output | ||
coverage | ||
|
||
# Don't lint cdk.out | ||
cdk.out | ||
|
||
# Don't lint build outputs in test | ||
/packages/cli/test/*/build/** | ||
/packages/cli/test/*/.build/** | ||
/packages/cli/test/*/cdk.out/** | ||
|
||
# Don't lint templates | ||
/packages/create-serverless-stack/templates/** | ||
|
||
# Don't lint eslint tests that need to fail | ||
/packages/cli/test/eslint-ignore/** | ||
/packages/cli/test/eslint-ts/** | ||
/packages/cli/test/eslint/** | ||
/packages/cli/test/lambda-override-tsconfig/** | ||
/packages/cli/test/lambda-override-eslintrc/** | ||
/packages/cli/test/start/src/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,5 +103,8 @@ dist | |
# TernJS port file | ||
.tern-port | ||
|
||
# CDK | ||
cdk.out | ||
|
||
# Vim | ||
.*.sw* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
# Ignore CDK outputs | ||
cdk.out | ||
# Ignore SST outputs | ||
.build | ||
# Ignore templates | ||
/packages/create-serverless-stack/templates/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Build outputs in test | ||
/test/*/build/** | ||
/test/*/cdk.out/** | ||
/test/**/.build/** | ||
/test/**/cdk.out/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
cdk.out | ||
node_modules | ||
test | ||
*.test.js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@babel/eslint-parser", | ||
parserOptions: { | ||
requireConfigFile: false, | ||
babelOptions: { | ||
presets: [ | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
targets: { | ||
node: "10", | ||
}, | ||
}, | ||
], | ||
], | ||
plugins: ["@babel/plugin-proposal-class-properties"], | ||
}, | ||
}, | ||
plugins: ["@babel"], | ||
overrides: [ | ||
{ | ||
files: ["*.ts", "*.tsx"], | ||
plugins: ["@typescript-eslint"], | ||
parser: "@typescript-eslint/parser", | ||
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended"], | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env node | ||
|
||
"use strict"; | ||
|
||
require("source-map-support").install(); | ||
|
||
process.on("uncaughtException", function (err) { | ||
console.error("\n" + (err.stack || err) + "\n"); | ||
process.exit(1); | ||
}); | ||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const chalk = require("chalk"); | ||
const sst = require("@serverless-stack/resources"); | ||
|
||
const config = require("./sst-merged.json"); | ||
|
||
const appPath = process.cwd(); | ||
|
||
// Disable color | ||
if (process.env.NO_COLOR === 'true') { | ||
chalk.level = 0; | ||
} | ||
|
||
// Check first and throw an error | ||
if (!fs.existsSync(path.join(__dirname, "lib", "index.js"))) { | ||
handlerNotFound(true); | ||
} | ||
|
||
const handler = require("./lib"); | ||
|
||
if (!handler.default) { | ||
handlerNotFound(false); | ||
} | ||
|
||
// When run inside `sst start`, we need to store a list of handlers to file for `sst start` to use | ||
let synthCallback; | ||
if (config.debugEndpoint) { | ||
synthCallback = (lambdaHandlers) => { | ||
fs.writeFileSync( | ||
path.join(appPath, app.buildDir, "lambda-handlers.json"), | ||
JSON.stringify(lambdaHandlers) | ||
); | ||
}; | ||
} | ||
|
||
const app = new sst.App({ | ||
synthCallback, | ||
name: config.name, | ||
stage: config.stage, | ||
region: config.region, | ||
debugEndpoint: config.debugEndpoint, | ||
}); | ||
|
||
// Run the handler | ||
handler.default(app); | ||
|
||
function handlerNotFound(importFailed) { | ||
const extCopy = fs.existsSync(path.join(appPath, "tsconfig.json")) | ||
? "ts" | ||
: "js"; | ||
console.error( | ||
importFailed | ||
? `\nCannot find app handler. Make sure to add a "lib/index.${extCopy}" file.\n` | ||
: `\nCannot find app handler. Make sure "lib/index.${extCopy}" has a default export.\n` | ||
); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env node | ||
|
||
const cdk = require("@aws-cdk/core"); | ||
const { DebugStack } = require("../lib/DebugStack"); | ||
|
||
const stage = process.argv[3]; | ||
const region = process.argv[4]; | ||
const stackName = process.argv[2]; | ||
|
||
// Override default region | ||
const env = { account: process.env.CDK_DEFAULT_ACCOUNT, region }; | ||
|
||
const app = new cdk.App(); | ||
|
||
new DebugStack(app, stackName, { env, stage, stackName, region }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"app": "node bin/index.js", | ||
"context": { | ||
"@aws-cdk/core:enableStackNameDuplicates": "true", | ||
"aws-cdk:enableDiffNoFail": "true" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exports.main = async function () { | ||
return { statusCode: 200, body: "Connected." }; | ||
}; |
Oops, something went wrong.