update packages, replace chalk with colorette
This commit is contained in:
parent
141eaca7b1
commit
d07d81681e
1891
package-lock.json
generated
1891
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@ -47,30 +47,29 @@
|
|||||||
},
|
},
|
||||||
"config": {},
|
"config": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/chai": "4.0.1",
|
"@types/chai": "4.1.7",
|
||||||
"@types/glob": "5.0.30",
|
"@types/cheerio": "0.22.11",
|
||||||
"@types/mocha": "2.2.41",
|
|
||||||
"@types/cheerio": "0.22.1",
|
|
||||||
"@types/chalk": "0.4.31",
|
|
||||||
"@types/flat": "0.0.28",
|
"@types/flat": "0.0.28",
|
||||||
"@types/yargs": "8.0.0",
|
"@types/glob": "7.1.1",
|
||||||
"@types/mkdirp": "0.3.29",
|
"@types/mkdirp": "0.5.2",
|
||||||
"chai": "4.0.2",
|
"@types/mocha": "5.2.7",
|
||||||
"mocha": "3.4.2",
|
"@types/yargs": "13.0.0",
|
||||||
"ts-node": "3.1.0",
|
"chai": "4.2.0",
|
||||||
"tslint": "5.4.3",
|
"mocha": "6.1.4",
|
||||||
"tslint-eslint-rules": "4.1.1"
|
"ts-node": "8.2.0",
|
||||||
|
"tslint": "5.17.0",
|
||||||
|
"tslint-eslint-rules": "5.4.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"chalk": "2.0.1",
|
"cheerio": "1.0.0-rc.3",
|
||||||
"yargs": "8.0.2",
|
"colorette": "^1.0.8",
|
||||||
"cheerio": "1.0.0-rc.2",
|
"flat": "4.1.0",
|
||||||
"fs": "0.0.1-security",
|
"fs": "0.0.1-security",
|
||||||
"gettext-parser": "1.2.2",
|
"gettext-parser": "4.0.0",
|
||||||
"glob": "7.1.2",
|
"glob": "7.1.4",
|
||||||
"path": "0.12.7",
|
|
||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
"flat": "2.0.1",
|
"path": "0.12.7",
|
||||||
"typescript": "2.4.1"
|
"typescript": "3.5.1",
|
||||||
|
"yargs": "13.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { TaskInterface } from './task.interface';
|
|||||||
import { ParserInterface } from '../../parsers/parser.interface';
|
import { ParserInterface } from '../../parsers/parser.interface';
|
||||||
import { CompilerInterface } from '../../compilers/compiler.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 glob from 'glob';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
@ -43,7 +43,7 @@ export class ExtractTask implements TaskInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const collection = this._extract();
|
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);
|
this._save(collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,12 +61,12 @@ export class ExtractTask implements TaskInterface {
|
|||||||
* Extract strings from input dirs using configured parsers
|
* Extract strings from input dirs using configured parsers
|
||||||
*/
|
*/
|
||||||
protected _extract(): TranslationCollection {
|
protected _extract(): TranslationCollection {
|
||||||
this._out(chalk.bold('Extracting strings...'));
|
this._out(bold('Extracting strings...'));
|
||||||
|
|
||||||
let collection: TranslationCollection = new TranslationCollection();
|
let collection: TranslationCollection = new TranslationCollection();
|
||||||
this._input.forEach(dir => {
|
this._input.forEach(dir => {
|
||||||
this._readDir(dir, this._options.patterns).forEach(path => {
|
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');
|
const contents: string = fs.readFileSync(path, 'utf-8');
|
||||||
this._parsers.forEach((parser: ParserInterface) => {
|
this._parsers.forEach((parser: ParserInterface) => {
|
||||||
collection = collection.union(parser.extract(contents, path));
|
collection = collection.union(parser.extract(contents, path));
|
||||||
@ -95,13 +95,13 @@ export class ExtractTask implements TaskInterface {
|
|||||||
const outputPath: string = path.join(dir, filename);
|
const outputPath: string = path.join(dir, filename);
|
||||||
let processedCollection: TranslationCollection = collection;
|
let processedCollection: TranslationCollection = collection;
|
||||||
|
|
||||||
this._out(chalk.bold('\nSaving: %s'), outputPath);
|
this._out(bold('\nSaving: %s'), outputPath);
|
||||||
|
|
||||||
if (fs.existsSync(outputPath) && !this._options.replace) {
|
if (fs.existsSync(outputPath) && !this._options.replace) {
|
||||||
const existingCollection: TranslationCollection = this._compiler.parse(fs.readFileSync(outputPath, 'utf-8'));
|
const existingCollection: TranslationCollection = this._compiler.parse(fs.readFileSync(outputPath, 'utf-8'));
|
||||||
if (!existingCollection.isEmpty()) {
|
if (!existingCollection.isEmpty()) {
|
||||||
processedCollection = processedCollection.union(existingCollection);
|
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) {
|
if (this._options.clean) {
|
||||||
@ -109,23 +109,23 @@ export class ExtractTask implements TaskInterface {
|
|||||||
processedCollection = processedCollection.intersect(collection);
|
processedCollection = processedCollection.intersect(collection);
|
||||||
const removeCount = collectionCount - processedCollection.count();
|
const removeCount = collectionCount - processedCollection.count();
|
||||||
if (removeCount > 0) {
|
if (removeCount > 0) {
|
||||||
this._out(chalk.dim('- removed %d obsolete strings'), removeCount);
|
this._out(dim('- removed %d obsolete strings'), removeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._options.sort) {
|
if (this._options.sort) {
|
||||||
processedCollection = processedCollection.sort();
|
processedCollection = processedCollection.sort();
|
||||||
this._out(chalk.dim('- sorted strings'));
|
this._out(dim('- sorted strings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
mkdirp.sync(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));
|
fs.writeFileSync(outputPath, this._compiler.compile(processedCollection));
|
||||||
|
|
||||||
this._out(chalk.green('Done!'));
|
this._out(green('Done!'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user