javascript-scaffolder
opinionated scaffolder for JavaScript projects
Table of Contents
- Features
-
Usage
- Installation
-
As one of the languages for scaffolding a project
- Example
-
Options
projectRoot
string (required)projectName
string (required)visibility
string (required)license
string (required)vcs
object (required)description
string (optional)configs
object (optional)overrides
object (optional)registries
object (optional)ciServices
object (optional)applicationTypes
object (optional)unitTestFrameworks
object (required)
- Contributing
- Related Projects
Features
- Sets the node.js version to the latest or LTS version (your choice) using nvm
- Scaffolds the
package.json
- Enables linting of:
- JavaScript with ESLint
- Markdown with remark-lint
- Peer-dependency compatibiltiy (by running
npm ls
and ensuring a0
exit code) - Sensitive files to prevent commiting secrets using ban-sensitive-files
- The
.travis.yml
using travis-lint, when Travis is the chosen CI
- Enables linting of:
- Enables transpilation with Babel
- Defines and enforces the commit message convention
- Defines badges for inclusion in the
README.md
- Defines files to be ignored from
git
andnpm
- Scaffolds CI service config from the user choice of the provided scaffolders
Usage
Installation
$ npm install @travi/javascript-scaffolder --save-prod
As one of the languages for scaffolding a project
This scaffolder is intended to be used to scaffold the language specific details within the project-scaffolder.
Example
Dependencies:
import yargs from 'yargs';
import {scaffold} from '@form8ion/project';
import {scaffold as scaffoldJavaScript} from './lib/index.cjs';
Register with yargs
yargs
.scriptName('form8ion-utils')
.usage('Usage: $0 <cmd> [args]')
.command('scaffold', 'Scaffold a new project', () => scaffold({
languages: {
JavaScript: options => scaffoldJavaScript({
...options,
configs: {
eslint: {scope: '@form8ion'},
remark: '@form8ion/remark-lint-preset',
babelPreset: {name: '@form8ion', packageName: '@form8ion/babel-preset'},
commitlint: {name: '@form8ion', packageName: '@form8ion/commitlint-config'}
},
overrides: {npmAccount: 'form8ion'},
ciServices: {}
})
},
overrides: {copyrightHolder: 'Matt Travi'}
}))
.help('h')
.alias('h', 'help')
.argv;
Options
projectRoot
string (required)
path to the root of the project
projectName
string (required)
name of the project (w/o a scope)
visibility
string (required)
visibility of the project (Public
or Private
)
license
string (required)
vcs
object (required)
-
host
string (required) VCS hosting service -
owner
string (required) account name on the host service for the repository -
name
string (required) repository name
description
string (optional)
short summary of the project
configs
object (optional)
-
eslint
: object (optional) details about the shareable config to be used for the project-
packageName
string (required) name of thenpm
package -
prefix
string (required) name to be used when referring to the config within the.eslintrc
files
⚠️ while i'm not confident that it is the recommended convention, it is assumed the defined config has arules/
directory exposed from the package with rulesets defined fores6.js
tests/base.js
tests/mocha.js
-
-
commitlint
object (optional) details about the shareable config to be used for the project-
packageName
string (required) name of thenpm
package -
name
string (required) name to be used when referring to the config within the.commitlintrc.js
file
-
-
babelPreset
object (optional) details about the preset to be used for the project-
packageName
string (required) name of thenpm
package -
name
string (required) shorthand name to be used when referring to the config
-
overrides
object (optional)
-
npmAccount
string (optional) the account the package should be published under. used to suggest a scope. defaults to$ npm whoami
-
author
object (optional) details about the package author-
name
string (required) defaults to$npm config get init.author.name
-
email
string (optional) defaults to$npm config get init.author.email
-
url
string (optional) defaults to$npm config get init.author.url
-
registries
object (optional)
- keys: string Scope of packages related to this registry (without the
@
) - values: string URL for the registry
ciServices
object (optional)
- keys: string Name of the service
- values: object
-
scaffolder
: function (required) scaffolds the ci service options -
public
: boolean (optional) whether this service should be presented as a public option -
private
: boolean (optional) whether this service should be presented as a private option
-
applicationTypes
object (optional)
- keys: string Name of the type of application
- values: object
-
scaffolder
function (required) scaffolds the application
-
unitTestFrameworks
object (required)
frameworks to be passed to the unit-testing scaffolder
Contributing
Dependencies
$ nvm install
$ npm install
Verification
$ npm test