How to add a language syntax to AWS Cloud9 - syntax

I'm trying to add the Lilypond language syntax to AWS Cloud9.
In my searching, I've found ajaxorg/ace/tool and textmate/lilypond.tmbundle on Github.org
I've tried cloning both repositories and I've run:
$ npm install
$ node add_mode.js Lilypond "ly|ily|lily"
$ node tmlanguage.js ../../lilypond.tmbundle/Syntaxes/Lilypond.tmLanguage
But I can't find any documentation on how to implement the result into the AWS Cloud9 IDE. What am I missing?

Related

Do NPM packages have to be installed globally to access their functionality via the command line?

I am having trouble understanding how the -g flag works in NPM. Specifically I'm struggling to understand how it relates to command-line functionality exposed by NPM modules.
I assumed that the difference between installing a package locally and globally was simply that a local package would not be available outside of the particular project. And of course that a globally installed package would be available in any project. I'm from a Rails background so this for me would be similar to installing a gem into a particular RVM versus installing it into the global RVM. It would simply affect which places it was available.
However there seems to be more significance than just scope in NPM. For packages that have command-line functionality, like wait-on, the package (as far as I can tell) is not available on the command line unless it's installed globally.
Local install doesn't make the command-line functionality available:
$ npm install wait-on
$ wait-on
=> -bash: /usr/local/bin/wait-on: No such file or directory
Global install does expose the command-line functionality
$ npm install wait-on -g
$ wait-on
=> Usage: wait-on {OPTIONS} resource [...resource]
Description:
wait-on is a command line utility which will wait for files, ports,
sockets, and http(s) resources to become available (or not available
using reverse flag). Exits with success code (0) when all resources
are ready. Non-zero exit code if interrupted or timed out.
Options may also be specified in a config file (js or json). For
example --config configFile.js would result in configFile.js being
required and the resulting object will be merged with any
Can you expose the command-line functionality using a local install?
Is it possible to install locally but also get the command line functionality? This would be very helpful for my CI setup as it's far easier to cache local modules than global modules so where possible I'd prefer to install locally.
If you are using npm 5.2.0 or later, the npx command is included by default. It will allow you to run from the local node modules: npx wait-on
For reference: https://www.npmjs.com/package/npx
I think you can access locally installed modules from the command line only if you add them to your "scripts" section of your package.json. So to use the locally installed version of wait-on, you can add an entry in "scripts" section of package.json like so "wait-on": "wait-on". Then to run it, you would have to do npm run wait-on. You can also do "wo": "wait-on" and then do npm run wo basically meaning what comes after the run is the script entry. In node_modules, there is a .bin folder and inside of this folder is all the executables that you can access this way.
Installing locally makes the package available to the current project (where it stores all of the node modules in node_modules). This is usually only good for using a module like so var module = require('module'); or importing a module.
It will not be available as a command that the shell can resolve until you install it globally npm install -g module where npm will install it in a place where your path variable will resolve this command.
You can find a pretty decent explanation here.
It is also useful to put commands in the scripts block in package.json as it automatically resolve local commands. That means you could have a script that depended on a package without having an undocumented dependency on the same.
If you need to run it locally on cmd, you have to go inside the node_modules and run from the path.

How to create an NPM package installing directly from a private TFS Repo

I've created an NPM Package on TFS (because my organisation uses TFS instead of normal git/gitbucket/gitlab), that I want to install to other projects.
On Github all I needed to do this was:
$ npm install git.com/username/privateRepoName
but when I try:
$ npm install tfs.organisationname.net/reponame
I get the following error:
npm ERR! code E401
npm ERR! Unable to authenticate, your authentication token seems to be
invalid.
I've tried multiple methods for hours now on adding my credentials (yes, my windows credentials are the same as my TFS credentials) but i'm not seeming to win nor find the answer anywhere as every example is using git credentials and not TFS.
Does anyone know how I can do this?
npm install xxx can be seen as a shorthand for modifying package.json, where dependencies can be precised in four ways, as per the docs:
version range: "foo": "^1.0.0"
URL: "foo": "https://url.to/the/tarball/of/foo"
git URL: "foo": "https://url.to/foo.git"
github: "foo": "github-username/foo"
local path: "foo": "file:./path/to/the/foo/package"
NPM has built-ins for using private git repos as dependencies, but nothing for TLS.
Luckily, it provides a local path installation which will save you. Simply get the package locally, which you're able to do, make it a local dependency, and you're good to go.
The best way to tackle this since I have the rights to the TFS repository was to clone it then link it.
First $ git clone tfs.foo.com/repo into the project directory then read this doc.

Installing and using godef

