@form8ion/javascript 1.1.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -61
- package/example.js +48 -5
- package/lib/index.cjs.js +1400 -13
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.es.js +1396 -15
- package/lib/index.es.js.map +1 -1
- package/package.json +33 -11
- package/templates/.eslintrc.yml +3 -0
- package/templates/example.mustache +3 -0
package/README.md
CHANGED
|
@@ -17,15 +17,7 @@ toolset
|
|
|
17
17
|
* [Example](#example)
|
|
18
18
|
* [Import](#import)
|
|
19
19
|
* [Execute](#execute)
|
|
20
|
-
* [
|
|
21
|
-
* [`scaffoldUnitTesting`](#scaffoldunittesting)
|
|
22
|
-
* [`projectRoot` __string__ (_required_)](#projectroot-string-required)
|
|
23
|
-
* [`frameworks` __object__ (_required_)](#frameworks-object-required)
|
|
24
|
-
* [`decisions` __object__ (_optional_)](#decisions-object-optional)
|
|
25
|
-
* [`visibility` __string__ (_required_)](#visibility-string-required)
|
|
26
|
-
* [`vcs` __object__ (_required_)](#vcs-object-required)
|
|
27
|
-
* [`unitTestFrameworksSchema`](#unittestframeworksschema)
|
|
28
|
-
* [`questionNames`](#questionnames)
|
|
20
|
+
* [Documentation](#documentation)
|
|
29
21
|
* [Contributing](#contributing)
|
|
30
22
|
* [Dependencies](#dependencies)
|
|
31
23
|
* [Verification](#verification)
|
|
@@ -52,13 +44,45 @@ $ npm install @form8ion/javascript --save
|
|
|
52
44
|
#### Import
|
|
53
45
|
|
|
54
46
|
```javascript
|
|
55
|
-
|
|
47
|
+
const {dialects, projectTypes} = require('@form8ion/javascript-core');
|
|
48
|
+
const {scaffold: scaffoldJavaScript, scaffoldUnitTesting, questionNames} = require('./lib/index.cjs');
|
|
56
49
|
```
|
|
57
50
|
|
|
58
51
|
#### Execute
|
|
59
52
|
|
|
60
53
|
```javascript
|
|
61
54
|
(async () => {
|
|
55
|
+
const accountName = 'form8ion';
|
|
56
|
+
|
|
57
|
+
await scaffoldJavaScript({
|
|
58
|
+
projectRoot: process.cwd(),
|
|
59
|
+
projectName: 'project-name',
|
|
60
|
+
visibility: 'Public',
|
|
61
|
+
license: 'MIT',
|
|
62
|
+
configs: {
|
|
63
|
+
eslint: {scope: `@${accountName}`},
|
|
64
|
+
remark: `@${accountName}/remark-lint-preset`,
|
|
65
|
+
babelPreset: {name: `@${accountName}`, packageName: `@${accountName}/babel-preset`},
|
|
66
|
+
commitlint: {name: `@${accountName}`, packageName: `@${accountName}/commitlint-config`}
|
|
67
|
+
},
|
|
68
|
+
overrides: {npmAccount: accountName},
|
|
69
|
+
ciServices: {},
|
|
70
|
+
unitTestFrameworks: {},
|
|
71
|
+
decisions: {
|
|
72
|
+
[questionNames.DIALECT]: dialects.BABEL,
|
|
73
|
+
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
|
|
74
|
+
[questionNames.PACKAGE_MANAGER]: 'npm',
|
|
75
|
+
[questionNames.PROJECT_TYPE]: projectTypes.PACKAGE,
|
|
76
|
+
[questionNames.SHOULD_BE_SCOPED]: true,
|
|
77
|
+
[questionNames.SCOPE]: accountName,
|
|
78
|
+
[questionNames.AUTHOR_NAME]: 'Your Name',
|
|
79
|
+
[questionNames.AUTHOR_EMAIL]: 'you@domain.tld',
|
|
80
|
+
[questionNames.AUTHOR_URL]: 'https://your.website.tld',
|
|
81
|
+
[questionNames.UNIT_TESTS]: true,
|
|
82
|
+
[questionNames.INTEGRATION_TESTS]: true
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
|
|
62
86
|
await scaffoldUnitTesting({
|
|
63
87
|
projectRoot: process.cwd(),
|
|
64
88
|
frameworks: {
|
|
@@ -72,53 +96,10 @@ import {scaffoldUnitTesting, questionNames} from '@form8ion/javascript';
|
|
|
72
96
|
})();
|
|
73
97
|
```
|
|
74
98
|
|
|
75
|
-
###
|
|
76
|
-
|
|
77
|
-
#### `scaffoldUnitTesting`
|
|
78
|
-
|
|
79
|
-
Scaffolder for enabling unit-testing in a project with the ability to choose a
|
|
80
|
-
desired framework from provided options.
|
|
81
|
-
|
|
82
|
-
Takes a single options object as an argument, containing:
|
|
83
|
-
|
|
84
|
-
##### `projectRoot` __string__ (_required_)
|
|
85
|
-
|
|
86
|
-
path to the root of the project
|
|
87
|
-
|
|
88
|
-
##### `frameworks` __object__ (_required_)
|
|
89
|
-
|
|
90
|
-
A [`choices` object](https://github.com/form8ion/javascript-core#choices-object-required)
|
|
91
|
-
for defining [unit-testing framework options](https://github.com/form8ion/awesome#unit-testing-frameworks)
|
|
92
|
-
|
|
93
|
-
##### `decisions` __object__ (_optional_)
|
|
94
|
-
|
|
95
|
-
Answers for prompt questions so that the prompt is skipped at execution time
|
|
96
|
-
|
|
97
|
-
* keys: __string__ Name of the prompt question
|
|
98
|
-
* values: Hard-coded answer for the prompt question
|
|
99
|
-
|
|
100
|
-
##### `visibility` __string__ (_required_)
|
|
101
|
-
|
|
102
|
-
visibility of the project (`Public` or `Private`)
|
|
103
|
-
|
|
104
|
-
##### `vcs` __object__ (_required_)
|
|
105
|
-
|
|
106
|
-
* `host` __string__ (_required_)
|
|
107
|
-
VCS hosting service
|
|
108
|
-
* `owner` __string__ (_required_)
|
|
109
|
-
account name on the host service for the repository
|
|
110
|
-
* `name` __string__ (_required_)
|
|
111
|
-
repository name
|
|
112
|
-
|
|
113
|
-
#### `unitTestFrameworksSchema`
|
|
114
|
-
|
|
115
|
-
[joi](https://hapi.dev/module/joi/) schema for the choices required for the
|
|
116
|
-
[unit-testing scaffolder](#scaffoldunittesting)
|
|
117
|
-
|
|
118
|
-
#### `questionNames`
|
|
99
|
+
### Documentation
|
|
119
100
|
|
|
120
|
-
|
|
121
|
-
|
|
101
|
+
* [API](./docs/api)
|
|
102
|
+
* [Constants](./docs/constants)
|
|
122
103
|
|
|
123
104
|
## Contributing
|
|
124
105
|
|
|
@@ -159,11 +140,11 @@ $ npm test
|
|
|
159
140
|
|
|
160
141
|
[semantic-release-link]: https://github.com/semantic-release/semantic-release
|
|
161
142
|
|
|
162
|
-
[semantic-release-badge]: https://img.shields.io/badge
|
|
143
|
+
[semantic-release-badge]: https://img.shields.io/badge/semantic--release-angular-e10079?logo=semantic-release
|
|
163
144
|
|
|
164
145
|
[renovate-link]: https://renovatebot.com
|
|
165
146
|
|
|
166
|
-
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=
|
|
147
|
+
[renovate-badge]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg?logo=renovatebot
|
|
167
148
|
|
|
168
149
|
[github-actions-ci-link]: https://github.com/form8ion/javascript/actions?query=workflow%3A%22Node.js+CI%22+branch%3Amaster
|
|
169
150
|
|
|
@@ -175,9 +156,9 @@ $ npm test
|
|
|
175
156
|
|
|
176
157
|
[npm-link]: https://www.npmjs.com/package/@form8ion/javascript
|
|
177
158
|
|
|
178
|
-
[npm-badge]: https://img.shields.io/npm/v/@form8ion/javascript.svg
|
|
159
|
+
[npm-badge]: https://img.shields.io/npm/v/@form8ion/javascript.svg?logo=npm
|
|
179
160
|
|
|
180
|
-
[node-badge]: https://img.shields.io/node/v/@form8ion/javascript.svg
|
|
161
|
+
[node-badge]: https://img.shields.io/node/v/@form8ion/javascript.svg?logo=node.js
|
|
181
162
|
|
|
182
163
|
[runkit-link]: https://npm.runkit.com/@form8ion/javascript
|
|
183
164
|
|
|
@@ -185,4 +166,4 @@ $ npm test
|
|
|
185
166
|
|
|
186
167
|
[coverage-link]: https://codecov.io/github/form8ion/javascript
|
|
187
168
|
|
|
188
|
-
[coverage-badge]: https://img.shields.io/codecov/c/github/form8ion/javascript.svg
|
|
169
|
+
[coverage-badge]: https://img.shields.io/codecov/c/github/form8ion/javascript.svg?logo=codecov
|
package/example.js
CHANGED
|
@@ -1,14 +1,57 @@
|
|
|
1
1
|
// #### Import
|
|
2
|
-
// remark-usage-ignore-next
|
|
2
|
+
// remark-usage-ignore-next 4
|
|
3
|
+
import {resolve} from 'path';
|
|
3
4
|
import stubbedFs from 'mock-fs';
|
|
4
|
-
import
|
|
5
|
+
import td from 'testdouble';
|
|
6
|
+
import 'validate-npm-package-name';
|
|
5
7
|
|
|
6
|
-
// remark-usage-ignore-next
|
|
7
|
-
stubbedFs(
|
|
8
|
+
// remark-usage-ignore-next 9
|
|
9
|
+
stubbedFs({
|
|
10
|
+
node_modules: stubbedFs.load(resolve(...[__dirname, 'node_modules'])),
|
|
11
|
+
lib: stubbedFs.load(resolve(...[__dirname, 'lib'])),
|
|
12
|
+
templates: stubbedFs.load(resolve(...[__dirname, 'templates']))
|
|
13
|
+
});
|
|
14
|
+
const execa = td.replace('execa');
|
|
15
|
+
td.when(execa('. ~/.nvm/nvm.sh && nvm ls-remote --lts', {shell: true}))
|
|
16
|
+
.thenResolve({stdout: ['v16.5.4', ''].join('\n')});
|
|
17
|
+
td.when(execa('. ~/.nvm/nvm.sh && nvm install', {shell: true})).thenReturn({stdout: {pipe: () => undefined}});
|
|
8
18
|
|
|
9
|
-
|
|
19
|
+
const {dialects, projectTypes} = require('@form8ion/javascript-core');
|
|
20
|
+
const {scaffold: scaffoldJavaScript, scaffoldUnitTesting, questionNames} = require('./lib/index.cjs');
|
|
10
21
|
|
|
22
|
+
// #### Execute
|
|
11
23
|
(async () => {
|
|
24
|
+
const accountName = 'form8ion';
|
|
25
|
+
|
|
26
|
+
await scaffoldJavaScript({
|
|
27
|
+
projectRoot: process.cwd(),
|
|
28
|
+
projectName: 'project-name',
|
|
29
|
+
visibility: 'Public',
|
|
30
|
+
license: 'MIT',
|
|
31
|
+
configs: {
|
|
32
|
+
eslint: {scope: `@${accountName}`},
|
|
33
|
+
remark: `@${accountName}/remark-lint-preset`,
|
|
34
|
+
babelPreset: {name: `@${accountName}`, packageName: `@${accountName}/babel-preset`},
|
|
35
|
+
commitlint: {name: `@${accountName}`, packageName: `@${accountName}/commitlint-config`}
|
|
36
|
+
},
|
|
37
|
+
overrides: {npmAccount: accountName},
|
|
38
|
+
ciServices: {},
|
|
39
|
+
unitTestFrameworks: {},
|
|
40
|
+
decisions: {
|
|
41
|
+
[questionNames.DIALECT]: dialects.BABEL,
|
|
42
|
+
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
|
|
43
|
+
[questionNames.PACKAGE_MANAGER]: 'npm',
|
|
44
|
+
[questionNames.PROJECT_TYPE]: projectTypes.PACKAGE,
|
|
45
|
+
[questionNames.SHOULD_BE_SCOPED]: true,
|
|
46
|
+
[questionNames.SCOPE]: accountName,
|
|
47
|
+
[questionNames.AUTHOR_NAME]: 'Your Name',
|
|
48
|
+
[questionNames.AUTHOR_EMAIL]: 'you@domain.tld',
|
|
49
|
+
[questionNames.AUTHOR_URL]: 'https://your.website.tld',
|
|
50
|
+
[questionNames.UNIT_TESTS]: true,
|
|
51
|
+
[questionNames.INTEGRATION_TESTS]: true
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
12
55
|
await scaffoldUnitTesting({
|
|
13
56
|
projectRoot: process.cwd(),
|
|
14
57
|
frameworks: {
|