Codeanywhere Environment - node.js

I'm Using CodeAnywhere as my IDE and I wanted to use testing Environment not development.
how can I do that?
when I try Console.Log(process.env)
this comes out
{ MANPATH: '/home/cabox/.nvm/versions/node/v4.4.0/share/man:/usr/local/man:/usr/local/share/man:/usr/share/man',
TERM: 'xterm-256color',
SHELL: '/bin/bash',
SSH_CLIENT: '(Confidential)',
NVM_PATH: '/home/cabox/.nvm/versions/node/v4.4.0/lib/node',
OLDPWD: '/home/cabox/workspace',
SSH_TTY: '/dev/pts/0',
NVM_DIR: '/home/cabox/.nvm',
USER: 'cabox',
LS_COLORS: 'rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:ca=30;41:tw=30;42:o
w=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;3
1:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.ja
r=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.g
if=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*
.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;
35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01
;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;
36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00
;36:*.spx=00;36:*.xspf=00;36:',
MAIL: '/var/mail/cabox',
PATH: '/home/cabox/.nvm/versions/node/v4.4.0/bin:/home/cabox/.npm-packages/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/
usr/games',
NVM_NODEJS_ORG_MIRROR: 'https://nodejs.org/dist',
PWD: '/home/cabox/workspace/login-app',
SHLVL: '1',
HOME: '/home/cabox',
LOGNAME: 'cabox',
SSH_CONNECTION: '(Confidential)',
NVM_BIN: '/home/cabox/.nvm/versions/node/v4.4.0/bin',
LESSOPEN: '| /usr/bin/lesspipe %s',
NVM_IOJS_ORG_MIRROR: 'https://iojs.org/dist',
LESSCLOSE: '/usr/bin/lesspipe %s %s',
_: '/home/cabox/.nvm/versions/node/v4.4.0/bin/node' }
I if I can add some variables into this environment, then how can I do that?
if I want to create another Environment, then how can I do that?

Related

Easy Localization: Localization key [...] not found

I am using easy_localization: ^2.3.3 in a flutter project with CSV loader. When I build it is not able to find keys and it gives "Easy Localization: Localization key [...] not found". Any ideas why is this happening?
runApp(EasyLocalization(
supportedLocales: [
Locale('en', ''),
Locale('it', ''),
Locale('es', ''),
Locale('de', ''),
Locale('fr', ''),
Locale('pt', ''),
],
path: 'resources/langs/langs.csv',
fallbackLocale: Locale('en', ''),
saveLocale: false,
useOnlyLangCode: true,
assetLoader: CsvAssetLoader(),
child: MyApp(status),
));
}
Also this error can be happen for not setting the material app; I mean, I got same error for forgeting the add these lines to my material app;
MaterialApp(
locale: context.locale,
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
),
and my problem solved !
You need to import import 'package:easy_localization/easy_localization.dart';
And add in your MaterialApp :
locale: context.locale,
supportedLocales: context.supportedLocales,
localizationsDelegates: context.localizationDelegates,
I found a solution looking at this bug: https://github.com/aissat/easy_localization/issues/190#
I added the following:
dependencies:
easy_localization_loader:
git:
url: git://github.com/aissat/easy_localization_loader.git
ref: overman-dev
then I did a
flutter pub upgrade
and also changed the code into this
runApp(EasyLocalization(
supportedLocales: [
Locale('en'),
Locale('it'),
Locale('es'),
Locale('de'),
Locale('fr'),
Locale('pt'),
],
path: 'resources/langs/langs.csv',
fallbackLocale: Locale('en'),
saveLocale: false,
useOnlyLangCode: true,
assetLoader: CsvAssetLoader(),
child: MyApp(status),
));
It worked.

Parameterisation of a groovy Pipeline for use with jenkins

I have a groovy pipeline which I've inherited from a project that I forked.
I wish to pass in Jenkins Choice Parameters as a Parameterised build. At present, I only wish to expose the environment in which to run ( but will want to parameterise further at a later stage), such that a user can choose it from the Jenkins dropdown and use on demand.
I used the snippet generator to help.
Can someone please help with the syntax? I am using Node with a package.json to run a script and with to pass in either dev or uat:
properties([[$class: 'BuildConfigProjectProperty', name: '', namespace: '', resourceVersion: '', uid: ''], parameters([choice(choices: 'e2e\nuat', description: 'environment ', name: 'env')])])
node('de-no1') {
try {
stage('DEV: Initialise') {
git url: 'https://myrepo.org/mycompany/create-new-user.git', branch: 'master', credentialsId: CREDENTIALS_ID
}
stage('DEV: Install Dependencies') {
sh 'npm install'
}
stage('${params.env}: Generate new users') {
sh 'npm run generate:${params.env}'
archiveArtifacts artifacts: '{params.env}-userids.txt', fingerprint: true
}
This currently fails with:
npm ERR! missing script: generate:{params.env}
Assume you want to replace ${params.env} with a value when you call npm?
If this is the case, you need to use double quotes " to let Groovy know you will be doing String templating...ie:
sh "npm run generate:${params.env}"

Node JS + Grunt-sonar-runner + Code Coverage not showing

I created a REST service in node js and wrote the test cases using mocha. I have been able to generate the code coverage using istanbul and is working absolutely fine. Now my requirement is to show the code coverage using Sonar. The code compliance violations are getting listed as expected. But the code coverage is not getting generated in sonar. I doubt there is something wrong with the gruntfile.js configuration. Currently, I generate the code compliance violation by copying the source inside the grunt-sonar-runner folder within node_modules and execute grunt-sonar-runner. My current folder structure is as shown below :
<ProjectRoot>
|--server.js
|--[test]
|--|--serverTest.js
|--[node_modules]
|--|--[grunt-sonar-runner]
|--|--|--[src]
|--|--|--|--server.js
In the gruntfile.js,
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'tasks/*.js',
'test/*.js'
],
options: {
jshintrc: '.jshintrc'
}
},
// Before generating any new files, remove any previously-created files.
clean: {
tests: ['tmp']
},
// Configuration to be run (and then tested).
sonarRunner: {
analysis: {
options: {
debug: true,
separator: '\n',
sonar: {
host: {
url: 'http://localhost:9000'
},
jdbc: {
url: 'jdbc:h2:tcp://localhost:9092/sonar',
username: 'sonar',
password: 'sonar'
},
projectKey: 'sonar:grunt-sonar-runner:0.1.0',
projectName: 'Grunt Sonar Runner',
projectVersion: '0.10',
sources: ['src'].join(','),
language: 'js',
sourceEncoding: 'UTF-8'
}
}
},
dryRun: {
options: {
dryRun: true,
debug: true,
separator: '\n',
sonar: {
host: {
url: 'http://localhost:9000'
},
jdbc: {
url: 'jdbc:mysql://localhost:3306/sonar',
username: 'sonar',
password: 'sonar'
},
projectKey: 'sonar:grunt-sonar-runner:0.1.0',
projectName: 'Grunt Sonar Runner',
projectVersion: '0.10',
sources: ['src'].join(','),
exclusions: '**/R.js'
}
}
}
},
// Unit tests.
mochaTest: {
test: {
options: {
reporter: 'spec'
},
src: ['test/**/*.js'],
}
}
});
we have two sections --> analysis and dryRun. What is this dryRun ?
Just outside that, we have a key called mochaTest.
While running mocha with istanbul, I am getting coverage reports generated in the project root inside a folder called coverage. Unfortunately it is not getting listed in sonar. Any help would be appreciated.
Thanks in Advance,
Noble
Just had to define a sonar-roject.properties in the project root folder. Inside that properties file, we can specify the relative path to the lcov.info generated by istanbul. After starting up the sonar qube server, just run sonar-runner (provided sonar runner is present in the system path). Sonar reports will be visible in sonar dashboard

Error importing Node.js modules into Intern tests

