update packages, replace chalk with colorette

This commit is contained in:
Kim Biesbjerg 2019-06-11 12:50:08 +02:00
parent 141eaca7b1
commit d07d81681e
3 changed files with 1159 additions and 801 deletions

1891
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -47,30 +47,29 @@
},
"config": {},
"devDependencies": {
"@types/chai": "4.0.1",
"@types/glob": "5.0.30",
"@types/mocha": "2.2.41",
"@types/cheerio": "0.22.1",
"@types/chalk": "0.4.31",
"@types/chai": "4.1.7",
"@types/cheerio": "0.22.11",
"@types/flat": "0.0.28",
"@types/yargs": "8.0.0",
"@types/mkdirp": "0.3.29",
"chai": "4.0.2",
"mocha": "3.4.2",
"ts-node": "3.1.0",
"tslint": "5.4.3",
"tslint-eslint-rules": "4.1.1"
"@types/glob": "7.1.1",
"@types/mkdirp": "0.5.2",
"@types/mocha": "5.2.7",
"@types/yargs": "13.0.0",
"chai": "4.2.0",
"mocha": "6.1.4",
"ts-node": "8.2.0",
"tslint": "5.17.0",
"tslint-eslint-rules": "5.4.0"
},
"dependencies": {
"chalk": "2.0.1",
"yargs": "8.0.2",
"cheerio": "1.0.0-rc.2",
"cheerio": "1.0.0-rc.3",
"colorette": "^1.0.8",
"flat": "4.1.0",
"fs": "0.0.1-security",
"gettext-parser": "1.2.2",
"glob": "7.1.2",
"path": "0.12.7",
"gettext-parser": "4.0.0",
"glob": "7.1.4",
"mkdirp": "0.5.1",
"flat": "2.0.1",
"typescript": "2.4.1"
"path": "0.12.7",
"typescript": "3.5.1",
"yargs": "13.2.4"
}
}

View File

@ -3,7 +3,7 @@ import { TaskInterface } from './task.interface';
import { ParserInterface } from '../../parsers/parser.interface';
import { CompilerInterface } from '../../compilers/compiler.interface';
import * as chalk from 'chalk';
import { green, bold, gray, dim } from 'colorette';
import * as glob from 'glob';
import * as fs from 'fs';
import * as path from 'path';
@ -43,7 +43,7 @@ export class ExtractTask implements TaskInterface {
}
const collection = this._extract();
this._out(chalk.green('Extracted %d strings\n'), collection.count());
this._out(green('Extracted %d strings\n'), collection.count());
this._save(collection);
}
@ -61,12 +61,12 @@ export class ExtractTask implements TaskInterface {
* Extract strings from input dirs using configured parsers
*/
protected _extract(): TranslationCollection {
this._out(chalk.bold('Extracting strings...'));
this._out(bold('Extracting strings...'));
let collection: TranslationCollection = new TranslationCollection();
this._input.forEach(dir => {
this._readDir(dir, this._options.patterns).forEach(path => {
this._options.verbose && this._out(chalk.gray('- %s'), path);
this._options.verbose && this._out(gray('- %s'), path);
const contents: string = fs.readFileSync(path, 'utf-8');
this._parsers.forEach((parser: ParserInterface) => {
collection = collection.union(parser.extract(contents, path));
@ -95,13 +95,13 @@ export class ExtractTask implements TaskInterface {
const outputPath: string = path.join(dir, filename);
let processedCollection: TranslationCollection = collection;
this._out(chalk.bold('\nSaving: %s'), outputPath);
this._out(bold('\nSaving: %s'), outputPath);
if (fs.existsSync(outputPath) && !this._options.replace) {
const existingCollection: TranslationCollection = this._compiler.parse(fs.readFileSync(outputPath, 'utf-8'));
if (!existingCollection.isEmpty()) {
processedCollection = processedCollection.union(existingCollection);
this._out(chalk.dim('- merged with %d existing strings'), existingCollection.count());
this._out(dim('- merged with %d existing strings'), existingCollection.count());
}
if (this._options.clean) {
@ -109,23 +109,23 @@ export class ExtractTask implements TaskInterface {
processedCollection = processedCollection.intersect(collection);
const removeCount = collectionCount - processedCollection.count();
if (removeCount > 0) {
this._out(chalk.dim('- removed %d obsolete strings'), removeCount);
this._out(dim('- removed %d obsolete strings'), removeCount);
}
}
}
if (this._options.sort) {
processedCollection = processedCollection.sort();
this._out(chalk.dim('- sorted strings'));
this._out(dim('- sorted strings'));
}
if (!fs.existsSync(dir)) {
mkdirp.sync(dir);
this._out(chalk.dim('- created dir: %s'), dir);
this._out(dim('- created dir: %s'), dir);
}
fs.writeFileSync(outputPath, this._compiler.compile(processedCollection));
this._out(chalk.green('Done!'));
this._out(green('Done!'));
});
}