How does npm/yarn serverless packageadded locally in a project know where to locate the serverless.yml file?
I am trying to locate the exact piece of code in the source code of serverless framework ( https://github.com/serverless/serverless), where this happens, but haven't had any luck so far.
I need to know this because my
yarn sls offline start
command does not seem to the new changes that i did in serverless.yml file.
It keeps picking the old one.
This is the code used by Serverless to load the configuration:
https://github.com/serverless/serverless/blob/master/lib/utils/getServerlessConfigFile.js#L9
Relevant excerpt:
const servicePath = srvcPath || process.cwd();
const jsonPath = path.join(servicePath, 'serverless.json');
const ymlPath = path.join(servicePath, 'serverless.yml');
const yamlPath = path.join(servicePath, 'serverless.yaml');
const jsPath = path.join(servicePath, 'serverless.js');
return BbPromise.props({
json: fileExists(jsonPath),
yml: fileExists(ymlPath),
yaml: fileExists(yamlPath),
js: fileExists(jsPath),
}).then(exists => {
Note that from the CLI servicePath is set to the current working directory.
Looking at the code, my guess is that you may have a serverless.json which takes precedence over serverless.yaml? The command serverless print will show your resolved configuration. (https://serverless.com/framework/docs/providers/aws/cli-reference/print/#print)
Related
I have downloaded the official lock repo: https://github.com/auth0/lock
I run the examples and they all work fine.
When I try and run the same code inside my Yarn project like so:
const cid = 'redacted';
const domain = 'redacted.auth0.com';
const lock = new Auth0Lock(cid, domain);
lock.show();
I get the following error:
TypeError: l.setup is not a function
at setupLock (app-root.entry.js:38263:13)
at Auth0Lock.Base (app-root.entry.js:47258:37)
at new Auth0Lock (app-root.entry.js:47517:56)
at AppRoot.auth0Login (app-root.entry.js:49538:20)
at AppRoot.handleLoginEvent (app-root.entry.js:49531:10)
at HTMLDocument.<anonymous> (index-64bf1dc2.js:94:51)
There are no references to this error on the internet except this post from 2017:
https://github.com/rollup/rollup-plugin-node-resolve/issues/87
The reporter kylecombes made a fork with substantial changes to fix the issue, but that fork is now quite out-of-date.
Because the example code is so terse, I'm not sure what else to try. I am concerned that its a compatibility issue between Yarn and Auth0/lock. Their only examples are in webpack and browserfy.
Any help would be greatly appreciated.
I am getting this error when try to run the test in Cypress. Can someone help me how to resolve this, please?
This is my index.js
// Import commands.js using ES2015 syntax:
import './commands'
// Alternatively you can use CommonJS syntax:
// require('./commands')
Cypress.on('uncaught:exception', (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false
})
The line where it errors
const env = process.env
is only valid in NodeJS, where process is a global object supplied by the Node runtime.
Cypress has both a Node process to which you can add plugins via the file cypress/plugins/index.js and a Browser process where you can add code to cypress/support/index.js.
The error comes from a package called ci-info, so it looks like you have imported it or something that uses it into cypress/support/index.js or cypress/support/commands.js, or directly into a test.
Please check all your imports.
I had to remove import "cypress" from my test. That fixed it. 9.7.0
This happened for me when I imported cypress within my test, removing that fixed the issue
This was the issue in my case , I removed it from my test's file. Now, Its working
const cypress = require("cypress");
I am trying to develop a google assistant app with actions sdk. I found lot of samples online which all are using google's firebase cloud functions to deploy.
From this link(https://actions-on-google.github.io/actions-on-google-nodejs/) I also found that it is possible to deploy the actions sdk functions into aws lambda.
But unfortunately I did not find any sample which is showing how to write and deploy actions sdk into aws lambda.
Can anybody help me to write an application which is similar to the one shown here(https://github.com/actions-on-google/actionssdk-say-number-nodejs) and deploy it into aws lambda?
I tried the following to do the same. But it did not worked.
Created a folder and initialized it with "npm init".
Added index.js file.
Then ran the command "npm install actions-on-google". It appeared in the package.json file.
Created a zip folder of the entire source inside that folder I created.
Created a aws lambda function and uploaded the zip folder and set the "Handler" of the lambda function as "index.fulfillment".
Created an api gateway and linked it to the lambda function and deployed it.
Then took the url and editted the "actions.json" file and ran the gactions command.
Then when I started testing the app in the actions console using the simulator I am getting the error "UnparseableJsonResponse API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: "error_message: Cannot find field"
Here is the code inside index.js file
'use strict';
const {actionssdk, SimpleResponse} = require('actions-on-google');
const app = actionssdk({debug: true});
app.intent('actions.intent.MAIN', (conv) => {
conv.ask("welcome");
});
app.intent('actions.intent.TEXT', async (conv, input) => {
conv.ask('You said ' + input);
});
exports.fulfillment = app
Here is the cloud watch logs from aws
2018-11-10T08:35:46.715Z 9dbb17f8-e4c3-11e8-bce3-730a5244a300
{
"errorMessage": "Cannot convert undefined or null to object",
"errorType": "TypeError",
"stackTrace": [
"Function.keys (<anonymous>)",
"Lambda.<anonymous> (/var/task/node_modules/actions-on-google/dist/framework/lambda.js:36:36)",
"Generator.next (<anonymous>)",
"/var/task/node_modules/actions-on-google/dist/framework/lambda.js:22:71",
"new Promise (<anonymous>)",
"__awaiter (/var/task/node_modules/actions-on-google/dist/framework/lambda.js:18:12)",
"/var/task/node_modules/actions-on-google/dist/framework/lambda.js:30:46",
"omni (/var/task/node_modules/actions-on-google/dist/assistant.js:44:53)"
]
}
The code changes to host it on AWS are fairly straightforward. Instead of importing the firebase-functions library and using it, you just need to establish the lambda endpoint with the dialogflow app itself. So the code might look something like:
const { dialogflow } = require('actions-on-google')
const app = dialogflow()
// Setup intent handlers with app.intent() here
exports.factsAboutGoogle = app
I am using webpack and electron and while I can reference my script files fine locally (app/scripts/scriptname.sh), when it comes to the production deploy, I get an error: Can't open app/components/scripts/scriptname.sh.
It's unclear to me if this is an electron-dependent issue or a webpack-issue.
I am running these using node child_process as:
var ls = spawn('sh', ['app/components/scripts/scriptname.sh']);
I don't necessarily need the scripts to be in their own folder it would just be helpful.
You need to provide the complete absolute path to the script. To do that you can use the app.getAppPath() API of electron
app.getAppPath()
Returns String - The current application directory.
So your code would be something like:
var scriptAbsolutePath = app.getAppPath() + '/app/components/scripts/scriptname.sh';
var ls = spawn('sh', [scriptAbsolutePath]);
You can also have a look at app.getPath(name) API if it satisfies your particular requirement.
In my attempt to get a 'hello world' skill with meanjs.org product, I cloned 0.4.2 and setup a mongolab account.
I opened > config > env > development.js, to setup db URL, where I have this:
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean-dev',
For trial, I simply replaced process.env.MONGOLAB_URI with my URL from mongolab and everthing worked for sure, but I doubt this is the way to go. I see a Procfile there, may be I should specify the process.env.MONGOLAB_URI there? Where I could specify it, so that if I upload it to Heroku, say, it will setup the process.env.MONGOLAB_URI and no edit will be needed here please?
p.s. I googled and searched SOF
Well just a small progress,
I got to my gulpfile.js and setup a task as:
gulp.task('setmydb', function () {
process.env.MONGOLAB_URI =
'mongodb://mylogin:mypassword#ds157479.mlab.com:57479/meantst1';
});
Then at the end of the file, added into the task sequence:
// Run the project in development mode
gulp.task('default', function (done) {
runSequence('env:dev', 'lint', ['setmydb','nodemon', 'watch'], done);
});
Well it worked, but I'm still not sure if this indeed is how it must be done! So please help me get sure.
Just in case if someone else also needed, this is how I solved my problem:
Setting configuration variables | Heroku
I first followed the Heroku getting started and edited their app there, added this root:
app.get('/envtst', function(request, response) {
var xterm = process.env.XVAR ==='yes' ? 'yes' : 'no';
response.send(xterm);
});
Then pushed the app to Heroku and also setup my test variable XVAR via command line:
heroku config:set XVAR=yes
finally, opened the root in browser and verified.