Skip to content

Commit f042029

Browse files
committed
docs(lift): capture adjustment to expected dependencies shape
1 parent 57ea6cd commit f042029

File tree

3 files changed

+68
-71
lines changed

3 files changed

+68
-71
lines changed

README.md

+63-66
Original file line numberDiff line numberDiff line change
@@ -46,88 +46,85 @@ $ npm install @form8ion/javascript --save
4646
#### Import
4747

4848
```javascript
49-
const {dialects, projectTypes} = require('@form8ion/javascript-core');
49+
const {dialects, projectTypes} = await import('@form8ion/javascript-core');
5050
const {
5151
scaffold: scaffoldJavaScript,
5252
lift: liftJavascript,
5353
test: thisIsAJavaScriptProject,
5454
scaffoldUnitTesting,
5555
questionNames
56-
} = require('@form8ion/javascript');
56+
} = await import('./lib/index.js');
5757
```
5858

5959
#### Execute
6060

6161
```javascript
62-
(async () => {
63-
const accountName = 'form8ion';
64-
const projectRoot = process.cwd();
62+
const accountName = 'form8ion';
63+
const projectRoot = process.cwd();
64+
65+
await scaffoldJavaScript({
66+
projectRoot,
67+
projectName: 'project-name',
68+
visibility: 'Public',
69+
license: 'MIT',
70+
configs: {
71+
eslint: {scope: `@${accountName}`},
72+
remark: `@${accountName}/remark-lint-preset`,
73+
babelPreset: {name: `@${accountName}`, packageName: `@${accountName}/babel-preset`},
74+
commitlint: {name: `@${accountName}`, packageName: `@${accountName}/commitlint-config`}
75+
},
76+
plugins: {
77+
unitTestFrameworks: {},
78+
applicationTypes: {},
79+
packageTypes: {},
80+
packageBundlers: {},
81+
ciServices: {}
82+
},
83+
decisions: {
84+
[questionNames.DIALECT]: dialects.BABEL,
85+
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
86+
[questionNames.PACKAGE_MANAGER]: 'npm',
87+
[questionNames.PROJECT_TYPE]: projectTypes.PACKAGE,
88+
[questionNames.SHOULD_BE_SCOPED]: true,
89+
[questionNames.SCOPE]: accountName,
90+
[questionNames.AUTHOR_NAME]: 'Your Name',
91+
[questionNames.AUTHOR_EMAIL]: '[email protected]',
92+
[questionNames.AUTHOR_URL]: 'https://your.website.tld',
93+
[questionNames.UNIT_TESTS]: true,
94+
[questionNames.INTEGRATION_TESTS]: true,
95+
[questionNames.PROVIDE_EXAMPLE]: true
96+
}
97+
});
6598

66-
await scaffoldJavaScript({
99+
if (await thisIsAJavaScriptProject({projectRoot})) {
100+
await liftJavascript({
67101
projectRoot,
68-
projectName: 'project-name',
69-
visibility: 'Public',
70-
license: 'MIT',
71-
configs: {
72-
eslint: {scope: `@${accountName}`},
73-
remark: `@${accountName}/remark-lint-preset`,
74-
babelPreset: {name: `@${accountName}`, packageName: `@${accountName}/babel-preset`},
75-
commitlint: {name: `@${accountName}`, packageName: `@${accountName}/commitlint-config`}
76-
},
77-
plugins: {
78-
unitTestFrameworks: {},
79-
applicationTypes: {},
80-
packageTypes: {},
81-
packageBundlers: {},
82-
ciServices: {}
102+
configs: {eslint: {scope: '@foo'}},
103+
results: {
104+
dependencies: {javascript: {production: [], development: []}},
105+
scripts: {},
106+
eslint: {configs: [], ignore: {directories: []}},
107+
packageManager: 'npm'
83108
},
84-
decisions: {
85-
[questionNames.DIALECT]: dialects.BABEL,
86-
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
87-
[questionNames.PACKAGE_MANAGER]: 'npm',
88-
[questionNames.PROJECT_TYPE]: projectTypes.PACKAGE,
89-
[questionNames.SHOULD_BE_SCOPED]: true,
90-
[questionNames.SCOPE]: accountName,
91-
[questionNames.AUTHOR_NAME]: 'Your Name',
92-
[questionNames.AUTHOR_EMAIL]: '[email protected]',
93-
[questionNames.AUTHOR_URL]: 'https://your.website.tld',
94-
[questionNames.UNIT_TESTS]: true,
95-
[questionNames.INTEGRATION_TESTS]: true,
96-
[questionNames.PROVIDE_EXAMPLE]: true
97-
}
98-
});
99-
100-
if (await thisIsAJavaScriptProject({projectRoot})) {
101-
await liftJavascript({
102-
projectRoot,
103-
configs: {eslint: {scope: '@foo'}},
104-
results: {
105-
dependencies: [],
106-
devDependencies: [],
107-
scripts: {},
108-
eslint: {configs: [], ignore: {directories: []}},
109-
packageManager: 'npm'
110-
},
111-
enhancers: {
112-
PluginName: {
113-
test: () => true,
114-
lift: () => ({})
115-
}
109+
enhancers: {
110+
PluginName: {
111+
test: () => true,
112+
lift: () => ({})
116113
}
117-
});
118-
}
119-
120-
await scaffoldUnitTesting({
121-
projectRoot: process.cwd(),
122-
frameworks: {
123-
Mocha: {scaffold: options => options},
124-
Jest: {scaffold: options => options}
125-
},
126-
visibility: 'Public',
127-
vcs: {host: 'GitHub', owner: 'foo', name: 'bar'},
128-
decisions: {[questionNames.UNIT_TEST_FRAMEWORK]: 'Mocha'}
114+
}
129115
});
130-
})();
116+
}
117+
118+
await scaffoldUnitTesting({
119+
projectRoot: process.cwd(),
120+
frameworks: {
121+
Mocha: {scaffold: options => options},
122+
Jest: {scaffold: options => options}
123+
},
124+
visibility: 'Public',
125+
vcs: {host: 'GitHub', owner: 'foo', name: 'bar'},
126+
decisions: {[questionNames.UNIT_TEST_FRAMEWORK]: 'Mocha'}
127+
});
131128
```
132129

133130
### Documentation

docs/api/scaffold.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Language scaffolder for JavaScript projects
88
* [`projectRoot` __string__ (_required_)](#projectroot-string-required)
99
* [`projectName` __string__ (_required_)](#projectname-string-required)
1010
* [`description` __string__ (_optional_)](#description-string-optional)
11-
* [`pathWithinParent` __string__ (_required_)](#pathwithinparent-string-required)
11+
* [`pathWithinParent` __string__ (_optional_)](#pathwithinparent-string-optional)
1212
* [`license` __string__ (_required_)](#license-string-required)
1313
* [`decisions` __object__ (_optional_)](#decisions-object-optional)
1414
* [`visibility` __string__ (_required_)](#visibility-string-required)

example.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import stubbedFs from 'mock-fs';
55
import * as td from 'testdouble';
66
import 'validate-npm-package-name';
77

8-
// remark-usage-ignore-next 10
8+
// remark-usage-ignore-next 11
99
stubbedFs({
1010
node_modules: stubbedFs.load(resolve('node_modules')),
1111
'.nvmrc': 'v1.2.3',
1212
lib: stubbedFs.load(resolve('lib')),
1313
templates: stubbedFs.load(resolve('templates'))
1414
});
15-
const execa = td.replace('execa');
15+
const {execa} = await td.replaceEsm('execa');
1616
td.when(execa('. ~/.nvm/nvm.sh && nvm ls-remote --lts', {shell: true}))
1717
.thenResolve({stdout: ['v16.5.4', ''].join('\n')});
1818
td.when(execa('. ~/.nvm/nvm.sh && nvm install', {shell: true})).thenReturn({stdout: {pipe: () => undefined}});
19+
td.when(execa('npm', ['--version'])).thenResolve({stdout: '10.6.18'});
1920

2021
const {dialects, projectTypes} = await import('@form8ion/javascript-core');
2122
const {
@@ -69,8 +70,7 @@ if (await thisIsAJavaScriptProject({projectRoot})) {
6970
projectRoot,
7071
configs: {eslint: {scope: '@foo'}},
7172
results: {
72-
dependencies: [],
73-
devDependencies: [],
73+
dependencies: {javascript: {production: [], development: []}},
7474
scripts: {},
7575
eslint: {configs: [], ignore: {directories: []}},
7676
packageManager: 'npm'

0 commit comments

Comments
 (0)