Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
statusBarStyle = 'black';
}
// write the index.html
this.cli.createHook('build.mobileweb.createIndexHtml', this, function (template, options, callback) {
fs.writeFile(path.join(this.buildDir, 'index.html'), ejs.render(template, options), callback);
})(
fs.readFileSync(path.join(this.platformPath, 'src', 'index.html')).toString(),
{
target: this.target,
tiHeader: ejs.render(fs.readFileSync(path.join(this.templatesDir, 'header.html.ejs')).toString()),
projectName: this.tiapp.name || '',
appDescription: this.tiapp.description || '',
appPublisher: this.tiapp.publisher || '',
tiGenerator: 'Appcelerator Titanium Mobile ' + ti.manifest.version,
tiStatusbarStyle: statusBarStyle,
tiCss: fs.readFileSync(path.join(this.buildDir, 'titanium.css')).toString(),
splashScreen: this.splashHtml,
tiJs: fs.readFileSync(path.join(this.buildDir, 'titanium.js')).toString(),
prefetch: this.prefetch,
escapeQuotes: escapeQuotes
},
next
);
};
this.logger.info(__('Forcing rebuild: JavaScript encryption flag changed'));
this.logger.info(' ' + __('Was: %s', manifest.encryptJS));
this.logger.info(' ' + __('Now: %s', this.encryptJS));
return true;
}
// check if the titanium sdk paths are different
if (this.platformPath !== manifest.platformPath) {
this.logger.info(__('Forcing rebuild: Titanium SDK path changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.platformPath));
this.logger.info(' ' + __('Now: %s', this.platformPath));
return true;
}
// check the git hashes are different
if (!manifest.gitHash || manifest.gitHash !== ti.manifest.githash) {
this.logger.info(__('Forcing rebuild: githash changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.gitHash));
this.logger.info(' ' + __('Now: %s', ti.manifest.githash));
return true;
}
// check if the modules hashes are different
if (this.modulesHash !== manifest.modulesHash) {
this.logger.info(__('Forcing rebuild: modules hash changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.modulesHash));
this.logger.info(' ' + __('Now: %s', this.modulesHash));
return true;
}
if (this.modulesManifestHash !== manifest.modulesManifestHash) {
this.logger.info(__('Forcing rebuild: module manifest hash changed since last build'));
return true;
}
// check if the titanium sdk paths are different
if (this.platformPath !== manifest.platformPath) {
this.logger.info(__('Forcing rebuild: Titanium SDK path changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.platformPath));
this.logger.info(' ' + __('Now: %s', this.platformPath));
return true;
}
// check the git hashes are different
if (!manifest.gitHash || manifest.gitHash !== ti.manifest.githash) {
this.logger.info(__('Forcing rebuild: githash changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.gitHash));
this.logger.info(' ' + __('Now: %s', ti.manifest.githash));
return true;
}
// check if the modules hashes are different
if (this.modulesHash !== manifest.modulesHash) {
this.logger.info(__('Forcing rebuild: modules hash changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.modulesHash));
this.logger.info(' ' + __('Now: %s', this.modulesHash));
return true;
}
if (this.modulesManifestHash !== manifest.modulesManifestHash) {
this.logger.info(__('Forcing rebuild: module manifest hash changed since last build'));
this.logger.info(' ' + __('Was: %s', manifest.modulesManifestHash));
this.logger.info(' ' + __('Now: %s', this.modulesManifestHash));
return true;
if (result && typeof result === 'function') {
result(finished);
} else {
finished(result);
}
});
};
} else {
let platforms = cli.argv.platforms || cli.argv.platform;
if (platforms) {
platforms = ti.scrubPlatforms(platforms);
if (platforms.bad.length) {
logger.error(__n('Invalid platform: %%s', 'Invalid platforms: %%s', platforms.bad.length, platforms.bad.join(', ')) + '\n');
logger.log(__('Available platforms for SDK version %s:', ti.manifest.sdkVersion) + '\n');
ti.targetPlatforms.forEach(function (p) {
logger.log(' ' + p.cyan);
});
logger.log();
process.exit(1);
}
cli.argv.platforms = platforms.scrubbed;
} else {
cli.argv.platforms = null;
}
ti.validateProjectDir(logger, cli, cli.argv, 'project-dir');
return function (finished) {
ti.loadPlugins(logger, config, cli, cli.argv['project-dir'], function () {
function writeBuildManifest(next) {
this.logger.info(__('Writing build manifest: %s', this.buildManifestFile.cyan));
this.cli.createHook('build.windows.writeBuildManifest', this, function (manifest, cb) {
fs.ensureDirSync(this.buildDir);
fs.existsSync(this.buildManifestFile) && fs.unlinkSync(this.buildManifestFile);
fs.writeFile(this.buildManifestFile, JSON.stringify(this.buildManifest = manifest, null, '\t'), cb);
})({
target: this.target,
deployType: this.deployType,
platformPath: this.platformPath,
modulesHash: this.modulesHash,
modulesManifestHash: this.modulesManifestHash,
modulesNativeHash: this.modulesNativeHash,
modulesBindingsHash: this.modulesBindingsHash,
gitHash: ti.manifest.githash,
outputDir: this.outputDir,
name: this.tiapp.name,
id: this.tiapp.id,
analytics: this.tiapp.analytics,
publisher: this.tiapp.publisher,
url: this.tiapp.url,
version: this.tiapp.version,
buildNumber: this.buildNumber,
description: this.tiapp.description,
copyright: this.tiapp.copyright,
guid: this.tiapp.guid,
icon: this.tiapp.icon,
skipJSMinification: !!this.cli.argv['skip-js-minify'],
encryptJS: this.encryptJS,
propertiesHash: this.propertiesHash
}, next);
appUrl: tiapp.url,
appVersion: tiapp.version,
buildType: this.buildType,
deployType: this.deployType,
locales: JSON.stringify(this.locales),
packages: JSON.stringify(this.packages),
projectId: tiapp.id,
projectName: tiapp.name,
target: this.target,
tiAnalyticsPlatformName: 'mobileweb',
tiFsRegistry: tiapp.mobileweb.filesystem.registry,
tiTheme: this.theme,
tiGithash: ti.manifest.githash,
tiOsName: 'mobileweb',
tiPlatformName: 'mobileweb',
tiTimestamp: ti.manifest.timestamp,
tiVersion: ti.manifest.version,
hasAnalyticsUseXhr: tiapp.mobileweb.analytics ? tiapp.mobileweb.analytics['use-xhr'] === true : false,
hasShowErrors: this.deployType != 'production' && tiapp.mobileweb['disable-error-screen'] !== true,
hasInstrumentation: !!tiapp.mobileweb.instrumentation,
hasAllowTouch: tiapp.mobileweb.hasOwnProperty('allow-touch') ? !!tiapp.mobileweb['allow-touch'] : true,
escapeQuotes: escapeQuotes
},
next
);
}.bind(this),
cli.on('build.finalize', function (builder) {
const deployType = builder.deployType || cli.argv['deploy-type'] || null;
if (deployType === 'production') {
cli.addAnalyticsEvent('Titanium API Usage', {
platform: platform,
tisdkname: (ti.manifest && ti.manifest.name) || (cli.sdk && cli.sdk.name) || null,
tisdkver: (ti.manifest && ti.manifest.version) || (cli.sdk && cli.sdk.name) || null,
deployType: deployType,
target: builder.target || cli.argv.target || null,
usage: jsanalyze.getAPIUsage()
}, 'ti.apiusage');
}
});
}
cli.on('build.finalize', function (builder) {
const deployType = builder.deployType || cli.argv['deploy-type'] || null;
if (deployType === 'production') {
cli.addAnalyticsEvent('Titanium API Usage', {
platform: platform,
tisdkname: (ti.manifest && ti.manifest.name) || (cli.sdk && cli.sdk.name) || null,
tisdkver: (ti.manifest && ti.manifest.version) || (cli.sdk && cli.sdk.name) || null,
deployType: deployType,
target: builder.target || cli.argv.target || null,
usage: jsanalyze.getAPIUsage()
}, 'ti.apiusage');
}
});
}
appName: tiapp.name,
appNames: JSON.stringify(this.appNames),
appPublisher: tiapp.publisher,
appUrl: tiapp.url,
appVersion: tiapp.version,
buildType: this.buildType,
deployType: this.deployType,
locales: JSON.stringify(this.locales),
packages: JSON.stringify(this.packages),
projectId: tiapp.id,
projectName: tiapp.name,
target: this.target,
tiAnalyticsPlatformName: 'mobileweb',
tiFsRegistry: tiapp.mobileweb.filesystem.registry,
tiTheme: this.theme,
tiGithash: ti.manifest.githash,
tiOsName: 'mobileweb',
tiPlatformName: 'mobileweb',
tiTimestamp: ti.manifest.timestamp,
tiVersion: ti.manifest.version,
hasAnalyticsUseXhr: tiapp.mobileweb.analytics ? tiapp.mobileweb.analytics['use-xhr'] === true : false,
hasShowErrors: this.deployType != 'production' && tiapp.mobileweb['disable-error-screen'] !== true,
hasInstrumentation: !!tiapp.mobileweb.instrumentation,
hasAllowTouch: tiapp.mobileweb.hasOwnProperty('allow-touch') ? !!tiapp.mobileweb['allow-touch'] : true,
escapeQuotes: escapeQuotes
},
next
);
}.bind(this),