I'm trying out Intern for testing our Node.js modules. I've got it set up to run an empty test and even require node modules, but when I try to require one of the modules in our package I get the error:
/path/to/app/node_modules/path/path.js:327
var path = (i >= 0) ? arguments[i] : process.cwd();
^
TypeError: undefined is not a function
at Object.exports.resolve (/path/to/app/node_modules/path/path.js:327:52)
at Object.exports.relative (/path/to/app/node_modules/path/path.js:405:20)
at getSource (/path/to/app/node_modules/intern/lib/util.js:368:21)
at formatLine (/path/to/app/node_modules/intern/lib/util.js:405:40)
at processChromeTrace (/path/to/app/node_modules/intern/lib/util.js:418:16)
at normalizeStackTrace (/path/to/app/node_modules/intern/lib/util.js:470:38)
at Object.getErrorMessage (/path/to/app/node_modules/intern/lib/util.js:597:14)
at PreExecutor._handleError (/path/to/app/node_modules/intern/lib/executors/PreExecutor.js:256:24)
at /path/to/app/node_modules/intern/node_modules/dojo/lang.js:78:32
at process.<anonymous> (/path/to/app/node_modules/intern/lib/executors/PreExecutor.js:302:6)
Folder structure is:
src/
**/*.coffee
tests
unit/**/*.coffee
intern.js
js/ (coffeescript is compiled here)
src/
**/*.js
tests/
**/*.js
all.js (compiled by rolling up the names of the other tests under /js/tests)
node_modules
Here's my intern.js:
define({
capabilities: {
'browserstack.selenium_version': '2.45.0'
},
environments: [
{browserName: 'internet explorer', version: '11', platform: 'WIN8'},
{browserName: 'internet explorer', version: '10', platform: 'WIN8'},
{browserName: 'internet explorer', version: '9', platform: 'WINDOWS'},
{browserName: 'firefox', version: '37', platform: ['WINDOWS', 'MAC']},
{browserName: 'chrome', version: '39', platform: ['WINDOWS', 'MAC']},
{browserName: 'safari', version: '8', platform: 'MAC'}
],
maxConcurrency: 2,
tunnel: 'BrowserStackTunnel',
loaderOptions: {
packages: [{name: 'app', location: 'js/src'}]
},
reporters: ['Console', 'Lcov'],
suites: ['js/tests/unit/all'],
excludeInstrumentation: /^(?:\.npm|js\/tests|src|tests|node_modules)\//
});
My test is just:
define (require) ->
registerSuite = require('intern!object')
assert = require('intern/chai!assert')
SchemaBuilder = require('intern/dojo/node!app/path/to/Module')
registerSuite
name: 'Testing'
'test': ->
From the project root I'm running './node_modules/.bin/intern-client config=tests/intern'
Is this a problem with my code, configuration, environment, or Intern?
I've tried with Node.js v0.12.0 and v0.12.7.
Interestingly, removing the path module from my app dependencies (package.json) resolved (well, avoided) the undefined is not a function error, seemingly falling back on Intern's own path resolution. I don't really know why, but this seems like a bug.
This presented a new, more tractable error: Error: Cannot find module 'app/path/to/Module', suggesting the path in the require() was simply wrong.
I think the problem is that the intern/dojo/node loader doesn't support the loaderOptions: {packages: [{name: 'app', location: 'js/src'}]} configuration, and hence it is searching for an app directory relative to the test module. If I replace app/ with ../../../../js/src/ then it resolves and works as expected.
It's a bit ugly, but it's the standard way of requiring local files in node, so it's also not too surprising, I had just hoped Intern's loader could make it cleaner.

Can't install custom SailsJS adapter

Every time I try to use an adapter other than sails-disk I'll get a No find() method defined in adapter! Error.
My sails app will lift fine, but when ever I get to a point where the adapter is being called it fails. I've tried several different adapters and they all fail.
I'm using the boilerplate config files.
I had this problem too and only happened with custom adapters. So instead of using the path api/adapters, i moved the adapter to node_modules where others adapters such as sails-mongo are installed, and it did the trick.
usually, you just need to enable your new adapter in yourapp/config/adapters.js
For exemple, with mongo :
add sails-mongo dependence in your package.json file
"dependencies": {
...
"sails-mongo": "~0.9.6"
}
run $ npm install
change your config file (ie: yourapp/config/adapters.js) by editing :
module.exports.adapters = {
'default': 'mongo',
mongo: {
module: 'sails-mongo',
host: 'localhost',
user: '',
password: '',
database: 'your-prod-db'
}
};
Of course for local dev, edit yourapp/config/local.js like:
adapters : {
'default': 'mongo',
mongo: {
module: 'sails-mongo',
host: 'localhost',
user: '',
password: '',
database: 'your-local-db'
}
}

Resources