-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from 2gis/update-packages
Update packages
- Loading branch information
Showing
27 changed files
with
3,315 additions
and
3,718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
module.exports = { | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: ['./tsconfig.json'], | ||
}, | ||
extends: ['plugin:@typescript-eslint/recommended'], | ||
plugins: ['functional'], | ||
overrides: [ | ||
{ | ||
files: ['*.spec.tsx', '*.spec.ts', '*.stories.tsx'], | ||
rules: { | ||
'no-unused-expressions': 'off', | ||
'functional/immutable-data': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
}, | ||
}, | ||
], | ||
rules: { | ||
'import/no-anonymous-default-export': 'off', | ||
'no-useless-rename': 'error', | ||
'object-shorthand': ['error', 'always'], | ||
'@typescript-eslint/ban-ts-comment': 'off', | ||
'@typescript-eslint/ban-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-loss-of-precision': 'off', | ||
'@typescript-eslint/no-unused-vars': 'off', | ||
'@typescript-eslint/no-var-requires': 'off', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"printWidth": 100, | ||
"useTabs": false, | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"arrowParens": "always" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/usr/bin/env node | ||
require('../dist/index.js') | ||
require('../dist/cli.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
var fs_1 = require("fs"); | ||
var yargs_1 = require("yargs"); | ||
var getStdin = require("get-stdin"); | ||
var convert_1 = require("./convert"); | ||
var yargsInstance = (0, yargs_1["default"])(process.argv.slice(2)) | ||
.usage('i18n PO -> JSON converter') | ||
.help() | ||
.options({ | ||
src: { | ||
alias: 's', | ||
description: 'Define input JSON file name. Defaults to stdin.', | ||
type: 'string', | ||
"default": '__stdin' | ||
}, | ||
output: { | ||
alias: 'o', | ||
description: 'Define output POT file name. If a file already ' + | ||
'exists, it s contents will be overwritten. Defaults to stdout.', | ||
type: 'string', | ||
"default": '__stdout' | ||
}, | ||
withOccurences: { | ||
alias: 'n', | ||
description: 'Include occurences info into JSON file, ' + 'parsed from "#: ..." comments.', | ||
type: 'boolean', | ||
"default": false | ||
}, | ||
withComments: { | ||
alias: 'c', | ||
description: 'Include comments into JSON file, parsed ' + 'from "#. ..." comments.', | ||
type: 'boolean', | ||
"default": false | ||
}, | ||
withMeta: { | ||
alias: 'm', | ||
description: 'Include parsed PO header or plural form ' + | ||
'into JSON file. Add all header values' + | ||
'without any params provided. Possable values "" | "full" | "plural"', | ||
type: 'string', | ||
"default": undefined | ||
}, | ||
prettify: { | ||
alias: 'p', | ||
description: 'Pretty-print JSON output.', | ||
type: 'boolean', | ||
"default": false | ||
} | ||
}); | ||
var yargOpts = yargsInstance.parseSync(); | ||
if (yargOpts.help) { | ||
yargsInstance.showHelp(); | ||
process.exit(0); | ||
} | ||
console.warn('Running conversion for file: ', yargOpts.src); | ||
var parsedOptions = { | ||
withOccurences: yargOpts.withOccurences, | ||
withComments: yargOpts.withComments, | ||
withMeta: false | ||
}; | ||
if (yargOpts.withMeta === '' || yargOpts.withMeta === 'full') { | ||
parsedOptions.withMeta = 'full'; | ||
} | ||
else { | ||
if (yargOpts.withMeta === 'plural') { | ||
parsedOptions.withMeta = 'plural'; | ||
} | ||
} | ||
if (yargOpts.src === '__stdin') { | ||
getStdin().then(function (data) { | ||
try { | ||
makeOutput((0, convert_1.convert)(data, parsedOptions), yargOpts.output, yargOpts.prettify); | ||
} | ||
catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
else { | ||
(0, fs_1.readFile)(yargOpts.src, { encoding: 'utf-8' }, function (err, data) { | ||
if (err) { | ||
console.error(err); | ||
process.exit(1); | ||
} | ||
try { | ||
makeOutput((0, convert_1.convert)(data, parsedOptions), yargOpts.output, yargOpts.prettify); | ||
} | ||
catch (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
}); | ||
} | ||
function makeOutput(data, output, prettify) { | ||
if (output === '__stdout') { | ||
console.log(JSON.stringify(data, undefined, prettify ? ' ' : undefined)); | ||
} | ||
else { | ||
(0, fs_1.writeFile)(output, JSON.stringify(data, undefined, prettify ? ' ' : undefined), function (e) { | ||
if (e) { | ||
console.error(e); | ||
process.exit(1); | ||
} | ||
process.exit(0); // success | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { I18NEntry, TranslationJson, TranslationMeta } from 'i18n-proto'; | ||
import { PoOptions } from './types'; | ||
export declare function splitInTwo(src: string, separator?: string): [string, string]; | ||
export declare function convert(data: string, opts: PoOptions): TranslationJson; | ||
export declare function parseHeader(headerString: string, opts: PoOptions): TranslationMeta | undefined; | ||
export declare function parseEntry(entry: string, withComments: boolean, withOccurences: boolean): I18NEntry | undefined; | ||
type _ParseRetval = { | ||
comments: string[]; | ||
occurences: string[]; | ||
context?: string; | ||
msgid?: string; | ||
msgidPlural?: string; | ||
msgStr?: string; | ||
msgStrPlural: string[]; | ||
}; | ||
export declare function _parse(entries: string[], withComments: boolean, withOccurences: boolean): _ParseRetval; | ||
export {}; |
Oops, something went wrong.