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

@lingui/conf

Package Overview
Dependencies
Maintainers
3
Versions
153
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lingui/conf - npm Package Compare versions

Comparing version 3.17.0 to 3.17.1

192

build/index.d.ts

@@ -1,22 +0,27 @@

import type { GeneratorOptions } from "@babel/core";
import type { GeneratorOptions } from "@babel/core"
export declare type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
export declare type CatalogFormat =
| "lingui"
| "minimal"
| "po"
| "csv"
| "po-gettext"
export type CatalogFormatOptions = {
origins?: boolean;
lineNumbers?: boolean;
origins?: boolean
lineNumbers?: boolean
}
export declare type OrderBy = "messageId" | "origin";
export declare type OrderBy = "messageId" | "origin"
declare type CatalogConfig = {
name?: string;
path: string;
include: string[];
exclude?: string[];
};
name?: string
path: string
include: string[]
exclude?: string[]
}
export type LocaleObject = {
[locale: string]: string[] | string
[locale: string]: string[] | string
}
export type DefaultLocaleObject = {
default: string
default: string
}

@@ -27,71 +32,92 @@

declare type CatalogService = {
name: string;
apiKey: string;
name: string
apiKey: string
}
declare type ExtractorType = {
match(filename: string): boolean;
extract(filename: string, targetDir: string, options?: any): void;
match(filename: string): boolean
extract(filename: string, targetDir: string, options?: any): void
}
export declare type LinguiConfig = {
catalogs: CatalogConfig[];
compileNamespace: "es" | "cjs" | "ts" | string;
extractBabelOptions: Record<string, unknown>;
compilerBabelOptions: GeneratorOptions;
fallbackLocales: FallbackLocales;
format: CatalogFormat;
extractors?: ExtractorType[];
prevFormat: CatalogFormat;
formatOptions: CatalogFormatOptions;
localeDir: string;
locales: string[];
catalogsMergePath: string;
orderBy: OrderBy;
pseudoLocale: string;
rootDir: string;
runtimeConfigModule: [source: string, identifier?: string] | {
catalogs: CatalogConfig[]
compileNamespace: "es" | "cjs" | "ts" | string
extractBabelOptions: Record<string, unknown>
compilerBabelOptions: GeneratorOptions
fallbackLocales: FallbackLocales
format: CatalogFormat
extractors?: ExtractorType[]
prevFormat: CatalogFormat
formatOptions: CatalogFormatOptions
localeDir: string
locales: string[]
catalogsMergePath: string
orderBy: OrderBy
pseudoLocale: string
rootDir: string
runtimeConfigModule:
| [source: string, identifier?: string]
| {
i18n?: [source: string, identifier?: string]
Trans?: [source: string, identifier?: string]
};
sourceLocale: string;
service: CatalogService;
};
export declare const defaultConfig: LinguiConfig;
export declare function getConfig({ cwd, configPath, skipValidation, }?: {
cwd?: string;
configPath?: string;
skipValidation?: boolean;
}): LinguiConfig;
}
sourceLocale: string
service: CatalogService
}
export declare const defaultConfig: LinguiConfig
export declare function getConfig({
cwd,
configPath,
skipValidation,
}?: {
cwd?: string
configPath?: string
skipValidation?: boolean
}): LinguiConfig
export declare function makeConfig(
userConfig: Partial<LinguiConfig>,
opts?: {
skipValidation?: boolean
}
): LinguiConfig
export declare const configValidation: {
exampleConfig: {
extractBabelOptions: {
extends: string;
rootMode: string;
plugins: string[];
presets: string[];
};
compilerBabelOptions: GeneratorOptions;
catalogs: CatalogConfig[];
compileNamespace: "es" | "ts" | "cjs" | string;
fallbackLocales: FallbackLocales;
format: CatalogFormat;
formatOptions: CatalogFormatOptions;
locales: string[];
orderBy: OrderBy;
pseudoLocale: string;
rootDir: string;
runtimeConfigModule: LinguiConfig['runtimeConfigModule'];
sourceLocale: string;
service: CatalogService;
};
deprecatedConfig: {
fallbackLocale: (config: LinguiConfig & DeprecatedFallbackLanguage) => string;
localeDir: (config: LinguiConfig & DeprecatedLocaleDir) => string;
srcPathDirs: (config: LinguiConfig & DeprecatedLocaleDir) => string;
srcPathIgnorePatterns: (config: LinguiConfig & DeprecatedLocaleDir) => string;
};
comment: string;
};
export declare function replaceRootDir(config: LinguiConfig, rootDir: string): LinguiConfig;
exampleConfig: {
extractBabelOptions: {
extends: string
rootMode: string
plugins: string[]
presets: string[]
}
compilerBabelOptions: GeneratorOptions
catalogs: CatalogConfig[]
compileNamespace: "es" | "ts" | "cjs" | string
fallbackLocales: FallbackLocales
format: CatalogFormat
formatOptions: CatalogFormatOptions
locales: string[]
orderBy: OrderBy
pseudoLocale: string
rootDir: string
runtimeConfigModule: LinguiConfig["runtimeConfigModule"]
sourceLocale: string
service: CatalogService
}
deprecatedConfig: {
fallbackLocale: (
config: LinguiConfig & DeprecatedFallbackLanguage
) => string
localeDir: (config: LinguiConfig & DeprecatedLocaleDir) => string
srcPathDirs: (config: LinguiConfig & DeprecatedLocaleDir) => string
srcPathIgnorePatterns: (
config: LinguiConfig & DeprecatedLocaleDir
) => string
}
comment: string
}
export declare function replaceRootDir(
config: LinguiConfig,
rootDir: string
): LinguiConfig
/**

@@ -104,6 +130,8 @@ * Replace fallbackLocale with fallbackLocales

declare type DeprecatedFallbackLanguage = {
fallbackLocale: string | null;
};
fallbackLocale: string | null
}
export declare function fallbackLanguageMigration(config: LinguiConfig & DeprecatedFallbackLanguage): LinguiConfig;
export declare function fallbackLanguageMigration(
config: LinguiConfig & DeprecatedFallbackLanguage
): LinguiConfig
/**

@@ -116,8 +144,10 @@ * Replace localeDir, srcPathDirs and srcPathIgnorePatterns with catalogs

declare type DeprecatedLocaleDir = {
localeDir: string;
srcPathDirs: string[];
srcPathIgnorePatterns: string[];
};
export declare function catalogMigration(config: LinguiConfig & DeprecatedLocaleDir): LinguiConfig;
export {};
localeDir: string
srcPathDirs: string[]
srcPathIgnorePatterns: string[]
}
export declare function catalogMigration(
config: LinguiConfig & DeprecatedLocaleDir
): LinguiConfig
export {}
//# sourceMappingURL=index.d.ts.map

@@ -6,27 +6,20 @@ "use strict";

});
exports.catalogMigration = catalogMigration;
exports.defaultConfig = exports.configValidation = void 0;
exports.fallbackLanguageMigration = fallbackLanguageMigration;
exports.getConfig = getConfig;
exports.makeConfig = makeConfig;
exports.replaceRootDir = replaceRootDir;
exports.fallbackLanguageMigration = fallbackLanguageMigration;
exports.catalogMigration = catalogMigration;
exports.configValidation = exports.defaultConfig = void 0;
var _path = _interopRequireDefault(require("path"));
var _fs = _interopRequireDefault(require("fs"));
var _chalk = _interopRequireDefault(require("chalk"));
var _cosmiconfig = require("cosmiconfig");
var _jestValidate = require("jest-validate");
var _cosmiconfigTypescriptLoader = require("cosmiconfig-typescript-loader");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
// Enforce posix path delimiters internally
const pathJoinPosix = (...values) => _path.default // normalize double slashes
.join(...values) // convert platform specific path.sep to posix
const pathJoinPosix = (...values) => _path.default
// normalize double slashes
.join(...values)
// convert platform specific path.sep to posix
.split(_path.default.sep).join("/");
const defaultConfig = {

@@ -68,7 +61,17 @@ catalogs: [{

exports.defaultConfig = defaultConfig;
function configExists(path) {
return path && _fs.default.existsSync(path);
}
function TypeScriptLoader() {
let loaderInstance;
return (filepath, content) => {
if (!loaderInstance) {
const {
TypeScriptLoader
} = require("cosmiconfig-typescript-loader");
loaderInstance = TypeScriptLoader();
}
return loaderInstance(filepath, content);
};
}
function getConfig({

@@ -84,3 +87,3 @@ cwd,

loaders: {
".ts": (0, _cosmiconfigTypescriptLoader.TypeScriptLoader)()
".ts": TypeScriptLoader()
}

@@ -90,12 +93,22 @@ });

const userConfig = result ? result.config : {};
const config = { ...defaultConfig,
return makeConfig({
rootDir: result ? _path.default.dirname(result.filepath) : defaultRootDir,
...userConfig
}, {
skipValidation
});
}
function makeConfig(userConfig, opts = {}) {
const config = {
...defaultConfig,
...userConfig
};
if (!skipValidation) {
if (!opts.skipValidation) {
(0, _jestValidate.validate)(config, configValidation);
return pipe( // List config migrations from oldest to newest
fallbackLanguageMigration, catalogMigration, // Custom validation
validateLocales, // `replaceRootDir` should always be the last
return pipe(
// List config migrations from oldest to newest
fallbackLanguageMigration, catalogMigration,
// Custom validation
validateLocales,
// `replaceRootDir` should always be the last
config => replaceRootDir(config, config.rootDir))(config);

@@ -106,4 +119,4 @@ } else {

}
const exampleConfig = { ...defaultConfig,
const exampleConfig = {
...defaultConfig,
extractors: (0, _jestValidate.multipleValidOptions)([], ["babel"], [{

@@ -129,6 +142,6 @@ match: fileName => false,

presets: ["preset"],
targets: (0, _jestValidate.multipleValidOptions)({}, '> 0.5%', ['> 0.5%', 'not dead'], undefined),
targets: (0, _jestValidate.multipleValidOptions)({}, "> 0.5%", ["> 0.5%", "not dead"], undefined),
assumptions: (0, _jestValidate.multipleValidOptions)({}, undefined),
browserslistConfigFile: (0, _jestValidate.multipleValidOptions)(true, undefined),
browserslistEnv: (0, _jestValidate.multipleValidOptions)('.browserslistrc', undefined)
browserslistEnv: (0, _jestValidate.multipleValidOptions)(".browserslistrc", undefined)
}

@@ -187,3 +200,2 @@ };

exports.configValidation = configValidation;
function validateLocales(config) {

@@ -194,10 +206,7 @@ if (!Array.isArray(config.locales) || !config.locales.length) {

}
return config;
}
function replaceRootDir(config, rootDir) {
return function replaceDeep(value, rootDir) {
const replace = s => s.replace("<rootDir>", rootDir);
if (value == null) {

@@ -216,6 +225,6 @@ return value;

}
return value;
}(config, rootDir);
}
/**

@@ -227,3 +236,2 @@ * Replace fallbackLocale, by the new standard fallbackLocales

function fallbackLanguageMigration(config) {

@@ -234,7 +242,7 @@ const {

} = config;
if (fallbackLocales === false) return { ...config,
if (fallbackLocales === false) return {
...config,
fallbackLocales: null
};
const DEFAULT_FALLBACK = fallbackLocales?.default || fallbackLocale;
const DEFAULT_FALLBACK = (fallbackLocales === null || fallbackLocales === void 0 ? void 0 : fallbackLocales.default) || fallbackLocale;
if (DEFAULT_FALLBACK) {

@@ -244,9 +252,8 @@ if (!config.fallbackLocales) config.fallbackLocales = {};

}
if (config.fallbackLocales !== false && !config.fallbackLocales.default) {
config.locales.forEach(locale => {
const fl = getCldrParentLocale(locale.toLowerCase());
if (fl && !config.fallbackLocales[locale]) {
config.fallbackLocales = { ...config.fallbackLocales,
config.fallbackLocales = {
...config.fallbackLocales,
[locale]: fl

@@ -257,6 +264,4 @@ };

}
return config;
}
function getCldrParentLocale(sourceLocale) {

@@ -440,2 +445,3 @@ return {

}
/**

@@ -448,3 +454,2 @@ * Replace localeDir, srcPathDirs and srcPathIgnorePatterns with catalogs

function catalogMigration(config) {

@@ -457,3 +462,2 @@ let {

} = config;
if (localeDir || srcPathDirs || srcPathIgnorePatterns) {

@@ -465,11 +469,8 @@ // Replace missing values with default ones

let newLocaleDir = localeDir.split(_path.default.sep).join("/");
if (newLocaleDir.slice(-1) !== _path.default.sep) {
newLocaleDir += "/";
}
if (!Array.isArray(newConfig.catalogs)) {
newConfig.catalogs = [];
}
newConfig.catalogs.push({

@@ -481,6 +482,4 @@ path: pathJoinPosix(newLocaleDir, "{locale}", "messages"),

}
return newConfig;
}
const pipe = (...functions) => args => functions.reduce((arg, fn) => fn(arg), args);

@@ -6,2 +6,14 @@ # Change Log

## [3.17.1](https://github.com/lingui/js-lingui/compare/v3.17.0...v3.17.1) (2023-02-07)
### Bug Fixes
* **compile:** remove verbose output when using flow with template ([#1388](https://github.com/lingui/js-lingui/issues/1388)) ([31316f9](https://github.com/lingui/js-lingui/commit/31316f938957dba8e908f9f60a452a2673a934ee))
* **conf:** lazy load cosmiconfig's TypeScriptLoader ([#1403](https://github.com/lingui/js-lingui/issues/1403)) ([617a333](https://github.com/lingui/js-lingui/commit/617a3330f6eee5ffe5670a6b41f06d0a8116fc92))
# [3.17.0](https://github.com/lingui/js-lingui/compare/v3.16.1...v3.17.0) (2023-02-01)

@@ -8,0 +20,0 @@

@@ -1,22 +0,27 @@

import type { GeneratorOptions } from "@babel/core";
import type { GeneratorOptions } from "@babel/core"
export declare type CatalogFormat = "lingui" | "minimal" | "po" | "csv" | "po-gettext";
export declare type CatalogFormat =
| "lingui"
| "minimal"
| "po"
| "csv"
| "po-gettext"
export type CatalogFormatOptions = {
origins?: boolean;
lineNumbers?: boolean;
origins?: boolean
lineNumbers?: boolean
}
export declare type OrderBy = "messageId" | "origin";
export declare type OrderBy = "messageId" | "origin"
declare type CatalogConfig = {
name?: string;
path: string;
include: string[];
exclude?: string[];
};
name?: string
path: string
include: string[]
exclude?: string[]
}
export type LocaleObject = {
[locale: string]: string[] | string
[locale: string]: string[] | string
}
export type DefaultLocaleObject = {
default: string
default: string
}

@@ -27,71 +32,92 @@

declare type CatalogService = {
name: string;
apiKey: string;
name: string
apiKey: string
}
declare type ExtractorType = {
match(filename: string): boolean;
extract(filename: string, targetDir: string, options?: any): void;
match(filename: string): boolean
extract(filename: string, targetDir: string, options?: any): void
}
export declare type LinguiConfig = {
catalogs: CatalogConfig[];
compileNamespace: "es" | "cjs" | "ts" | string;
extractBabelOptions: Record<string, unknown>;
compilerBabelOptions: GeneratorOptions;
fallbackLocales: FallbackLocales;
format: CatalogFormat;
extractors?: ExtractorType[];
prevFormat: CatalogFormat;
formatOptions: CatalogFormatOptions;
localeDir: string;
locales: string[];
catalogsMergePath: string;
orderBy: OrderBy;
pseudoLocale: string;
rootDir: string;
runtimeConfigModule: [source: string, identifier?: string] | {
catalogs: CatalogConfig[]
compileNamespace: "es" | "cjs" | "ts" | string
extractBabelOptions: Record<string, unknown>
compilerBabelOptions: GeneratorOptions
fallbackLocales: FallbackLocales
format: CatalogFormat
extractors?: ExtractorType[]
prevFormat: CatalogFormat
formatOptions: CatalogFormatOptions
localeDir: string
locales: string[]
catalogsMergePath: string
orderBy: OrderBy
pseudoLocale: string
rootDir: string
runtimeConfigModule:
| [source: string, identifier?: string]
| {
i18n?: [source: string, identifier?: string]
Trans?: [source: string, identifier?: string]
};
sourceLocale: string;
service: CatalogService;
};
export declare const defaultConfig: LinguiConfig;
export declare function getConfig({ cwd, configPath, skipValidation, }?: {
cwd?: string;
configPath?: string;
skipValidation?: boolean;
}): LinguiConfig;
}
sourceLocale: string
service: CatalogService
}
export declare const defaultConfig: LinguiConfig
export declare function getConfig({
cwd,
configPath,
skipValidation,
}?: {
cwd?: string
configPath?: string
skipValidation?: boolean
}): LinguiConfig
export declare function makeConfig(
userConfig: Partial<LinguiConfig>,
opts?: {
skipValidation?: boolean
}
): LinguiConfig
export declare const configValidation: {
exampleConfig: {
extractBabelOptions: {
extends: string;
rootMode: string;
plugins: string[];
presets: string[];
};
compilerBabelOptions: GeneratorOptions;
catalogs: CatalogConfig[];
compileNamespace: "es" | "ts" | "cjs" | string;
fallbackLocales: FallbackLocales;
format: CatalogFormat;
formatOptions: CatalogFormatOptions;
locales: string[];
orderBy: OrderBy;
pseudoLocale: string;
rootDir: string;
runtimeConfigModule: LinguiConfig['runtimeConfigModule'];
sourceLocale: string;
service: CatalogService;
};
deprecatedConfig: {
fallbackLocale: (config: LinguiConfig & DeprecatedFallbackLanguage) => string;
localeDir: (config: LinguiConfig & DeprecatedLocaleDir) => string;
srcPathDirs: (config: LinguiConfig & DeprecatedLocaleDir) => string;
srcPathIgnorePatterns: (config: LinguiConfig & DeprecatedLocaleDir) => string;
};
comment: string;
};
export declare function replaceRootDir(config: LinguiConfig, rootDir: string): LinguiConfig;
exampleConfig: {
extractBabelOptions: {
extends: string
rootMode: string
plugins: string[]
presets: string[]
}
compilerBabelOptions: GeneratorOptions
catalogs: CatalogConfig[]
compileNamespace: "es" | "ts" | "cjs" | string
fallbackLocales: FallbackLocales
format: CatalogFormat
formatOptions: CatalogFormatOptions
locales: string[]
orderBy: OrderBy
pseudoLocale: string
rootDir: string
runtimeConfigModule: LinguiConfig["runtimeConfigModule"]
sourceLocale: string
service: CatalogService
}
deprecatedConfig: {
fallbackLocale: (
config: LinguiConfig & DeprecatedFallbackLanguage
) => string
localeDir: (config: LinguiConfig & DeprecatedLocaleDir) => string
srcPathDirs: (config: LinguiConfig & DeprecatedLocaleDir) => string
srcPathIgnorePatterns: (
config: LinguiConfig & DeprecatedLocaleDir
) => string
}
comment: string
}
export declare function replaceRootDir(
config: LinguiConfig,
rootDir: string
): LinguiConfig
/**

@@ -104,6 +130,8 @@ * Replace fallbackLocale with fallbackLocales

declare type DeprecatedFallbackLanguage = {
fallbackLocale: string | null;
};
fallbackLocale: string | null
}
export declare function fallbackLanguageMigration(config: LinguiConfig & DeprecatedFallbackLanguage): LinguiConfig;
export declare function fallbackLanguageMigration(
config: LinguiConfig & DeprecatedFallbackLanguage
): LinguiConfig
/**

@@ -116,8 +144,10 @@ * Replace localeDir, srcPathDirs and srcPathIgnorePatterns with catalogs

declare type DeprecatedLocaleDir = {
localeDir: string;
srcPathDirs: string[];
srcPathIgnorePatterns: string[];
};
export declare function catalogMigration(config: LinguiConfig & DeprecatedLocaleDir): LinguiConfig;
export {};
localeDir: string
srcPathDirs: string[]
srcPathIgnorePatterns: string[]
}
export declare function catalogMigration(
config: LinguiConfig & DeprecatedLocaleDir
): LinguiConfig
export {}
//# sourceMappingURL=index.d.ts.map
{
"name": "@lingui/conf",
"version": "3.17.0",
"version": "3.17.1",
"sideEffects": false,

@@ -22,3 +22,3 @@ "description": "Get lingui configuration from package.json",

"dependencies": {
"@babel/runtime": "^7.11.2",
"@babel/runtime": "^7.20.13",
"chalk": "^4.1.0",

@@ -39,3 +39,15 @@ "cosmiconfig": "^8.0.0",

},
"gitHead": "1c8bc46213b35b25da8fe7a80ddcf6f6a5d9d539"
"peerDependencies": {
"ts-node": ">=10",
"typescript": ">=4"
},
"peerDependenciesMeta": {
"ts-node": {
"optional": true
},
"typescript": {
"optional": true
}
},
"gitHead": "76ef4e8d1c668578ce2c3829ebf35d22ca5e679c"
}
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