From 8d1a40315e643661584d45322a2b455a5dd4239b Mon Sep 17 00:00:00 2001 From: Staci Cooper Date: Tue, 30 Sep 2014 14:48:28 -0400 Subject: [PATCH 1/2] Mostly fixes for the mobilespec project - add in new-style tests - addWWWForMobileSpec not needed based on my testing (?) --- corimf-build-wp8.js | 3 -- corimf-build.js | 71 +++++++++++++++++++++++++++++++++++++-- corimf-settings-js.sample | 4 +-- 3 files changed, 71 insertions(+), 7 deletions(-) diff --git a/corimf-build-wp8.js b/corimf-build-wp8.js index f39ceae..2f1fd60 100644 --- a/corimf-build-wp8.js +++ b/corimf-build-wp8.js @@ -46,9 +46,6 @@ var WP8BuildSpecifics = function(DPO) { //build mobilespec in visual studio if (settings.MOBILESPEC) { - //register www files - addWWWForMobileSpec(DPO.MOBILESPEC_DIR, DPO.PROJECT_NAME+'.csproj'); - tests.reportStatus(shelljs.exec('msbuild' + ' ' + path.join(DPO.MOBILESPEC_DIR, DPO.PROJECT_NAME +'.sln') + ' ' +'/p:Configuration=Release', {silent:false}).code == 0); } diff --git a/corimf-build.js b/corimf-build.js index c0b2033..a5fd81e 100644 --- a/corimf-build.js +++ b/corimf-build.js @@ -117,6 +117,8 @@ var RunPreliminaryTests = function(platformSpecificCode) { repos = settings.PLUGINS.concat(settings.PLATFORM_REPO); if (settings.PLUGMAN_REPO.length > 0) repos = repos.concat(settings.PLUGMAN_REPO); + // We will also need these platform-independent repos + repos = repos.concat(['cordova-js', 'cordova-mobile-spec', 'cordova-plugin-test-framework']); // If not building project only, git-archive the branch that is desired if(!settings.PROJECT_ONLY) { @@ -152,6 +154,7 @@ var RunPreliminaryTests = function(platformSpecificCode) { } } // If not building project only, make sure that the branch matches the latest tag in Git + // If not building project only, make sure that the branch matches the latest tag in Git else { for (var i = 0; i < repos.length; i++) { console.log(repos[i] + ': '); @@ -191,6 +194,18 @@ var RunPreliminaryTests = function(platformSpecificCode) { shelljs.cd('..'); } + // run npm install in cordova-js before cd'ing back into main directory where script was ran + console.log('Loading pre-reqs for js...'); + shelljs.cd('cordova-js'); + if (shelljs.test('-d', 'node_modules')) { + execOutput = shelljs.rm('-rf', 'node_modules'); + console.log('true'); + } else console.log('false'); + reportStatus((execOutput = shelljs.exec('npm install', {silent:true})).code == 0, execOutput.output); + console.log('Running grunt in the cordova.js directory...'); + reportStatus(shelljs.exec('grunt', {silent:true}).code == 0); + shelljs.cd('..'); + shelljs.cd(cwd); // Android has code that must be run before build starts @@ -207,6 +222,7 @@ var BuildProject = function(platformSpecificCode) { var MOBILESPEC_DIR = 'mobilespec-' + platform + '-' + settings.NEW_TAG; var PROJECT_NAME = platform === "wp8" ? 'WPCordovaClassLib' : 'example'; var pathProject = pathCorimf + path.sep + PROJECT_DIR; + var pathMobileSpec = pathCorimf + path.sep + MOBILESPEC_DIR; var pathSnapshot = tmpDir + path.sep + SNAPSHOT_DIR; console.log('Checking that project ' + PROJECT_DIR + ' does not exist yet...'); @@ -242,8 +258,59 @@ var BuildProject = function(platformSpecificCode) { console.log('Checking that project ' + MOBILESPEC_DIR + ' does not exist yet...'); reportStatus(!shelljs.test('-d', MOBILESPEC_DIR)); - shelljs.cp('-R', path.join(PROJECT_DIR,'*'), MOBILESPEC_DIR); - shelljs.cp('-Rf', path.join(process.cwd(),'cordova-mobile-spec','*'), path.join(MOBILESPEC_DIR, WWW_DIR)); + console.log('Creating a new ' + platform.toUpperCase() + ' Project...'); + cmd = execPath + ' ' + MOBILESPEC_DIR + ' ' + PROJECT_NAME + ' ' + PROJECT_NAME; + tests.reportStatus(shelljs.exec(cmd, {silent : false}).code == 0); + + console.log('Copying mobile-spec resources into project www...'); + shelljs.cp("-rf", path.join(tmpDir, 'cordova-mobile-spec', 'www', '*'), path.join(MOBILESPEC_DIR, WWW_DIR)); + + // copy config.xml + shelljs.cp("-f", path.join(tmpDir, 'cordova-mobile-spec', "config.xml"), MOBILESPEC_DIR); + + //copy and rename cordova.js + console.log('Adding cordova.js...'); + var jsSrc = path.join(tmpDir, 'cordova-js', 'pkg', 'cordova.' + (platform === 'wp8' ? 'windowsphone' : platform) + '.js'); + shelljs.cp("-f", jsSrc, path.join(MOBILESPEC_DIR, 'www', 'cordova.js')); + + console.log('Installing plugins into project...'); + var pathPlugman = path.join(pathCorimf, settings.PLUGMAN_REPO, 'main.js'); + var baseCommand = 'node ' + pathPlugman + ' --debug install --platform ' + platform + ' --project ' + pathMobileSpec + ' --plugin '; + + // console.log('Installing core plugins...'); + for (var i = 0; i < settings.PLUGINS.length; i++) { + var execCommand = baseCommand + tmpDir + path.sep + settings.PLUGINS[i]; + reportStatus((execOutput = shelljs.exec(execCommand, {silent:true})).code == 0, execOutput.output); + } + + var majorBranchNum = Number(settings.BRANCH.substring(0,3)); + + if (majorBranchNum >= 3.0) { + // Install echo and whitelist plugins + console.log('Installing echo and whitelist...'); + + var execCommand = baseCommand + path.join(tmpDir, 'cordova-mobile-spec', 'cordova-plugin-whitelist'); + reportStatus((execOutput = shelljs.exec(execCommand, {silent:true})).code == 0, execOutput.output); + + execCommand = baseCommand + path.join(tmpDir, 'cordova-mobile-spec', 'cordova-plugin-echo'); + reportStatus((execOutput = shelljs.exec(execCommand, {silent:true})).code == 0, execOutput.output); + } + + if (majorBranchNum >= 3.6) { + // Install plugin-test-framework and the test plugins + console.log('Installing new-style plugin tests...'); + + var execCommand = baseCommand + tmpDir + path.sep + 'cordova-plugin-test-framework'; + shelljs.exec(execCommand, {silent:true}); + + for (var i = 0; i < settings.PLUGINS.length; i++) { + var potentialPlugin = path.join(settings.PLUGINS[i], 'tests'); + if (fs.existsSync(potentialPlugin)) { + var testsCommand = baseCommand + tmpDir + path.sep + potentialPlugin; + reportStatus(shelljs.exec(testsCommand, {silent:true}).code == 0); + } + } + } } //Execute platform specific code to populate SNAPSHOT_DIR, moving needed files & directories into SNAPSHOT_DIR diff --git a/corimf-settings-js.sample b/corimf-settings-js.sample index 88650f7..831b8a6 100644 --- a/corimf-settings-js.sample +++ b/corimf-settings-js.sample @@ -65,9 +65,9 @@ var PLATFORM_REPO = 'cordova-wp8', PLUGIN_COUNT = 18, - PLUGINS = ['cordova-plugin-battery-status', 'cordova-plugin-camera', 'cordova-plugin-console', 'cordova-plugin-contacts', 'cordova-plugin-device', 'cordova-plugin-device-motion', 'cordova-plugin-device-orientation', 'cordova-plugin-dialogs', 'cordova-plugin-file', 'cordova-plugin-file-transfer', 'cordova-plugin-geolocation', 'cordova-plugin-globalization', 'cordova-plugin-inappbrowser', 'cordova-plugin-media', 'cordova-plugin-media-capture', 'cordova-plugin-network-information', 'cordova-plugin-splashscreen', 'cordova-plugin-vibration'], + PLUGINS = ['cordova-plugin-battery-status', 'cordova-plugin-camera', 'cordova-plugin-console', 'cordova-plugin-contacts', 'cordova-plugin-device', 'cordova-plugin-device-motion', 'cordova-plugin-device-orientation', 'cordova-plugin-dialogs', 'cordova-plugin-file', 'cordova-plugin-file-transfer', 'cordova-plugin-geolocation', 'cordova-plugin-globalization', 'cordova-plugin-inappbrowser', 'cordova-plugin-media', 'cordova-plugin-media-capture', 'cordova-plugin-network-information', 'cordova-plugin-statusbar', 'cordova-plugin-splashscreen', 'cordova-plugin-vibration'], PLATFORM_REPOS = ['cordova-android', 'cordova-blackberry', 'cordova-ios', 'cordova-windows', 'cordova-wp8', 'cordova-js'], - OTHER_REPOS = ['cordova-blackberry-plugins', 'cordova-cli', 'cordova-plugman']; + OTHER_REPOS = ['cordova-blackberry-plugins', 'cordova-cli', 'cordova-plugman', 'cordova-mobile-spec', 'cordova-plugin-test-framework']; exports.PLATFORM_REPO = PLATFORM_REPO; exports.PROJECT_ONLY = PROJECT_ONLY; From 33c6f0adafced3816ff0146ddb4d1a617eab043a Mon Sep 17 00:00:00 2001 From: Staci Cooper Date: Thu, 2 Oct 2014 16:06:09 -0400 Subject: [PATCH 2/2] Fixes needed for 3.1 and 3.4 - addWWWForMobileSpec needed < 3.6 - account for difference in cordova-mobile-spec structure ('www' folder added in 3.6) --- corimf-build-wp8.js | 4 ++++ corimf-build.js | 33 ++++++++++++--------------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/corimf-build-wp8.js b/corimf-build-wp8.js index 2f1fd60..b531446 100644 --- a/corimf-build-wp8.js +++ b/corimf-build-wp8.js @@ -46,6 +46,10 @@ var WP8BuildSpecifics = function(DPO) { //build mobilespec in visual studio if (settings.MOBILESPEC) { + var majorBranchNum = Number(settings.BRANCH.substring(0,3)); + if (majorBranchNum < 3.6) { + addWWWForMobileSpec(DPO.MOBILESPEC_DIR, DPO.PROJECT_NAME+'.csproj'); + } tests.reportStatus(shelljs.exec('msbuild' + ' ' + path.join(DPO.MOBILESPEC_DIR, DPO.PROJECT_NAME +'.sln') + ' ' +'/p:Configuration=Release', {silent:false}).code == 0); } diff --git a/corimf-build.js b/corimf-build.js index a5fd81e..00e0d59 100644 --- a/corimf-build.js +++ b/corimf-build.js @@ -118,7 +118,9 @@ var RunPreliminaryTests = function(platformSpecificCode) { if (settings.PLUGMAN_REPO.length > 0) repos = repos.concat(settings.PLUGMAN_REPO); // We will also need these platform-independent repos - repos = repos.concat(['cordova-js', 'cordova-mobile-spec', 'cordova-plugin-test-framework']); + repos = repos.concat(['cordova-mobile-spec']); + if (Number(settings.BRANCH.substring(0,3)) >= 3.6) + repos = repos.concat(['cordova-plugin-test-framework']); // If not building project only, git-archive the branch that is desired if(!settings.PROJECT_ONLY) { @@ -194,18 +196,6 @@ var RunPreliminaryTests = function(platformSpecificCode) { shelljs.cd('..'); } - // run npm install in cordova-js before cd'ing back into main directory where script was ran - console.log('Loading pre-reqs for js...'); - shelljs.cd('cordova-js'); - if (shelljs.test('-d', 'node_modules')) { - execOutput = shelljs.rm('-rf', 'node_modules'); - console.log('true'); - } else console.log('false'); - reportStatus((execOutput = shelljs.exec('npm install', {silent:true})).code == 0, execOutput.output); - console.log('Running grunt in the cordova.js directory...'); - reportStatus(shelljs.exec('grunt', {silent:true}).code == 0); - shelljs.cd('..'); - shelljs.cd(cwd); // Android has code that must be run before build starts @@ -248,6 +238,8 @@ var BuildProject = function(platformSpecificCode) { //build mobilespec if(settings.MOBILESPEC) { + var majorBranchNum = Number(settings.BRANCH.substring(0,3)); + var WWW_DIR; if(platform == "android") WWW_DIR = path.join('assets','www'); @@ -263,16 +255,17 @@ var BuildProject = function(platformSpecificCode) { tests.reportStatus(shelljs.exec(cmd, {silent : false}).code == 0); console.log('Copying mobile-spec resources into project www...'); - shelljs.cp("-rf", path.join(tmpDir, 'cordova-mobile-spec', 'www', '*'), path.join(MOBILESPEC_DIR, WWW_DIR)); + var resourcesPath; + if (majorBranchNum >= 3.6) { + resourcesPath = path.join(tmpDir, 'cordova-mobile-spec', 'www', '*'); + } else { + resourcesPath = path.join(tmpDir, 'cordova-mobile-spec', '*'); + } + shelljs.cp("-rf", resourcesPath, path.join(MOBILESPEC_DIR, WWW_DIR)); // copy config.xml shelljs.cp("-f", path.join(tmpDir, 'cordova-mobile-spec', "config.xml"), MOBILESPEC_DIR); - //copy and rename cordova.js - console.log('Adding cordova.js...'); - var jsSrc = path.join(tmpDir, 'cordova-js', 'pkg', 'cordova.' + (platform === 'wp8' ? 'windowsphone' : platform) + '.js'); - shelljs.cp("-f", jsSrc, path.join(MOBILESPEC_DIR, 'www', 'cordova.js')); - console.log('Installing plugins into project...'); var pathPlugman = path.join(pathCorimf, settings.PLUGMAN_REPO, 'main.js'); var baseCommand = 'node ' + pathPlugman + ' --debug install --platform ' + platform + ' --project ' + pathMobileSpec + ' --plugin '; @@ -283,8 +276,6 @@ var BuildProject = function(platformSpecificCode) { reportStatus((execOutput = shelljs.exec(execCommand, {silent:true})).code == 0, execOutput.output); } - var majorBranchNum = Number(settings.BRANCH.substring(0,3)); - if (majorBranchNum >= 3.0) { // Install echo and whitelist plugins console.log('Installing echo and whitelist...');