Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions packages/ext-gen/appMigrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var gitIgnore = '.gitIgnore';
var gitIgnoreAppend = '/generatedFiles ' + os.EOL + '/cordova ' + os.EOL + '/node_modules' + os.EOL;
var gitIgnoreData = '/build ' + os.EOL + gitIgnoreAppend;
var extFrameworkPath = 'node_modules/@sencha/ext';
var themes = ['theme-base', 'theme-ios', 'theme-material',
'theme-aria', 'theme-neutral', 'theme-classic', 'theme-gray',
'theme-crisp', 'theme-crisp-touch', 'theme-neptune', 'theme-neptune-touch',
'theme-triton', 'theme-graphite'];
var classic = false;
var modern = false;
var universal = false;
Expand Down Expand Up @@ -340,10 +344,6 @@ function removeDebugJsPath(jsonLocation) {

function handleWorkspaceJsonmigrate() {
var workspaceJsonObject = getJson(workspaceJson),
themes = ['theme-base', 'theme-ios', 'theme-material',
'theme-aria', 'theme-neutral', 'theme-classic', 'theme-gray',
'theme-crisp', 'theme-crisp-touch', 'theme-neptune', 'theme-neptune-touch',
'theme-triton', 'theme-graphite'],
packageNames = ['treegrid', 'calendar', 'charts', 'froala-editor', 'amf', 'd3',
'exporter', 'pivot', 'pivot-d3', 'pivot-locale', 'ux', 'font-ios'],
basePath = '$\u007Bworkspace.dir}/node_modules/@sencha/ext-',
Expand Down Expand Up @@ -513,11 +513,11 @@ function buildToolKitAndThemeDetails() {
if (appJsonObject.hasOwnProperty('toolkit')) {
if (appJsonObject.toolkit == classicProfile) {
classic = true;
classicTheme = appJsonObject.theme;
classicTheme = appJsonObject.theme = verifyAndUpdateTheme(appJsonObject.theme);
}
else {
modern = true;
modernTheme = appJsonObject.theme;
modernTheme = appJsonObject.theme = verifyAndUpdateTheme(appJsonObject.theme);
}
}
else {
Expand All @@ -532,12 +532,32 @@ function buildToolKitAndThemeDetails() {
for (profile in appJsonObject.builds) {
if (profile === classicProfile) {
classic = true;
classicTheme = appJsonObject.builds[profile].theme;
classicTheme = appJsonObject.builds[profile].theme = verifyAndUpdateTheme(appJsonObject.builds[profile].theme);
}
if (profile == modernProfile) {
modern = true;
modernTheme = appJsonObject.builds[profile].theme;
modernTheme = appJsonObject.builds[profile].theme = verifyAndUpdateTheme(appJsonObject.builds[profile].theme);
}
}
}
}

function verifyAndUpdateTheme(appTheme) {
var themeStr = appTheme.replace(/[^a-z-]/g, ''),
matchedTheme;

// once special chars are removed check if it is one of the existing themes
if (themes.indexOf(themeStr) >= 0) {
return themeStr;
}

// if doesn't exists return the appropriate theme from built-in theme list
for (var i = 0; i < themes.length; i++) {
if (themeStr.includes(themes[i])) {
matchedTheme = themes[i];
break;
}
}
return matchedTheme ? matchedTheme : appTheme;
}