feat: transition from TSLint to ESLint

This commit is contained in:
Thea Schöbl
2022-06-01 12:00:53 +00:00
parent 73501e0fa3
commit 9430e10387
8 changed files with 1371 additions and 564 deletions

View File

@@ -1,3 +1,4 @@
/* eslint-disable unicorn/prefer-module */
/*
* Copyright (C) 2018, 2019 StApps
* This program is free software: you can redistribute it and/or modify it
@@ -15,7 +16,7 @@
import chalk from 'chalk';
import {execSync} from 'child_process';
import {copyFileSync, existsSync, lstatSync, PathLike, readdirSync, readFileSync} from 'fs';
import {join, resolve, sep} from 'path';
import path from 'path';
import {satisfies, valid} from 'semver';
import {isDeepStrictEqual} from 'util';
import {parse, stringify} from 'yaml';
@@ -128,7 +129,7 @@ export interface Rules {
/**
* Expected CI config
*/
ciConfig: { [k: string]: string | object; };
ciConfig: {[k: string]: string | object};
/**
* Expected dependencies
*/
@@ -152,48 +153,48 @@ export interface Rules {
/**
* Expected scripts
*/
scripts: { [k: string]: string; };
scripts: {[k: string]: string};
}
/**
* Wrapper for console.info that outputs every argument in cyan
*
* @param args Arguments to output
* @param arguments_ Arguments to output
*/
export function consoleInfo(...args: string[]): void {
args.forEach((arg) => {
export function consoleInfo(...arguments_: string[]): void {
for (const argument of arguments_) {
/* tslint:disable-next-line:no-console */
console.info(`\n${chalk.cyan(arg)}`);
});
console.info(`\n${chalk.cyan(argument)}`);
}
}
/**
* Wrapper for console.warn that outputs every argument in red
*
* @param args Arguments to output
* @param arguments_ Arguments to output
*/
export function consoleWarn(...args: string[]): void {
args.forEach((arg) => {
const lines = arg.split('\n');
export function consoleWarn(...arguments_: string[]): void {
for (const argument of arguments_) {
const lines = argument.split('\n');
/* tslint:disable-next-line:no-console */
console.warn(`\n${chalk.red.bold(lines[0])}`);
for (const line of lines.slice(1)) {
/* tslint:disable-next-line:no-console */
console.info(line);
}
});
}
}
/**
* Wrapper for console.log that outputs every argument in green
*
* @param args Arguments to output
* @param arguments_ Arguments to output
*/
export function consoleLog(...args: string[]): void {
args.forEach((arg) => {
export function consoleLog(...arguments_: string[]): void {
for (const argument of arguments_) {
/* tslint:disable-next-line:no-console */
console.log(`\n${chalk.green.bold(arg)}`);
});
console.log(`\n${chalk.green.bold(argument)}`);
}
}
/**
@@ -208,13 +209,16 @@ export function checkDependencies(rules: Rules, packageJson: PackageJSON): void
const [name, version] = dependency.split(':');
const installedVersion = packageJson.dependencies[name];
if (typeof packageJson.dependencies === 'undefined' || typeof packageJson.dependencies[name] === 'undefined') {
if (
typeof packageJson.dependencies === 'undefined' ||
typeof packageJson.dependencies[name] === 'undefined'
) {
consoleWarn(`Dependency '${name}' is missing.
Please install with 'npm install --save-exact ${name}'.`);
} else if (
typeof version !== 'undefined'
&& typeof valid(version) === 'string'
&& !satisfies(installedVersion, version)
typeof version !== 'undefined' &&
typeof valid(version) === 'string' &&
!satisfies(installedVersion, version)
) {
consoleWarn(
`Version '${installedVersion}' of dependency '${name} does not satisfy constraint '${version}'.`,
@@ -224,32 +228,31 @@ Please install with 'npm install --save-exact ${name}'.`);
}
if (typeof packageJson.devDependencies === 'object') {
for (const devDependency of rules.devDependencies) {
const [devName, devVersion] = devDependency.split(':');
let installedVersion = packageJson.devDependencies[devName];
for (const developmentDependency of rules.devDependencies) {
const [developmentName, developmentVersion] = developmentDependency.split(':');
let installedVersion = packageJson.devDependencies[developmentName];
if (typeof packageJson.dependencies === 'object') {
const [name] = devDependency.split(':');
const [name] = developmentDependency.split(':');
if (typeof packageJson.devDependencies[name] === 'string') {
installedVersion = packageJson.dependencies[name];
}
}
if (
(typeof packageJson.dependencies === 'undefined' || typeof packageJson.dependencies[devName] === 'undefined')
&& (
typeof packageJson.devDependencies === 'undefined'
|| typeof packageJson.devDependencies[devName] === 'undefined'
)
(typeof packageJson.dependencies === 'undefined' ||
typeof packageJson.dependencies[developmentName] === 'undefined') &&
(typeof packageJson.devDependencies === 'undefined' ||
typeof packageJson.devDependencies[developmentName] === 'undefined')
) {
consoleWarn(`Dev dependency '${devName}' is missing.
Please install with 'npm install --save-exact --save-dev ${devName}'.`);
consoleWarn(`Dev dependency '${developmentName}' is missing.
Please install with 'npm install --save-exact --save-dev ${developmentName}'.`);
} else if (
typeof devVersion !== 'undefined'
&& typeof valid(devVersion) === 'string'
&& !satisfies(installedVersion, devVersion)
typeof developmentVersion !== 'undefined' &&
typeof valid(developmentVersion) === 'string' &&
!satisfies(installedVersion, developmentVersion)
) {
consoleWarn(
`Version '${installedVersion}' of dev dependency '${devName} does not satisfy constraint '${devVersion}'.`,
`Version '${installedVersion}' of dev dependency '${developmentName} does not satisfy constraint '${developmentVersion}'.`,
);
}
}
@@ -259,47 +262,42 @@ Please install with 'npm install --save-exact --save-dev ${devName}'.`);
/**
* Check that configuration files are extended
*
* @param path Path, where configuration files are located
* @param configPath Path, where configuration files are located
*/
export function checkConfigurationFilesAreExtended(path: string): void {
export function checkConfigurationFilesAreExtended(configPath: string): void {
// check if configuration files are extended
['tsconfig.json', 'tslint.json'].forEach((file) => {
const fileToCheck = resolve(path, file);
for (const file of ['tsconfig.json', 'eslintrc.json']) {
const fileToCheck = path.resolve(configPath, file);
const expectedPath = `./node_modules/@openstapps/configuration/${file}`;
if (existsSync(fileToCheck)) {
const configFile = JSON.parse(readFileSync(fileToCheck)
.toString());
const configFile = JSON.parse(readFileSync(fileToCheck).toString());
const configFileExtended = (
typeof configFile.extends === 'string'
&& configFile.extends === expectedPath
)
|| (
file === 'tslint.json'
&& Array.isArray(configFile.extends)
&& configFile.extends.indexOf(expectedPath) >= 0
);
const configFileExtended =
(typeof configFile.extends === 'string' && configFile.extends === expectedPath) ||
(file === 'eslintrc.json' &&
Array.isArray(configFile.extends) &&
configFile.extends.includes('@openstapps'));
if (!configFileExtended) {
consoleWarn(`File '${fileToCheck}' should extend '${expectedPath}'!
Example:
${readFileSync(resolve(__dirname, '..', 'templates', `template-${file}`))}`);
${readFileSync(path.resolve(__dirname, '..', 'templates', `template-${file}`))}`);
}
}
});
}
}
/**
* Check needed files
*
* @param rules Rules for check
* @param path Path to files to check
* @param filePath Path to files to check
* @param replaceFlag Whether or not to replace files
* @return Whether or not overwrite is suggested
* @returns Whether or not overwrite is suggested
*/
export function checkNeededFiles(rules: Rules, path: string, replaceFlag: boolean): boolean {
export function checkNeededFiles(rules: Rules, filePath: string, replaceFlag: boolean): boolean {
let suggestOverwrite = false;
// copy needed files
@@ -308,27 +306,25 @@ export function checkNeededFiles(rules: Rules, path: string, replaceFlag: boolea
// remove templates directory for destination files
if (destinationFile.indexOf('templates') === 0) {
destinationFile = destinationFile.split(sep)
.slice(1)
.join(sep);
file = join('templates', `template-${destinationFile}`);
destinationFile = destinationFile.split(path.sep).slice(1).join(path.sep);
file = path.join('templates', `template-${destinationFile}`);
}
const source = resolve(__dirname, '..', file);
const destination = resolve(path, destinationFile);
const source = path.resolve(__dirname, '..', file);
const destination = path.resolve(filePath, destinationFile);
// check if file exists or replace flag is set
if (!existsSync(destination) || replaceFlag) {
copyFileSync(source, destination);
consoleInfo(`Copied file '${source}' to '${destination}'.`);
} else if (destinationFile === '.npmignore') {
const npmIgnore = readFileSync(destination)
.toString();
const npmIgnore = readFileSync(destination).toString();
const ignoredPatterns = npmIgnore.split('\n');
let ignoresEverything = false;
let unignoresDocs = false;
// eslint-disable-next-line unicorn/prevent-abbreviations
let includeDocs = false;
for (const ignoredPattern of ignoredPatterns) {
if (ignoredPattern === '/*') {
@@ -336,7 +332,7 @@ export function checkNeededFiles(rules: Rules, path: string, replaceFlag: boolea
}
if (ignoredPattern === '!docs') {
unignoresDocs = true;
includeDocs = true;
}
}
@@ -346,7 +342,7 @@ export function checkNeededFiles(rules: Rules, path: string, replaceFlag: boolea
suggestOverwrite = true;
}
if (unignoresDocs) {
if (includeDocs) {
consoleWarn(`'.npmignore' contains '!docs' and thus the package will contain the documentation.
Consider creating a CI job to publish those files, rather than committing this folder to the npm repo.
Please double check that this is desired behavior since the docs can become huge:
@@ -368,7 +364,7 @@ https://gitlab.com/openstapps/configuration/issues/11`);
*/
export function checkLicenses(rules: Rules, packageJson: PackageJSON): void {
// check if license is one of the expected ones
if (rules.licenses.indexOf(packageJson.license) === -1) {
if (!rules.licenses.includes(packageJson.license)) {
consoleWarn(`License should be one of '${rules.licenses.join(', ')}'!`);
}
}
@@ -379,16 +375,21 @@ export function checkLicenses(rules: Rules, packageJson: PackageJSON): void {
* @param rules Rules for check
* @param packageJson package.json to check NYC configuration in
* @param replaceFlag Whether or not to replace NYC configuration
* @return Whether or not package.json was changed and if overwrite is suggested
* @returns Whether or not package.json was changed and if overwrite is suggested
*/
export function checkNYCConfiguration(rules: Rules, packageJson: PackageJSON, replaceFlag: boolean)
: [boolean, boolean] {
export function checkNYCConfiguration(
rules: Rules,
packageJson: PackageJSON,
replaceFlag: boolean,
): [boolean, boolean] {
let packageJsonChanged = false;
let suggestOverwrite = false;
// check if nyc is a dependency
if (typeof packageJson.devDependencies === 'object' && Object.keys(packageJson.devDependencies)
.indexOf('nyc') >= 0) {
if (
typeof packageJson.devDependencies === 'object' &&
Object.keys(packageJson.devDependencies).includes('nyc')
) {
if (typeof packageJson.nyc === 'undefined' || replaceFlag) {
// add NYC configuration
packageJson.nyc = rules.nycConfiguration;
@@ -397,7 +398,9 @@ export function checkNYCConfiguration(rules: Rules, packageJson: PackageJSON, re
consoleLog(`Added NYC configuration in to 'package.json'.`);
} else if (!isDeepStrictEqual(packageJson.nyc, rules.nycConfiguration)) {
consoleInfo(`NYC configuration in 'package.json' differs from the proposed one. Please check manually.`);
consoleInfo(
`NYC configuration in 'package.json' differs from the proposed one. Please check manually.`,
);
suggestOverwrite = true;
}
@@ -412,7 +415,7 @@ export function checkNYCConfiguration(rules: Rules, packageJson: PackageJSON, re
* @param rules Rules for check
* @param packageJson package.json to check scripts in
* @param replaceFlag Whether or not to replace scripts
* @return Whether or not the package.json was changed
* @returns Whether or not the package.json was changed
*/
export function checkScripts(rules: Rules, packageJson: PackageJSON, replaceFlag: boolean): boolean {
let packageJsonChanged = false;
@@ -454,9 +457,10 @@ export function checkScripts(rules: Rules, packageJson: PackageJSON, replaceFlag
* @param packageJson package.json to check contributors in
*/
export function checkContributors(path: PathLike, packageJson: PackageJSON): void {
const execBuffer = execSync(`git --git-dir=${path}/.git --work-tree=${path} log --format=\'%aN\' | sort -u`);
for (let person of execBuffer.toString()
.split('\n')) {
const execBuffer = execSync(
`git --git-dir=${path}/.git --work-tree=${path} log --format=\'%aN\' | sort -u`,
);
for (let person of execBuffer.toString().split('\n')) {
person = person.trim();
if (person === '') {
@@ -465,11 +469,13 @@ export function checkContributors(path: PathLike, packageJson: PackageJSON): voi
let authorIsAttributed = false;
authorIsAttributed = authorIsAttributed
|| (typeof packageJson.author === 'string' && packageJson.author.indexOf(person) >= 0)
|| (Array.isArray(packageJson.contributors) && packageJson.contributors.findIndex((contributor) => {
return typeof contributor === 'string' && contributor.indexOf(person) >= 0;
}) >= 0);
authorIsAttributed =
authorIsAttributed ||
(typeof packageJson.author === 'string' && packageJson.author.includes(person)) ||
(Array.isArray(packageJson.contributors) &&
packageJson.contributors.findIndex(contributor => {
return typeof contributor === 'string' && contributor.includes(person);
}) >= 0);
if (!authorIsAttributed) {
consoleWarn(`'${person}' should be attributed as author or contributor.`);
@@ -481,23 +487,20 @@ export function checkContributors(path: PathLike, packageJson: PackageJSON): voi
* Check CI config
*
* @param rules Rules for check
* @param path Path to CI config
* @param configPath Path to CI config
*/
export function checkCIConfig(rules: Rules, path: string): void {
const pathToCiConfig = resolve(path, '.gitlab-ci.yml');
export function checkCIConfig(rules: Rules, configPath: string): void {
const pathToCiConfig = path.resolve(configPath, '.gitlab-ci.yml');
// check CI config if it exists
if (existsSync(pathToCiConfig)) {
// read CI config
const content = readFileSync(pathToCiConfig)
.toString();
const content = readFileSync(pathToCiConfig).toString();
let ciConfigWithoutTemplates = '';
for (const line of content.split('\n')) {
const match = line
.trim()
.match(/^<</);
const match = line.trim().match(/^<</);
if (match === null) {
ciConfigWithoutTemplates += `${line}\n`;
@@ -514,7 +517,7 @@ export function checkCIConfig(rules: Rules, path: string): void {
}
if (!isDeepStrictEqual(rules.ciConfig[entry], ciConfig[entry])) {
const completeEntry: { [k: string]: string | object; } = {};
const completeEntry: {[k: string]: string | object} = {};
completeEntry[entry] = rules.ciConfig[entry];
consoleWarn(`Entry '${entry}' in '${pathToCiConfig}' is incorrect. Expected value is:
${stringify(completeEntry)}`);
@@ -531,26 +534,32 @@ ${stringify(rules.ciConfig)}`);
/**
* Check copyright years in files
*
* @param path Path to project root
* @param subDir Subordinated directory to examine
* @param projectPath Path to project root
* @param checkPathFragment Subordinated directory to examine
*/
export function checkCopyrightYears(path: PathLike, subDir: PathLike): void {
const fileSystemObjects = readdirSync(resolve(path.toString(), subDir.toString()));
export function checkCopyrightYears(projectPath: PathLike, checkPathFragment: PathLike): void {
const fileSystemObjects = readdirSync(path.resolve(projectPath.toString(), checkPathFragment.toString()));
for (const fileSystemObject of fileSystemObjects) {
const fileSystemObjectPath = resolve(path.toString(), subDir.toString(), fileSystemObject);
const fileSystemObjectPath = path.resolve(
projectPath.toString(),
checkPathFragment.toString(),
fileSystemObject,
);
// tslint:disable-next-line:max-line-length
const execBuffer = execSync(`git --git-dir=${path}/.git --work-tree=${path} log --oneline --format='%cI' -- ${fileSystemObjectPath}`);
const execBuffer = execSync(
`git --git-dir=${projectPath}/.git --work-tree=${projectPath} log --oneline --format='%cI' -- ${fileSystemObjectPath}`,
);
const seen: number[] = [];
let changedYears = execBuffer
.toString()
.split('\n')
.map((date) => parseInt(date.split('-')[0], 10))
.filter((year) => {
.map(date => Number.parseInt(date.split('-')[0], 10))
.filter(year => {
const stringYear = year.toString();
if (seen.indexOf(year) >= 0 || stringYear.match(/[0-9]{4}/) === null) {
if (seen.includes(year) || stringYear.match(/[0-9]{4}/) === null) {
return false;
}
@@ -559,7 +568,7 @@ export function checkCopyrightYears(path: PathLike, subDir: PathLike): void {
return true;
})
.sort();
changedYears = [changedYears[0], changedYears[changedYears.length -1]];
changedYears = [changedYears[0], changedYears[changedYears.length - 1]];
changedYears = [...new Set(changedYears)].sort();
const fileStats = lstatSync(fileSystemObjectPath);
@@ -569,9 +578,7 @@ export function checkCopyrightYears(path: PathLike, subDir: PathLike): void {
continue;
}
const content = readFileSync(fileSystemObjectPath)
.toString()
.split('\n');
const content = readFileSync(fileSystemObjectPath).toString().split('\n');
let copyrightYearsString = '';
for (const line of content) {
@@ -587,16 +594,20 @@ export function checkCopyrightYears(path: PathLike, subDir: PathLike): void {
if (copyrightYearsString === '') {
consoleWarn(`Copyright line for file '${fileSystemObjectPath}' could not be found!`);
} else {
const copyrightYearsWithIntervals = copyrightYearsString.split('-')
.map((year) => year.trim());
const copyrightYears: number[] = copyrightYearsWithIntervals.map(year => parseInt(year, 10))
.sort();
const copyrightYearsWithIntervals = copyrightYearsString.split('-').map(year => year.trim());
const copyrightYears: number[] = copyrightYearsWithIntervals
.map(year => Number.parseInt(year, 10))
.sort();
let copyrightYearNeedsUpdate = false;
if (typeof copyrightYears[0] !== 'undefined' && typeof changedYears[0] !== 'undefined') {
copyrightYearNeedsUpdate = copyrightYears[0] !== changedYears[0];
}
if (typeof copyrightYears[1] !== 'undefined' && typeof changedYears[1] !== 'undefined' && !copyrightYearNeedsUpdate) {
if (
typeof copyrightYears[1] !== 'undefined' &&
typeof changedYears[1] !== 'undefined' &&
!copyrightYearNeedsUpdate
) {
copyrightYearNeedsUpdate = copyrightYears[1] !== changedYears[1];
}
if (copyrightYears.length !== changedYears.length) {
@@ -605,11 +616,16 @@ export function checkCopyrightYears(path: PathLike, subDir: PathLike): void {
if (copyrightYearNeedsUpdate) {
// tslint:disable-next-line:max-line-length
consoleWarn(`File '${join(subDir.toString(), fileSystemObject)}' has to specify '${changedYears.join('-')}' as year(s) in the copyright line.`);
consoleWarn(
`File '${path.join(
checkPathFragment.toString(),
fileSystemObject,
)}' has to specify '${changedYears.join('-')}' as year(s) in the copyright line.`,
);
}
}
} else if (fileStats.isDirectory()) {
checkCopyrightYears(path, join(subDir.toString(), fileSystemObject));
checkCopyrightYears(projectPath, path.join(checkPathFragment.toString(), fileSystemObject));
}
}
}
@@ -651,152 +667,114 @@ export function getRules(configuration: Configuration): Rules {
// expected dev dependencies
const devDependencies = [
'@typescript-eslint/eslint-plugin',
'@typescript-eslint/parser',
'@openstapps/eslint-config',
'conventional-changelog-cli',
'tslint',
'typescript:3.8.3',
'eslint',
'eslint-config-prettier',
'eslint-plugin-jsdoc',
'eslint-plugin-prettier',
'eslint-plugin-unicorn',
'prettier',
'typescript:4.4.4',
];
// files that need to be copied
const files = [
'.editorconfig',
join('templates', '.gitignore'),
join('templates', 'tsconfig.json'),
join('templates', 'tslint.json'),
'.eslintrc.json',
'.eslintignore',
path.join('templates', '.gitignore'),
path.join('templates', 'tsconfig.json'),
];
// configuration for nyc to add to package.json
const nycConfiguration: NYCConfiguration = {
all: true,
branches: 95,
'all': true,
'branches': 95,
'check-coverage': true,
exclude: [
'src/cli.ts',
],
extension: [
'.ts',
],
functions: 95,
include: [
'src',
],
lines: 95,
'exclude': ['src/cli.ts'],
'extension': ['.ts'],
'functions': 95,
'include': ['src'],
'lines': 95,
'per-file': true,
reporter: [
'html',
'text-summary',
],
require: [
'ts-node/register',
],
statements: 95,
'reporter': ['html', 'text-summary'],
'require': ['ts-node/register'],
'statements': 95,
};
// expected scripts
const scripts: { [k: string]: string; } = {
const scripts: {[k: string]: string} = {
/* tslint:disable-next-line:max-line-length */
changelog: 'conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m \'docs: update changelog\'',
'changelog':
"conventional-changelog -p angular -i CHANGELOG.md -s -r 0 && git add CHANGELOG.md && git commit -m 'docs: update changelog'",
'check-configuration': 'openstapps-configuration',
postversion: 'npm run changelog',
preversion: 'npm run prepublishOnly',
push: 'git push && git push origin "v$npm_package_version"',
tslint: 'tslint -p tsconfig.json -c tslint.json \'src/**/*.ts\'',
'postversion': 'npm run changelog',
'preversion': 'npm run prepublishOnly',
'push': 'git push && git push origin "v$npm_package_version"',
'lint': 'eslint --ext .ts src/',
};
// list of expected licenses
const licenses = [
'AGPL-3.0-only',
'GPL-3.0-only',
];
const licenses = ['AGPL-3.0-only', 'GPL-3.0-only'];
// expected values in CI config
const ciConfig = {
/* tslint:disable:object-literal-sort-keys */
image: 'registry.gitlab.com/openstapps/projectmanagement/node',
before_script: 'npm ci',
build: {
'image': 'registry.gitlab.com/openstapps/projectmanagement/node',
'before_script': 'npm ci',
'build': {
stage: 'build',
script: [
'npm run build',
],
script: ['npm run build'],
artifacts: {
paths: [
'lib',
],
paths: ['lib'],
},
},
audit: {
'audit': {
allow_failure: true,
except: [
'schedules',
],
script: [
'npm audit',
],
except: ['schedules'],
script: ['npm audit'],
stage: 'audit',
},
'scheduled-audit': {
only: [
'schedules',
],
script: [
'npm audit --audit-level=high',
],
only: ['schedules'],
script: ['npm audit --audit-level=high'],
stage: 'audit',
},
package: {
dependencies: [
'build',
],
tags: [
'secrecy',
],
'package': {
dependencies: ['build'],
tags: ['secrecy'],
stage: 'publish',
script: [
'echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc',
'npm publish',
],
only: [
'/^v[0-9]+\.[0-9]+\.[0-9]+$/',
],
script: ['echo "//registry.npmjs.org/:_authToken=$NPM_AUTH_TOKEN" > ~/.npmrc', 'npm publish'],
only: ['/^v[0-9]+.[0-9]+.[0-9]+$/'],
artifacts: {
paths: [
'lib',
],
paths: ['lib'],
},
},
pages: {
'pages': {
artifacts: {
'paths': [
'public',
],
paths: ['public'],
},
only: [
'/^v[0-9]+\\.[0-9]+\\.[0-9]+$/',
],
script: [
'npm run documentation',
'mv docs public',
],
only: ['/^v[0-9]+\\.[0-9]+\\.[0-9]+$/'],
script: ['npm run documentation', 'mv docs public'],
stage: 'deploy',
},
/* tslint:enable */
};
for (const ignoreCiEntry of configuration.ignoreCiEntries) {
// tslint:disable-next-line:ban-ts-ignore
// @ts-ignore
// @ts-expect-error can't be used to index
delete ciConfig[ignoreCiEntry];
}
if (configuration.forPackaging) {
scripts.prepublishOnly = 'npm ci && npm run build';
files.push(
join('templates', '.npmignore'),
);
files.push(path.join('templates', '.npmignore'));
} else {
// tslint:disable-next-line:ban-ts-ignore
// @ts-ignore
// @ts-expect-error can't be used to index
delete ciConfig[`package`];
}
@@ -805,20 +783,21 @@ export function getRules(configuration: Configuration): Rules {
}
if (configuration.standardBuild || configuration.hasCli) {
scripts.build = 'npm run tslint && npm run compile';
scripts.build = 'npm run lint && npm run compile';
scripts.compile = 'rimraf lib && tsc';
devDependencies.push('rimraf');
if (configuration.hasCli) {
devDependencies.push('prepend-file-cli');
scripts.compile += ' && prepend lib/cli.js \'#!/usr/bin/env node\n\'';
scripts.compile += " && prepend lib/cli.js '#!/usr/bin/env node\n'";
}
}
if (configuration.standardDocumentation) {
devDependencies.push('typedoc');
/* tslint:disable-next-line:max-line-length */
scripts.documentation = 'typedoc --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks src';
scripts.documentation =
'typedoc --includeDeclarations --mode modules --out docs --readme README.md --listInvalidSymbolLinks --entryPointStrategy expand src';
}
for (const ignoreScript of configuration.ignoreScripts) {