@react-native-community/cli-config 15.1.0 → 15.1.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readConfigFromDisk.d.ts","sourceRoot":"","sources":["../src/readConfigFromDisk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"readConfigFromDisk.d.ts","sourceRoot":"","sources":["../src/readConfigFromDisk.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,UAAU,EACV,oBAAoB,EACrB,MAAM,mCAAmC,CAAC;AA4B3C;;;GAGG;AACH,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,CAAC,CAQrB;AAED;;;GAGG;AAEH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAQjE;AA2BD;;;GAGG;AACH,wBAAsB,iCAAiC,CACrD,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,OAAO,CAAC,oBAAoB,CAAC,CAQ/B;AAED;;;GAGG;AAEH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,oBAAoB,CAQtB"}
|
|
@@ -35,8 +35,20 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
35
35
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
36
36
|
/**
|
|
37
37
|
* Places to look for the configuration file.
|
|
38
|
+
* Note that we need different sets for CJS and ESM because the synchronous
|
|
39
|
+
* version cannot contain `.mjs` files. Doing so will cause "Error: Missing
|
|
40
|
+
* loader for extension" during runtime.
|
|
38
41
|
*/
|
|
39
|
-
const
|
|
42
|
+
const searchPlacesForCJS = ['react-native.config.js', 'react-native.config.cjs', 'react-native.config.ts'];
|
|
43
|
+
const searchPlaces = [...searchPlacesForCJS, 'react-native.config.mjs'];
|
|
44
|
+
function parseUserConfig(searchResult) {
|
|
45
|
+
const config = searchResult ? searchResult.config : undefined;
|
|
46
|
+
const result = schema.projectConfig.validate(config);
|
|
47
|
+
if (result.error) {
|
|
48
|
+
throw new _errors.JoiError(result.error);
|
|
49
|
+
}
|
|
50
|
+
return result.value;
|
|
51
|
+
}
|
|
40
52
|
|
|
41
53
|
/**
|
|
42
54
|
* Reads a project configuration as defined by the user in the current
|
|
@@ -48,12 +60,7 @@ async function readConfigFromDiskAsync(rootFolder) {
|
|
|
48
60
|
searchPlaces
|
|
49
61
|
});
|
|
50
62
|
const searchResult = await explorer.search(rootFolder);
|
|
51
|
-
|
|
52
|
-
const result = schema.projectConfig.validate(config);
|
|
53
|
-
if (result.error) {
|
|
54
|
-
throw new _errors.JoiError(result.error);
|
|
55
|
-
}
|
|
56
|
-
return result.value;
|
|
63
|
+
return parseUserConfig(searchResult);
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
/**
|
|
@@ -64,13 +71,22 @@ async function readConfigFromDiskAsync(rootFolder) {
|
|
|
64
71
|
function readConfigFromDisk(rootFolder) {
|
|
65
72
|
const explorer = (0, _cosmiconfig().cosmiconfigSync)('react-native', {
|
|
66
73
|
stopDir: rootFolder,
|
|
67
|
-
searchPlaces
|
|
74
|
+
searchPlaces: searchPlacesForCJS
|
|
68
75
|
});
|
|
69
76
|
const searchResult = explorer.search(rootFolder);
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
return parseUserConfig(searchResult);
|
|
78
|
+
}
|
|
79
|
+
function parseDependencyConfig(dependencyName, searchResult) {
|
|
80
|
+
const config = searchResult ? searchResult.config : emptyDependencyConfig;
|
|
81
|
+
const result = schema.dependencyConfig.validate(config, {
|
|
82
|
+
abortEarly: false
|
|
83
|
+
});
|
|
72
84
|
if (result.error) {
|
|
73
|
-
|
|
85
|
+
const validationError = new _errors.JoiError(result.error);
|
|
86
|
+
_cliTools().logger.warn((0, _cliTools().inlineString)(`
|
|
87
|
+
Package ${_chalk().default.bold(dependencyName)} contains invalid configuration: ${_chalk().default.bold(validationError.message)}.
|
|
88
|
+
|
|
89
|
+
Please verify it's properly linked using "npx react-native config" command and contact the package maintainers about this.`));
|
|
74
90
|
}
|
|
75
91
|
return result.value;
|
|
76
92
|
}
|
|
@@ -85,18 +101,7 @@ async function readDependencyConfigFromDiskAsync(rootFolder, dependencyName) {
|
|
|
85
101
|
searchPlaces
|
|
86
102
|
});
|
|
87
103
|
const searchResult = await explorer.search(rootFolder);
|
|
88
|
-
|
|
89
|
-
const result = schema.dependencyConfig.validate(config, {
|
|
90
|
-
abortEarly: false
|
|
91
|
-
});
|
|
92
|
-
if (result.error) {
|
|
93
|
-
const validationError = new _errors.JoiError(result.error);
|
|
94
|
-
_cliTools().logger.warn((0, _cliTools().inlineString)(`
|
|
95
|
-
Package ${_chalk().default.bold(dependencyName)} contains invalid configuration: ${_chalk().default.bold(validationError.message)}.
|
|
96
|
-
|
|
97
|
-
Please verify it's properly linked using "npx react-native config" command and contact the package maintainers about this.`));
|
|
98
|
-
}
|
|
99
|
-
return result.value;
|
|
104
|
+
return parseDependencyConfig(dependencyName, searchResult);
|
|
100
105
|
}
|
|
101
106
|
|
|
102
107
|
/**
|
|
@@ -107,21 +112,10 @@ async function readDependencyConfigFromDiskAsync(rootFolder, dependencyName) {
|
|
|
107
112
|
function readDependencyConfigFromDisk(rootFolder, dependencyName) {
|
|
108
113
|
const explorer = (0, _cosmiconfig().cosmiconfigSync)('react-native', {
|
|
109
114
|
stopDir: rootFolder,
|
|
110
|
-
searchPlaces
|
|
115
|
+
searchPlaces: searchPlacesForCJS
|
|
111
116
|
});
|
|
112
117
|
const searchResult = explorer.search(rootFolder);
|
|
113
|
-
|
|
114
|
-
const result = schema.dependencyConfig.validate(config, {
|
|
115
|
-
abortEarly: false
|
|
116
|
-
});
|
|
117
|
-
if (result.error) {
|
|
118
|
-
const validationError = new _errors.JoiError(result.error);
|
|
119
|
-
_cliTools().logger.warn((0, _cliTools().inlineString)(`
|
|
120
|
-
Package ${_chalk().default.bold(dependencyName)} contains invalid configuration: ${_chalk().default.bold(validationError.message)}.
|
|
121
|
-
|
|
122
|
-
Please verify it's properly linked using "npx react-native config" command and contact the package maintainers about this.`));
|
|
123
|
-
}
|
|
124
|
-
return result.value;
|
|
118
|
+
return parseDependencyConfig(dependencyName, searchResult);
|
|
125
119
|
}
|
|
126
120
|
const emptyDependencyConfig = {
|
|
127
121
|
dependency: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["searchPlaces","
|
|
1
|
+
{"version":3,"names":["searchPlacesForCJS","searchPlaces","parseUserConfig","searchResult","config","undefined","result","schema","projectConfig","validate","error","JoiError","value","readConfigFromDiskAsync","rootFolder","explorer","cosmiconfig","stopDir","search","readConfigFromDisk","cosmiconfigSync","parseDependencyConfig","dependencyName","emptyDependencyConfig","dependencyConfig","abortEarly","validationError","logger","warn","inlineString","chalk","bold","message","readDependencyConfigFromDiskAsync","readDependencyConfigFromDisk","dependency","platforms","commands"],"sources":["../src/readConfigFromDisk.ts"],"sourcesContent":["import type {CosmiconfigResult} from 'cosmiconfig';\nimport {cosmiconfig, cosmiconfigSync} from 'cosmiconfig';\nimport {JoiError} from './errors';\nimport * as schema from './schema';\nimport type {\n UserConfig,\n UserDependencyConfig,\n} from '@react-native-community/cli-types';\nimport {logger, inlineString} from '@react-native-community/cli-tools';\nimport chalk from 'chalk';\n\n/**\n * Places to look for the configuration file.\n * Note that we need different sets for CJS and ESM because the synchronous\n * version cannot contain `.mjs` files. Doing so will cause \"Error: Missing\n * loader for extension\" during runtime.\n */\nconst searchPlacesForCJS = [\n 'react-native.config.js',\n 'react-native.config.cjs',\n 'react-native.config.ts',\n];\nconst searchPlaces = [...searchPlacesForCJS, 'react-native.config.mjs'];\n\nfunction parseUserConfig(searchResult: CosmiconfigResult): UserConfig {\n const config = searchResult ? searchResult.config : undefined;\n const result = schema.projectConfig.validate(config);\n\n if (result.error) {\n throw new JoiError(result.error);\n }\n\n return result.value as UserConfig;\n}\n\n/**\n * Reads a project configuration as defined by the user in the current\n * workspace.\n */\nexport async function readConfigFromDiskAsync(\n rootFolder: string,\n): Promise<UserConfig> {\n const explorer = cosmiconfig('react-native', {\n stopDir: rootFolder,\n searchPlaces,\n });\n\n const searchResult = await explorer.search(rootFolder);\n return parseUserConfig(searchResult);\n}\n\n/**\n * Reads a project configuration as defined by the user in the current\n * workspace synchronously.\n */\n\nexport function readConfigFromDisk(rootFolder: string): UserConfig {\n const explorer = cosmiconfigSync('react-native', {\n stopDir: rootFolder,\n searchPlaces: searchPlacesForCJS,\n });\n\n const searchResult = explorer.search(rootFolder);\n return parseUserConfig(searchResult);\n}\n\nfunction parseDependencyConfig(\n dependencyName: string,\n searchResult: CosmiconfigResult,\n): UserDependencyConfig {\n const config = searchResult ? searchResult.config : emptyDependencyConfig;\n\n const result = schema.dependencyConfig.validate(config, {abortEarly: false});\n\n if (result.error) {\n const validationError = new JoiError(result.error);\n logger.warn(\n inlineString(`\n Package ${chalk.bold(\n dependencyName,\n )} contains invalid configuration: ${chalk.bold(\n validationError.message,\n )}.\n\n Please verify it's properly linked using \"npx react-native config\" command and contact the package maintainers about this.`),\n );\n }\n\n return result.value as UserDependencyConfig;\n}\n\n/**\n * Reads a dependency configuration as defined by the developer\n * inside `node_modules`.\n */\nexport async function readDependencyConfigFromDiskAsync(\n rootFolder: string,\n dependencyName: string,\n): Promise<UserDependencyConfig> {\n const explorer = cosmiconfig('react-native', {\n stopDir: rootFolder,\n searchPlaces,\n });\n\n const searchResult = await explorer.search(rootFolder);\n return parseDependencyConfig(dependencyName, searchResult);\n}\n\n/**\n * Reads a dependency configuration as defined by the developer\n * inside `node_modules` synchronously.\n */\n\nexport function readDependencyConfigFromDisk(\n rootFolder: string,\n dependencyName: string,\n): UserDependencyConfig {\n const explorer = cosmiconfigSync('react-native', {\n stopDir: rootFolder,\n searchPlaces: searchPlacesForCJS,\n });\n\n const searchResult = explorer.search(rootFolder);\n return parseDependencyConfig(dependencyName, searchResult);\n}\n\nconst emptyDependencyConfig = {\n dependency: {\n platforms: {},\n },\n commands: [],\n platforms: {},\n};\n"],"mappings":";;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;AACA;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA0B;AAAA;AAAA;AAE1B;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,kBAAkB,GAAG,CACzB,wBAAwB,EACxB,yBAAyB,EACzB,wBAAwB,CACzB;AACD,MAAMC,YAAY,GAAG,CAAC,GAAGD,kBAAkB,EAAE,yBAAyB,CAAC;AAEvE,SAASE,eAAe,CAACC,YAA+B,EAAc;EACpE,MAAMC,MAAM,GAAGD,YAAY,GAAGA,YAAY,CAACC,MAAM,GAAGC,SAAS;EAC7D,MAAMC,MAAM,GAAGC,MAAM,CAACC,aAAa,CAACC,QAAQ,CAACL,MAAM,CAAC;EAEpD,IAAIE,MAAM,CAACI,KAAK,EAAE;IAChB,MAAM,IAAIC,gBAAQ,CAACL,MAAM,CAACI,KAAK,CAAC;EAClC;EAEA,OAAOJ,MAAM,CAACM,KAAK;AACrB;;AAEA;AACA;AACA;AACA;AACO,eAAeC,uBAAuB,CAC3CC,UAAkB,EACG;EACrB,MAAMC,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AW,EAAC,cAAc,EAAE;IAC3CC,OAAO,EAAEH,UAAU;IACnBb;EACF,CAAC,CAAC;EAEF,MAAME,YAAY,GAAG,MAAMY,QAAQ,CAACG,MAAM,CAACJ,UAAU,CAAC;EACtD,OAAOO,qBAAqB,CAACC,cAAc,EAAEnB,YAAY,CAAC;AAC5D;;AAEA;AACA;AACA;AACA;;AAEO,SAAS+B,4BAA4B,CAC1CpB,UAAkB,EAClBQ,cAAsB,EACA;EACtB,MAAMP,QAAQ,GAAG,IAAAK,8BAAe,EAAC,cAAc,EAAE;IAC/CH,OAAO,EAAEH,UAAU;IACnBb,YAAY,EAAED;EAChB,CAAC,CAAC;EAEF,MAAMG,YAAY,GAAGY,QAAQ,CAACG,MAAM,CAACJ,UAAU,CAAC;EAChD,OAAOO,qBAAqB,CAACC,cAAc,EAAEnB,YAAY,CAAC;AAC5D;AAEA,MAAMoB,qBAAqB,GAAG;EAC5BY,UAAU,EAAE;IACVC,SAAS,EAAE,CAAC;EACd,CAAC;EACDC,QAAQ,EAAE,EAAE;EACZD,SAAS,EAAE,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-community/cli-config",
|
|
3
|
-
"version": "15.1.
|
|
3
|
+
"version": "15.1.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
},
|
|
9
9
|
"types": "build/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@react-native-community/cli-tools": "15.1.
|
|
11
|
+
"@react-native-community/cli-tools": "15.1.2",
|
|
12
12
|
"chalk": "^4.1.2",
|
|
13
13
|
"cosmiconfig": "^9.0.0",
|
|
14
14
|
"deepmerge": "^4.3.0",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"!*.map"
|
|
22
22
|
],
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@react-native-community/cli-types": "15.1.
|
|
24
|
+
"@react-native-community/cli-types": "15.1.2",
|
|
25
25
|
"@types/cosmiconfig": "^5.0.3"
|
|
26
26
|
},
|
|
27
27
|
"homepage": "https://github.com/react-native-community/cli/tree/main/packages/cli-config",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"url": "https://github.com/react-native-community/cli.git",
|
|
31
31
|
"directory": "packages/cli-config"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "7207ef0ae3cd8e77f5e953fae89b84a1d479d6c3"
|
|
34
34
|
}
|