@lingui/conf 3.17.2 → 4.0.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ import { LinguiConfigNormalized } from "./types";
2
+ export declare function getConfig({ cwd, configPath, skipValidation, }?: {
3
+ cwd?: string;
4
+ configPath?: string;
5
+ skipValidation?: boolean;
6
+ }): LinguiConfigNormalized;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getConfig = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const cosmiconfig_1 = require("cosmiconfig");
9
+ const path_1 = __importDefault(require("path"));
10
+ const makeConfig_1 = require("./makeConfig");
11
+ function configExists(path) {
12
+ return path && fs_1.default.existsSync(path);
13
+ }
14
+ function JitiLoader() {
15
+ return (filepath, content) => {
16
+ const opts = {
17
+ interopDefault: true,
18
+ };
19
+ const jiti = require("jiti")(__filename, opts);
20
+ return jiti(filepath);
21
+ };
22
+ }
23
+ function getConfig({ cwd, configPath, skipValidation = false, } = {}) {
24
+ const defaultRootDir = cwd || process.cwd();
25
+ const moduleName = "lingui";
26
+ const configExplorer = (0, cosmiconfig_1.cosmiconfigSync)(moduleName, {
27
+ searchPlaces: [
28
+ `${moduleName}.config.js`,
29
+ `${moduleName}.config.ts`,
30
+ `${moduleName}.config.mjs`,
31
+ "package.json",
32
+ `.${moduleName}rc`,
33
+ `.${moduleName}rc.json`,
34
+ `.${moduleName}rc.yaml`,
35
+ `.${moduleName}rc.yml`,
36
+ `.${moduleName}rc.ts`,
37
+ `.${moduleName}rc.js`,
38
+ ],
39
+ loaders: {
40
+ ".ts": JitiLoader(),
41
+ ".mjs": JitiLoader(),
42
+ },
43
+ });
44
+ configPath = configPath || process.env.LINGUI_CONFIG;
45
+ const result = configExists(configPath)
46
+ ? configExplorer.load(configPath)
47
+ : configExplorer.search(defaultRootDir);
48
+ const userConfig = result ? result.config : {};
49
+ return (0, makeConfig_1.makeConfig)({
50
+ rootDir: result ? path_1.default.dirname(result.filepath) : defaultRootDir,
51
+ ...userConfig,
52
+ }, { skipValidation });
53
+ }
54
+ exports.getConfig = getConfig;
55
+ //# sourceMappingURL=getConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getConfig.js","sourceRoot":"","sources":["../src/getConfig.ts"],"names":[],"mappings":";;;;;;AAAA,4CAAmB;AAEnB,6CAAyD;AACzD,gDAAuB;AACvB,6CAAyC;AAGzC,SAAS,YAAY,CAAC,IAAY;IAChC,OAAO,IAAI,IAAI,YAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;AACpC,CAAC;AAED,SAAS,UAAU;IACjB,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE;QAC3B,MAAM,IAAI,GAAgB;YACxB,cAAc,EAAE,IAAI;SACrB,CAAA;QACD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAC9C,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAA;IACvB,CAAC,CAAA;AACH,CAAC;AAED,SAAgB,SAAS,CAAC,EACxB,GAAG,EACH,UAAU,EACV,cAAc,GAAG,KAAK,MAKpB,EAAE;IACJ,MAAM,cAAc,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAA;IAC3C,MAAM,UAAU,GAAG,QAAQ,CAAA;IAE3B,MAAM,cAAc,GAAG,IAAA,6BAAe,EAAC,UAAU,EAAE;QACjD,YAAY,EAAE;YACZ,GAAG,UAAU,YAAY;YACzB,GAAG,UAAU,YAAY;YACzB,GAAG,UAAU,aAAa;YAC1B,cAAc;YACd,IAAI,UAAU,IAAI;YAClB,IAAI,UAAU,SAAS;YACvB,IAAI,UAAU,SAAS;YACvB,IAAI,UAAU,QAAQ;YACtB,IAAI,UAAU,OAAO;YACrB,IAAI,UAAU,OAAO;SACtB;QACD,OAAO,EAAE;YACP,KAAK,EAAE,UAAU,EAAE;YACnB,MAAM,EAAE,UAAU,EAAE;SACrB;KACF,CAAC,CAAA;IAEF,UAAU,GAAG,UAAU,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,CAAA;IAEpD,MAAM,MAAM,GAAG,YAAY,CAAC,UAAU,CAAC;QACrC,CAAC,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,CAAC;QACjC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,cAAc,CAAC,CAAA;IACzC,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAA;IAE9C,OAAO,IAAA,uBAAU,EACf;QACE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,cAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,cAAc;QAChE,GAAG,UAAU;KACd,EACD,EAAE,cAAc,EAAE,CACnB,CAAA;AACH,CAAC;AA7CD,8BA6CC"}
package/build/index.d.ts CHANGED
@@ -1,150 +1,3 @@
1
- import type { GeneratorOptions } from "@babel/core"
2
-
3
- export declare type CatalogFormat =
4
- | "lingui"
5
- | "minimal"
6
- | "po"
7
- | "csv"
8
- | "po-gettext"
9
- export type CatalogFormatOptions = {
10
- origins?: boolean
11
- lineNumbers?: boolean
12
- }
13
- export declare type OrderBy = "messageId" | "origin"
14
- declare type CatalogConfig = {
15
- name?: string
16
- path: string
17
- include: string[]
18
- exclude?: string[]
19
- }
20
-
21
- export type LocaleObject = {
22
- [locale: string]: string[] | string
23
- }
24
-
25
- export type DefaultLocaleObject = {
26
- default: string
27
- }
28
-
29
- export declare type FallbackLocales = LocaleObject | DefaultLocaleObject
30
-
31
- declare type CatalogService = {
32
- name: string
33
- apiKey: string
34
- }
35
-
36
- declare type ExtractorType = {
37
- match(filename: string): boolean
38
- extract(filename: string, targetDir: string, options?: any): void
39
- }
40
-
41
- export declare type LinguiConfig = {
42
- catalogs: CatalogConfig[]
43
- compileNamespace: "es" | "cjs" | "ts" | string
44
- extractBabelOptions: Record<string, unknown>
45
- compilerBabelOptions: GeneratorOptions
46
- fallbackLocales: FallbackLocales
47
- format: CatalogFormat
48
- extractors?: ExtractorType[]
49
- prevFormat: CatalogFormat
50
- formatOptions: CatalogFormatOptions
51
- localeDir: string
52
- locales: string[]
53
- catalogsMergePath: string
54
- orderBy: OrderBy
55
- pseudoLocale: string
56
- rootDir: string
57
- runtimeConfigModule:
58
- | [source: string, identifier?: string]
59
- | {
60
- i18n?: [source: string, identifier?: string]
61
- Trans?: [source: string, identifier?: string]
62
- }
63
- sourceLocale: string
64
- service: CatalogService
65
- }
66
- export declare const defaultConfig: LinguiConfig
67
- export declare function getConfig({
68
- cwd,
69
- configPath,
70
- skipValidation,
71
- }?: {
72
- cwd?: string
73
- configPath?: string
74
- skipValidation?: boolean
75
- }): LinguiConfig
76
-
77
- export declare function makeConfig(
78
- userConfig: Partial<LinguiConfig>,
79
- opts?: {
80
- skipValidation?: boolean
81
- }
82
- ): LinguiConfig
83
-
84
- export declare const configValidation: {
85
- exampleConfig: {
86
- extractBabelOptions: {
87
- extends: string
88
- rootMode: string
89
- plugins: string[]
90
- presets: string[]
91
- }
92
- compilerBabelOptions: GeneratorOptions
93
- catalogs: CatalogConfig[]
94
- compileNamespace: "es" | "ts" | "cjs" | string
95
- fallbackLocales: FallbackLocales
96
- format: CatalogFormat
97
- formatOptions: CatalogFormatOptions
98
- locales: string[]
99
- orderBy: OrderBy
100
- pseudoLocale: string
101
- rootDir: string
102
- runtimeConfigModule: LinguiConfig["runtimeConfigModule"]
103
- sourceLocale: string
104
- service: CatalogService
105
- }
106
- deprecatedConfig: {
107
- fallbackLocale: (
108
- config: LinguiConfig & DeprecatedFallbackLanguage
109
- ) => string
110
- localeDir: (config: LinguiConfig & DeprecatedLocaleDir) => string
111
- srcPathDirs: (config: LinguiConfig & DeprecatedLocaleDir) => string
112
- srcPathIgnorePatterns: (
113
- config: LinguiConfig & DeprecatedLocaleDir
114
- ) => string
115
- }
116
- comment: string
117
- }
118
- export declare function replaceRootDir(
119
- config: LinguiConfig,
120
- rootDir: string
121
- ): LinguiConfig
122
- /**
123
- * Replace fallbackLocale with fallbackLocales
124
- *
125
- * Released in lingui-conf 0.9
126
- * Remove anytime after 4.x
127
- */
128
- declare type DeprecatedFallbackLanguage = {
129
- fallbackLocale: string | null
130
- }
131
-
132
- export declare function fallbackLanguageMigration(
133
- config: LinguiConfig & DeprecatedFallbackLanguage
134
- ): LinguiConfig
135
- /**
136
- * Replace localeDir, srcPathDirs and srcPathIgnorePatterns with catalogs
137
- *
138
- * Released in @lingui/conf 3.0
139
- * Remove anytime after 4.x
140
- */
141
- declare type DeprecatedLocaleDir = {
142
- localeDir: string
143
- srcPathDirs: string[]
144
- srcPathIgnorePatterns: string[]
145
- }
146
- export declare function catalogMigration(
147
- config: LinguiConfig & DeprecatedLocaleDir
148
- ): LinguiConfig
149
- export {}
150
- //# sourceMappingURL=index.d.ts.map
1
+ export { makeConfig } from "./makeConfig";
2
+ export { getConfig } from "./getConfig";
3
+ export * from "./types";