Skip to content

Commit 07164c2

Browse files
committed
feat(esm): convert the package to esm-only
BREAKING CHANGE: the package is no longer dual mode, but now esm-only. consumption from commonjs is no longer supported closes #440
1 parent fc9ddb2 commit 07164c2

11 files changed

+219
-2341
lines changed

.babelrc

Lines changed: 0 additions & 1 deletion
This file was deleted.

.commitlintrc.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

.commitlintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"extends": ["@form8ion"]}

.eslintrc.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@ extends:
44
- '@form8ion/mocha'
55
- '@form8ion/cucumber'
66

7-
overrides:
8-
- files: example.js
9-
rules:
10-
import/no-extraneous-dependencies: off
11-
no-console: off
7+
parserOptions:
8+
ecmaVersion: 2022

.remarkrc.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

.remarkrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"settings": {
3+
"listItemIndent": "one",
4+
"emphasis": "_",
5+
"strong": "_",
6+
"bullet": "*",
7+
"incrementListMarker": false
8+
},
9+
"plugins": [
10+
"@form8ion/remark-lint-preset",
11+
["remark-toc", {"tight": true}],
12+
["remark-usage", {"heading": "example"}]
13+
]
14+
}
File renamed without changes.

example.js

Lines changed: 67 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -2,97 +2,95 @@
22
// remark-usage-ignore-next 4
33
import {resolve} from 'path';
44
import stubbedFs from 'mock-fs';
5-
import td from 'testdouble';
5+
import * as td from 'testdouble';
66
import 'validate-npm-package-name';
77

88
// remark-usage-ignore-next 10
99
stubbedFs({
10-
node_modules: stubbedFs.load(resolve(...[__dirname, 'node_modules'])),
10+
node_modules: stubbedFs.load(resolve('node_modules')),
1111
'.nvmrc': 'v1.2.3',
12-
lib: stubbedFs.load(resolve(...[__dirname, 'lib'])),
13-
templates: stubbedFs.load(resolve(...[__dirname, 'templates']))
12+
lib: stubbedFs.load(resolve('lib')),
13+
templates: stubbedFs.load(resolve('templates'))
1414
});
1515
const execa = td.replace('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}});
1919

20-
const {dialects, projectTypes} = require('@form8ion/javascript-core');
20+
const {dialects, projectTypes} = await import('@form8ion/javascript-core');
2121
const {
2222
scaffold: scaffoldJavaScript,
2323
lift: liftJavascript,
2424
test: thisIsAJavaScriptProject,
2525
scaffoldUnitTesting,
2626
questionNames
27-
} = require('./lib/index.js');
27+
} = await import('./lib/index.js');
2828

