How to put .sequelizerc configuration in package.json? - node.js

I rather not have multiple configuration files. So I'm trying to consolidate as much as possible.

It's not being documented (at least not well documented) but looking into the source code of Sequelize-cli you can find an options-path parameter:
In your case use it like --options-path package.json
Source code:
cli/src/core/yargs.js

Related

Webpack first steps on npm module

This is my first npm module, so be kind to me. The repository is available here. The package content is available on folder src. My question is about functionality export.
During research, this fellow provides a great step-by-step tutorial to create such package. At step 2, it exports its functionalities from multiple files into index.js and modify them in such a way that he may export only with ONE default name (neat!).
As you can see in my case, there are several functions to export.
How can I make it in a proper and clean way? The current way outputs the following error:
SyntaxError: ./arqeo/src/index.js: Identifier 'isArtifact' has already been declared. (15:11)

How to use certain node module

My goal is to read in graphml files and retreive information about the fields that are contained within the nodes.
I have found a node module that seems to do just that so I decided I'd give it a try before writing my own code.
Unfortunately I the documentation is pretty poor and I have only been using node.js for about three months so I cannot figure out what the few clues given mean.
Global Install
npm install -g graphml-schema-generator
To have the wizard assist you with questions, type: gschema And answer the questions until finished.
Alternatively, you can use the following syntax: gschema path/to/graphml/file path/to/out/directory The paths can be either relative or absolute. The tool should pick on it either way.
Local Install
npm install --save graphm-schema-generator
You can either type the whole path to the file each time, such as: ./node_modules/gml-to-typescript/build/index Or you can create an npm script that references the path
However you choose to go about it, the usage is exactly the same as stated in the Global Install section. Please refer to that.
If you don't want to pollute your development environment this might be a better way to install this. Then you can use npm scripts to alias it to a more manageable command.
There's no GitHub repository or what-so-ever. I have read through the code and basically there are three files of which two seem to be sourcefiles (exporting some modules that are used in the last one) and one that's called "app.ts".
I somehow expected that I could use this module like
import {<ModuleName>} from 'graphml-schema-generator';
or
require('./node_modules/graphml-schema-generator";
but this isn't the case. I do not understand what
gschema path/to/graphml/file path/to/out/directory
would mean or how it would be used. I guess there's some basic misunderstanding about packages on my side.
here's an Image of the modules hierarchy
So I want to understand how to use this module and if so, what I did wrong
Thanks in advance

How to use webpack components

Due to the lack of support of modules or packages under development in npm I have decided to use webpack's components which from the look of the example provided here webpack/examples/components seems to be exactly what I am looking for. However there is no example how to actually use the example. Drawing from webpack's convention I thought that:
webpack/examples/components> webpack component.json > bundle.js
would do the trick but nope I get an error. Tried some other stuff like putting an entry file and an output file in the webpack.config.js but no luck there either. Has someone ever use it, does it work and most importantly how to start it?

What naming conventions exist for the primary Node.js file?

This question has been completely edited in hopes that it will be reopened.
The naming of the main Node.js file is something left to the user and and does not seem to be defined by any well established convention. In hopes of finding a good name, I am curious if there are naming conventions in other parts of the Node.js ecosystem that might suggest a name to use.
Some names I have seen are: app.js, index.js, main.js, server.js, etc.
Please provide only well documented standards in answers.
NPM seems to suggest a standard whereby one can define the primary file in the package.json file like so:
"scripts": {"start": "node server.js"}
If no such property is set, NPM looks for a server.js file in the root of the package. If server.js exists, it will be run with Node.
This default seems to be a strong suggestion that the name server.js should be the standard.
index.js has a special usage in Node.js. From the Module docs.
...
If there is no package.json file present in the directory, then node
will attempt to load an index.js or index.node file out of that
directory. For example, if there was no package.json file in the above
example, then require('./some-library') would attempt to load:
./some-library/index.js
./some-library/index.node
I prefer to use app.js or even main.js
The two predominant filenames are 'app.js' & 'server.js'. Its better to go with 'server.js'. This is for nodejs applications. In the case of libraries, most libraries use 'index.js' and specify it in their 'main' param in the package.json file.
From what I have seen, app.js is the most universally accepted.
I personally prefer server.js, but this is probably biased in that I run a massive Single Page Application so all my files are .... javascript ..... and I have an app.js controller for my front-end. So it helps me distinguish the two.
do you know how well-established conventions start? you make a decision that is logical, and forthrightly forward it with resolute certainty - then others will follow. there clearly is no well established convention, so pick one and tell it to others.

Requirejs: Remove/delete build.txt after build

After successfully optimizing and building the modules using r.js library, you would find the file build.txt with the summary of all the modules and its dependencies.
I don't want this build.txt file to reach the production server.
Apart from manually deleting the build.txt, is there any way to suppress or remove this file?
Manual deletion is not the answer that I am looking for as you might forget to delete it sometimes.
As I understood the source code, there is no way to prevent the creation of the build.txt.
This feature has been requested: https://github.com/jrburke/r.js/pull/722/files
To use it, you would add the following option to your build.js file:
noBuildTxt: true
As Louis points out, it hasn't actually been added :/
If you want, you can do what I did and restructure your application so you don't need a modules property, add the noBuildTxt option and then pretend it works. (Removing the modules property was what got rid of the module definitions, not the noBuildTxt)

Resources