alloy 3.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/cla.yaml +1 -1
- package/Alloy/alloy.js +7 -4
- package/Alloy/builtins/social.js +1 -1
- package/Alloy/builtins/string.js +1 -4
- package/Alloy/commands/compile/Orphanage.js +1 -2
- package/Alloy/commands/compile/README.md +1 -1
- package/Alloy/commands/compile/ast/builtins-plugin.js +1 -1
- package/Alloy/commands/compile/ast/controller.js +52 -27
- package/Alloy/commands/compile/compilerUtils.js +24 -11
- package/Alloy/commands/compile/index.js +211 -62
- package/Alloy/commands/compile/parsers/Alloy.Abstract._BackboneClass.js +3 -2
- package/Alloy/commands/compile/parsers/Alloy.Require.js +10 -4
- package/Alloy/commands/compile/parsers/Ti.UI.ActivityIndicator.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Column.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.MaskedImage.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Notification.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.ProgressBar.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.RefreshControl.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Row.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.SearchBar.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.Shortcut.js +9 -0
- package/Alloy/commands/compile/parsers/Ti.UI.ShortcutItem.js +9 -0
- package/Alloy/commands/compile/sourceMapper.js +0 -16
- package/Alloy/commands/compile/styler.js +101 -58
- package/Alloy/commands/db/index.js +76 -0
- package/Alloy/commands/generate/targets/jmk.js +1 -1
- package/Alloy/commands/generate/targets/style.js +1 -1
- package/Alloy/commands/generate/targets/widget.js +2 -2
- package/Alloy/commands/new/index.js +1 -1
- package/Alloy/commands/purgetss/index.js +5 -0
- package/Alloy/common/constants.js +2 -11
- package/Alloy/lib/alloy/sync/localStorage.js +0 -8
- package/Alloy/lib/alloy/sync/sql.js +12 -9
- package/Alloy/plugin/plugin.py +1 -123
- package/Alloy/template/lib/alloy.js +7 -8
- package/Alloy/tiapp.js +18 -0
- package/CHANGELOG.md +6 -0
- package/README.md +4 -0
- package/package.json +1 -1
- package/platforms/windows/index.js +0 -4
- package/samples/apps/advanced/complex_styling/config.json +1 -4
- package/samples/apps/advanced/custom_tss_queries/styles/index.tss +0 -6
- package/samples/apps/advanced/device_query/specs/index.js +1 -12
- package/samples/apps/advanced/device_query/styles/index.tss +0 -12
- package/samples/apps/advanced/form_factor/views/index.xml +1 -7
- package/samples/apps/advanced/inheritance/controllers/index.js +4 -8
- package/samples/apps/advanced/inheritance/specs/baseDialog.js +2 -2
- package/samples/apps/advanced/master_detail/specs/row.js +3 -3
- package/samples/apps/advanced/proxy_property_requires/widgets/com.foo.widget/views/section.xml +3 -3
- package/samples/apps/advanced/proxy_property_requires/widgets/com.foo.widget/widget.json +2 -2
- package/samples/apps/advanced/require_children/widgets/alloy.container/widget.json +2 -2
- package/samples/apps/advanced/themes/specs/dialog.js +1 -18
- package/samples/apps/advanced/themes/specs/index.js +1 -45
- package/samples/apps/advanced/theming_widgets/widgets/starrating/widget.json +2 -2
- package/samples/apps/basics/builtins/specs/index.js +2 -2
- package/samples/apps/basics/config_json/config.json +1 -4
- package/samples/apps/basics/global_style/specs/item.js +2 -2
- package/samples/apps/basics/simple/specs/index.js +2 -2
- package/samples/apps/models/binding_tableview/controllers/tab_1.js +2 -2
- package/samples/apps/models/binding_tableview/controllers/tab_2.js +2 -2
- package/samples/apps/models/binding_tableview/controllers/tab_3.js +2 -2
- package/samples/apps/models/binding_tableview/controllers/tab_4.js +2 -2
- package/samples/apps/ui/buttonbar/views/index.xml +1 -1
- package/samples/apps/ui/switch/views/index.xml +2 -2
- package/samples/apps/widgets/basic/widgets/com.foo.widget/widget.json +2 -2
- package/samples/apps/widgets/complex/widgets/com.appcelerator.loading/widget.json +1 -1
- package/samples/apps/widgets/complex/widgets/com.testing.searchForBooks/widget.json +1 -1
- package/samples/apps/widgets/models/widgets/alloy.datatable/widget.json +1 -1
- package/samples/apps/widgets/wpath/widgets/com.test.hellobutton/widget.json +1 -1
- package/test/specs/new.js +0 -2
- package/test/specs/optimizer.js +0 -2
- package/test/specs/purgetss.js +74 -0
- package/test/specs/require.js +94 -0
- package/test/specs/styler.js +271 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var path = require('path'),
|
|
2
|
+
fs = require('fs'),
|
|
2
3
|
walkSync = require('walk-sync'),
|
|
3
4
|
CU = require('../compilerUtils'),
|
|
4
5
|
U = require('../../../utils'),
|
|
@@ -30,7 +31,7 @@ function parse(node, state, args) {
|
|
|
30
31
|
// Make sure there's models to be used as the "src" of the Backbone class
|
|
31
32
|
var modelsPath = path.join(CU.getCompilerConfig().dir.home, CONST.DIR.MODEL);
|
|
32
33
|
var validModels;
|
|
33
|
-
if (!
|
|
34
|
+
if (!fs.existsSync(modelsPath) || !(validModels = walkSync(modelsPath)).length) {
|
|
34
35
|
U.dieWithNode(node, [
|
|
35
36
|
'You must have a valid model in your app/' + CONST.DIR.MODEL + ' folder to create a <' + nodeName + '>',
|
|
36
37
|
'Once you have a valid model, assign it like this for a singleton:',
|
|
@@ -50,7 +51,7 @@ function parse(node, state, args) {
|
|
|
50
51
|
]);
|
|
51
52
|
} else {
|
|
52
53
|
var modelPath = path.join(modelsPath, src + '.' + CONST.FILE_EXT.MODEL);
|
|
53
|
-
if (!
|
|
54
|
+
if (!fs.existsSync(modelPath)) {
|
|
54
55
|
U.dieWithNode(node, [
|
|
55
56
|
'"src" attribute\'s model "' + src + '" does not exist in app/' + CONST.DIR.MODEL,
|
|
56
57
|
'Valid models: ' + validModelsPrint
|
|
@@ -88,9 +88,11 @@ function parse(node, state, args) {
|
|
|
88
88
|
args.symbol = CU.generateUniqueId();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
// process the children, if any
|
|
91
|
+
// process the children, if any. Each child is pushed onto a local array by
|
|
92
|
+
// code generated inside that child's own condition (if, platform, formFactor),
|
|
93
|
+
// so a child that is not created at runtime is not referenced either.
|
|
92
94
|
var children = U.XML.getElementsFromNodes(node.childNodes),
|
|
93
|
-
|
|
95
|
+
childrenVar;
|
|
94
96
|
_.each(children, function(child) {
|
|
95
97
|
if (!CU.isNodeForCurrentPlatform(child)) { return; }
|
|
96
98
|
var childArgs = CU.getParserArgs(child);
|
|
@@ -98,16 +100,20 @@ function parse(node, state, args) {
|
|
|
98
100
|
parent: {},
|
|
99
101
|
post: function(node, state, args) {
|
|
100
102
|
if (state.parent.symbol) {
|
|
101
|
-
|
|
103
|
+
childrenVar = childrenVar || CU.generateUniqueId();
|
|
104
|
+
return childrenVar + '.push(' + state.parent.symbol + ');\n';
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
107
|
});
|
|
105
108
|
});
|
|
109
|
+
if (childrenVar) {
|
|
110
|
+
code = 'var ' + childrenVar + ' = [];\n' + code;
|
|
111
|
+
}
|
|
106
112
|
|
|
107
113
|
// add extra createArgs if present
|
|
108
114
|
var xArgs = {};
|
|
109
115
|
|
|
110
|
-
if (
|
|
116
|
+
if (childrenVar) { xArgs.children = '__ALLOY_EXPR__--' + childrenVar; }
|
|
111
117
|
if (state.model) { xArgs[CONST.BIND_MODEL_VAR] = '__ALLOY_EXPR__--' + state.model; }
|
|
112
118
|
if (state.parent && state.parent.symbol) {
|
|
113
119
|
xArgs[CONST.PARENT_SYMBOL_VAR] = '__ALLOY_EXPR__--' + state.parent.symbol;
|
|
@@ -214,22 +214,6 @@ exports.generateSourceMap = function(generator, compileConfig) {
|
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
216
|
|
|
217
|
-
// parse composite code into an AST
|
|
218
|
-
// TODO: Remove? This is a sanity check, I suppose, but is it necessary?
|
|
219
|
-
// Our classic build should blow up on bad JS files
|
|
220
|
-
var ast;
|
|
221
|
-
try {
|
|
222
|
-
ast = babylon.parse(genMap.code, {
|
|
223
|
-
sourceFilename: genMap.file,
|
|
224
|
-
sourceType: 'unambiguous',
|
|
225
|
-
allowReturnOutsideFunction: true,
|
|
226
|
-
});
|
|
227
|
-
} catch (e) {
|
|
228
|
-
const filename = path.relative(compileConfig.dir.project, generator.target.template);
|
|
229
|
-
|
|
230
|
-
U.dieWithCodeFrame(`Error parsing code in ${filename}. ${e.message}`, e.loc, genMap.code);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
217
|
// TODO: We do not run the babel plugins (optimizer/builtins) here. Is that ok?
|
|
234
218
|
// TODO: embed sourcesContent into source map? Shouldn't need to since this is supposed to be a straight copy
|
|
235
219
|
|
|
@@ -47,6 +47,16 @@ var KEYBOARD_PROPERTIES = ['keyboardType', 'returnKeyType', 'autocapitalization'
|
|
|
47
47
|
|
|
48
48
|
// private variables
|
|
49
49
|
var styleOrderCounter = 1;
|
|
50
|
+
|
|
51
|
+
// The style order counter feeds into the priority value written to every
|
|
52
|
+
// runtime style module. Priorities only order the styles of one component
|
|
53
|
+
// against each other, so the counter restarts for every component right
|
|
54
|
+
// after the global styles. That keeps each component's output independent of
|
|
55
|
+
// the components generated before it, which lets the compiler cache them.
|
|
56
|
+
var componentStyleOrderStart = 1;
|
|
57
|
+
exports.resetStyleOrder = function() {
|
|
58
|
+
styleOrderCounter = componentStyleOrderStart;
|
|
59
|
+
};
|
|
50
60
|
var platform;
|
|
51
61
|
|
|
52
62
|
exports.setPlatform = function(p) {
|
|
@@ -139,7 +149,7 @@ exports.loadGlobalStyles = function(appPath, opts) {
|
|
|
139
149
|
// get rid of entries that don't exist
|
|
140
150
|
var len = loadArray.length;
|
|
141
151
|
for (var i = len - 1; i >= 0; i--) {
|
|
142
|
-
if (!
|
|
152
|
+
if (!fs.existsSync(loadArray[i].path)) {
|
|
143
153
|
loadArray.splice(i, 1);
|
|
144
154
|
}
|
|
145
155
|
}
|
|
@@ -148,21 +158,24 @@ exports.loadGlobalStyles = function(appPath, opts) {
|
|
|
148
158
|
var hash = U.createHash(_.map(loadArray, 'path'));
|
|
149
159
|
|
|
150
160
|
// see if we can use the cached global style
|
|
151
|
-
if (buildlog.data.globalStyleCacheHash === hash && fs.existsSync(cacheFile)
|
|
161
|
+
if (buildlog.data.globalStyleCacheHash === hash && fs.existsSync(cacheFile) &&
|
|
162
|
+
_.isNumber(buildlog.data.globalStyleOrder)) {
|
|
152
163
|
// load global style object from cache
|
|
153
164
|
logger.info('[global style] loading from cache...');
|
|
154
165
|
exports.globalStyle = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
|
|
155
166
|
ret = true;
|
|
156
167
|
|
|
157
|
-
//
|
|
158
|
-
|
|
168
|
+
// advance the style order counter exactly as processing the files
|
|
169
|
+
// would have, so the priorities of all component styles stay stable
|
|
170
|
+
styleOrderCounter += buildlog.data.globalStyleOrder;
|
|
159
171
|
} else {
|
|
160
172
|
// add new hash to the buildlog
|
|
161
173
|
buildlog.data.globalStyleCacheHash = hash;
|
|
174
|
+
var styleOrderStart = styleOrderCounter;
|
|
162
175
|
|
|
163
176
|
// create the new global style object
|
|
164
177
|
_.each(loadArray, function(g) {
|
|
165
|
-
if (
|
|
178
|
+
if (fs.existsSync(g.path)) {
|
|
166
179
|
logger.info('[' + g.msg + '] global style processing...');
|
|
167
180
|
exports.globalStyle = exports.loadAndSortStyle(g.path, _.extend(
|
|
168
181
|
{ existingStyle: exports.globalStyle },
|
|
@@ -177,7 +190,9 @@ exports.loadGlobalStyles = function(appPath, opts) {
|
|
|
177
190
|
|
|
178
191
|
// simply increment the style order counter
|
|
179
192
|
styleOrderCounter++;
|
|
193
|
+
buildlog.data.globalStyleOrder = styleOrderCounter - styleOrderStart;
|
|
180
194
|
}
|
|
195
|
+
componentStyleOrderStart = styleOrderCounter;
|
|
181
196
|
|
|
182
197
|
return ret;
|
|
183
198
|
};
|
|
@@ -195,63 +210,91 @@ exports.sortStyles = function(style, opts) {
|
|
|
195
210
|
var sortedStyles = [];
|
|
196
211
|
opts = opts || {};
|
|
197
212
|
|
|
213
|
+
function splitSelectors(key) {
|
|
214
|
+
const result = [];
|
|
215
|
+
let current = '';
|
|
216
|
+
let depth = 0;
|
|
217
|
+
|
|
218
|
+
for (let i = 0, len = key.length; i < len; i++) {
|
|
219
|
+
const char = key[i];
|
|
220
|
+
|
|
221
|
+
if (char === '[') {
|
|
222
|
+
depth++;
|
|
223
|
+
} else if (char === ']') {
|
|
224
|
+
depth--;
|
|
225
|
+
} else if (char === ',' && depth === 0) {
|
|
226
|
+
if (current.trim()) { result.push(current.trim()); }
|
|
227
|
+
current = '';
|
|
228
|
+
continue;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
current += char;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (current.trim()) { result.push(current.trim()); }
|
|
235
|
+
return result;
|
|
236
|
+
}
|
|
237
|
+
|
|
198
238
|
if (_.isObject(style) && !_.isEmpty(style)) {
|
|
199
239
|
for (var key in style) {
|
|
200
|
-
var
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
240
|
+
var keys = splitSelectors(key);
|
|
241
|
+
_.each(keys, function(singleKey) {
|
|
242
|
+
var obj = {};
|
|
243
|
+
var priority = styleOrderCounter++ * VALUES.ORDER;
|
|
244
|
+
var match = singleKey.match(STYLE_REGEX);
|
|
245
|
+
if (match === null) {
|
|
246
|
+
U.die('Invalid style specifier "' + singleKey + '"');
|
|
247
|
+
}
|
|
248
|
+
var newKey = match[2];
|
|
249
|
+
|
|
250
|
+
if (newKey === 'undefined' && !match[1]) { return; }
|
|
251
|
+
|
|
252
|
+
switch (match[1]) {
|
|
253
|
+
case '#':
|
|
254
|
+
obj.isId = true;
|
|
255
|
+
priority += VALUES.ID;
|
|
256
|
+
break;
|
|
257
|
+
case '.':
|
|
258
|
+
obj.isClass = true;
|
|
259
|
+
priority += VALUES.CLASS;
|
|
260
|
+
break;
|
|
261
|
+
default:
|
|
262
|
+
if (match[2]) {
|
|
263
|
+
obj.isApi = true;
|
|
264
|
+
priority += VALUES.API;
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
228
268
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
269
|
+
if (match[3]) {
|
|
270
|
+
obj.queries = {};
|
|
271
|
+
_.each(match[3].replace(/\s*,\s*/g, ',').split(/\s+/), function(query) {
|
|
272
|
+
var parts = query.split('=');
|
|
273
|
+
var q = U.trim(parts[0]);
|
|
274
|
+
var v = U.trim(parts[1]);
|
|
275
|
+
if (q === 'platform') {
|
|
276
|
+
priority += VALUES.PLATFORM + VALUES.SUM;
|
|
277
|
+
v = v.split(',');
|
|
278
|
+
} else if (q === 'formFactor') {
|
|
279
|
+
priority += VALUES.FORMFACTOR + VALUES.SUM;
|
|
280
|
+
} else if (q === 'if') {
|
|
281
|
+
priority += VALUES.TSSIF + VALUES.SUM;
|
|
282
|
+
} else {
|
|
283
|
+
priority += VALUES.SUM;
|
|
284
|
+
}
|
|
285
|
+
obj.queries[q] = v;
|
|
286
|
+
});
|
|
287
|
+
}
|
|
248
288
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
289
|
+
_.extend(obj, {
|
|
290
|
+
priority: priority + (opts.platform ? VALUES.PLATFORM : 0) + (opts.theme ? VALUES.THEME : 0),
|
|
291
|
+
key: newKey,
|
|
292
|
+
// clone so entries from one comma-separated key don't share
|
|
293
|
+
// (and mutate) the same style object
|
|
294
|
+
style: keys.length > 1 ? _.cloneDeep(style[key]) : style[key]
|
|
295
|
+
});
|
|
296
|
+
sortedStyles.push(obj);
|
|
253
297
|
});
|
|
254
|
-
sortedStyles.push(obj);
|
|
255
298
|
}
|
|
256
299
|
}
|
|
257
300
|
|
|
@@ -260,7 +303,7 @@ exports.sortStyles = function(style, opts) {
|
|
|
260
303
|
};
|
|
261
304
|
|
|
262
305
|
exports.loadStyle = function(tssFile) {
|
|
263
|
-
if (
|
|
306
|
+
if (fs.existsSync(tssFile)) {
|
|
264
307
|
// read the style file
|
|
265
308
|
var contents;
|
|
266
309
|
var originalContents;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const {
|
|
2
|
+
exec,
|
|
3
|
+
execSync
|
|
4
|
+
} = require('child_process');
|
|
5
|
+
const U = require('../../utils');
|
|
6
|
+
const tiapp = require('../../tiapp');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
const os = require('os');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
module.exports = async function(args, program) {
|
|
12
|
+
if (args.length === 0) {
|
|
13
|
+
U.die('Missing parameter "get"');
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
if (!args.includes('get')) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
tiapp.init();
|
|
23
|
+
const bundleId = tiapp.getBundleId();
|
|
24
|
+
const adbPath = getAdbPath();
|
|
25
|
+
|
|
26
|
+
console.log('Downloading _alloy_ database to: ' + bundleId + '.db');
|
|
27
|
+
execCommand(adbPath + ' shell "run-as ' + bundleId + ' cat /data/data/' + bundleId + '/databases/_alloy_" > ' + bundleId + '.db');
|
|
28
|
+
} catch (error) {
|
|
29
|
+
console.error('Failed to get database: ' + error);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function getAdbPath() {
|
|
34
|
+
if (os.platform() !== 'darwin') {
|
|
35
|
+
return 'adb';
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// try to get android.sdkPath from ti config
|
|
39
|
+
let sdkPath;
|
|
40
|
+
const output = execSync('ti config android.sdkPath --json');
|
|
41
|
+
const jsonObject = JSON.parse(output);
|
|
42
|
+
if (!Object.hasOwn(jsonObject, 'success')) {
|
|
43
|
+
// found string
|
|
44
|
+
sdkPath = jsonObject;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// fall back to the default location (the folder has been spelled "sdk" and "Sdk" over the years)
|
|
48
|
+
if (!sdkPath) {
|
|
49
|
+
sdkPath = ['sdk', 'Sdk']
|
|
50
|
+
.map(dir => path.join(os.homedir(), 'Library', 'Android', dir))
|
|
51
|
+
.find(dir => fs.existsSync(dir)) || path.join(os.homedir(), 'Library', 'Android', 'sdk');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// check if adb is in that folder
|
|
55
|
+
const adbPath = path.join(sdkPath, 'platform-tools', 'adb');
|
|
56
|
+
if (!fs.existsSync(adbPath)) {
|
|
57
|
+
U.die('adb not found at ' + adbPath + '. Please check "ti config android.sdkPath" and point to your SDK folder.');
|
|
58
|
+
}
|
|
59
|
+
return adbPath;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function execCommand(currentCommand) {
|
|
63
|
+
exec(currentCommand, (error, response) => {
|
|
64
|
+
if (error) {
|
|
65
|
+
if (error.message) {
|
|
66
|
+
console.error(error.message);
|
|
67
|
+
} else {
|
|
68
|
+
console.error("Couldn't fetch database");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (response) {
|
|
72
|
+
console.log(response);
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
@@ -10,7 +10,7 @@ module.exports = function(name, args, program) {
|
|
|
10
10
|
var templatePath = path.join(alloyRoot, 'template', filename);
|
|
11
11
|
|
|
12
12
|
// only overwrite if using force option
|
|
13
|
-
if (
|
|
13
|
+
if (fs.existsSync(filepath) && !program.force) {
|
|
14
14
|
U.die('"alloy.jmk" file already exists. Use "-f,--force" to overwrite.');
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -15,7 +15,7 @@ module.exports = function(name, args, program) {
|
|
|
15
15
|
var paths = getPaths(thePaths.app, widgetId);
|
|
16
16
|
|
|
17
17
|
// don't overwrite an existing widget unless force is specified
|
|
18
|
-
if (
|
|
18
|
+
if (fs.existsSync(paths.widget) && !program.force) {
|
|
19
19
|
U.die('Widget already exists: ' + paths.widget);
|
|
20
20
|
}
|
|
21
21
|
|
|
@@ -45,7 +45,7 @@ module.exports = function(name, args, program) {
|
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
// Add this widget as a dependency to our project
|
|
48
|
-
var configReadPath =
|
|
48
|
+
var configReadPath = fs.existsSync(paths.config) ? paths.config : paths.configTemplate;
|
|
49
49
|
var content = fs.readFileSync(configReadPath, 'utf8');
|
|
50
50
|
try {
|
|
51
51
|
var json = jsonlint.parse(content);
|
|
@@ -260,7 +260,7 @@ function getPaths(project, templateName, testapp) {
|
|
|
260
260
|
// alloy paths
|
|
261
261
|
alloy: alloy,
|
|
262
262
|
template: path.join(alloy, 'template'),
|
|
263
|
-
readme: fs.existsSync(readMeFile) ? readMeFile : path.join(template, 'README'),
|
|
263
|
+
readme: readMeFile != undefined && fs.existsSync(readMeFile) ? readMeFile : path.join(template, 'README'),
|
|
264
264
|
appTemplate: (!testapp) ? customAppDir || path.join(projectTemplates, templateName, 'app') : path.join(sampleAppsDir, testapp),
|
|
265
265
|
projectTemplate: (!testapp) ? customTemplateDir || path.join(projectTemplates, templateName) : path.join(sampleAppsDir, testapp),
|
|
266
266
|
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
const { exec } = require('child_process');
|
|
2
2
|
const U = require('../../utils');
|
|
3
|
+
const logger = require('../../logger');
|
|
3
4
|
|
|
4
5
|
module.exports = async function(args, program) {
|
|
6
|
+
logger.warn([
|
|
7
|
+
'`alloy purgetss` is deprecated. Run `purgetss` directly instead.',
|
|
8
|
+
'Use `purgetss --help` for the current commands and options.'
|
|
9
|
+
]);
|
|
5
10
|
let options = '';
|
|
6
11
|
try {
|
|
7
12
|
if (args.length === 0) {
|
|
@@ -152,9 +152,7 @@ var NS_ALLOY = 'Alloy',
|
|
|
152
152
|
NS_TI_MEDIA = 'Ti.Media',
|
|
153
153
|
NS_TI_UI_IOS = 'Ti.UI.iOS',
|
|
154
154
|
NS_TI_UI_IPAD = 'Ti.UI.iPad',
|
|
155
|
-
NS_TI_UI_IPHONE = 'Ti.UI.iPhone'
|
|
156
|
-
NS_TI_UI_MOBILEWEB = 'Ti.UI.MobileWeb',
|
|
157
|
-
NS_TI_UI_WINDOWS = 'Ti.UI.Windows';
|
|
155
|
+
NS_TI_UI_IPHONE = 'Ti.UI.iPhone';
|
|
158
156
|
|
|
159
157
|
exports.IMPLICIT_NAMESPACES = {
|
|
160
158
|
// Alloy
|
|
@@ -217,16 +215,9 @@ exports.IMPLICIT_NAMESPACES = {
|
|
|
217
215
|
Popover: NS_TI_UI_IPAD,
|
|
218
216
|
|
|
219
217
|
// Ti.UI.iPhone
|
|
220
|
-
NavigationGroup:
|
|
221
|
-
NS_TI_UI_MOBILEWEB : NS_TI_UI_IPHONE,
|
|
218
|
+
NavigationGroup: NS_TI_UI_IPHONE,
|
|
222
219
|
StatusBar: NS_TI_UI_IPHONE,
|
|
223
220
|
|
|
224
|
-
// Ti.UI.Windows
|
|
225
|
-
CommandBar: NS_TI_UI_WINDOWS,
|
|
226
|
-
AppBarButton: NS_TI_UI_WINDOWS,
|
|
227
|
-
AppBarToggleButton: NS_TI_UI_WINDOWS,
|
|
228
|
-
AppBarSeparator: NS_TI_UI_WINDOWS,
|
|
229
|
-
|
|
230
221
|
// Ti.UI.Window
|
|
231
222
|
LeftNavButton: 'Ti.UI.Window',
|
|
232
223
|
RightNavButton: 'Ti.UI.Window',
|
|
@@ -11,12 +11,6 @@ function guid() {
|
|
|
11
11
|
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4());
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
function InitAdapter() {
|
|
15
|
-
if (!OS_MOBILEWEB) {
|
|
16
|
-
throw 'localStorage persistence supported only with MobileWeb.';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
14
|
function Sync(method, model, opts) {
|
|
21
15
|
var name = model.config.adapter.collection_name,
|
|
22
16
|
data = model.config.data,
|
|
@@ -86,8 +80,6 @@ module.exports.beforeModelCreate = function(config) {
|
|
|
86
80
|
|
|
87
81
|
config.data = {}; // for localStorage or case where entire collection is needed to maintain store
|
|
88
82
|
|
|
89
|
-
InitAdapter();
|
|
90
|
-
|
|
91
83
|
return config;
|
|
92
84
|
};
|
|
93
85
|
|
|
@@ -236,15 +236,18 @@ function Sync(method, model, opts) {
|
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
// iterate through all queried rows
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
try {
|
|
240
|
+
while (rs.isValidRow()) {
|
|
241
|
+
var o = {};
|
|
242
|
+
for (i = 0; i < fieldCount; i++) {
|
|
243
|
+
o[fieldNames[i]] = rs.field(i);
|
|
244
|
+
}
|
|
245
|
+
values.push(o);
|
|
246
|
+
rs.next();
|
|
243
247
|
}
|
|
244
|
-
|
|
245
|
-
rs.
|
|
248
|
+
} finally {
|
|
249
|
+
rs.close();
|
|
246
250
|
}
|
|
247
|
-
rs.close();
|
|
248
251
|
|
|
249
252
|
// shape response based on whether it's a model or collection
|
|
250
253
|
var len = values.length;
|
|
@@ -471,8 +474,8 @@ module.exports.beforeModelCreate = function(config, name) {
|
|
|
471
474
|
}
|
|
472
475
|
|
|
473
476
|
// check platform compatibility
|
|
474
|
-
if (
|
|
475
|
-
throw 'No support for Titanium.Database
|
|
477
|
+
if (typeof Ti.Database === 'undefined') {
|
|
478
|
+
throw 'No support for Titanium.Database.';
|
|
476
479
|
}
|
|
477
480
|
|
|
478
481
|
// install database file, if specified
|