2929
// #### Execute
30-
(async () => {
31-
const accountName = 'form8ion';
32-
const projectRoot = process.cwd();
30+
const accountName = 'form8ion';
31+
const projectRoot = process.cwd();
3332

34-
await scaffoldJavaScript({
33+
await scaffoldJavaScript({
34+
projectRoot,
35+
projectName: 'project-name',
36+
visibility: 'Public',
37+
license: 'MIT',
38+
configs: {
39+
eslint: {scope: `@${accountName}`},
40+
remark: `@${accountName}/remark-lint-preset`,
41+
babelPreset: {name: `@${accountName}`, packageName: `@${accountName}/babel-preset`},
42+
commitlint: {name: `@${accountName}`, packageName: `@${accountName}/commitlint-config`}
43+
},
44+
plugins: {
45+
unitTestFrameworks: {},
46+
applicationTypes: {},
47+
packageTypes: {},
48+
packageBundlers: {},
49+
ciServices: {}
50+
},
51+
decisions: {
52+
[questionNames.DIALECT]: dialects.BABEL,
53+
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
54+
[questionNames.PACKAGE_MANAGER]: 'npm',
55+
[questionNames.PROJECT_TYPE]: projectTypes.PACKAGE,
56+
[questionNames.SHOULD_BE_SCOPED]: true,
57+
[questionNames.SCOPE]: accountName,
58+
[questionNames.AUTHOR_NAME]: 'Your Name',
59+
[questionNames.AUTHOR_EMAIL]: '[email protected]',
60+
[questionNames.AUTHOR_URL]: 'https://your.website.tld',
61+
[questionNames.UNIT_TESTS]: true,
62+
[questionNames.INTEGRATION_TESTS]: true,
63+
[questionNames.PROVIDE_EXAMPLE]: true
64+
}
65+
});
66+
67+
if (await thisIsAJavaScriptProject({projectRoot})) {
68+
await liftJavascript({
3569
projectRoot,
36-
projectName: 'project-name',
37-
visibility: 'Public',
38-
license: 'MIT',
39-
configs: {
40-
eslint: {scope: `@${accountName}`},
41-
remark: `@${accountName}/remark-lint-preset`,
42-
babelPreset: {name: `@${accountName}`, packageName: `@${accountName}/babel-preset`},
43-
commitlint: {name: `@${accountName}`, packageName: `@${accountName}/commitlint-config`}
70+
configs: {eslint: {scope: '@foo'}},
71+
results: {
72+
dependencies: [],
73+
devDependencies: [],
74+
scripts: {},
75+
eslint: {configs: [], ignore: {directories: []}},
76+
packageManager: 'npm'
4477
},
45-
plugins: {
46-
unitTestFrameworks: {},
47-
applicationTypes: {},
48-
packageTypes: {},
49-
packageBundlers: {},
50-
ciServices: {}
51-
},
52-
decisions: {
53-
[questionNames.DIALECT]: dialects.BABEL,
54-
[questionNames.NODE_VERSION_CATEGORY]: 'LTS',
55-
[questionNames.PACKAGE_MANAGER]: 'npm',
56-
[questionNames.PROJECT_TYPE]: projectTypes.PACKAGE,
57-
[questionNames.SHOULD_BE_SCOPED]: true,
58-
[questionNames.SCOPE]: accountName,
59-
[questionNames.AUTHOR_NAME]: 'Your Name',
60-
[questionNames.AUTHOR_EMAIL]: '[email protected]',
61-
[questionNames.AUTHOR_URL]: 'https://your.website.tld',
62-
[questionNames.UNIT_TESTS]: true,
63-
[questionNames.INTEGRATION_TESTS]: true,
64-
[questionNames.PROVIDE_EXAMPLE]: true
78+
enhancers: {
79+
PluginName: {
80+
test: () => true,
81+
lift: () => ({})
82+
}
6583
}
6684
});
85+
}
6786

68-
if (await thisIsAJavaScriptProject({projectRoot})) {
69-
await liftJavascript({
70-
projectRoot,
71-
configs: {eslint: {scope: '@foo'}},
72-
results: {
73-
dependencies: [],
74-
devDependencies: [],
75-
scripts: {},
76-
eslint: {configs: [], ignore: {directories: []}},
77-
packageManager: 'npm'
78-
},
79-
enhancers: {
80-
PluginName: {
81-
test: () => true,
82-
lift: () => ({})
83-
}
84-
}
85-
});
86-
}
87-
88-
await scaffoldUnitTesting({
89-
projectRoot: process.cwd(),
90-
frameworks: {
91-
Mocha: {scaffold: options => options},
92-
Jest: {scaffold: options => options}
93-
},
94-
visibility: 'Public',
95-
vcs: {host: 'GitHub', owner: 'foo', name: 'bar'},
96-
decisions: {[questionNames.UNIT_TEST_FRAMEWORK]: 'Mocha'}
97-
});
98-
})();
87+
await scaffoldUnitTesting({
88+
projectRoot: process.cwd(),
89+
frameworks: {
90+
Mocha: {scaffold: options => options},
91+
Jest: {scaffold: options => options}
92+
},
93+
visibility: 'Public',
94+
vcs: {host: 'GitHub', owner: 'foo', name: 'bar'},
95+
decisions: {[questionNames.UNIT_TEST_FRAMEWORK]: 'Mocha'}
96+
});

0 commit comments

Comments
 (0)