@react-native-community/cli-config 8.0.2 → 8.0.6
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.
- package/build/loadConfig.d.ts.map +1 -1
- package/build/loadConfig.js +2 -25
- package/build/loadConfig.js.map +1 -1
- package/build/readConfigFromDisk.d.ts +1 -1
- package/build/readConfigFromDisk.d.ts.map +1 -1
- package/build/readConfigFromDisk.js +30 -3
- package/build/readConfigFromDisk.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../src/loadConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../src/loadConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAKL,MAAM,EACP,MAAM,mCAAmC,CAAC;AA8C3C;;GAEG;AACH,iBAAS,UAAU,CAAC,WAAW,GAAE,MAA0B,GAAG,MAAM,CAyEnE;AAED,eAAe,UAAU,CAAC"}
|
package/build/loadConfig.js
CHANGED
|
@@ -15,16 +15,6 @@ function _path() {
|
|
|
15
15
|
return data;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
function _chalk() {
|
|
19
|
-
const data = _interopRequireDefault(require("chalk"));
|
|
20
|
-
|
|
21
|
-
_chalk = function () {
|
|
22
|
-
return data;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return data;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
18
|
function _cliTools() {
|
|
29
19
|
const data = require("@react-native-community/cli-tools");
|
|
30
20
|
|
|
@@ -100,21 +90,8 @@ function loadConfig(projectRoot = (0, _cliTools().findProjectRoot)()) {
|
|
|
100
90
|
};
|
|
101
91
|
const finalConfig = Array.from(new Set([...Object.keys(userConfig.dependencies), ...(0, _findDependencies.default)(projectRoot)])).reduce((acc, dependencyName) => {
|
|
102
92
|
const localDependencyRoot = userConfig.dependencies[dependencyName] && userConfig.dependencies[dependencyName].root;
|
|
103
|
-
let root;
|
|
104
|
-
let config;
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
root = localDependencyRoot || (0, _cliTools().resolveNodeModuleDir)(projectRoot, dependencyName);
|
|
108
|
-
config = (0, _readConfigFromDisk.readDependencyConfigFromDisk)(root);
|
|
109
|
-
} catch (error) {
|
|
110
|
-
_cliTools().logger.warn((0, _cliTools().inlineString)(`
|
|
111
|
-
Package ${_chalk().default.bold(dependencyName)} has been ignored because it contains invalid configuration.
|
|
112
|
-
|
|
113
|
-
Reason: ${_chalk().default.dim(error.message)}`));
|
|
114
|
-
|
|
115
|
-
return acc;
|
|
116
|
-
}
|
|
117
|
-
|
|
93
|
+
let root = localDependencyRoot || (0, _cliTools().resolveNodeModuleDir)(projectRoot, dependencyName);
|
|
94
|
+
let config = (0, _readConfigFromDisk.readDependencyConfigFromDisk)(root, dependencyName);
|
|
118
95
|
const isPlatform = Object.keys(config.platforms).length > 0;
|
|
119
96
|
return (0, _assign.default)({}, acc, {
|
|
120
97
|
dependencies: (0, _assign.default)({}, acc.dependencies, {
|
package/build/loadConfig.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/loadConfig.ts"],"names":["getDependencyConfig","root","dependencyName","finalConfig","config","userConfig","isPlatform","name","platforms","Object","keys","reduce","dependency","platform","platformConfig","dependencyConfig","dependencies","loadConfig","projectRoot","lazyProject","initialConfig","reactNativePath","path","resolve","commands","healthChecks","project","projectConfig","Array","from","Set","acc","localDependencyRoot","
|
|
1
|
+
{"version":3,"sources":["../src/loadConfig.ts"],"names":["getDependencyConfig","root","dependencyName","finalConfig","config","userConfig","isPlatform","name","platforms","Object","keys","reduce","dependency","platform","platformConfig","dependencyConfig","dependencies","loadConfig","projectRoot","lazyProject","initialConfig","reactNativePath","path","resolve","commands","healthChecks","project","projectConfig","Array","from","Set","acc","localDependencyRoot","length"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AA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;AACrBf,MAAAA,YAAY,EAAE,qBAAO,EAAP,EAAWe,GAAG,CAACf,YAAf,EAA6B;AACzC,aAAKd,cAAL,IAAyC;AACvC,iBAAOF,mBAAmB,CACxBC,IADwB,EAExBC,cAFwB,EAGxBC,WAHwB,EAIxBC,MAJwB,EAKxBC,UALwB,EAMxBC,UANwB,CAA1B;AAQD;;AAVwC,OAA7B,CADO;AAarBkB,MAAAA,QAAQ,EAAE,CAAC,GAAGO,GAAG,CAACP,QAAR,EAAkB,GAAGpB,MAAM,CAACoB,QAA5B,CAbW;AAcrBhB,MAAAA,SAAS,EAAE,EACT,GAAGuB,GAAG,CAACvB,SADE;AAET,WAAGJ,MAAM,CAACI;AAFD,OAdU;AAkBrBiB,MAAAA,YAAY,EAAE,CAAC,GAAGM,GAAG,CAACN,YAAR,EAAsB,GAAGrB,MAAM,CAACqB,YAAhC;AAlBO,KAAhB,CAAP;AAoBD,GAnCmB,EAmCjBL,aAnCiB,CAApB;AAqCA,SAAOjB,WAAP;AACD;;eAEcc,U","sourcesContent":["import path from 'path';\nimport {\n UserDependencyConfig,\n ProjectConfig,\n DependencyConfig,\n UserConfig,\n Config,\n} from '@react-native-community/cli-types';\nimport {\n findProjectRoot,\n resolveNodeModuleDir,\n} from '@react-native-community/cli-tools';\nimport findDependencies from './findDependencies';\nimport resolveReactNativePath from './resolveReactNativePath';\nimport {\n readConfigFromDisk,\n readDependencyConfigFromDisk,\n} from './readConfigFromDisk';\nimport assign from './assign';\nimport merge from './merge';\n\nfunction getDependencyConfig(\n root: string,\n dependencyName: string,\n finalConfig: Config,\n config: UserDependencyConfig,\n userConfig: UserConfig,\n isPlatform: boolean,\n): DependencyConfig {\n return merge(\n {\n root,\n name: dependencyName,\n platforms: Object.keys(finalConfig.platforms).reduce(\n (dependency, platform) => {\n const platformConfig = finalConfig.platforms[platform];\n dependency[platform] =\n // Linking platforms is not supported\n isPlatform || !platformConfig\n ? null\n : platformConfig.dependencyConfig(\n root,\n config.dependency.platforms[platform],\n );\n return dependency;\n },\n {} as Config['platforms'],\n ),\n },\n userConfig.dependencies[dependencyName] || {},\n ) as DependencyConfig;\n}\n\n/**\n * Loads CLI configuration\n */\nfunction loadConfig(projectRoot: string = findProjectRoot()): Config {\n let lazyProject: ProjectConfig;\n const userConfig = readConfigFromDisk(projectRoot);\n\n const initialConfig: Config = {\n root: projectRoot,\n get reactNativePath() {\n return userConfig.reactNativePath\n ? path.resolve(projectRoot, userConfig.reactNativePath)\n : resolveReactNativePath(projectRoot);\n },\n dependencies: userConfig.dependencies,\n commands: userConfig.commands,\n healthChecks: [],\n platforms: userConfig.platforms,\n get project() {\n if (lazyProject) {\n return lazyProject;\n }\n\n lazyProject = {};\n for (const platform in finalConfig.platforms) {\n const platformConfig = finalConfig.platforms[platform];\n if (platformConfig) {\n lazyProject[platform] = platformConfig.projectConfig(\n projectRoot,\n userConfig.project[platform] || {},\n );\n }\n }\n\n return lazyProject;\n },\n };\n\n const finalConfig = Array.from(\n new Set([\n ...Object.keys(userConfig.dependencies),\n ...findDependencies(projectRoot),\n ]),\n ).reduce((acc: Config, dependencyName) => {\n const localDependencyRoot =\n userConfig.dependencies[dependencyName] &&\n userConfig.dependencies[dependencyName].root;\n let root =\n localDependencyRoot || resolveNodeModuleDir(projectRoot, dependencyName);\n let config = readDependencyConfigFromDisk(root, dependencyName);\n\n const isPlatform = Object.keys(config.platforms).length > 0;\n\n return assign({}, acc, {\n dependencies: assign({}, acc.dependencies, {\n get [dependencyName](): DependencyConfig {\n return getDependencyConfig(\n root,\n dependencyName,\n finalConfig,\n config,\n userConfig,\n isPlatform,\n );\n },\n }),\n commands: [...acc.commands, ...config.commands],\n platforms: {\n ...acc.platforms,\n ...config.platforms,\n },\n healthChecks: [...acc.healthChecks, ...config.healthChecks],\n }) as Config;\n }, initialConfig);\n\n return finalConfig;\n}\n\nexport default loadConfig;\n"]}
|
|
@@ -8,5 +8,5 @@ export declare function readConfigFromDisk(rootFolder: string): UserConfig;
|
|
|
8
8
|
* Reads a dependency configuration as defined by the developer
|
|
9
9
|
* inside `node_modules`.
|
|
10
10
|
*/
|
|
11
|
-
export declare function readDependencyConfigFromDisk(rootFolder: string): UserDependencyConfig;
|
|
11
|
+
export declare function readDependencyConfigFromDisk(rootFolder: string, dependencyName: string): UserDependencyConfig;
|
|
12
12
|
//# sourceMappingURL=readConfigFromDisk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readConfigFromDisk.d.ts","sourceRoot":"","sources":["../src/readConfigFromDisk.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,oBAAoB,EACrB,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"readConfigFromDisk.d.ts","sourceRoot":"","sources":["../src/readConfigFromDisk.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,oBAAoB,EACrB,MAAM,mCAAmC,CAAC;AAS3C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAejE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,EAClB,cAAc,EAAE,MAAM,GACrB,oBAAoB,CA0BtB"}
|
|
@@ -20,6 +20,26 @@ var _errors = require("./errors");
|
|
|
20
20
|
|
|
21
21
|
var schema = _interopRequireWildcard(require("./schema"));
|
|
22
22
|
|
|
23
|
+
function _cliTools() {
|
|
24
|
+
const data = require("@react-native-community/cli-tools");
|
|
25
|
+
|
|
26
|
+
_cliTools = function () {
|
|
27
|
+
return data;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function _chalk() {
|
|
34
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
35
|
+
|
|
36
|
+
_chalk = function () {
|
|
37
|
+
return data;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
|
|
23
43
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
44
|
|
|
25
45
|
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; }
|
|
@@ -56,17 +76,24 @@ function readConfigFromDisk(rootFolder) {
|
|
|
56
76
|
*/
|
|
57
77
|
|
|
58
78
|
|
|
59
|
-
function readDependencyConfigFromDisk(rootFolder) {
|
|
79
|
+
function readDependencyConfigFromDisk(rootFolder, dependencyName) {
|
|
60
80
|
const explorer = (0, _cosmiconfig().default)('react-native', {
|
|
61
81
|
stopDir: rootFolder,
|
|
62
82
|
searchPlaces
|
|
63
83
|
});
|
|
64
84
|
const searchResult = explorer.searchSync(rootFolder);
|
|
65
85
|
const config = searchResult ? searchResult.config : emptyDependencyConfig;
|
|
66
|
-
const result = schema.dependencyConfig.validate(config
|
|
86
|
+
const result = schema.dependencyConfig.validate(config, {
|
|
87
|
+
abortEarly: false
|
|
88
|
+
});
|
|
67
89
|
|
|
68
90
|
if (result.error) {
|
|
69
|
-
|
|
91
|
+
const validationError = new _errors.JoiError(result.error);
|
|
92
|
+
|
|
93
|
+
_cliTools().logger.warn((0, _cliTools().inlineString)(`
|
|
94
|
+
Package ${_chalk().default.bold(dependencyName)} contains invalid configuration: ${_chalk().default.bold(validationError.message)}.
|
|
95
|
+
|
|
96
|
+
Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.`));
|
|
70
97
|
}
|
|
71
98
|
|
|
72
99
|
return result.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/readConfigFromDisk.ts"],"names":["searchPlaces","readConfigFromDisk","rootFolder","explorer","stopDir","searchResult","searchSync","config","undefined","result","schema","projectConfig","validate","error","JoiError","value","readDependencyConfigFromDisk","emptyDependencyConfig","dependencyConfig","dependency","platforms","commands"],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/readConfigFromDisk.ts"],"names":["searchPlaces","readConfigFromDisk","rootFolder","explorer","stopDir","searchResult","searchSync","config","undefined","result","schema","projectConfig","validate","error","JoiError","value","readDependencyConfigFromDisk","dependencyName","emptyDependencyConfig","dependencyConfig","abortEarly","validationError","logger","warn","chalk","bold","message","dependency","platforms","commands"],"mappings":";;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;AAEA;AACA;AACA;AACA,MAAMA,YAAY,GAAG,CAAC,wBAAD,CAArB;AAEA;AACA;AACA;AACA;;AACO,SAASC,kBAAT,CAA4BC,UAA5B,EAA4D;AACjE,QAAMC,QAAQ,GAAG,4BAAY,cAAZ,EAA4B;AAC3CH,IAAAA,YAD2C;AAE3CI,IAAAA,OAAO,EAAEF;AAFkC,GAA5B,CAAjB;AAKA,QAAMG,YAAY,GAAGF,QAAQ,CAACG,UAAT,CAAoBJ,UAApB,CAArB;AACA,QAAMK,MAAM,GAAGF,YAAY,GAAGA,YAAY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JoiError} from './errors';\nimport * as schema from './schema';\nimport {\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 */\nconst searchPlaces = ['react-native.config.js'];\n\n/**\n * Reads a project configuration as defined by the user in the current\n * workspace.\n */\nexport function readConfigFromDisk(rootFolder: string): UserConfig {\n const explorer = cosmiconfig('react-native', {\n searchPlaces,\n stopDir: rootFolder,\n });\n\n const searchResult = explorer.searchSync(rootFolder);\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 dependency configuration as defined by the developer\n * inside `node_modules`.\n */\nexport function readDependencyConfigFromDisk(\n rootFolder: string,\n dependencyName: string,\n): UserDependencyConfig {\n const explorer = cosmiconfig('react-native', {\n stopDir: rootFolder,\n searchPlaces,\n });\n\n const searchResult = explorer.searchSync(rootFolder);\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 \"react-native config\" command and contact the package maintainers about this.`),\n );\n }\n\n return result.value as UserDependencyConfig;\n}\n\nconst emptyDependencyConfig = {\n dependency: {\n platforms: {},\n },\n commands: [],\n platforms: {},\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-community/cli-config",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.6",
|
|
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": "^8.0.
|
|
11
|
+
"@react-native-community/cli-tools": "^8.0.4",
|
|
12
12
|
"cosmiconfig": "^5.1.0",
|
|
13
13
|
"deepmerge": "^3.2.0",
|
|
14
14
|
"glob": "^7.1.3",
|
|
@@ -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": "0d5f1e420c9e1e709bdfa9452833e18a5281e9b0"
|
|
34
34
|
}
|