@capacitor/cli
Advanced tools
Comparing version 0.0.76 to 0.0.77
@@ -9,4 +9,4 @@ "use strict"; | ||
const path_1 = require("path"); | ||
const platform = 'android'; | ||
async function updateAndroid(config, needsUpdate) { | ||
const platform = 'android'; | ||
const plugins = await common_1.runTask('Fetching plugins', async () => { | ||
@@ -22,2 +22,3 @@ const allPlugins = await plugin_1.getPlugins(); | ||
await update_1.copyPluginsJS(config, cordovaPlugins, platform); | ||
copyPluginsNativeFiles(config, cordovaPlugins); | ||
} | ||
@@ -73,1 +74,19 @@ else { | ||
exports.writeXML = writeXML; | ||
function copyPluginsNativeFiles(config, cordovaPlugins) { | ||
const pluginsPath = path_1.resolve('node_modules', '@capacitor/cli', 'assets', 'capacitor-android-plugins', 'src', 'main'); | ||
fs_1.removeSync(path_1.join(pluginsPath, 'java')); | ||
fs_1.removeSync(path_1.join(pluginsPath, 'res')); | ||
cordovaPlugins.map(p => { | ||
const platformFiles = p.xml.platform.filter(function (item) { return item.$.name === platform; }); | ||
const sourceFiles = platformFiles[0]['source-file']; | ||
sourceFiles.map((sourceFile) => { | ||
const fileName = sourceFile.$.src.split("/").pop(); | ||
const target = sourceFile.$["target-dir"].replace('src/', 'java/'); | ||
fs_1.copySync(path_1.join(p.rootPath, sourceFile.$.src), path_1.join(pluginsPath, target, fileName)); | ||
}); | ||
const resourceFiles = platformFiles[0]['resource-file']; | ||
resourceFiles.map((resourceFile) => { | ||
fs_1.copySync(path_1.join(p.rootPath, resourceFile.$.src), path_1.join(pluginsPath, resourceFile.$["target"])); | ||
}); | ||
}); | ||
} |
@@ -32,3 +32,3 @@ "use strict"; | ||
}); | ||
// printPlugins(plugins); | ||
plugin_1.printPlugins(plugins); | ||
const cordovaPlugins = plugins | ||
@@ -35,0 +35,0 @@ .filter(p => update_1.getPluginType(p, platform) === 2 /* Cordova */); |
@@ -66,2 +66,3 @@ "use strict"; | ||
function printPlugins(plugins) { | ||
console.log('Printing plugins'); | ||
const chalk = require('chalk'); | ||
@@ -68,0 +69,0 @@ const pluginNames = plugins.map(p => p.id).sort(); |
@@ -57,2 +57,5 @@ "use strict"; | ||
} | ||
else if (platformName === config.web.name) { | ||
return []; | ||
} | ||
else { | ||
@@ -59,0 +62,0 @@ throw `Platform ${platformName} is not valid.`; |
@@ -19,2 +19,5 @@ "use strict"; | ||
} | ||
else if (platformName === config.web.name) { | ||
return Promise.resolve(); | ||
} | ||
else { | ||
@@ -21,0 +24,0 @@ throw `Platform ${platformName} is not valid.`; |
@@ -36,2 +36,5 @@ "use strict"; | ||
} | ||
else if (platformName === config.web.name) { | ||
return Promise.resolve(); | ||
} | ||
else { | ||
@@ -38,0 +41,0 @@ throw `Platform ${platformName} is not valid.`; |
@@ -23,5 +23,5 @@ "use strict"; | ||
async function sync(config, platformName) { | ||
const tasks = [() => update_1.update(config, platformName, false), () => copy_1.copy(config, platformName)]; | ||
const tasks = [() => copy_1.copy(config, platformName), () => update_1.update(config, platformName, false)]; | ||
await promise_1.allSerial(tasks); | ||
} | ||
exports.sync = sync; |
@@ -35,2 +35,5 @@ "use strict"; | ||
} | ||
else if (platformName === config.web.name) { | ||
return []; | ||
} | ||
else { | ||
@@ -44,2 +47,3 @@ throw `Platform ${platformName} is not valid.`; | ||
async function update(config, platformName, needsUpdate) { | ||
common_1.log(`Updating platform ${platformName}`); | ||
if (platformName === config.ios.name) { | ||
@@ -54,4 +58,7 @@ await update_2.updateIOS(config, needsUpdate); | ||
exports.update = update; | ||
/** | ||
* Build the plugins/* files for each Cordova plugin installed. | ||
*/ | ||
async function copyPluginsJS(config, cordovaPlugins, platform) { | ||
const webDir = getwebDir(config, platform); | ||
const webDir = getWebDir(config, platform); | ||
const pluginsDir = path_1.join(webDir, 'plugins'); | ||
@@ -75,2 +82,5 @@ const cordovaPluginsJSFile = path_1.join(webDir, 'cordova_plugins.js'); | ||
exports.copyPluginsJS = copyPluginsJS; | ||
/** | ||
* Build the root cordova_plugins.js file referencing each Plugin JS file. | ||
*/ | ||
function generateCordovaPluginsJSFile(config, plugins, platform) { | ||
@@ -83,12 +93,17 @@ let pluginModules = []; | ||
let clobbers = []; | ||
jsModule.clobbers.map((clobber) => { | ||
clobbers.push(clobber.$.target); | ||
}); | ||
let clobbersModule = ""; | ||
if (jsModule.clobbers) { | ||
jsModule.clobbers.map((clobber) => { | ||
clobbers.push(clobber.$.target); | ||
}); | ||
clobbersModule = `, | ||
"clobbers": [ | ||
"${clobbers.join('",\n "')}" | ||
]`; | ||
} | ||
pluginModules.push(`{ | ||
"id": "${p.id}.${jsModule.$.name}", | ||
"file": "plugins/${p.id}/${jsModule.$.src}", | ||
"pluginId": "${p.id}", | ||
"clobbers": [ | ||
"${clobbers.join(',')}" | ||
]}`); | ||
"pluginId": "${p.id}"${clobbersModule} | ||
}`); | ||
}); | ||
@@ -100,3 +115,3 @@ pluginExports.push(`"${p.id}": "${p.xml.$.version}"`); | ||
module.exports = [ | ||
${pluginModules.join(',')} | ||
${pluginModules.join(',\n ')} | ||
]; | ||
@@ -106,3 +121,3 @@ module.exports.metadata = | ||
{ | ||
${pluginExports.join(',\n')} | ||
${pluginExports.join(',\n ')} | ||
}; | ||
@@ -114,2 +129,5 @@ // BOTTOM OF METADATA | ||
exports.generateCordovaPluginsJSFile = generateCordovaPluginsJSFile; | ||
/** | ||
* Get each JavaScript Module for the give nplugin | ||
*/ | ||
function getJSModules(p, platform) { | ||
@@ -126,3 +144,3 @@ let modules = []; | ||
} | ||
function getwebDir(config, platform) { | ||
function getWebDir(config, platform) { | ||
if (platform === 'ios') { | ||
@@ -152,12 +170,12 @@ return config.ios.webDir; | ||
} | ||
return fs_extra_1.copy(cordovaPath, path_1.join(getwebDir(config, platform), 'cordova.js')); | ||
return fs_extra_1.copy(cordovaPath, path_1.join(getWebDir(config, platform), 'cordova.js')); | ||
} | ||
exports.copyCordovaJS = copyCordovaJS; | ||
function createEmptyCordovaJS(config, platform) { | ||
fs_1.writeFileAsync(path_1.join(getwebDir(config, platform), 'cordova.js'), ""); | ||
fs_1.writeFileAsync(path_1.join(getwebDir(config, platform), 'cordova_plugins.js'), ""); | ||
fs_1.writeFileAsync(path_1.join(getWebDir(config, platform), 'cordova.js'), ""); | ||
fs_1.writeFileAsync(path_1.join(getWebDir(config, platform), 'cordova_plugins.js'), ""); | ||
} | ||
exports.createEmptyCordovaJS = createEmptyCordovaJS; | ||
function removePluginFiles(config, platform) { | ||
const webDir = getwebDir(config, platform); | ||
const webDir = getWebDir(config, platform); | ||
const pluginsDir = path_1.join(webDir, 'plugins'); | ||
@@ -164,0 +182,0 @@ const cordovaPluginsJSFile = path_1.join(webDir, 'cordova_plugins.js'); |
{ | ||
"name": "@capacitor/cli", | ||
"version": "0.0.76", | ||
"version": "0.0.77", | ||
"description": "Capacitor: Cross-platform apps with JavaScript and the web", | ||
@@ -5,0 +5,0 @@ "homepage": "https://capacitor.ionicframework.com/", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1336903
2267
263