Linked with new local-cli, refactored
This commit is contained in:
parent
2e2e577a09
commit
9caee3248b
24
init.js
24
init.js
|
@ -2,7 +2,6 @@
|
|||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var file = require('file');
|
||||
|
||||
function init(projectDir, appName) {
|
||||
console.log('Setting up new React Native app in ' + projectDir);
|
||||
|
@ -19,13 +18,18 @@ function init(projectDir, appName) {
|
|||
'SampleApp': appName
|
||||
};
|
||||
|
||||
var dest = f.replace(new RegExp('SampleApp', 'g'), appName);
|
||||
var dest = f.replace(/SampleApp/g, appName).replace(/^_/, ".");
|
||||
copyAndReplace(
|
||||
path.resolve(source, f),
|
||||
path.resolve(projectDir, dest),
|
||||
replacements
|
||||
);
|
||||
});
|
||||
|
||||
console.log('Next Steps:');
|
||||
console.log(' Open ' + path.resolve(projectDir, appName) + '.xcodeproj in Xcode');
|
||||
console.log(' Hit Run button');
|
||||
console.log('');
|
||||
}
|
||||
|
||||
function copyAndReplace(src, dest, replacements) {
|
||||
|
@ -43,22 +47,6 @@ function copyAndReplace(src, dest, replacements) {
|
|||
}
|
||||
}
|
||||
|
||||
function copyAndReplace2(src, dest, appName) {
|
||||
if (fs.lstatSync(src).isDirectory()) {
|
||||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest);
|
||||
}
|
||||
}
|
||||
else {
|
||||
var content = fs.readFileSync(src, 'utf8')
|
||||
.replace(new RegExp('SampleApp', 'g'), appName)
|
||||
.replace(new RegExp('Examples/' + appName + '/', 'g'), '')
|
||||
.replace(new RegExp('../../Libraries/', 'g'), 'node_modules/react-native/Libraries/')
|
||||
.replace(new RegExp('../../React/', 'g'), 'node_modules/react-native/React/');
|
||||
fs.writeFileSync(dest, content);
|
||||
}
|
||||
}
|
||||
|
||||
function walk(current) {
|
||||
if(fs.lstatSync(current).isDirectory()) {
|
||||
var files = fs.readdirSync(current).map(function(child) {
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
var spawn = require('child_process').spawn;
|
||||
var path = require('path');
|
||||
|
||||
var init = require('../init.js');
|
||||
var install = require('./install.js');
|
||||
var bundle = require('./bundle.js');
|
||||
|
||||
|
@ -59,10 +61,6 @@ function run() {
|
|||
// Here goes any cli commands we need to
|
||||
}
|
||||
|
||||
function init(root, projectName) {
|
||||
spawn(path.resolve(__dirname, '../init.sh'), [projectName], {stdio:'inherit'});
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
run();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue