elm-package.json failing to load - intellij-idea

I am attempting to create an Elm project in Intellij. To do this, I am using a fairly standard elm-package.json fle:
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
I am trying to load this project, and am getting the following failure:
org.elm.workspace.ProjectLoadException: The 'type' field is 'null', but expected either 'application' or 'package'
There does not seem to be any documentation of this 'type' field! What is it? Where do I place it? More importantly, why wasn't it generated with the rest of the json file when I created it using elm-package install???

Related

How do I package a node module for BuckleScript / ReasonML?

Background
I'm an absolute beginner in BuckleScript, and while I've downloaded packgages with npm before, I've never written a library.
Goal: installing my new package local package in my project using npm
I am trying to wrap some parts of the service worker api in JavaScript. I have started with a file bs-service-worker/src/ExtendableEvent.re like so
type _extendableEvent('a);
type extendableEvent_like('a) = Dom.event_like(_extendableEvent('a));
type extendableEvent = extendableEvent_like(Dom._baseClass);
[#bs.send] external waitUntil: (extendableEvent, Js.Promise.t('a)) => unit
= "waitUntil";
This compiles and produces ExtendableEvent.bs.js as expected.
Now, though, I'd like to go ahead and test what I have so far by creating a new npm project and importing what I have locally. I created a new sibling directory and did an npm install ../bs-service-worker. That succeeded, and then I did a sanity-check build on my new BuckleScript project. That also succeeded.
The issue: opening my module causes an error
When I add open ExtendableEvent; to Demo.re in the new project, I get the following error:
We've found a bug for you!
/home/el/workbench/bucklescript/bs-service-worker-examples/src/Demo.re 11:6-20
9 │
10 │ /**/
11 │ open ExtendableEvent;
12 │
13 │ /*
The module or file ExtendableEvent can't be found.
- If it's a third-party dependency:
- Did you list it in bsconfig.json?
- Did you run `bsb` instead of `bsb -make-world`
(latter builds third-parties)?
- Did you include the file's directory in bsconfig.json?
What I've tried
I'm guessing I'm misusing BuckleScript here instead of npm because npm is so widely adopted and well documented that I think I'd have found the problem, but I'm definitely not ruling out the possibility that I'm misusing npm, too.
I do have "bs-service-worker" listed as a bs-dependency. I also tried "../bs-service-worker" in case BuckleScript didn't like the virtual directory, but it didn't seem to help.
My npm run build command is indeed npx bsb -make-world.
More code:
bs-service-worker/bs-config.json
{
"name": "bs-service-worker",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true,
"public": "all"
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
bs-service-worker-examples/bsconfig.json
{
"name": "bs-service-worker-examples",
"version": "0.1.0",
"sources": {
"dir" : "src",
"subdirs" : true
},
"package-specs": {
"module": "commonjs",
"in-source": true
},
"suffix": ".bs.js",
"bs-dependencies": [
"bs-service-worker",
"bs-fetch",
],
"warnings": {
"error" : "+101"
},
"namespace": true,
"refmt": 3
}
bs-service-worker-examples/package.json
{
"name": "bs-service-worker-examples",
"version": "0.0.1",
"scripts": {
"build": "npx bsb -make-world",
"start": "npx bsb -make-world -w",
"clean": "npx bsb -clean-world"
},
"keywords": [
"BuckleScript"
],
"author": "Eleanor (https://webbureaucrat.bitbucket.io)",
"license": "MIT",
"devDependencies": {
"bs-platform": "^7.3.2"
},
"dependencies": {
"bs-fetch": "^0.6.1",
"bs-service-worker": "file:../bs-service-worker"
}
}
Easy Reproduction of the Issue
The fastest way to reproduce this would be to fork this repository and try to add it as a local npm dependency.
The problem seems to be that you have "namespace": true in your library's bsconfig.json, which will wrap all the modules in a namespace module with a silly generated name based on the name field. In this case it will be BsServiceWorker I think.
You could just remove that setting, or set it to false, but namespacing is a good idea to avoid collisions between modules from different libraries, or your own app, so I would recommend setting it to a custom, sensible name. For example:
"namespace": "ServiceWorker"
You can then open ExtendableEvent in the consumer project with:
open ServiceWorker.ExtendableEvent;
For more details, see the documentation on the namespace field.

Can a package be published to both github and npm? (with a single `npm publish`)

I got access to the github package registry beta, just fiddled with it and followed the configuration steps to publish.
The thing is, I published it correctly, but noticed it didn't publish to npm. Is there a way to publish in both registries with the same command? Does it make sense to have the package published in both registries?
Also, my package name in the package.json is #alvarocastro/quicksort (as stated in the doc) and the name in the github page ends up being that, but in the command example to install, the scope is duplicated, eg: #alvarocastro/#alvarocastro/quicksort
Here is the complete package.json file as a reference:
{
"name": "#alvarocastro/quicksort",
"version": "1.0.1",
"description": "An implementation of the quicksort algorithm",
"main": "index.js",
"scripts": {
"performance": "node performance.js",
"test": "xo && nyc ava",
"coverage": "nyc report --reporter=text-lcov | coveralls"
},
"publishConfig": {
"registry":"https://npm.pkg.github.com/#alvarocastro"
},
"repository": {
"type": "git",
"url": "git+https://github.com/alvarocastro/quicksort.git"
},
"keywords": [
"quicksort",
"sort",
"algorithm"
],
"author": "Alvaro Castro",
"license": "MIT",
"bugs": {
"url": "https://github.com/alvarocastro/quicksort/issues"
},
"homepage": "https://github.com/alvarocastro/quicksort#readme",
"devDependencies": {
"ava": "2.3.0",
"coveralls": "3.0.6",
"nyc": "14.1.1",
"xo": "0.24.0"
}
}

Elm : install specific version of a github library

I want to use v9 branch of elm-mdl library.
I added native-modules to true in my elm-package.json and added external\elm-mdl to my source-directories list.
I then added "debois/elm-mdl": "9.0.0 <= v < 10.0.0", to elm-package.json
I ran elm-install but it complains about :
▶ No solution found: Unable to satisfy the following requirements:
- `debois/elm-mdl (< 10.0.0)` required by `user-specified dependency`
- `debois/elm-mdl (>= 9.0.0)` required by `user-specified dependency`
How can i make elm-install and elm-make to pick up my cloned directory version of the library ?
Please see directory structure and elm-package.json output below :
└─ $ ▶ elm --version
0.18.0
└─ $ ▶ cat elm-package.json
{
"version": "1.0.0",
"summary": "Track your life.",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"native-modules": true,
"source-directories": [
"src",
"external/elm-mdl"
],
"exposed-modules": [],
"dependencies": {
"danyx23/elm-uuid": "2.1.0 <= v < 3.0.0",
"debois/elm-mdl": "9.0.0 <= v < 10.0.0",
"elm-lang/core": "5.1.1 <= v < 6.0.0",
"elm-lang/html": "2.0.0 <= v < 3.0.0",
"mgold/elm-random-pcg": "4.0.2 <= v < 6.0.0",
"rtfeldman/elm-css": "9.1.0 <= v < 10.0.0",
"rtfeldman/elm-css-helpers": "2.1.0 <= v < 3.0.0",
"sporto/elm-dropdown": "1.3.0 <= v < 2.0.0"
},
"elm-version": "0.18.0 <= v < 0.19.0"
}
└─ $ ▶ cat external/elm-mdl/elm-package.json
{
"version": "9.1.0",
"summary": "Material Design Lite port to Elm",
"repository": "https://github.com/debois/elm-mdl.git",
"license": "Apache License, version 2.0",
"source-directories": [
"src"
...
└─ $ ▶ ls external/elm-mdl/
build_scripts CONTRIBUTING.md COPYING.md demo elm-package.json examples FAQ.md foo.md LICENSE.md Makefile MIGRATION.md PR.md README.md RELEASE.md src TEMPLATES.md TESTING.md tests USERS.md
ashish # 7567 ~/work/be_autonomous (master)
└─ $ ▶ ls
Architecture.md compile_css.sh elm-package.json elm-stuff external index.css index.html index.js run.sh src TAGS tests
Here's an answer I prepared earlier: Using local packages
In summary, remove the elm-mdl reference in your dependencies and link to the folder where the Material module is defined, ie:
"source-directories": [
-- ADD src because Material.elm is under that folder
"external/elm-mdl/src"
],
"dependencies": {
-- REMOVE LINE BELOW
"debois/elm-mdl": "9.0.0 <= v < 10.0.0",
},
It will then error for every package that elm-mdl depends on, add them locally as per the SO link I referenced above.

Using MaterializeCSS with Aurelia

I'm following the tutorial here http://aurelia.io/hub.html#/doc/article/aurelia/framework/latest/contact-manager-tutorial/4
and I added bootstrap as per the instructions and it all works according to plan
there's a config that I have to add to the vendor part of the aurelia.json file
"dependencies": [
...
"jquery",
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": ["jquery"],
"exports": "$",
"resources": [
"css/bootstrap.css"
]
},
...
]
but I like materialize-css and I figure I could just install materialize-css via npm and then change the bootstrap bit of the config to this
{
"name": "materialize-css",
"path": "../node_modules/materialize-css/dist",
"main": "js/materialize",
"deps": ["jquery"],
"exports": "$",
"resources": [
"css/materialize.css"
]
}
when I use this in app.html
<require from="materialize-css/css/materialize.css"></require>
the app blows up with a Unhandled rejection Error: Failed loading required CSS file: materialize-css/css/materialize.css
I can't work out why this is the case. To me it seems like I did a like for like swap of css frameworks
Nothing wrong with it.
Check the instructions http://aurelia-ui-toolkits.github.io/demo-materialize/#/installation in case missed a step

Having trouble packaging node webkit app

I wrote a small app in node webkit, and am having trouble packaging it. My eventual goal is to have a .exe that I can give to other people.
I can run it from the command line with "nodewebkit".
I've tried zipping the files and saving the result as app.nw, but when I try to run that I just get the default node webkit screen. I've read through the docs on rogerwang github, but haven't gotten anywhere because I can't get through that first step.
The app consists of a few files: index.html, main.js, styles.css. It depends on a few node modules as well as jquery. The package.json file is pasted below... any suggestions would be much appreciated.
{
"name": "spl",
"version": "0.0.0",
"description": "",
"keywords": [],
"main": "index.html",
"homepage": "https://github.com/lpappone/spl",
"bugs": "https://github.com/lpappone/spl/issues",
"window": {
"title": "Splitter",
"toolbar": false,
"frame": true,
"width": 800,
"height": 500
},
"author": {
"name": "Lauren Pappone",
"email": "",
"url": "https://github.com/lpappone"
},
"repository": {
"type": "git",
"url": "git://github.com/lpappone/spl.git"
},
"dependencies": {
"fast-csv": "^0.5.3",
"recursive-readdir": "^1.2.0"
},
"devDependencies": {},
"engines": {
"node": ">=0.8.0"
}
}
The directory structure looks like this, and when I inspect the contents of the .nw, it is exactly the same:
You seem to be doing this on a Mac, so I'll cover that. Windows and Linux are slightly more complicated because they don't have App Bundles the way Mac OSX does.
Are you copying your app.nw to the right place? Are you sure you're including everything in app.nw?
Is this what you're doing?:
First you need to create app.nw, which is just a zip file of your entire project. If you go to your project dir (the one containing package.json) you can do this by typing
zip -r ../app.nw .
Now create a copy of node-webkit.app and copy app.nw into node-webkit.app/Contents/Resources/
cp app.nw node-webkit.app/Contents/Resources/
You should be able to run node-webkit.app now and it should run your app. (You might have some issues with security settings and such)
See https://github.com/rogerwang/node-webkit/wiki/How-to-package-and-distribute-your-apps#mac-os-x for further details.