MCPcopy
hub / github.com/vladikoff/chromeos-apk / createExtension

Function createExtension

chromeos-apk.js:74–115  ·  view source on GitHub ↗
(packageName)

Source from the content-addressed store, hash-verified

72 }
73
74 function createExtension(packageName) {
75 var templatePath = path.join(__dirname, '_template');
76 var appPath = path.join(packageName + '.android');
77
78 // TODO: refactor this if needed in the future
79 ncp(templatePath, appPath, function (err) {
80 if (err) {
81 throw err;
82 }
83
84 fs.writeFileSync(path.join(appPath, 'vendor', 'chromium', 'crx', 'custom-android-release-1400197.apk'), fs.readFileSync(apk));
85
86 var manifest = JSON.parse(fs.readFileSync(path.join(templatePath, 'manifest.json')));
87 var messages = JSON.parse(fs.readFileSync(path.join(templatePath, '_locales', 'en', 'messages.json')));
88 manifest.arc_metadata.name = packageName;
89 manifest.arc_metadata.packageName = packageName;
90 manifest.version = '1337';
91
92 if (program.name) {
93 messages.extName.message = program.name;
94 } else if (packageName) {
95 messages.extName.message = packageName;
96 } else {
97 messages.extName.message = 'App';
98 }
99
100 if (program.tablet) {
101 manifest.arc_metadata.formFactor = 'tablet';
102 manifest.arc_metadata.orientation = 'landscape';
103 }
104
105 if (program.scale) {
106 manifest.arc_metadata.resize = 'scale';
107 }
108
109 fs.writeFileSync(path.join(appPath, 'manifest.json'), JSON.stringify(manifest, null, 2));
110 fs.writeFileSync(path.join(appPath, '_locales', 'en', 'messages.json'), JSON.stringify(messages, null, 2));
111
112 // done.
113 callback(appPath);
114 });
115 }
116 });
117
118};

Callers 1

chromeos-apk.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected