Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@vendure/ngx-translate-extract

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vendure/ngx-translate-extract - npm Package Compare versions

Comparing version 9.2.0-next.0 to 9.2.0

11

dist/cli/cli.js

@@ -74,2 +74,9 @@ import yargs from 'yargs';

})
.option('sort-sensitivity', {
alias: 'ss',
describe: 'Sort sensitivitiy of strings (only to be used when sorting)',
type: 'string',
choices: ['base', 'accent', 'case', 'variant'],
default: undefined
})
.option('clean', {

@@ -119,3 +126,3 @@ alias: 'c',

})
.group(['format', 'format-indentation', 'sort', 'clean', 'replace', 'strip-prefix'], 'Output')
.group(['format', 'format-indentation', 'sort', 'sort-sensitivity', 'clean', 'replace', 'strip-prefix'], 'Output')
.group(['key-as-default-value', 'key-as-initial-default-value', 'null-as-default-value', 'string-as-default-value'], 'Extracted key value (defaults to empty string)')

@@ -168,3 +175,3 @@ .conflicts('key-as-default-value', 'null-as-default-value')

if (cli.sort) {
postProcessors.push(new SortByKeyPostProcessor());
postProcessors.push(new SortByKeyPostProcessor(cli.sortSensitivity));
}

@@ -171,0 +178,0 @@ extractTask.setPostProcessors(postProcessors);

5

dist/parsers/function.parser.js

@@ -1,4 +0,3 @@

import { tsquery } from '@phenomnomnominal/tsquery';
import { TranslationCollection } from '../utils/translation.collection.js';
import { getStringsFromExpression, findSimpleCallExpressions } from '../utils/ast-helpers.js';
import { getStringsFromExpression, findSimpleCallExpressions, getAST } from '../utils/ast-helpers.js';
import pkg from 'typescript';

@@ -12,3 +11,3 @@ const { isIdentifier } = pkg;

