1
0
mirror of synced 2025-11-08 21:07:23 +00:00

feat(CLI): implement strict, immutable, and vscode options

This commit is contained in:
Jason Dreyzehner
2018-03-11 17:00:50 -04:00
parent 583915a99e
commit 3bf7a7ea0b
2 changed files with 45 additions and 11 deletions

View File

@@ -13,13 +13,16 @@ export async function typescriptStarter(
description,
domDefinitions,
email,
install,
projectName,
nodeDefinitions,
runner,
fullName,
githubUsername,
immutable,
install,
nodeDefinitions,
projectName,
repoURL,
runner,
strict,
vscode,
workingDirectory
}: TypescriptStarterOptions,
tasks: Tasks
@@ -128,6 +131,7 @@ export async function typescriptStarter(
spinnerLicense.succeed();
const spinnerDelete = ora('Deleting unnecessary files').start();
await del([
join(projectPath, 'examples'),
join(projectPath, 'CHANGELOG.md'),
@@ -136,15 +140,25 @@ export async function typescriptStarter(
join(projectPath, 'src', 'cli'),
join(projectPath, 'src', 'types', 'cli.d.ts')
]);
if (!vscode) {
del([join(projectPath, '.vscode')]);
}
spinnerDelete.succeed();
const spinnertsconfigModule = ora('Removing traces of the CLI').start();
const spinnerTsconfigModule = ora('Removing traces of the CLI').start();
await replace({
files: join(projectPath, 'tsconfig.module.json'),
from: /,\s+\/\/ typescript-starter:[\s\S]*"src\/cli\/\*\*\/\*\.ts"/,
to: ''
});
spinnertsconfigModule.succeed();
if (vscode) {
await replace({
files: join(projectPath, '.vscode', 'launch.json'),
from: /,[\s]*\/\/ --- cut here ---[\s\S]*]/,
to: ']'
});
}
spinnerTsconfigModule.succeed();
const spinnerReadme = ora('Creating README.md').start();
renameSync(
@@ -163,6 +177,16 @@ export async function typescriptStarter(
});
spinnerReadme.succeed();
if (!strict) {
const spinnerStrict = ora(`tsconfig: disable strict`).start();
await replace({
files: join(projectPath, 'tsconfig.json'),
from: '"strict": true',
to: '// "strict": true'
});
spinnerStrict.succeed();
}
if (!domDefinitions) {
const spinnerDom = ora(`tsconfig: don't include "dom" lib`).start();
await replace({
@@ -194,6 +218,16 @@ export async function typescriptStarter(
spinnerNode.succeed();
}
if (!immutable) {
const spinnerTslint = ora(`tslint: disable tslint-immutable`).start();
await replace({
files: join(projectPath, 'tslint.json'),
from: /,[\s]*\/\* tslint-immutable rules \*\/[\s\S]*\/\* end tslint-immutable rules \*\//,
to: ''
});
spinnerTslint.succeed();
}
if (install) {
await tasks.install(runner, projectPath);
}