@react-native-community/cli-config 7.0.1
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/assign.d.ts +9 -0
- package/build/assign.d.ts.map +1 -0
- package/build/assign.js +39 -0
- package/build/assign.js.map +1 -0
- package/build/commands/config.d.ts +8 -0
- package/build/commands/config.d.ts.map +1 -0
- package/build/commands/config.js +32 -0
- package/build/commands/config.js.map +1 -0
- package/build/errors.d.ts +6 -0
- package/build/errors.d.ts.map +1 -0
- package/build/errors.js +49 -0
- package/build/errors.js.map +1 -0
- package/build/findAssets.d.ts +8 -0
- package/build/findAssets.d.ts.map +1 -0
- package/build/findAssets.js +53 -0
- package/build/findAssets.js.map +1 -0
- package/build/findDependencies.d.ts +5 -0
- package/build/findDependencies.d.ts.map +1 -0
- package/build/findDependencies.js +46 -0
- package/build/findDependencies.js.map +1 -0
- package/build/index.d.ts +7 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +23 -0
- package/build/index.js.map +1 -0
- package/build/loadConfig.d.ts +7 -0
- package/build/loadConfig.d.ts.map +1 -0
- package/build/loadConfig.js +149 -0
- package/build/loadConfig.js.map +1 -0
- package/build/merge.d.ts +6 -0
- package/build/merge.d.ts.map +1 -0
- package/build/merge.js +30 -0
- package/build/merge.js.map +1 -0
- package/build/readConfigFromDisk.d.ts +12 -0
- package/build/readConfigFromDisk.d.ts.map +1 -0
- package/build/readConfigFromDisk.js +86 -0
- package/build/readConfigFromDisk.js.map +1 -0
- package/build/resolveReactNativePath.d.ts +6 -0
- package/build/resolveReactNativePath.d.ts.map +1 -0
- package/build/resolveReactNativePath.js +39 -0
- package/build/resolveReactNativePath.js.map +1 -0
- package/build/schema.d.ts +10 -0
- package/build/schema.d.ts.map +1 -0
- package/build/schema.js +177 -0
- package/build/schema.js.map +1 -0
- package/package.json +33 -0
- package/src/__tests__/__snapshots__/index-test.ts.snap +185 -0
- package/src/__tests__/findAssets-test.ts +51 -0
- package/src/__tests__/findDependencies-test.ts +23 -0
- package/src/__tests__/index-test.ts +350 -0
- package/src/assign.ts +27 -0
- package/src/commands/config.ts +30 -0
- package/src/errors.ts +31 -0
- package/src/findAssets.ts +28 -0
- package/src/findDependencies.ts +24 -0
- package/src/index.ts +5 -0
- package/src/loadConfig.ts +157 -0
- package/src/merge.ts +12 -0
- package/src/readConfigFromDisk.ts +68 -0
- package/src/resolveReactNativePath.ts +25 -0
- package/src/schema.ts +201 -0
- package/tsconfig.json +8 -0
- package/tsconfig.tsbuildinfo +1957 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
3
|
+
*
|
|
4
|
+
* Similar to Object.assign(), but it doesn't execute getters. This allows us to have
|
|
5
|
+
* lazy properties on an object and still be able to merge them together
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export default function assign(target: Object, ...sources: Object[]): Object;
|
|
9
|
+
//# sourceMappingURL=assign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assign.d.ts","sourceRoot":"","sources":["../src/assign.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,UAmBlE"}
|
package/build/assign.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = assign;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
|
10
|
+
*
|
|
11
|
+
* Similar to Object.assign(), but it doesn't execute getters. This allows us to have
|
|
12
|
+
* lazy properties on an object and still be able to merge them together
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
function assign(target, ...sources) {
|
|
16
|
+
sources.forEach(source => {
|
|
17
|
+
let descriptors = Object.keys(source).reduce((acc, key) => {
|
|
18
|
+
const propertyDescriptor = Object.getOwnPropertyDescriptor(source, key);
|
|
19
|
+
|
|
20
|
+
if (propertyDescriptor !== undefined) {
|
|
21
|
+
acc[key] = propertyDescriptor;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return acc;
|
|
25
|
+
}, {}); // by default, Object.assign copies enumerable Symbols too
|
|
26
|
+
|
|
27
|
+
Object.getOwnPropertySymbols(source).forEach(sym => {
|
|
28
|
+
let descriptor = Object.getOwnPropertyDescriptor(source, sym);
|
|
29
|
+
|
|
30
|
+
if (descriptor && descriptor.enumerable) {
|
|
31
|
+
descriptors[sym.toString()] = descriptor;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperties(target, descriptors);
|
|
35
|
+
});
|
|
36
|
+
return target;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//# sourceMappingURL=assign.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/assign.ts"],"names":["assign","target","sources","forEach","source","descriptors","Object","keys","reduce","acc","key","propertyDescriptor","getOwnPropertyDescriptor","undefined","getOwnPropertySymbols","sym","descriptor","enumerable","toString","defineProperties"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,MAAT,CAAgBC,MAAhB,EAAgC,GAAGC,OAAnC,EAAsD;AACnEA,EAAAA,OAAO,CAACC,OAAR,CAAiBC,MAAD,IAAY;AAC1B,QAAIC,WAAW,GAAGC,MAAM,CAACC,IAAP,CAAYH,MAAZ,EAAoBI,MAApB,CAA2B,CAACC,GAAD,EAAMC,GAAN,KAAc;AACzD,YAAMC,kBAAkB,GAAGL,MAAM,CAACM,wBAAP,CAAgCR,MAAhC,EAAwCM,GAAxC,CAA3B;;AACA,UAAIC,kBAAkB,KAAKE,SAA3B,EAAsC;AACpCJ,QAAAA,GAAG,CAACC,GAAD,CAAH,GAAWC,kBAAX;AACD;;AACD,aAAOF,GAAP;AACD,KANiB,EAMf,EANe,CAAlB,CAD0B,CAQ1B;;AACAH,IAAAA,MAAM,CAACQ,qBAAP,CAA6BV,MAA7B,EAAqCD,OAArC,CAA8CY,GAAD,IAAS;AACpD,UAAIC,UAAU,GAAGV,MAAM,CAACM,wBAAP,CAAgCR,MAAhC,EAAwCW,GAAxC,CAAjB;;AACA,UAAIC,UAAU,IAAIA,UAAU,CAACC,UAA7B,EAAyC;AACvCZ,QAAAA,WAAW,CAACU,GAAG,CAACG,QAAJ,EAAD,CAAX,GAA8BF,UAA9B;AACD;AACF,KALD;AAMAV,IAAAA,MAAM,CAACa,gBAAP,CAAwBlB,MAAxB,EAAgCI,WAAhC;AACD,GAhBD;AAiBA,SAAOJ,MAAP;AACD","sourcesContent":["/**\n * Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign\n *\n * Similar to Object.assign(), but it doesn't execute getters. This allows us to have\n * lazy properties on an object and still be able to merge them together\n *\n */\nexport default function assign(target: Object, ...sources: Object[]) {\n sources.forEach((source) => {\n let descriptors = Object.keys(source).reduce((acc, key) => {\n const propertyDescriptor = Object.getOwnPropertyDescriptor(source, key);\n if (propertyDescriptor !== undefined) {\n acc[key] = propertyDescriptor;\n }\n return acc;\n }, {} as PropertyDescriptorMap);\n // by default, Object.assign copies enumerable Symbols too\n Object.getOwnPropertySymbols(source).forEach((sym) => {\n let descriptor = Object.getOwnPropertyDescriptor(source, sym);\n if (descriptor && descriptor.enumerable) {\n descriptors[sym.toString()] = descriptor;\n }\n });\n Object.defineProperties(target, descriptors);\n });\n return target;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/commands/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAa,MAAM,mCAAmC,CAAC;;;;;;AAuBrE,wBAME"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function isValidRNDependency(config) {
|
|
9
|
+
return Object.keys(config.platforms).filter(key => Boolean(config.platforms[key])).length !== 0 || config.hooks && Object.keys(config.hooks).length !== 0 || config.assets && config.assets.length !== 0 || config.params && config.params.length !== 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function filterConfig(config) {
|
|
13
|
+
const filtered = { ...config
|
|
14
|
+
};
|
|
15
|
+
Object.keys(filtered.dependencies).forEach(item => {
|
|
16
|
+
if (!isValidRNDependency(filtered.dependencies[item])) {
|
|
17
|
+
delete filtered.dependencies[item];
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return filtered;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
var _default = {
|
|
24
|
+
name: 'config',
|
|
25
|
+
description: 'Print CLI configuration',
|
|
26
|
+
func: async (_argv, ctx) => {
|
|
27
|
+
console.log(JSON.stringify(filterConfig(ctx), null, 2));
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
exports.default = _default;
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/commands/config.ts"],"names":["isValidRNDependency","config","Object","keys","platforms","filter","key","Boolean","length","hooks","assets","params","filterConfig","filtered","dependencies","forEach","item","name","description","func","_argv","ctx","console","log","JSON","stringify"],"mappings":";;;;;;;AAEA,SAASA,mBAAT,CAA6BC,MAA7B,EAAiD;AAC/C,SACEC,MAAM,CAACC,IAAP,CAAYF,MAAM,CAACG,SAAnB,EAA8BC,MAA9B,CAAsCC,GAAD,IACnCC,OAAO,CAACN,MAAM,CAACG,SAAP,CAAiBE,GAAjB,CAAD,CADT,EAEEE,MAFF,KAEa,CAFb,IAGCP,MAAM,CAACQ,KAAP,IAAgBP,MAAM,CAACC,IAAP,CAAYF,MAAM,CAACQ,KAAnB,EAA0BD,MAA1B,KAAqC,CAHtD,IAICP,MAAM,CAACS,MAAP,IAAiBT,MAAM,CAACS,MAAP,CAAcF,MAAd,KAAyB,CAJ3C,IAKCP,MAAM,CAACU,MAAP,IAAiBV,MAAM,CAACU,MAAP,CAAcH,MAAd,KAAyB,CAN7C;AAQD;;AAED,SAASI,YAAT,CAAsBX,MAAtB,EAAsC;AACpC,QAAMY,QAAQ,GAAG,EAAC,GAAGZ;AAAJ,GAAjB;AACAC,EAAAA,MAAM,CAACC,IAAP,CAAYU,QAAQ,CAACC,YAArB,EAAmCC,OAAnC,CAA4CC,IAAD,IAAU;AACnD,QAAI,CAAChB,mBAAmB,CAACa,QAAQ,CAACC,YAAT,CAAsBE,IAAtB,CAAD,CAAxB,EAAuD;AACrD,aAAOH,QAAQ,CAACC,YAAT,CAAsBE,IAAtB,CAAP;AACD;AACF,GAJD;AAKA,SAAOH,QAAP;AACD;;eAEc;AACbI,EAAAA,IAAI,EAAE,QADO;AAEbC,EAAAA,WAAW,EAAE,yBAFA;AAGbC,EAAAA,IAAI,EAAE,OAAOC,KAAP,EAAwBC,GAAxB,KAAwC;AAC5CC,IAAAA,OAAO,CAACC,GAAR,CAAYC,IAAI,CAACC,SAAL,CAAeb,YAAY,CAACS,GAAD,CAA3B,EAAkC,IAAlC,EAAwC,CAAxC,CAAZ;AACD;AALY,C","sourcesContent":["import {Config, Dependency} from '@react-native-community/cli-types';\n\nfunction isValidRNDependency(config: Dependency) {\n return (\n Object.keys(config.platforms).filter((key) =>\n Boolean(config.platforms[key]),\n ).length !== 0 ||\n (config.hooks && Object.keys(config.hooks).length !== 0) ||\n (config.assets && config.assets.length !== 0) ||\n (config.params && config.params.length !== 0)\n );\n}\n\nfunction filterConfig(config: Config) {\n const filtered = {...config};\n Object.keys(filtered.dependencies).forEach((item) => {\n if (!isValidRNDependency(filtered.dependencies[item])) {\n delete filtered.dependencies[item];\n }\n });\n return filtered;\n}\n\nexport default {\n name: 'config',\n description: 'Print CLI configuration',\n func: async (_argv: string[], ctx: Config) => {\n console.log(JSON.stringify(filterConfig(ctx), null, 2));\n },\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,KAAK,CAAC;AAEpC,qBAAa,QAAS,SAAQ,QAAQ;gBACxB,QAAQ,EAAE,eAAe;CA0BtC"}
|
package/build/errors.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.JoiError = void 0;
|
|
7
|
+
|
|
8
|
+
function _cliTools() {
|
|
9
|
+
const data = require("@react-native-community/cli-tools");
|
|
10
|
+
|
|
11
|
+
_cliTools = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class JoiError extends _cliTools().CLIError {
|
|
19
|
+
constructor(joiError) {
|
|
20
|
+
const message = joiError.details.map(error => {
|
|
21
|
+
const name = error.path.join('.');
|
|
22
|
+
|
|
23
|
+
switch (error.type) {
|
|
24
|
+
case 'object.allowUnknown':
|
|
25
|
+
{
|
|
26
|
+
const value = JSON.stringify(error.context && error.context.value);
|
|
27
|
+
return `
|
|
28
|
+
Unknown option ${name} with value "${value}" was found.
|
|
29
|
+
This is either a typing error or a user mistake. Fixing it will remove this message.
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
default:
|
|
34
|
+
return error.message;
|
|
35
|
+
}
|
|
36
|
+
}).join().trim();
|
|
37
|
+
super(message);
|
|
38
|
+
this.name = 'Config Validation Error';
|
|
39
|
+
|
|
40
|
+
if (Error.captureStackTrace) {
|
|
41
|
+
Error.captureStackTrace(this, JoiError);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.JoiError = JoiError;
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts"],"names":["JoiError","CLIError","constructor","joiError","message","details","map","error","name","path","join","type","value","JSON","stringify","context","trim","Error","captureStackTrace"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,QAAN,SAAuBC,oBAAvB,CAAgC;AACrCC,EAAAA,WAAW,CAACC,QAAD,EAA4B;AACrC,UAAMC,OAAO,GAAGD,QAAQ,CAACE,OAAT,CACbC,GADa,CACRC,KAAD,IAAW;AACd,YAAMC,IAAI,GAAGD,KAAK,CAACE,IAAN,CAAWC,IAAX,CAAgB,GAAhB,CAAb;;AACA,cAAQH,KAAK,CAACI,IAAd;AACE,aAAK,qBAAL;AAA4B;AAC1B,kBAAMC,KAAK,GAAGC,IAAI,CAACC,SAAL,CAAeP,KAAK,CAACQ,OAAN,IAAiBR,KAAK,CAACQ,OAAN,CAAcH,KAA9C,CAAd;AACA,mBAAQ;AACpB,+BAA+BJ,IAAK,gBAAeI,KAAM;AACzD;AACA,aAHY;AAID;;AACD;AACE,iBAAOL,KAAK,CAACH,OAAb;AATJ;AAWD,KAda,EAebM,IAfa,GAgBbM,IAhBa,EAAhB;AAkBA,UAAMZ,OAAN;AACA,SAAKI,IAAL,GAAY,yBAAZ;;AAEA,QAAIS,KAAK,CAACC,iBAAV,EAA6B;AAC3BD,MAAAA,KAAK,CAACC,iBAAN,CAAwB,IAAxB,EAA8BlB,QAA9B;AACD;AACF;;AA1BoC","sourcesContent":["import {CLIError} from '@react-native-community/cli-tools';\nimport {ValidationError} from 'joi';\n\nexport class JoiError extends CLIError {\n constructor(joiError: ValidationError) {\n const message = joiError.details\n .map((error) => {\n const name = error.path.join('.');\n switch (error.type) {\n case 'object.allowUnknown': {\n const value = JSON.stringify(error.context && error.context.value);\n return `\n Unknown option ${name} with value \"${value}\" was found.\n This is either a typing error or a user mistake. Fixing it will remove this message.\n `;\n }\n default:\n return error.message;\n }\n })\n .join()\n .trim();\n\n super(message);\n this.name = 'Config Validation Error';\n\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, JoiError);\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given an array of assets folders, e.g. ['Fonts', 'Images'],
|
|
3
|
+
* it globs in them to find all files that can be copied.
|
|
4
|
+
*
|
|
5
|
+
* It returns an array of absolute paths to files found.
|
|
6
|
+
*/
|
|
7
|
+
export default function findAssets(folder: string, assets: Array<string>): Array<string>;
|
|
8
|
+
//# sourceMappingURL=findAssets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findAssets.d.ts","sourceRoot":"","sources":["../src/findAssets.ts"],"names":[],"mappings":"AAWA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,UAAU,CAChC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,GACpB,KAAK,CAAC,MAAM,CAAC,CAOf"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = findAssets;
|
|
7
|
+
|
|
8
|
+
function _glob() {
|
|
9
|
+
const data = _interopRequireDefault(require("glob"));
|
|
10
|
+
|
|
11
|
+
_glob = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _path() {
|
|
19
|
+
const data = _interopRequireDefault(require("path"));
|
|
20
|
+
|
|
21
|
+
_path = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
30
|
+
const findAssetsInFolder = folder => {
|
|
31
|
+
const assets = _glob().default.sync(_path().default.join(folder, '**'), {
|
|
32
|
+
nodir: true
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (process.platform === 'win32') {
|
|
36
|
+
return assets.map(asset => asset.split('/').join('\\'));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return assets;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Given an array of assets folders, e.g. ['Fonts', 'Images'],
|
|
43
|
+
* it globs in them to find all files that can be copied.
|
|
44
|
+
*
|
|
45
|
+
* It returns an array of absolute paths to files found.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
function findAssets(folder, assets) {
|
|
50
|
+
return (assets || []).map(asset => _path().default.join(folder, asset)).reduce((acc, assetPath) => acc.concat(findAssetsInFolder(assetPath)), []);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=findAssets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/findAssets.ts"],"names":["findAssetsInFolder","folder","assets","glob","sync","path","join","nodir","process","platform","map","asset","split","findAssets","reduce","acc","assetPath","concat"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA,MAAMA,kBAAkB,GAAIC,MAAD,IAA8B;AACvD,QAAMC,MAAM,GAAGC,gBAAKC,IAAL,CAAUC,gBAAKC,IAAL,CAAUL,MAAV,EAAkB,IAAlB,CAAV,EAAmC;AAACM,IAAAA,KAAK,EAAE;AAAR,GAAnC,CAAf;;AACA,MAAIC,OAAO,CAACC,QAAR,KAAqB,OAAzB,EAAkC;AAChC,WAAOP,MAAM,CAACQ,GAAP,CAAYC,KAAD,IAAWA,KAAK,CAACC,KAAN,CAAY,GAAZ,EAAiBN,IAAjB,CAAsB,IAAtB,CAAtB,CAAP;AACD;;AACD,SAAOJ,MAAP;AACD,CAND;AAQA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASW,UAAT,CACbZ,MADa,EAEbC,MAFa,EAGE;AACf,SAAO,CAACA,MAAM,IAAI,EAAX,EACJQ,GADI,CACCC,KAAD,IAAWN,gBAAKC,IAAL,CAAUL,MAAV,EAAkBU,KAAlB,CADX,EAEJG,MAFI,CAGH,CAACC,GAAD,EAAMC,SAAN,KAAoBD,GAAG,CAACE,MAAJ,CAAWjB,kBAAkB,CAACgB,SAAD,CAA7B,CAHjB,EAIH,EAJG,CAAP;AAMD","sourcesContent":["import glob from 'glob';\nimport path from 'path';\n\nconst findAssetsInFolder = (folder: string): string[] => {\n const assets = glob.sync(path.join(folder, '**'), {nodir: true});\n if (process.platform === 'win32') {\n return assets.map((asset) => asset.split('/').join('\\\\'));\n }\n return assets;\n};\n\n/**\n * Given an array of assets folders, e.g. ['Fonts', 'Images'],\n * it globs in them to find all files that can be copied.\n *\n * It returns an array of absolute paths to files found.\n */\nexport default function findAssets(\n folder: string,\n assets: Array<string>,\n): Array<string> {\n return (assets || [])\n .map((asset) => path.join(folder, asset))\n .reduce(\n (acc, assetPath) => acc.concat(findAssetsInFolder(assetPath)),\n [] as string[],\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"findDependencies.d.ts","sourceRoot":"","sources":["../src/findDependencies.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAiBpE"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = findDependencies;
|
|
7
|
+
|
|
8
|
+
function _path() {
|
|
9
|
+
const data = _interopRequireDefault(require("path"));
|
|
10
|
+
|
|
11
|
+
_path = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _fs() {
|
|
19
|
+
const data = _interopRequireDefault(require("fs"));
|
|
20
|
+
|
|
21
|
+
_fs = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Returns an array of dependencies from project's package.json
|
|
32
|
+
*/
|
|
33
|
+
function findDependencies(root) {
|
|
34
|
+
let pjson;
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
pjson = JSON.parse(_fs().default.readFileSync(_path().default.join(root, 'package.json'), 'UTF-8'));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const deps = [...Object.keys(pjson.dependencies || {}), ...Object.keys(pjson.devDependencies || {})];
|
|
43
|
+
return deps;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=findDependencies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/findDependencies.ts"],"names":["findDependencies","root","pjson","JSON","parse","fs","readFileSync","path","join","e","deps","Object","keys","dependencies","devDependencies"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA;AACA;AACA;AACe,SAASA,gBAAT,CAA0BC,IAA1B,EAAuD;AACpE,MAAIC,KAAJ;;AAEA,MAAI;AACFA,IAAAA,KAAK,GAAGC,IAAI,CAACC,KAAL,CACNC,cAAGC,YAAH,CAAgBC,gBAAKC,IAAL,CAAUP,IAAV,EAAgB,cAAhB,CAAhB,EAAiD,OAAjD,CADM,CAAR;AAGD,GAJD,CAIE,OAAOQ,CAAP,EAAU;AACV,WAAO,EAAP;AACD;;AAED,QAAMC,IAAI,GAAG,CACX,GAAGC,MAAM,CAACC,IAAP,CAAYV,KAAK,CAACW,YAAN,IAAsB,EAAlC,CADQ,EAEX,GAAGF,MAAM,CAACC,IAAP,CAAYV,KAAK,CAACY,eAAN,IAAyB,EAArC,CAFQ,CAAb;AAKA,SAAOJ,IAAP;AACD","sourcesContent":["import path from 'path';\nimport fs from 'fs';\n\n/**\n * Returns an array of dependencies from project's package.json\n */\nexport default function findDependencies(root: string): Array<string> {\n let pjson;\n\n try {\n pjson = JSON.parse(\n fs.readFileSync(path.join(root, 'package.json'), 'UTF-8'),\n );\n } catch (e) {\n return [];\n }\n\n const deps = [\n ...Object.keys(pjson.dependencies || {}),\n ...Object.keys(pjson.devDependencies || {}),\n ];\n\n return deps;\n}\n"]}
|
package/build/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAErC,eAAO,MAAM,QAAQ;;;;GAAW,CAAC"}
|
package/build/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "default", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _loadConfig.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
exports.commands = void 0;
|
|
13
|
+
|
|
14
|
+
var _config = _interopRequireDefault(require("./commands/config"));
|
|
15
|
+
|
|
16
|
+
var _loadConfig = _interopRequireDefault(require("./loadConfig"));
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
const commands = [_config.default];
|
|
21
|
+
exports.commands = commands;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["commands","config"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;;;AAEO,MAAMA,QAAQ,GAAG,CAACC,eAAD,CAAjB","sourcesContent":["import config from './commands/config';\n\nexport {default} from './loadConfig';\n\nexport const commands = [config];\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../src/loadConfig.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,MAAM,EACP,MAAM,mCAAmC,CAAC;AAoD3C;;GAEG;AACH,iBAAS,UAAU,CAAC,WAAW,GAAE,MAA0B,GAAG,MAAM,CA2FnE;AAED,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
function _path() {
|
|
9
|
+
const data = _interopRequireDefault(require("path"));
|
|
10
|
+
|
|
11
|
+
_path = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
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
|
+
function _cliTools() {
|
|
29
|
+
const data = require("@react-native-community/cli-tools");
|
|
30
|
+
|
|
31
|
+
_cliTools = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
var _findDependencies = _interopRequireDefault(require("./findDependencies"));
|
|
39
|
+
|
|
40
|
+
var _resolveReactNativePath = _interopRequireDefault(require("./resolveReactNativePath"));
|
|
41
|
+
|
|
42
|
+
var _findAssets = _interopRequireDefault(require("./findAssets"));
|
|
43
|
+
|
|
44
|
+
var _readConfigFromDisk = require("./readConfigFromDisk");
|
|
45
|
+
|
|
46
|
+
var _assign = _interopRequireDefault(require("./assign"));
|
|
47
|
+
|
|
48
|
+
var _merge = _interopRequireDefault(require("./merge"));
|
|
49
|
+
|
|
50
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
51
|
+
|
|
52
|
+
function getDependencyConfig(root, dependencyName, finalConfig, config, userConfig, isPlatform) {
|
|
53
|
+
return (0, _merge.default)({
|
|
54
|
+
root,
|
|
55
|
+
name: dependencyName,
|
|
56
|
+
platforms: Object.keys(finalConfig.platforms).reduce((dependency, platform) => {
|
|
57
|
+
const platformConfig = finalConfig.platforms[platform];
|
|
58
|
+
dependency[platform] = // Linking platforms is not supported
|
|
59
|
+
isPlatform || !platformConfig ? null : platformConfig.dependencyConfig(root, config.dependency.platforms[platform]);
|
|
60
|
+
return dependency;
|
|
61
|
+
}, {}),
|
|
62
|
+
assets: (0, _findAssets.default)(root, config.dependency.assets),
|
|
63
|
+
hooks: config.dependency.hooks,
|
|
64
|
+
params: config.dependency.params
|
|
65
|
+
}, userConfig.dependencies[dependencyName] || {});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Loads CLI configuration
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
function loadConfig(projectRoot = (0, _cliTools().findProjectRoot)()) {
|
|
73
|
+
let lazyProject;
|
|
74
|
+
const userConfig = (0, _readConfigFromDisk.readConfigFromDisk)(projectRoot);
|
|
75
|
+
const initialConfig = {
|
|
76
|
+
root: projectRoot,
|
|
77
|
+
|
|
78
|
+
get reactNativePath() {
|
|
79
|
+
return userConfig.reactNativePath ? _path().default.resolve(projectRoot, userConfig.reactNativePath) : (0, _resolveReactNativePath.default)(projectRoot);
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
dependencies: userConfig.dependencies,
|
|
83
|
+
commands: userConfig.commands,
|
|
84
|
+
|
|
85
|
+
get assets() {
|
|
86
|
+
return (0, _findAssets.default)(projectRoot, userConfig.assets);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
healthChecks: [],
|
|
90
|
+
platforms: userConfig.platforms,
|
|
91
|
+
|
|
92
|
+
get project() {
|
|
93
|
+
if (lazyProject) {
|
|
94
|
+
return lazyProject;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
lazyProject = {};
|
|
98
|
+
|
|
99
|
+
for (const platform in finalConfig.platforms) {
|
|
100
|
+
const platformConfig = finalConfig.platforms[platform];
|
|
101
|
+
|
|
102
|
+
if (platformConfig) {
|
|
103
|
+
lazyProject[platform] = platformConfig.projectConfig(projectRoot, userConfig.project[platform] || {});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return lazyProject;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
};
|
|
111
|
+
const finalConfig = Array.from(new Set([...Object.keys(userConfig.dependencies), ...(0, _findDependencies.default)(projectRoot)])).reduce((acc, dependencyName) => {
|
|
112
|
+
const localDependencyRoot = userConfig.dependencies[dependencyName] && userConfig.dependencies[dependencyName].root;
|
|
113
|
+
let root;
|
|
114
|
+
let config;
|
|
115
|
+
|
|
116
|
+
try {
|
|
117
|
+
root = localDependencyRoot || (0, _cliTools().resolveNodeModuleDir)(projectRoot, dependencyName);
|
|
118
|
+
config = (0, _readConfigFromDisk.readDependencyConfigFromDisk)(root);
|
|
119
|
+
} catch (error) {
|
|
120
|
+
_cliTools().logger.warn((0, _cliTools().inlineString)(`
|
|
121
|
+
Package ${_chalk().default.bold(dependencyName)} has been ignored because it contains invalid configuration.
|
|
122
|
+
|
|
123
|
+
Reason: ${_chalk().default.dim(error.message)}`));
|
|
124
|
+
|
|
125
|
+
return acc;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const isPlatform = Object.keys(config.platforms).length > 0;
|
|
129
|
+
return (0, _assign.default)({}, acc, {
|
|
130
|
+
dependencies: (0, _assign.default)({}, acc.dependencies, {
|
|
131
|
+
get [dependencyName]() {
|
|
132
|
+
return getDependencyConfig(root, dependencyName, finalConfig, config, userConfig, isPlatform);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
}),
|
|
136
|
+
commands: [...acc.commands, ...config.commands],
|
|
137
|
+
platforms: { ...acc.platforms,
|
|
138
|
+
...config.platforms
|
|
139
|
+
},
|
|
140
|
+
healthChecks: [...acc.healthChecks, ...config.healthChecks]
|
|
141
|
+
});
|
|
142
|
+
}, initialConfig);
|
|
143
|
+
return finalConfig;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var _default = loadConfig;
|
|
147
|
+
exports.default = _default;
|
|
148
|
+
|
|
149
|
+
//# sourceMappingURL=loadConfig.js.map
|
|
@@ -0,0 +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","assets","hooks","params","dependencies","loadConfig","projectRoot","lazyProject","initialConfig","reactNativePath","path","resolve","commands","healthChecks","project","projectConfig","Array","from","Set","acc","localDependencyRoot","error","logger","warn","chalk","bold","dim","message","length"],"mappings":"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","sourcesContent":["import path from 'path';\nimport chalk from 'chalk';\nimport {\n UserDependencyConfig,\n ProjectConfig,\n Dependency,\n UserConfig,\n Config,\n} from '@react-native-community/cli-types';\nimport {\n logger,\n inlineString,\n findProjectRoot,\n resolveNodeModuleDir,\n} from '@react-native-community/cli-tools';\nimport findDependencies from './findDependencies';\nimport resolveReactNativePath from './resolveReactNativePath';\nimport findAssets from './findAssets';\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): Dependency {\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 assets: findAssets(root, config.dependency.assets),\n hooks: config.dependency.hooks,\n params: config.dependency.params,\n },\n userConfig.dependencies[dependencyName] || {},\n ) as Dependency;\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 get assets() {\n return findAssets(projectRoot, userConfig.assets);\n },\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: string;\n let config: UserDependencyConfig;\n try {\n root =\n localDependencyRoot ||\n resolveNodeModuleDir(projectRoot, dependencyName);\n config = readDependencyConfigFromDisk(root);\n } catch (error) {\n logger.warn(\n inlineString(`\n Package ${chalk.bold(\n dependencyName,\n )} has been ignored because it contains invalid configuration.\n\n Reason: ${chalk.dim(error.message)}`),\n );\n return acc;\n }\n\n const isPlatform = Object.keys(config.platforms).length > 0;\n\n return assign({}, acc, {\n dependencies: assign({}, acc.dependencies, {\n get [dependencyName](): Dependency {\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"]}
|
package/build/merge.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../src/merge.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,WAK7C"}
|
package/build/merge.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = merge;
|
|
7
|
+
|
|
8
|
+
function _deepmerge() {
|
|
9
|
+
const data = _interopRequireDefault(require("deepmerge"));
|
|
10
|
+
|
|
11
|
+
_deepmerge = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* `deepmerge` concatenates arrays by default instead of overwriting them.
|
|
22
|
+
* We define custom merging function for arrays to change that behaviour
|
|
23
|
+
*/
|
|
24
|
+
function merge(x, y) {
|
|
25
|
+
return (0, _deepmerge().default)(x, y, {
|
|
26
|
+
arrayMerge: (_destinationArray, sourceArray) => sourceArray
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/merge.ts"],"names":["merge","x","y","arrayMerge","_destinationArray","sourceArray"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA;AACA;AACA;AACA;AACe,SAASA,KAAT,CAAqBC,CAArB,EAA2BC,CAA3B,EAAiC;AAC9C,SAAO,0BAAUD,CAAV,EAAaC,CAAb,EAAgB;AACrBC,IAAAA,UAAU,EAAE,CAACC,iBAAD,EAA2BC,WAA3B,KACVA;AAFmB,GAAhB,CAAP;AAID","sourcesContent":["import deepmerge from 'deepmerge';\n\n/**\n * `deepmerge` concatenates arrays by default instead of overwriting them.\n * We define custom merging function for arrays to change that behaviour\n */\nexport default function merge<X, Y>(x: X, y: Y) {\n return deepmerge(x, y, {\n arrayMerge: (_destinationArray: any[], sourceArray: any[]): any[] =>\n sourceArray,\n });\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UserConfig, UserDependencyConfig } from '@react-native-community/cli-types';
|
|
2
|
+
/**
|
|
3
|
+
* Reads a project configuration as defined by the user in the current
|
|
4
|
+
* workspace.
|
|
5
|
+
*/
|
|
6
|
+
export declare function readConfigFromDisk(rootFolder: string): UserConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Reads a dependency configuration as defined by the developer
|
|
9
|
+
* inside `node_modules`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function readDependencyConfigFromDisk(rootFolder: string): UserDependencyConfig;
|
|
12
|
+
//# sourceMappingURL=readConfigFromDisk.d.ts.map
|
|
@@ -0,0 +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;AAO3C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAejE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,GACjB,oBAAoB,CAgBtB"}
|