@form8ion/javascript 2.0.0-alpha.1 → 2.0.0
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 +37 -50
- package/example.js +48 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,14 +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
|
-
* [`questionNames`](#questionnames)
|
|
20
|
+
* [Documentation](#documentation)
|
|
28
21
|
* [Contributing](#contributing)
|
|
29
22
|
* [Dependencies](#dependencies)
|
|
30
23
|
* [Verification](#verification)
|
|
@@ -51,13 +44,45 @@ $ npm install @form8ion/javascript --save
|
|
|
51
44
|
#### Import
|
|
52
45
|
|
|
53
46
|
```javascript
|
|
54
|
-
|
|
47
|
+
const {dialects, projectTypes} = require('@form8ion/javascript-core');
|
|
48
|
+
const {scaffold: scaffoldJavaScript, scaffoldUnitTesting, questionNames} = require('./lib/index.cjs');
|
|
55
49
|
```
|
|
56
50
|
|
|
57
51
|
#### Execute
|
|
58
52
|
|
|
59
53
|
```javascript
|
|
60
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
|
+
|
|
61
86
|
await scaffoldUnitTesting({
|
|
62
87
|
projectRoot: process.cwd(),
|
|
63
88
|
frameworks: {
|
|
@@ -71,48 +96,10 @@ import {scaffoldUnitTesting, questionNames} from '@form8ion/javascript';
|
|
|
71
96
|
})();
|
|
72
97
|
```
|
|
73
98
|
|
|
74
|
-
###
|
|
75
|
-
|
|
76
|
-
#### `scaffoldUnitTesting`
|
|
77
|
-
|
|
78
|
-
Scaffolder for enabling unit-testing in a project with the ability to choose a
|
|
79
|
-
desired framework from provided options.
|
|
80
|
-
|
|
81
|
-
Takes a single options object as an argument, containing:
|
|
82
|
-
|
|
83
|
-
##### `projectRoot` __string__ (_required_)
|
|
84
|
-
|
|
85
|
-
path to the root of the project
|
|
86
|
-
|
|
87
|
-
##### `frameworks` __object__ (_required_)
|
|
88
|
-
|
|
89
|
-
A [`choices` object](https://github.com/form8ion/javascript-core#choices-object-required)
|
|
90
|
-
for defining [unit-testing framework options](https://github.com/form8ion/awesome#unit-testing-frameworks)
|
|
91
|
-
|
|
92
|
-
##### `decisions` __object__ (_optional_)
|
|
93
|
-
|
|
94
|
-
Answers for prompt questions so that the prompt is skipped at execution time
|
|
95
|
-
|
|
96
|
-
* keys: __string__ Name of the prompt question
|
|
97
|
-
* values: Hard-coded answer for the prompt question
|
|
98
|
-
|
|
99
|
-
##### `visibility` __string__ (_required_)
|
|
100
|
-
|
|
101
|
-
visibility of the project (`Public` or `Private`)
|
|
102
|
-
|
|
103
|
-
##### `vcs` __object__ (_required_)
|
|
104
|
-
|
|
105
|
-
* `host` __string__ (_required_)
|
|
106
|
-
VCS hosting service
|
|
107
|
-
* `owner` __string__ (_required_)
|
|
108
|
-
account name on the host service for the repository
|
|
109
|
-
* `name` __string__ (_required_)
|
|
110
|
-
repository name
|
|
111
|
-
|
|
112
|
-
#### `questionNames`
|
|
99
|
+
### Documentation
|
|
113
100
|
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
* [API](./docs/api)
|
|
102
|
+
* [Constants](./docs/constants)
|
|
116
103
|
|
|
117
104
|
## Contributing
|
|
118
105
|
|
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: {
|