switch node template to jasmine
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timo Hocker 2020-09-24 12:08:31 +02:00
parent d3a568cfe4
commit da8c39c91b
5 changed files with 49 additions and 17 deletions

View File

@ -1,6 +1,6 @@
# @sapphirecode/snippeteer # @sapphirecode/snippeteer
version: 1.4.x version: 1.5.x
macros for setting up projects or project parts macros for setting up projects or project parts

View File

@ -13,7 +13,7 @@ export class FileMapper {
public static async map_all_files ( public static async map_all_files (
folder: string, folder: string,
mutator: (data: string, file: string, args: Array<unknown>) => string|null, mutator: (data: string, file: string, args: Array<unknown>) => string|null,
args: Array<unknown> = [] opts: Array<unknown> = []
): Promise<void> { ): Promise<void> {
const files = await fs.readdir (folder); const files = await fs.readdir (folder);
for (const file of files) { for (const file of files) {
@ -21,11 +21,11 @@ export class FileMapper {
continue; continue;
const abs_path = path.join (folder, file); const abs_path = path.join (folder, file);
if ((await fs.stat (abs_path)).isDirectory ()) { if ((await fs.stat (abs_path)).isDirectory ()) {
await FileMapper.map_all_files (abs_path, mutator, args); await FileMapper.map_all_files (abs_path, mutator, opts);
continue; continue;
} }
const data = await fs.readFile (abs_path, 'utf-8'); const data = await fs.readFile (abs_path, 'utf-8');
const res = mutator (data, file, args); const res = mutator (data, file, opts);
if (res === null) if (res === null)
continue; continue;
await fs.writeFile (abs_path, res, 'utf-8'); await fs.writeFile (abs_path, res, 'utf-8');

View File

@ -8,7 +8,8 @@
import path from 'path'; import path from 'path';
import { Input, Confirm } from 'enquirer'; import { Input, Confirm } from 'enquirer';
import { import {
scripts as standard_scripts scripts as standard_scripts,
files as standard_files
} from '@sapphirecode/standard'; } from '@sapphirecode/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';
@ -18,6 +19,24 @@ import {
tsconfig, eslintrc_ts, eslintignore tsconfig, eslintrc_ts, eslintignore
} from './Assets'; } 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 * initialize the package.json
* *
@ -30,6 +49,19 @@ async function init_package (
use_ts: boolean, use_ts: boolean,
use_tests: boolean use_tests: boolean
): Promise<void> { ): 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>) => { await modify_json ((obj: Record<string, unknown>) => {
const scripts const scripts
= { = {
@ -94,13 +126,13 @@ export default class Node implements Snippet {
); );
} }
run_command ('git init', folder); run_command ('git init', folder);
run_command ('yarn init -y', folder);
run_command ( if (use_tests) {
`yarn add --dev @sapphirecode/eslint-config${use_ts apply_template (
? '-ts typescript @ava/typescript' standard_files.jasmine,
: ''} eslint${use_tests ? ' nyc ava' : ''}`, path.join (folder, 'jasmine.json')
folder );
); }
await init_package (folder, use_ts, use_tests); await init_package (folder, use_ts, use_tests);
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "@sapphirecode/snippeteer", "name": "@sapphirecode/snippeteer",
"version": "1.4.7", "version": "1.5.0",
"description": "macros for setting up projects or project parts", "description": "macros for setting up projects or project parts",
"main": "index.js", "main": "index.js",
"bin": { "bin": {

View File

@ -107,9 +107,9 @@
eslint-plugin-sort-requires-by-path "^1.0.2" eslint-plugin-sort-requires-by-path "^1.0.2"
"@sapphirecode/standard@^1.0.1": "@sapphirecode/standard@^1.0.1":
version "1.4.0" version "1.4.1"
resolved "https://registry.yarnpkg.com/@sapphirecode/standard/-/standard-1.4.0.tgz#c191bf818b311a18b9765a072cd6a4acd21731f7" resolved "https://registry.yarnpkg.com/@sapphirecode/standard/-/standard-1.4.1.tgz#9d02b8648a76feeb591dc0df428aa7973963f47b"
integrity sha512-IDxqRc2z5K7O25lUVkx+dlwE+3C2mJIZd6YUU/9KjJKnsz7iaFDzoSkFFPJLqHmuZ+uq0dPLEo59C6bdf/Dj7w== integrity sha512-ecxRNxcNGvdzHaSMgdRR5XP/kk/PmiC08zzev9rc/vruTj6L/yZwLI7bgWnbimFab2CbD21ExufFTDOiMIp9Vg==
"@types/color-name@^1.1.1": "@types/color-name@^1.1.1":
version "1.1.1" version "1.1.1"