I install godef:
$ go get -u github.com/rogpeppe/godef
Looks great:
$ which godef
/home/username/go/bin/godef
Right where I expect it:
$ echo $GOPATH
/home/username/go
But when called as a command line tool:
$ godef version
godef: cannot read : open : no such file or directory
What's happening?
I would suggest you to read the documentation found here: https://github.com/rogpeppe/godef/blob/master/doc.go
You can also try typing godef -h.
If you want more information, please explain what you are actually trying to do.
EDIT: Regarding your comment above, I think that this library can't help you to accomplish what you are trying to do.
I ran into an issue trying to use godef-describe (C-c C-d) which would output the following error:
No description found for expression at point
If I tried using godef directly on a file, I would receive the following error:
% godef -f path/to/file.go "SomeFunction()"
2020/08/26 14:57:46 internal error: nil Pkg importing "io" from "github.com/some/package"
I fixed this by reinstalling godef and using the master branch as described here:
go get -v github.com/rogpeppe/godef#master
since the latest updates on go and go.mod you might want to install it on your user so you should use install instead of get
if you want to install godef to your gopath:
go install -v github.com/rogpeppe/godef#master

Gemfile git branch for Beanstalk unable to bundle install

In my Gemfile I have
gem 'slim', :git => 'git://github.com/brennancheung/slim.git', :branch => 'angularjs_support'
which is a branch of the slim gem required for me to run AngularJS correctly with my views. I've pushed my code to my beanstalk application but am unable to bundle install according to the logs shown below...
sh: git: command not found
Git error: command `git clone 'git://github.com/brennancheung/slim.git'
"/usr/share/ruby/1.9/gems/1.9.1/cache/bundler/git/slim-700ed452e752ccb6baf9de9d0a46fbded8bb2da5"
--bare --no-hardlinks` in directory /var/app/ondeck has failed.
I'm new to Beanstalk and have no idea how to fix this. Any help on how to get bundle to install successfully would be greatly appreciated. Thanks.
Since git is not installed on by default on EC2 instance, you would have to find a workaround solution:
a. Install git on instance with configuration file and command.
It is the most obvious way to solve the problem, although not be the most efficient.
b. Clone slim repository into your project, so it will be deployed together.
Seems that slim is not being actively developed lately, so having the copy in your project might not be a bad idea. It protects you from github.com being down, yet you will have extra files to carry around.
c. Use configuration file and commands to pull the data from github.com directly with http.
Too many files to work with, and also dependency on third party service.
d. Use a combination of above. Clone slim repository and copy files to S3. Use configuration and commands to copy files from S3 to your instance.
It seems like the most elegant and efficient way to solve the problem.
It might look something like:
$ cat .ebextensions/myapp.config
commands:
10-copy-slim-from-s3
command: "aws s3 cp s3://mybucket/slim slim --recursive"

Heroku NodeJS + CouchBase Custom Buildpack

I'm trying to put together a custom buildpack with NodeJS and the CouchBase module/libraries
I've gotten as far as using Vulcan to build libcouchbase and libvbucket and getting the buildpack to retrieve and unpack the tgz files for both.
Everything looks ok there, but I receive errors when npm tries to install the couchbase module:
I get a bunch of errors, but this line:
"../src/couchbase_impl.h:52:36: warning: libcouchbase/couchbase.h: No such file or directory"
leads me to think that it can't find the libcouchbase libraries (which is possible since they aren't in the usual place).
I've tried to add the correct path using CPPFLAGS="-I/app/vendor/couchbase/include/libcouchbase" in both the Config Vars and just exporting that as part of the compile phase, but still no luck.
Here is the gist with the Heroku deploy output and the compile/release buildpack files:
https://gist.github.com/ahamidi/5620503
Any help would be greatly appreciated.
Thanks,
Ali
[Update 1]
I've made some progress and I can now get the slug to compile when deploying to Heroku.
The key was figuring out the ENV Variables that CouchNode looks for when adding custom directories to include.
In this case, the Env Variables were EXTRA_CPPFLAGS and EXTRA_LDFLAGS.
So I updated the compile file to include the following:
export EXTRA_CPPFLAGS="-I$BUILD_DIR/vendor/couchbase/include"
export EXTRA_LDFLAGS="-L$BUILD_DIR/vendor/couchbase/lib -Wl,-rpath,$BUILD_DIR/vendor/couchbase/lib"
The slug compiles and the app is deployed, but I now get a different error in the logs:
Error: libcouchbase.so.2: cannot open shared object file: No such file or directory
So it looks like Node can't see the libcouchbase libraries directory.
For anyone who is curious or experiencing a similar issue, here's what worked for me.
In order to get the couchbase npm module to install I had to tell it where to find the libcouchbase libraries (in compile file):
export EXTRA_CPPFLAGS="-I$BUILD_DIR/vendor/couchbase/include"
export EXTRA_LDFLAGS="-L$BUILD_DIR/vendor/couchbase/lib -Wl,-rpath,$BUILD_DIR/vendor/couchbase/lib"
Then in order to require couchbase in my app I had to set the following Env Variable:
LD_LIBRARY_PATH="/app/vendor/couchbase/lib:$LD_LIBRARY_PATH"
With the command:
heroku config:add LD_LIBRARY_PATH="/app/vendor/couchbase/lib:$LD_LIBRARY_PATH"
You should set CPPFLAGS="-I/app/vendor/couchbase/include" LDFLAGS="-L/app/vendor/couchbase/include -lcouchbase"
from your script it seems like you just unpacking libcouchbase without any further work. you should also build it and install. typical magic spell for node.js client will be ./configure --disable-plugins --disable-examples && make && sudo make install. I'm not sure if sudo part needed on heroku, probably just make install

Resources