This repository has been archived by the owner on Nov 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
69 lines (62 loc) · 2.29 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const utils = require('rsx-common');
const path = require('path');
const generator = require('yeoman-generator');
const chalk = utils.chalk;
module.exports = generator.Base.extend({
constructor: function() {
generator.Base.apply(this, arguments);
this.argument('name', { type: String, required: true });
this.option('package', {
desc: 'Package name for the application (com.example.app)',
type: String,
defaults: 'com.rsx.' + this.name.toLowerCase()
});
},
initializing: function() {
if (!utils.validate.isPackageName(this.options.package)) {
throw new Error('Package name ' + this.options.package + ' is not valid');
}
},
writing: function() {
const templateParams = {
package: this.options.package,
name: this.name
};
// SomeApp/ios/SomeApp
this.fs.copyTpl(
this.templatePath(path.join('app', '**')),
this.destinationPath(path.join('ios', this.name)),
templateParams
);
// SomeApp/ios/SomeAppTests
this.fs.copyTpl(
this.templatePath(path.join('tests', 'Tests.m')),
this.destinationPath(path.join('ios', this.name + 'Tests', this.name + 'Tests.m')),
templateParams
);
this.fs.copy(
this.templatePath(path.join('tests', 'Info.plist')),
this.destinationPath(path.join('ios', this.name + 'Tests', 'Info.plist'))
);
// SomeApp/ios/SomeApp.xcodeproj
this.fs.copyTpl(
this.templatePath(path.join('xcodeproj', 'project.pbxproj')),
this.destinationPath(path.join('ios', this.name + '.xcodeproj', 'project.pbxproj')),
templateParams
);
this.fs.copyTpl(
this.templatePath(path.join('xcodeproj', 'xcshareddata', 'xcschemes', '_xcscheme')),
this.destinationPath(path.join('ios', this.name + '.xcodeproj', 'xcshareddata', 'xcschemes', this.name + '.xcscheme')),
templateParams
);
},
end: function() {
const projectPath = path.resolve(this.destinationRoot(), 'ios', this.name);
this.log(chalk.white.bold('To run your app on iOS:'));
this.log(chalk.white(' cd ' + this.destinationRoot()));
this.log(chalk.white(' react-native run-ios'));
this.log(chalk.white(' - or -'));
this.log(chalk.white(' Open ' + projectPath + '.xcodeproj in Xcode'));
this.log(chalk.white(' Hit the Run button'));
}
});