Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

alloy

Package Overview
Dependencies
Maintainers
4
Versions
269
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alloy - npm Package Compare versions

Comparing version 0.1.8 to 0.1.10

Alloy/common/titanium.js

10

Alloy/commands/compile.js

@@ -557,3 +557,3 @@ var path = require('path'),

var xml = fs.readFileSync(viewFile);
var doc = new DOMParser().parseFromString(String(xml));
var doc = new DOMParser().parseFromString('<root>' + String(xml) + '</root>');
var docRoot = doc.documentElement;

@@ -567,8 +567,4 @@ var id = viewid || doc.documentElement.getAttribute('id') || viewName;

if (docRoot.nodeName === 'App') {
for (var i = 0, l = docRoot.childNodes.length; i < l; i++) {
template.viewCode += generateNode(false,viewFile,docRoot.childNodes.item(i),state,viewid||viewname);
}
} else {
template.viewCode += generateNode(false,viewFile,doc.documentElement,state,viewid||viewName);
for (var i = 0, l = docRoot.childNodes.length; i < l; i++) {
template.viewCode += generateNode(false,viewFile,docRoot.childNodes.item(i),state,viewid||viewname);
}

@@ -575,0 +571,0 @@ template.controllerCode += generateController(viewName,dir,state,id);

var path = require('path'),
fs = require('fs'),
spawn = require('child_process').spawn,
_ = require("../lib/alloy/underscore")._,
U = require('../utils'),
logger = require('../common/logger');
logger = require('../common/logger'),
titanium = require('../common/titanium');
// SDK constants for supported platforms
var HOME = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'];
var SDK = {
darwin: {
path: '/Library/Application Support/Titanium/',
suffix: 'mobilesdk/osx'
},
linux: {
path: '~/.titanium/',
suffix: 'mobilesdk/linux'
},
win32: {
path: path.join(process.env.APPDATA, 'Titanium'),
suffix: 'mobilesdk\\win32'
}
}
// Find out to which path the SDK is installed on OSX
if (process.platform === 'darwin') {
var osxSdkPaths = [
SDK.darwin.path,
path.join(HOME, SDK.darwin.path)
];
_.each(osxSdkPaths, function(sdkPath) {
if (path.existsSync(sdkPath)) {
SDK.darwin.path = sdkPath;
}
});
if (!SDK.darwin.path) {
U.die('Unable to find Titanium SDK, looked in: \n' + osxSdkPaths.join('\n'));
}
}
module.exports = function(args, program) {
var sdk = SDK[process.platform];
if (!sdk) {
if (!titanium.home) {
U.die('run command not supported on platform "' + process.platform + '"');
}
sdk.osPath = path.join(sdk.path, sdk.suffix);

@@ -60,97 +24,10 @@ // Validate the input path

}
// Get the target platform
// TODO: check tiapp.xml for <deployment-targets>
var platform = args.length > 1 ? args[1] : 'iphone';
// Find and validate target SDK for build
var targetSdk = args[2];
if (targetSdk) {
sdk.target = path.join(sdk.osPath, targetSdk);
}
if (!sdk.target && path.existsSync(sdk.osPath)) {
var dirs = fs.readdirSync(sdk.osPath);
if (dirs.length > 0) {
// sort and get the latest if we don't pass it in
dirs = dirs.sort();
sdk.target = path.join(sdk.osPath, dirs[dirs.length-1]);
}
}
if (!sdk.target || !path.existsSync(sdk.target)) {
U.die('Unable to find target SDK ' + (sdk.target || sdk.osPath));
}
function filterLog(line) {
line =U.trim(line);
if (!line) return;
var lines = line.split('\n');
if (lines.length > 1)
{
_.each(lines,function(l){
filterLog(l);
});
return;
}
var idx = line.indexOf(' -- [');
if (idx > 0)
{
var idx2 = line.indexOf(']', idx+7);
line = line.substring(idx2+1);
}
if (line.charAt(0)=='[')
{
var i = line.indexOf(']');
var label = line.substring(1,i);
var rest = U.trim(line.substring(i+1));
if (!rest) return;
switch(label)
{
case 'INFO':
{
logger.info(rest);
return;
}
case 'TRACE':
case 'DEBUG':
{
logger.debug(rest);
return;
}
case 'WARN':
{
logger.warn(rest);
return;
}
case 'ERROR':
{
logger.error(rest);
return;
}
}
}
logger.debug(line);
}
//run the project using titanium.py
var runArgs = [
path.join(sdk.target,'titanium.py'),
'run',
'--dir=' + path.resolve(inputPath),
'--platform=' + platform
];
var runcmd = spawn('python', runArgs, process.env);
//run stdout/stderr back through console.log
runcmd.stdout.on('data', function (data) {
filterLog(data);
});
runcmd.stderr.on('data', function (data) {
filterLog(data);
});
runcmd.on('exit', function (code) {
logger.info('Finished with code ' + code);
});
//run the project
var p = titanium.run(
inputPath,
args[1], //optional platform
program.tiverson, //optional version
program.tiSDK //optional SDK direct path
);
}

@@ -7,4 +7,3 @@ /**

function FileSysSync(model)
{
function FileSysSync(model) {
this.model = model;

@@ -16,4 +15,3 @@ this.table = model.config.adapter.tablename;

this.create = function(opts)
{
this.create = function(opts) {
// need to increment

@@ -26,4 +24,3 @@ model.set("id", Ti.App.guid);

this.read = function(opts)
{
this.read = function(opts) {
var filename = model.config.adapter.filename;

@@ -34,4 +31,3 @@ var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);

this.update = function(opts)
{
this.update = function(opts) {
var filename = model.config.adapter.filename;

@@ -42,4 +38,3 @@ var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);

this['delete'] = function(opts)
{
this['delete'] = function(opts) {
var filename = model.config.adapter.filename;

@@ -46,0 +41,0 @@ var f = Titanium.Filesystem.getFile(Titanium.Filesystem.applicationDataDirectory, filename);

@@ -8,6 +8,4 @@ /**

function InitDB()
{
if (!db)
{
function InitDB() {
if (!db) {
if (Ti.Platform.osname === 'mobileweb' || typeof Ti.Database === 'undefined') {

@@ -27,9 +25,7 @@ throw "No support for Titanium.Database in MobileWeb environment";

function GetMigrationFor(table)
{
function GetMigrationFor(table) {
var mid;
// get the latest migratino
var rs = db.execute("SELECT latest FROM migrations where model = ?",table);
if (rs.isValidRow())
{
if (rs.isValidRow()) {
mid = rs.field(0);

@@ -88,4 +84,3 @@ }

this.createTable = function(name,config)
{
this.createTable = function(name,config) {
Ti.API.info("create table migration called for "+config.adapter.tablename);

@@ -96,8 +91,7 @@

for (var k in config.columns)
{
for (var k in config.columns) {
columns.push(k + ' ' + self.column(config.columns[k]));
}
var sql = "CREATE TABLE "+config.adapter.tablename+" ( " + columns.join(",") + " )";
var sql = "CREATE TABLE "+config.adapter.tablename+" ( " + columns.join(",")+",id" + " )";
Ti.API.info(sql);

@@ -108,4 +102,3 @@

this.dropTable = function(name)
{
this.dropTable = function(name) {
Ti.API.info("drop table migration called for "+name);

@@ -116,4 +109,3 @@ db.execute("DROP TABLE IF EXISTS "+name);

function SQLSync(model)
{
function SQLSync(model) {
this.model = model;

@@ -125,2 +117,19 @@ this.table = model.config.adapter.tablename;

this.create = function(opts) {
var names = [];
var values = [];
var q = [];
for (var k in self.columns)
{
names.push(k);
values.push(self.model.get(k));
q.push('?');
}
var lastRowID = db.getLastInsertRowId();
var sql = 'INSERT INTO '+self.table+' ('+names.join(',')+',id) values ('+q.join(',')+',?)';
values.push(lastRowID);
db.execute(sql,values);
self.model.id = lastRowID;
};
this.read = function(opts)

@@ -130,3 +139,2 @@ {

var rs = db.execute(sql);
var results = [];
while(rs.isValidRow())

@@ -144,13 +152,13 @@ {

});
o.id = rs.fieldByName('rowid');
var m = new self.model.model(o);
results.push(m);
//o.id = rs.fieldByName('rowid');
//var m = new self.model.model(o);
//results.push(m);
rs.next();
}
rs.close();
return results;
//return results;
};
this.create = function(opts)
{
this.update = function(opts) {
//var sql = 'UPDATE '+self.table+' SET 'icon=? WHERE id=?s rowid,* from "+self.table;
var names = [];

@@ -161,13 +169,15 @@ var values = [];

{
names.push(k);
names.push(k+'=?');
values.push(self.model.get(k));
q.push("?");
}
var sql = "insert into "+self.table + " (" + names.join(",") + ") values (" + q.join(",") +")";
var sql = 'UPDATE '+self.table+' SET '+names.join(',')+' WHERE id=?';
var e = sql +","+values.join(',')+','+self.model.id;
Ti.API.info(e);
values.push(self.model.id);
db.execute(sql,values);
self.model.id = db.getLastInsertRowId();
};
this['delete'] = function(opts)
{
this['delete'] = function(opts) {
var sql = "delete from "+self.table+" where rowid = ?";

@@ -180,11 +190,8 @@ db.execute(sql,self.model.id);

function GetMigrationForCached(t,m)
{
if (m[t])
{
function GetMigrationForCached(t,m) {
if (m[t]) {
return m[t];
}
var v = GetMigrationFor(t);
if (v)
{
if (v) {
m[t] = v;

@@ -195,4 +202,3 @@ }

function Migrate(migrations)
{
function Migrate(migrations) {
var prev;

@@ -209,4 +215,3 @@

// oldest to newest based on timestamp
_.each(migrations,function(migration)
{
_.each(migrations,function(migration) {
var mctx = {};

@@ -216,11 +221,8 @@ migration(mctx);

Ti.API.info("mid = "+mid+", name = "+mctx.name);
if (!mid || mctx.id > mid)
{
if (!mid || mctx.id > mid) {
Ti.API.info("Migration starting to "+mctx.id+" for "+mctx.name);
if (prev && _.isFunction(prev.down))
{
if (prev && _.isFunction(prev.down)) {
prev.down(sqlMigration);
}
if (_.isFunction(mctx.up))
{
if (_.isFunction(mctx.up)) {
mctx.down(sqlMigration);

@@ -231,4 +233,3 @@ mctx.up(sqlMigration);

}
else
{
else {
Ti.API.info("skipping migration "+mctx.id+", already performed");

@@ -239,4 +240,3 @@ prev = null;

if (prev && prev.id)
{
if (prev && prev.id) {
db.execute("DELETE FROM migrations where model = ?",prev.name);

@@ -249,4 +249,3 @@ db.execute("INSERT INTO migrations VALUES (?,?)",prev.id,prev.name);

function Sync(model, method, opts)
{
function Sync(model, method, opts) {
var sync = new SQLSync(model);

@@ -253,0 +252,0 @@ return sync[method](opts);

@@ -16,3 +16,3 @@ {

],
"version": "0.1.8",
"version": "0.1.10",
"author": "Appcelerator, Inc. <info@appcelerator.com>",

@@ -19,0 +19,0 @@ "maintainers": [

@@ -19,24 +19,8 @@ var exec = require('child_process').exec;

runs(function() {
console.log(output);
expect(output).toContain('Alloy by Appcelerator. The MVC app framework for Titanium.');
//ensure usage data and some known options are displayed
expect(output).toContain('Usage:');
expect(output).toContain('-h');
expect(output).toContain('--force');
});
});
});
describe('the "run" command in the CLI', function() {
it('will do something awesome (placeholder)', function() {
expect(true).toBe(true);
});
});
describe('the "new" command in the CLI', function() {
it('will generate a view', function() {
expect(true).toBe(true);
});
});
describe('the "compile" command in the CLI', function() {
it('will do something awesome (placeholder)', function() {
expect(true).toBe(true);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc