diff --git a/CHANGELOG.md b/CHANGELOG.md index c01477d..63f31db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## v1.2.1 - 2018-04-21 +- add source map support + ## v1.1.27 - 2018-02-22 - fixed vars cloud compiling diff --git a/lib/plugins/run/lib/index.js b/lib/plugins/run/lib/index.js index 567c22c..eef98d8 100644 --- a/lib/plugins/run/lib/index.js +++ b/lib/plugins/run/lib/index.js @@ -24,9 +24,10 @@ class Run { const functionName = this.options.function || functionArg; const data = runCommon.findFunction(functionName); const projectPath = this.sqz.vars.project.path; - const eventInputFile = path.join(data.func.path, 'event.input.json'); + const eventInputFile = path.join(data.func.path, '.event.input.json'); + const eventOutputFile = path.join(data.func.path, '.event.output.json'); - fs.writeFileSync(`${projectPath}/.build/development/response.json`, JSON.stringify({})); + fs.writeFileSync(eventOutputFile, JSON.stringify({})); let eventInput; @@ -67,7 +68,7 @@ class Run { return this.sqz.command.run(command.description, command.bin, command.args || []); }).then(() => { - const responseData = JSON.parse(fs.readFileSync(`${projectPath}/.build/development/response.json`)); + const responseData = JSON.parse(fs.readFileSync(eventOutputFile)); const response = JSON.stringify(responseData.body, null, 2) || 'null'; this.sqz.cli.log.console(`${colors.blue.bold('RESPONSE OUTPUT')}\n\n${response}\n`); resolve(); diff --git a/lib/plugins/templates/lib/samples/api-nodejs/data/services/my-service/hello/src/handler.js b/lib/plugins/templates/lib/samples/api-nodejs/data/services/my-service/hello/src/handler.js index a393816..0cdc3c2 100644 --- a/lib/plugins/templates/lib/samples/api-nodejs/data/services/my-service/hello/src/handler.js +++ b/lib/plugins/templates/lib/samples/api-nodejs/data/services/my-service/hello/src/handler.js @@ -5,7 +5,7 @@ import fs from 'fs'; const vars = JSON.parse(fs.readFileSync('.vars.json', 'utf8')); -exports.handler = (...args) => event(vars, (req, res) => { +export const handler = (...args) => event(vars, (req, res) => { res.json(200, { name : `Your name : ${req.query.name}`, message: req.body.message || 'hello world !!!' diff --git a/lib/plugins/templates/lib/shared/nodejs/.eslintrc b/lib/plugins/templates/lib/shared/nodejs/.eslintrc index e5604fb..8976058 100644 --- a/lib/plugins/templates/lib/shared/nodejs/.eslintrc +++ b/lib/plugins/templates/lib/shared/nodejs/.eslintrc @@ -52,6 +52,7 @@ "strict": 0, "import/no-extraneous-dependencies": "off", "import/no-dynamic-require": "off", + "import/prefer-default-export" : "off", "react/require-extension": "off", "import/no-unresolved" : "off" }, diff --git a/lib/plugins/templates/lib/shared/nodejs/.gitignore b/lib/plugins/templates/lib/shared/nodejs/.gitignore index ed70b7a..eacbc1f 100644 --- a/lib/plugins/templates/lib/shared/nodejs/.gitignore +++ b/lib/plugins/templates/lib/shared/nodejs/.gitignore @@ -11,7 +11,8 @@ .build # events samples -event.input.json +.event.input.json +.event.output.json # Logs *.log diff --git a/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/cloud.js b/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/cloud.js index b4b186b..b14109d 100644 --- a/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/cloud.js +++ b/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/cloud.js @@ -1,8 +1,10 @@ const nodeExternals = require('webpack-node-externals'); +const WebpackSourceMapSupport = require('webpack-source-map-support'); module.exports = { target: 'node', externals: [nodeExternals()], + devtool: 'source-map', module: { loaders: [{ test: /\.js$/, @@ -14,5 +16,7 @@ module.exports = { output: { libraryTarget: 'commonjs' }, - plugins : [] + plugins: [ + new WebpackSourceMapSupport() + ] }; diff --git a/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/development.js b/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/development.js index bbc6daa..d315844 100644 --- a/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/development.js +++ b/lib/plugins/templates/lib/shared/nodejs/lib/webpack/functions/development.js @@ -1,9 +1,15 @@ const nodeExternals = require('webpack-node-externals'); +const WebpackSourceMapSupport = require('webpack-source-map-support'); module.exports = { target: 'node', externals: [nodeExternals()], + devtool: 'source-map', + node: { + __filename: true, + __dirname: true + }, module: { loaders: [{ test: /\.js$/, @@ -14,5 +20,8 @@ module.exports = { }, output: { libraryTarget: 'commonjs' - } + }, + plugins: [ + new WebpackSourceMapSupport() + ] }; diff --git a/lib/plugins/templates/lib/shared/nodejs/package.json b/lib/plugins/templates/lib/shared/nodejs/package.json index ad3dd71..c1407d4 100644 --- a/lib/plugins/templates/lib/shared/nodejs/package.json +++ b/lib/plugins/templates/lib/shared/nodejs/package.json @@ -24,6 +24,7 @@ "json-loader": "^0.5.4", "jest": "^21.2.1", "webpack": "^3.6.0", - "webpack-node-externals": "^1.6.0" + "webpack-node-externals": "^1.6.0", + "webpack-source-map-support": "^2.0.1" } } diff --git a/package.json b/package.json index cda66d8..1b2d510 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "squeezer-cli", - "version": "1.1.28", + "version": "1.2.1", "preferGlobal": true, "description": "Event-driven APIs & Web apps on functions, serverless ! Squeezer is a framework designed to help developers to get a better architecture on serverless zero-administration compute platforms with code that runs into cloud functions like [AWS Lambda](https://aws.amazon.com/documentation/lambda/) , [Azure Functions](https://azure.microsoft.com/en-us/services/functions/) , [Google Cloud Functions](https://cloud.google.com/functions/docs/) and [IBM OpenWhisk](https://developer.ibm.com/openwhisk/) .", "homepage": "https://squeezer.io/",