Dive into secure and efficient coding practices with our curated list of the top 10 examples showcasing 'node-titanium-sdk' in functional components in JavaScript. Our advanced machine learning engine meticulously scans each line of code, cross-referencing millions of open source libraries to ensure your implementation is not just functional, but also robust and secure. Elevate your React applications to new heights by mastering the art of handling side effects, API calls, and asynchronous operations with confidence and precision.
AndroidModuleBuilder.prototype.run = async function run(logger, config, cli, finished) {
try {
// Call the base builder's run() method.
Builder.prototype.run.apply(this, arguments);
// Notify plugins that we're about to begin.
await new Promise((resolve) => {
cli.emit('build.module.pre.construct', this, resolve);
});
// Update module's config files, if necessary.
await this.migrate();
// Post build anlytics.
await this.doAnalytics();
// Initialize build variables and directory.
await this.initialize();
await this.loginfo();
await this.cleanup();
function validate(logger, config, cli) {
Builder.prototype.validate.apply(this, arguments);
this.target = cli.argv.target;
this.wpsdk = this.getWindowsSDKTarget();
this.deployType = !/^dist-$/.test(this.target) && cli.argv['deploy-type'] ? cli.argv['deploy-type'] : this.deployTypes[this.target];
this.buildType = cli.argv['build-type'] || '';
if (this.wpsdk == '8.1') {
logger.warn(__('Support for Windows 8.1 and Windows Phone 8.1 SDKs has been dropped as of Titanium SDK 6.3.0.GA, and will be removed in Titanium SDK 7.0.0.GA'));
}
// ti.deploytype is deprecated and so we force the real deploy type
if (cli.tiapp.properties['ti.deploytype']) {
logger.warn(__('The %s tiapp.xml property has been deprecated, please use the %s option', 'ti.deploytype'.cyan, '--deploy-type'.cyan));
}
cli.tiapp.properties['ti.deploytype'] = {type: 'string', value: this.deployType};
// Non-destructively copy over files from /templates/app/<template>/template
templateDir = path.join(sdkPath, 'templates', 'app', cli.argv.template, 'template');
if (!appc.fs.exists(templateDir)) {
logger.error(__('Unknown project template %s', cli.argv.template) + '\n');
process.exit(1);
}
n = appc.fs.nonDestructiveCopyDirSyncRecursive(templateDir, projectDir, {
logger: logger.log,
ignoreHiddenFiles: true
});
// Non-destructively copy over files from //templates/app/<template>/
for (p = 0; p < value.length; p++) {
if (value[p]) {
templateDir = path.join(sdkPath, ti.resolvePlatform(value[p]), 'templates', 'app', cli.argv.template, 'template');
if (appc.fs.exists(templateDir)) {
n += appc.fs.nonDestructiveCopyDirSyncRecursive(templateDir, projectDir, {
logger: logger.log,
ignoreHiddenFiles: true
});
}
}
}
value = value.join(', ');
n && logger.log();
break;
case 'sdk-version':
value = args[1];
if (value === 'latest') {
value = Object.keys(cli.env.sdks).sort().reverse()[0];
}</template></template>
} else if (fs.existsSync(path.join(projectDir, 'timodule.xml'))) {
let timodule;
try {
timodule = cli.tiapp = cli.timodule = new tiappxml(path.join(projectDir, 'timodule.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
}
const manifest = cli.manifest = ti.loadModuleManifest(logger, path.join(projectDir, 'manifest'));
// if they didn't explicitly set --platform and we have a platform in the manifest,
// then just use that and skip the platform prompting
if (!cli.argv.platform && manifest.platform) {
cli.argv.platform = ti.resolvePlatform(manifest.platform);
conf.options.platform.required = false;
}
timodule.properties || (timodule.properties = {});
cli.argv.type = 'module';
} else {
// neither app nor module
return;
}
cli.scanHooks(path.join(projectDir, 'hooks'));
return projectDir;
},
exports.run = function (logger, config, cli) {
function done(err) {
if (err) {
logger.error(__('Failed to clean project in %s', appc.time.prettyDiff(cli.startTime, Date.now())) + '\n');
} else {
logger.info(__('Project cleaned successfully in %s', appc.time.prettyDiff(cli.startTime, Date.now())) + '\n');
}
}
if (cli.argv.type === 'module') {
// TODO Iterate over platforms? For multi-platform modules we should handle this...
const platform = ti.resolvePlatform(cli.argv.platform);
const cleanModule = path.join(__dirname, '..', '..', platform, 'cli', 'commands', '_cleanModule.js');
if (!fs.existsSync(cleanModule)) {
logger.error(__('Unable to find platform specific module clean command') + '\n');
logger.log(__('Your SDK installation may be corrupt. You can reinstall it by running \'%s\'.', (cli.argv.$ + ' sdk install --force --default').cyan) + '\n');
process.exit(1);
}
// Now wrap the actual cleaning of the module (specific to a given platform),
// in hooks so a module itself could potentially do additional cleanup itself
cli.fireHook('clean.module.pre', function () {
cli.fireHook('clean.module.' + platform + '.pre', function () {
// Do the actual cleaning per-sdk _cleanModule command
require(cleanModule).run(logger, config, cli, function (err) { // eslint-disable-line security/detect-non-literal-require
const delta = appc.time.prettyDiff(cli.startTime, Date.now());
if (err) {
} else if (fs.existsSync(path.join(projectDir, 'timodule.xml'))) {
let timodule;
try {
timodule = cli.tiapp = cli.timodule = new tiappxml(path.join(projectDir, 'timodule.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
}
const manifest = cli.manifest = ti.loadModuleManifest(logger, path.join(projectDir, 'manifest'));
// if they didn't explicitly set --platform and we have a platform in the manifest,
// then just use that and skip the platform prompting
if (!cli.argv.platform && manifest.platform) {
cli.argv.platform = ti.resolvePlatform(manifest.platform);
conf.options.platform.required = false;
}
timodule.properties || (timodule.properties = {});
cli.argv.type = 'module';
} else {
// neither app nor module
return;
}
cli.scanHooks(path.join(projectDir, 'hooks'));
return projectDir;
},
logger.log.init(function () {
function next(result) {
if (result !== false) {
// no error, load the tiapp.xml plugins
ti.loadPlugins(logger, config, cli, cli.argv['project-dir'], function () {
finished(result);
});
} else {
finished(result);
}
}
// loads the platform specific bulid command and runs its validate() function
const result = ti.validatePlatformOptions(logger, config, cli, 'build');
if (result && typeof result === 'function') {
result(next);
} else {
next(result);
}
});
};
// load the tiapp.xml/timodule.xml
if (fs.existsSync(path.join(projectDir, 'tiapp.xml'))) {
let tiapp;
try {
tiapp = cli.tiapp = new tiappxml(path.join(projectDir, 'tiapp.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
}
tiapp.properties || (tiapp.properties = {});
// make sure the tiapp.xml is sane
ti.validateTiappXml(logger, config, tiapp);
// check that the Titanium SDK version is correct
if (!ti.validateCorrectSDK(logger, config, cli, 'clean')) {
throw new cli.GracefulShutdown();
}
cli.argv.type = 'app';
} else if (fs.existsSync(path.join(projectDir, 'timodule.xml'))) {
let timodule;
try {
timodule = cli.tiapp = cli.timodule = new tiappxml(path.join(projectDir, 'timodule.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
// load the tiapp.xml/timodule.xml
if (fs.existsSync(path.join(projectDir, 'tiapp.xml'))) {
let tiapp;
try {
tiapp = cli.tiapp = new tiappxml(path.join(projectDir, 'tiapp.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
}
tiapp.properties || (tiapp.properties = {});
// make sure the tiapp.xml is sane
ti.validateTiappXml(logger, config, tiapp);
// check that the Titanium SDK version is correct
if (!ti.validateCorrectSDK(logger, config, cli, 'build')) {
throw new cli.GracefulShutdown();
}
cli.argv.type = 'app';
} else if (fs.existsSync(path.join(projectDir, 'timodule.xml'))) {
let timodule;
try {
timodule = cli.tiapp = cli.timodule = new tiappxml(path.join(projectDir, 'timodule.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
projectDir = appc.fs.resolvePath(projectDir);
// load the tiapp.xml
try {
this.tiapp = new tiappxml(path.join(projectDir, 'tiapp.xml'));
} catch (ex) {
logger.error(ex);
logger.log();
process.exit(1);
}
this.tiapp.properties || (this.tiapp.properties = {});
// make sure the tiapp.xml is sane
ti.validateTiappXml(this.logger, this.config, this.tiapp);
// set the --name default to the app's name
this.conf.options.name.default = appc.string.capitalize(this.tiapp.name);
return projectDir;
}.bind(this),
desc: __('the directory containing the project'),