Skip to content

Commit

Permalink
remove old code, fix sdk version, update action
Browse files Browse the repository at this point in the history
  • Loading branch information
m1ga committed Oct 1, 2024
1 parent be399c8 commit 4170204
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 154 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '18.x'
- name: Install dependencies
run: npm ci
- name: Lint
Expand All @@ -28,23 +28,22 @@ jobs:
strategy:
fail-fast: false
matrix:
nodeVersion: [ '16.x' ]
nodeVersion: [ '18.x' ]
os: [ macos-latest ]
tiSDK: [ latest ]
tiSDK: [ '12.5.0.GA' ]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.nodeVersion }}
- name: Install dependencies
run: |
npm ci
npm i titanium -g
ti sdk install ${{ matrix.tiSDK }} -d
ti sdk install ${{ matrix.tiSDK }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run tests
run: npm test

6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
Expand Down
13 changes: 2 additions & 11 deletions Alloy/commands/compile/parsers/Alloy.Abstract.FixedSpace.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
var U = require('../../../utils'),
CU = require('../compilerUtils'),
tiapp = require('../../../tiapp'),
iOSProxy;

var MIN_VERSION = '5.4.0';
tiapp = require('../../../tiapp');

exports.parse = function(node, state) {
return require('./base').parse(node, state, parse);
Expand All @@ -13,18 +10,12 @@ function parse(node, state, args) {
// width is a valid property for a FIXED_SPACE button, add in if specified
var width = (args.createArgs.width) ? ", width:'" + args.createArgs.width + "'" : '';

if (tiapp.version.gte(tiapp.getSdkVersion(), MIN_VERSION)) {
iOSProxy = 'iOS';
} else {
iOSProxy = 'iPhone';
}

return {
parent: {
node: node,
symbol: args.symbol
},
styles: state.styles,
code: args.symbol + ' = Ti.UI.createButton({systemButton: Ti.UI.' + iOSProxy + '.SystemButton.FIXED_SPACE' + width + '});'
code: args.symbol + ' = Ti.UI.createButton({systemButton: Ti.UI.iOS.SystemButton.FIXED_SPACE' + width + '});'
};
}
13 changes: 2 additions & 11 deletions Alloy/commands/compile/parsers/Alloy.Abstract.FlexSpace.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
var U = require('../../../utils'),
CU = require('../compilerUtils'),
tiapp = require('../../../tiapp'),
iOSProxy;

var MIN_VERSION = '5.4.0';
tiapp = require('../../../tiapp');

exports.parse = function(node, state) {
return require('./base').parse(node, state, parse);
};

function parse(node, state, args) {

if (tiapp.version.gte(tiapp.getSdkVersion(), MIN_VERSION)) {
iOSProxy = 'iOS';
} else {
iOSProxy = 'iPhone';
}

return {
parent: {
node: node,
symbol: args.symbol
},
styles: state.styles,
code: args.symbol + ' = Ti.UI.createButton({systemButton: Ti.UI.' + iOSProxy + '.SystemButton.FLEXIBLE_SPACE});'
code: args.symbol + ' = Ti.UI.createButton({systemButton: Ti.UI.iOS.SystemButton.FLEXIBLE_SPACE});'
};
}
5 changes: 0 additions & 5 deletions Alloy/commands/compile/parsers/Ti.UI.AttributedString.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,11 @@ var _ = require('lodash'),
CU = require('../compilerUtils'),
tiapp = require('../../../tiapp');

var MIN_VERSION = '3.6.0';

exports.parse = function(node, state) {
return require('./base').parse(node, state, parse);
};

function parse(node, state, args) {
if (tiapp.version.lt(tiapp.getSdkVersion(), MIN_VERSION)) {
U.die('Ti.UI.AttributedString (line ' + node.lineNumber + ') requires Titanium 3.6.0+');
}

// Get label text from node text, if present
var nodeText = U.XML.getNodeText(node);
Expand Down
13 changes: 2 additions & 11 deletions Alloy/commands/compile/parsers/Ti.UI.Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ var _ = require('lodash'),
styler = require('../styler'),
CU = require('../compilerUtils'),
U = require('../../../utils'),
tiapp = require('../../../tiapp'),
iOSProxy;

var MIN_VERSION = '5.4.0';
tiapp = require('../../../tiapp');

var systemButtons = [
'ACTION', 'ACTIVITY', 'ADD', 'BOOKMARKS', 'CAMERA', 'CANCEL', 'COMPOSE', 'CONTACT_ADD',
Expand All @@ -25,15 +22,9 @@ function parse(node, state, args) {
state.extraStyle = styler.createVariableStyle('title', U.possibleMultilineString(U.trim(nodeText.replace(/'/g, "\\'"))));
}

if (tiapp.version.gte(tiapp.getSdkVersion(), MIN_VERSION)) {
iOSProxy = 'iOS';
} else {
iOSProxy = 'iPhone';
}

var systemButton = node.getAttribute('systemButton');
if (_.includes(systemButtons, systemButton)) {
node.setAttribute('systemButton', 'Ti.UI.' + iOSProxy + '.SystemButton.' + systemButton);
node.setAttribute('systemButton', 'Ti.UI.iOS.SystemButton.' + systemButton);
}

// Generate runtime code using default
Expand Down
15 changes: 0 additions & 15 deletions Alloy/commands/compile/parsers/Ti.UI.NavigationWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,13 @@ var _ = require('lodash'),
CU = require('../compilerUtils'),
tiapp = require('../../../tiapp');

const MIN_VERSION_FOR_IOS = '3.1.3';
const MIN_VERSION = '8.0.0';
const MIN_ANDROID_TABGROUP_CHILD = '8.3.0';

exports.parse = function(node, state) {
return require('./base').parse(node, state, parse);
};

function parse(node, state, args) {
const tiappSdkVersion = tiapp.getSdkVersion();
const platform = CU.getCompilerConfig().alloyConfig.platform;
if (tiapp.version.lt(tiappSdkVersion, MIN_VERSION_FOR_IOS)) {
U.die(`Ti.UI.iOS.NavigationWindow (line ${node.lineNumber}) requires Titanium ${MIN_VERSION_FOR_IOS}+`);
}

if (tiapp.version.lt(tiappSdkVersion, MIN_VERSION)) {
node.setAttribute('ns', 'Ti.UI.iOS');
}

var children = U.XML.getElementsFromNodes(node.childNodes),
err = ['NavigationWindow must have only one child element, which must be a Window or TabGroup'],
Expand All @@ -37,10 +26,6 @@ function parse(node, state, args) {
theNode = CU.validateNodeName(child, [ 'Ti.UI.Window', 'Ti.UI.TabGroup' ]),
windowSymbol;

if (platform === 'android' && theNode === 'Ti.UI.TabGroup' && tiapp.version.lt(tiappSdkVersion, MIN_ANDROID_TABGROUP_CHILD)) {
U.die(`TabGroup can only be a child of a NavigationWindow on Android from SDK ${MIN_ANDROID_TABGROUP_CHILD} onwards. Current SDK is ${tiappSdkVersion}`);
}

// generate the code for the child first
if (theNode) {
code += CU.generateNodeExtended(child, state, {
Expand Down
5 changes: 0 additions & 5 deletions Alloy/commands/compile/parsers/Ti.UI.OptionBar.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
const _ = require('lodash');
const tiapp = require('../../../tiapp');
const U = require('../../../utils');
const MIN_VERSION = '10.0.0';

exports.parse = function(node, state) {
const tiappSdkVersion = tiapp.getSdkVersion();
if (tiapp.version.lt(tiappSdkVersion, MIN_VERSION)) {
U.die(`Ti.UI.OptionBar requires Titanium SDK ${MIN_VERSION}+`);
}
return require('./Ti.UI.ButtonBar').parse(node, state);
};
9 changes: 0 additions & 9 deletions Alloy/commands/compile/parsers/Ti.UI.TabbedBar.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
const tiapp = require('../../../tiapp');
const CU = require('../compilerUtils');
const U = require('../../../utils');
const MIN_VERSION = '8.0.0';

exports.parse = function(node, state) {
const tiappSdkVersion = tiapp.getSdkVersion();
if (tiapp.version.lt(tiappSdkVersion, MIN_VERSION)) {
const platform = CU.getCompilerConfig().alloyConfig.platform;
if (platform !== 'ios') {
U.die(`Ti.UI.TabbedBar for ${platform} requires Titanium ${MIN_VERSION}+`);
}
node.setAttribute('ns', 'Ti.UI.iOS');
}
return require('./Ti.UI.ButtonBar').parse(node, state);
};
6 changes: 0 additions & 6 deletions Alloy/commands/compile/parsers/Ti.UI.Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ var _ = require('lodash'),

exports.parse = function(node, state) {
var platform = CU.getCompilerConfig().alloyConfig.platform;
if (tiapp.version.lt(tiapp.getSdkVersion(), '6.2.0')) {
if (platform !== 'ios') {
U.die('Ti.UI.Toolbar requires Titanium 6.2.0+');
}
node.setAttribute('ns', 'Ti.UI.iOS');
}

var eventObject = 'e',
code = '',
Expand Down
58 changes: 0 additions & 58 deletions Alloy/commands/compile/parsers/Ti.UI.iPhone.NavigationGroup.js

This file was deleted.

12 changes: 1 addition & 11 deletions Alloy/tiapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,10 @@ tiapp.getSdkVersion = function() {
} else {
if (process.env.sdk) {
return process.env.sdk;
} else {
return getSdkSelectVersion();
}
}
};
function getSdkSelectVersion() {
var homeDir = process.env[(process.platform == 'win32') ? 'USERPROFILE' : 'HOME'],
file = path.join(homeDir, '.titanium', 'config.json');
if (!fs.existsSync(file)) {
U.die('Titanium configuration file does not exist at "' + file + '"');
}
var ticonfig = JSON.parse(fs.readFileSync(file, {encoding: 'utf8'}));
return ticonfig.sdk.selected;
}


// Get the value of a property from the tiapp.xml
tiapp.getProperty = function(name) {
Expand Down
1 change: 1 addition & 0 deletions test/projects/HarnessTemplate/tiapp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,5 @@
<module platform="android">ti.map</module>
<module platform="iphone">ti.map</module>
</modules>
<sdk-version>12.5.0.GA</sdk-version>
</ti:app>

0 comments on commit 4170204

Please sign in to comment.