extract(source, filePath) {
const sourceFile = tsquery.ast(source, filePath);
const sourceFile = getAST(source, filePath);
let collection = new TranslationCollection();

@@ -15,0 +14,0 @@ const callExpressions = findSimpleCallExpressions(sourceFile, this.fnName);

@@ -1,5 +0,3 @@

import { ScriptKind, tsquery } from '@phenomnomnominal/tsquery';
import { extname } from 'path';
import { TranslationCollection } from '../utils/translation.collection.js';
import { getNamedImportAlias, findFunctionCallExpressions, getStringsFromExpression } from '../utils/ast-helpers.js';
import { getNamedImportAlias, findFunctionCallExpressions, getStringsFromExpression, getAST } from '../utils/ast-helpers.js';
const MARKER_MODULE_NAME = 'ngx-translate-extract-marker';

@@ -9,10 +7,3 @@ const MARKER_IMPORT_NAME = 'marker';

extract(source, filePath) {
const supportedScriptTypes = {
'.js': ScriptKind.JS,
'.jsx': ScriptKind.JSX,
'.ts': ScriptKind.TS,
'.tsx': ScriptKind.TSX
};
const scriptKind = supportedScriptTypes[extname(filePath)] ?? ScriptKind.TS;
const sourceFile = tsquery.ast(source, filePath, scriptKind);
const sourceFile = getAST(source, filePath);
const markerImportName = getNamedImportAlias(sourceFile, MARKER_MODULE_NAME, MARKER_IMPORT_NAME);

@@ -19,0 +10,0 @@ if (!markerImportName) {

@@ -5,5 +5,4 @@ import path from 'node:path';

import JSON5 from 'json5';
import { tsquery } from '@phenomnomnominal/tsquery';
import { TranslationCollection } from '../utils/translation.collection.js';
import { findClassDeclarations, findClassPropertiesByType, findPropertyCallExpressions, findMethodCallExpressions, getStringsFromExpression, findMethodParameterByType, findConstructorDeclaration, getSuperClassName, getImportPath, findFunctionExpressions, findVariableNameByInjectType } from '../utils/ast-helpers.js';
import { findClassDeclarations, findClassPropertiesByType, findPropertyCallExpressions, findMethodCallExpressions, getStringsFromExpression, findMethodParameterByType, findConstructorDeclaration, getSuperClassName, getImportPath, findFunctionExpressions, findVariableNameByInjectType, getAST } from '../utils/ast-helpers.js';
const TRANSLATE_SERVICE_TYPE_REFERENCE = 'TranslateService';

@@ -14,3 +13,3 @@ const TRANSLATE_SERVICE_METHOD_NAMES = ['get', 'instant', 'stream'];

extract(source, filePath) {
const sourceFile = tsquery.ast(source, filePath);
const sourceFile = getAST(source, filePath);
const classDeclarations = findClassDeclarations(sourceFile);

@@ -108,3 +107,3 @@ const functionDeclarations = findFunctionExpressions(sourceFile);

const superClassFileContent = fs.readFileSync(file, 'utf8');
const superClassAst = tsquery.ast(superClassFileContent, file);
const superClassAst = getAST(superClassFileContent, file);
const superClassDeclarations = findClassDeclarations(superClassAst, superClassName);

@@ -111,0 +110,0 @@ const superClassPropertyNames = superClassDeclarations

@@ -5,3 +5,5 @@ import { TranslationCollection } from '../utils/translation.collection.js';

name: string;
sortSensitivity: 'base' | 'accent' | 'case' | 'variant' | undefined;
constructor(sortSensitivity: string | undefined);
process(draft: TranslationCollection, extracted: TranslationCollection, existing: TranslationCollection): TranslationCollection;
}
export class SortByKeyPostProcessor {
name = 'SortByKey';
sortSensitivity = undefined;
constructor(sortSensitivity) {
if (isOfTypeSortSensitivity(sortSensitivity)) {
this.sortSensitivity = sortSensitivity;
}
else {
throw new Error(`Unknown sortSensitivity: ${sortSensitivity}`);
}
}
process(draft, extracted, existing) {
const compareFn = new Intl.Collator('en', { sensitivity: 'base' }).compare;
const compareFn = this.sortSensitivity ? new Intl.Collator('en', { sensitivity: this.sortSensitivity }).compare : undefined;
return draft.sort(compareFn);
}
}
function isOfTypeSortSensitivity(keyInput) {
return ['base', 'accent', 'case', 'variant'].includes(keyInput) || keyInput === undefined;
}
//# sourceMappingURL=sort-by-key.post-processor.js.map

@@ -1,2 +0,3 @@

import pkg, { Node, NamedImports, ClassDeclaration, ConstructorDeclaration, CallExpression, Expression } from 'typescript';
import pkg, { Node, NamedImports, ClassDeclaration, ConstructorDeclaration, CallExpression, Expression, SourceFile } from 'typescript';
export declare function getAST(source: string, fileName?: string): SourceFile;
export declare function getNamedImports(node: Node, moduleName: string): NamedImports[];

@@ -3,0 +4,0 @@ export declare function getNamedImportAlias(node: Node, moduleName: string, importName: string): string | null;

@@ -1,4 +0,15 @@

import { tsquery } from '@phenomnomnominal/tsquery';
import { extname } from 'node:path';
import { ScriptKind, tsquery } from '@phenomnomnominal/tsquery';
import pkg from 'typescript';
const { SyntaxKind, isStringLiteralLike, isArrayLiteralExpression, isBinaryExpression, isConditionalExpression } = pkg;
export function getAST(source, fileName = '') {
const supportedScriptTypes = {
'.js': ScriptKind.JS,
'.jsx': ScriptKind.JSX,
'.ts': ScriptKind.TS,
'.tsx': ScriptKind.TSX
};
const scriptKind = supportedScriptTypes[extname(fileName)] ?? ScriptKind.TS;
return tsquery.ast(source, fileName, scriptKind);
}
export function getNamedImports(node, moduleName) {

@@ -5,0 +16,0 @@ const query = `ImportDeclaration[moduleSpecifier.text=/${moduleName}/] NamedImports`;

{
"name": "@vendure/ngx-translate-extract",
"version": "9.2.0-next.0",
"version": "9.2.0",
"description": "Extract strings from projects using ngx-translate",

@@ -5,0 +5,0 @@ "author": "Kim Biesbjerg <kim@biesbjerg.com>",

@@ -91,2 +91,12 @@ # ngx-translate-extract

### Sorting
Extracted keys are by default not sorted. You can enable sorting by using the `--sort` or `-s` flag.
If sorting is enabled, the keys will be sorted using the default variant sort sensitivity. Other sort sensitivity options are also available using the `--sort-sensitivity` or `-ss` flag:
- `base`: Strings that differ in base letters are unequal. For example `a !== b`, `a === á`, `a === A`
- `accent`: Strings that differ in base letters and accents are unequal. For example `a !== b`, `a !== á`, `a === A`
- `case`: Strings that differ in base letters or casing are unequal. For example `a !== b`, `a === á`, `a !== A`
- `variant`: Strings that differ in base letters, accents, or casing are unequal. For example `a !== b`, `a !== á`, `a !== A`
### Marker function

@@ -114,2 +124,3 @@

--sort, -s Sort strings in alphabetical order [boolean]
--sort-sensitivity, -ss Sensitivity when sorting strings (only when sort is enabled) [string]
--clean, -c Remove obsolete strings after merge [boolean]

@@ -116,0 +127,0 @@ --replace, -r Replace the contents of output file if it exists (Merges by default) [boolean]

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc