fixes, option for no tests
This commit is contained in:
parent
91869b3183
commit
c9fd021634
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Input, Confirm } from 'enquirer';
|
import { Input, Confirm } from 'enquirer';
|
||||||
|
import { scripts as standard_scripts } from '@scode/standard';
|
||||||
import { Snippet } from '../../Snippet';
|
import { Snippet } from '../../Snippet';
|
||||||
import { apply_template, modify_json, run_command } from '../../Helper';
|
import { apply_template, modify_json, run_command } from '../../Helper';
|
||||||
|
|
||||||
@ -19,24 +20,35 @@ import {
|
|||||||
* initialize the package.json
|
* initialize the package.json
|
||||||
*
|
*
|
||||||
* @param {string} folder folder
|
* @param {string} folder folder
|
||||||
|
* @param {boolean} use_ts use_ts
|
||||||
|
* @param {boolean} use_tests use_tests
|
||||||
*/
|
*/
|
||||||
async function init_package (folder: string): Promise<void> {
|
async function init_package (
|
||||||
|
folder: string,
|
||||||
|
use_ts: boolean,
|
||||||
|
use_tests: boolean
|
||||||
|
): Promise<void> {
|
||||||
await modify_json ((obj: Record<string, unknown>) => {
|
await modify_json ((obj: Record<string, unknown>) => {
|
||||||
const scripts
|
const scripts
|
||||||
= {
|
= {
|
||||||
lint: 'eslint . --ext .js,.jsx,.ts,.tsx,.vue,.mjs',
|
lint: standard_scripts.lint,
|
||||||
test: 'nyc ava',
|
test: standard_scripts.test.common,
|
||||||
compile: 'tsc --allowJs --declaration --emitDeclarationOnly index.js'
|
compile: standard_scripts.compile.common
|
||||||
};
|
};
|
||||||
const files = [ 'LICENSE' ];
|
const files = [ 'LICENSE' ];
|
||||||
|
|
||||||
if (use_ts) {
|
if (use_ts) {
|
||||||
scripts.compile = 'tsc';
|
scripts.compile = standard_scripts.compile.ts;
|
||||||
scripts.test = 'tsc && nyc ava';
|
scripts.test = standard_scripts.test.ts;
|
||||||
files.push ('/dist/');
|
files.push ('/dist/');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
files.push ('*.js', '*.d.ts');
|
files.push ('*.js', '*.d.ts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!use_tests)
|
||||||
|
scripts.test = standard_scripts.test.no;
|
||||||
|
|
||||||
obj.scripts = scripts;
|
obj.scripts = scripts;
|
||||||
obj.files = files;
|
obj.files = files;
|
||||||
return obj;
|
return obj;
|
||||||
@ -56,6 +68,12 @@ export default class Node implements Snippet {
|
|||||||
})
|
})
|
||||||
.run ();
|
.run ();
|
||||||
|
|
||||||
|
const use_tests = await new Confirm ({
|
||||||
|
message: 'use tests?',
|
||||||
|
initial: true
|
||||||
|
})
|
||||||
|
.run ();
|
||||||
|
|
||||||
await apply_template (eslintrc, path.join (folder, '.eslintrc.js'));
|
await apply_template (eslintrc, path.join (folder, '.eslintrc.js'));
|
||||||
await apply_template (npmrc, path.join (folder, '.npmrc'));
|
await apply_template (npmrc, path.join (folder, '.npmrc'));
|
||||||
await apply_template (gitignore, path.join (folder, '.gitignore'));
|
await apply_template (gitignore, path.join (folder, '.gitignore'));
|
||||||
@ -79,6 +97,6 @@ export default class Node implements Snippet {
|
|||||||
folder
|
folder
|
||||||
);
|
);
|
||||||
|
|
||||||
await init_package (folder);
|
await init_package (folder, use_ts, use_tests);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user