switch node template to jasmine
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@ -7,8 +7,9 @@
|
||||
|
||||
import path from 'path';
|
||||
import { Input, Confirm } from 'enquirer';
|
||||
import {
|
||||
scripts as standard_scripts
|
||||
import {
|
||||
scripts as standard_scripts,
|
||||
files as standard_files
|
||||
} from '@sapphirecode/standard';
|
||||
import { Snippet } from '../../Snippet';
|
||||
import { apply_template, modify_json, run_command } from '../../Helper';
|
||||
@ -18,6 +19,24 @@ import {
|
||||
tsconfig, eslintrc_ts, eslintignore
|
||||
} from './Assets';
|
||||
|
||||
|
||||
const packages = {
|
||||
common: [ '@sapphirecode/eslint-config' ],
|
||||
test: [
|
||||
'nyc',
|
||||
'jasmine',
|
||||
'@types/jasmine'
|
||||
],
|
||||
test_ts: [
|
||||
'jasmine-ts',
|
||||
'ts-node'
|
||||
],
|
||||
ts: [
|
||||
'typescript',
|
||||
'@sapphirecode/eslint-config-ts'
|
||||
]
|
||||
};
|
||||
|
||||
/**
|
||||
* initialize the package.json
|
||||
*
|
||||
@ -30,6 +49,19 @@ async function init_package (
|
||||
use_ts: boolean,
|
||||
use_tests: boolean
|
||||
): Promise<void> {
|
||||
run_command ('yarn init -y', folder);
|
||||
|
||||
const bundle = [
|
||||
...(use_ts ? packages.ts : packages.common),
|
||||
...(use_tests ? packages.test : []),
|
||||
...(use_ts && use_tests ? packages.test_ts : [])
|
||||
];
|
||||
|
||||
run_command (
|
||||
`yarn add --dev ${bundle.join (' ')}`,
|
||||
folder
|
||||
);
|
||||
|
||||
await modify_json ((obj: Record<string, unknown>) => {
|
||||
const scripts
|
||||
= {
|
||||
@ -94,13 +126,13 @@ export default class Node implements Snippet {
|
||||
);
|
||||
}
|
||||
run_command ('git init', folder);
|
||||
run_command ('yarn init -y', folder);
|
||||
run_command (
|
||||
`yarn add --dev @sapphirecode/eslint-config${use_ts
|
||||
? '-ts typescript @ava/typescript'
|
||||
: ''} eslint${use_tests ? ' nyc ava' : ''}`,
|
||||
folder
|
||||
);
|
||||
|
||||
if (use_tests) {
|
||||
apply_template (
|
||||
standard_files.jasmine,
|
||||
path.join (folder, 'jasmine.json')
|
||||
);
|
||||
}
|
||||
|
||||
await init_package (folder, use_ts, use_tests);
|
||||
}
|
||||
|
Reference in New Issue
Block a user