Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use external compiler package #952

Open
wants to merge 20 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
21 changes: 11 additions & 10 deletions Alloy/alloy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@
* See LICENSE for more information on licensing.
*/
var program = require('commander'),
logger = require('./logger'),
os = require('os'),
U = require('./utils'),
colors = require('colors'),
_ = require('lodash'),
pkginfo = require('pkginfo')(module, 'version'),
path = require('path'),
fs = require('fs'),
CONST = require('./common/constants');
fs = require('fs');

// patch to remove the warning in node >=0.8
path.existsSync = fs.existsSync || path.existsSync;
const {
logger,
platforms,
utils: U
} = require('alloy-utils');

require('pkginfo')(module, 'version');

// avoid io issues on Windows in nodejs 0.10.X: https://github.com/joyent/node/issues/3584
if (process.env.ALLOY_TESTS && /^win/i.test(os.platform())) {
Expand Down Expand Up @@ -98,8 +99,8 @@ if (program.args.length === 0) {
process.exit(0);
}

if (program.platform && !_.includes(CONST.PLATFORM_FOLDERS_ALLOY, program.platform)) {
U.die('Invalid platform "' + program.platform + '" specified, must be [' + CONST.PLATFORM_FOLDERS_ALLOY.join(',') + ']');
if (program.platform && !_.includes(platforms.constants.PLATFORM_FOLDERS_ALLOY, program.platform)) {
U.die('Invalid platform "' + program.platform + '" specified, must be [' + platforms.constants.PLATFORM_FOLDERS_ALLOY.join(',') + ']');
}

// Validate the given command
Expand Down Expand Up @@ -134,7 +135,7 @@ function getCommands() {
try {
var commandsPath = path.join(__dirname, 'commands');
return _.filter(fs.readdirSync(commandsPath), function(file) {
return path.existsSync(path.join(commandsPath, file, 'index.js'));
return fs.existsSync(path.join(commandsPath, file, 'index.js'));
});
} catch (e) {
U.die('Error getting command list', e);
Expand Down
5 changes: 1 addition & 4 deletions Alloy/builtins/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ exports.lcfirst = function (text) {
* @param {String} amount Amount to format.
* @return {String} Amount formatted as a currency value.
*/
exports.formatCurrency = !(OS_MOBILEWEB) ? String.formatCurrency : function (amount) {
var num = isNaN(amount) || amount === '' || amount === null ? 0.00 : amount;
return '$' + parseFloat(num).toFixed(2);
};
exports.formatCurrency = String.formatCurrency;


/**
Expand Down
59 changes: 0 additions & 59 deletions Alloy/commands/compile/BuildLog.js

This file was deleted.

5 changes: 3 additions & 2 deletions Alloy/commands/compile/CompilerMakeFile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var logger = require('../../logger'),
colors = require('colors');
var colors = require('colors');

const { logger } = require('alloy-utils');

function CompilerMakeFile() {
var handlers = {};
Expand Down
11 changes: 7 additions & 4 deletions Alloy/commands/compile/Orphanage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
var fs = require('fs-extra'),
walkSync = require('walk-sync'),
path = require('path'),
platforms = require('../../../platforms/index'),
logger = require('../../logger'),
CONST = require('../../common/constants'),
U = require('../../utils'),
_ = require('lodash');

const {
constants: CONST,
logger,
platforms,
utils: U
} = require('alloy-utils');

var ALLOY_ROOT = path.join(__dirname, '..', '..');

var dirs, platform, titaniumFolder, theme, adapters;
Expand Down
91 changes: 0 additions & 91 deletions Alloy/commands/compile/ast/builtins-plugin.js

This file was deleted.

96 changes: 0 additions & 96 deletions Alloy/commands/compile/ast/controller.js

This file was deleted.

Loading