1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.installTemplatePackage = installTemplatePackage;
|
7 | exports.getTemplateConfig = getTemplateConfig;
|
8 | exports.copyTemplate = copyTemplate;
|
9 | exports.executePostInitScript = executePostInitScript;
|
10 |
|
11 | function _execa() {
|
12 | const data = _interopRequireDefault(require("execa"));
|
13 |
|
14 | _execa = function () {
|
15 | return data;
|
16 | };
|
17 |
|
18 | return data;
|
19 | }
|
20 |
|
21 | function _path() {
|
22 | const data = _interopRequireDefault(require("path"));
|
23 |
|
24 | _path = function () {
|
25 | return data;
|
26 | };
|
27 |
|
28 | return data;
|
29 | }
|
30 |
|
31 | function _cliTools() {
|
32 | const data = require("@react-native-community/cli-tools");
|
33 |
|
34 | _cliTools = function () {
|
35 | return data;
|
36 | };
|
37 |
|
38 | return data;
|
39 | }
|
40 |
|
41 | var PackageManager = _interopRequireWildcard(require("../../tools/packageManager"));
|
42 |
|
43 | var _copyFiles = _interopRequireDefault(require("../../tools/copyFiles"));
|
44 |
|
45 | var _replacePathSepForRegex = _interopRequireDefault(require("../../tools/replacePathSepForRegex"));
|
46 |
|
47 | function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
|
48 |
|
49 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
50 |
|
51 | function installTemplatePackage(templateName, root, npm) {
|
52 | _cliTools().logger.debug(`Installing template from ${templateName}`);
|
53 |
|
54 | return PackageManager.install([templateName], {
|
55 | preferYarn: !npm,
|
56 | silent: true,
|
57 | root
|
58 | });
|
59 | }
|
60 |
|
61 | function getTemplateConfig(templateName, templateSourceDir) {
|
62 | const configFilePath = _path().default.resolve(templateSourceDir, 'node_modules', templateName, 'template.config');
|
63 |
|
64 | _cliTools().logger.debug(`Getting config from ${configFilePath}.js`);
|
65 |
|
66 | return require(configFilePath);
|
67 | }
|
68 |
|
69 | async function copyTemplate(templateName, templateDir, templateSourceDir) {
|
70 | const templatePath = _path().default.resolve(templateSourceDir, 'node_modules', templateName, templateDir);
|
71 |
|
72 | _cliTools().logger.debug(`Copying template from ${templatePath}`);
|
73 |
|
74 | let regexStr = _path().default.resolve(templatePath, 'node_modules');
|
75 |
|
76 | await (0, _copyFiles.default)(templatePath, process.cwd(), {
|
77 | exclude: [new RegExp((0, _replacePathSepForRegex.default)(regexStr))]
|
78 | });
|
79 | }
|
80 |
|
81 | function executePostInitScript(templateName, postInitScript, templateSourceDir) {
|
82 | const scriptPath = _path().default.resolve(templateSourceDir, 'node_modules', templateName, postInitScript);
|
83 |
|
84 | _cliTools().logger.debug(`Executing post init script located ${scriptPath}`);
|
85 |
|
86 | return (0, _execa().default)(scriptPath, {
|
87 | stdio: 'inherit'
|
88 | });
|
89 | } |
\ | No newline at end of file |