Socket
Socket
Sign inDemoInstall

@capacitor/cli

Package Overview
Dependencies
Maintainers
5
Versions
847
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@capacitor/cli - npm Package Compare versions

Comparing version 0.0.12 to 0.0.13

assets/app-template/public/js/capacitor-welcome.js

6

assets/app-template/package.json
{
"name": "avocado-app",
"name": "capacitor-app",
"version": "1.0.0",
"description": "An Amazing Avocado App",
"description": "An Amazing Capacitor App",
"main": "index.js",

@@ -10,3 +10,3 @@ "scripts": {

"keywords": [
"avocado",
"capacitor",
"mobile"

@@ -13,0 +13,0 @@ ],

@@ -16,2 +16,3 @@ "use strict";

//printPlugins(plugins);
await copyPluginsJS(config, plugins, "ios");
await autoGeneratePods(plugins);

@@ -21,2 +22,22 @@ await installCocoaPodsPlugins(config, plugins, needsUpdate);

exports.updateIOS = updateIOS;
async function copyPluginsJS(config, plugins, platform) {
const pluginsDir = path_1.join(config.ios.webDir, 'plugins');
const cordovaPluginsJSFile = path_1.join(config.ios.webDir, 'cordova_plugins.js');
fs_1.removeSync(pluginsDir);
fs_1.removeSync(cordovaPluginsJSFile);
plugins.filter(p => p.ios.type === 2 /* Cordova */).map(async (p) => {
const pluginDir = path_1.join(pluginsDir, p.id, 'www');
fs_1.ensureDirSync(pluginDir);
const jsModules = getJSModules(p, platform);
jsModules.map(async (jsModule) => {
const filePath = path_1.join(config.ios.webDir, 'plugins', p.id, jsModule.$.src);
fs_1.copySync(path_1.join(p.rootPath, jsModule.$.src), filePath);
let data = await fs_1.readFileAsync(filePath, 'utf8');
data = `cordova.define("${p.id}.${jsModule.$.name}", function(require, exports, module) { \n${data}\n});`;
await fs_1.writeFileAsync(filePath, data, 'utf8');
});
});
fs_1.writeFileAsync(cordovaPluginsJSFile, generateCordovaPluginsJSFile(config, plugins, platform));
}
exports.copyPluginsJS = copyPluginsJS;
async function autoGeneratePods(plugins) {

@@ -60,3 +81,3 @@ return Promise.all(plugins

const projectName = config.ios.nativeProjectName;
const podfilePath = path_1.join(path_1.join(config.ios.name, projectName), 'Podfile');
const podfilePath = path_1.join(config.ios.name, projectName, 'Podfile');
await fs_1.writeFileAsync(podfilePath, content, 'utf8');

@@ -88,1 +109,41 @@ if (needsUpdate) {

exports.generatePodFile = generatePodFile;
function generateCordovaPluginsJSFile(config, plugins, platform) {
let pluginModules = [];
let pluginExports = [];
plugins.map((p) => {
const jsModules = getJSModules(p, platform);
jsModules.map((jsModule) => {
let clobbers = [];
jsModule.clobbers.map((clobber) => {
clobbers.push(clobber.$.target);
});
pluginModules.push(`{
"id": "${p.id}.${jsModule.$.name}",
"file": "plugins/${p.id}/${jsModule.$.src}",
"pluginId": "${p.id}",
"clobbers": [
"${clobbers.join(',')}"
]}`);
});
pluginExports.push(`"${p.id}": "${p.xml.$.version}"`);
});
return `
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
${pluginModules.join(',')}
];
module.exports.metadata =
// TOP OF METADATA
{
${pluginExports.join(',')}
};
// BOTTOM OF METADATA
});
`;
}
exports.generateCordovaPluginsJSFile = generateCordovaPluginsJSFile;
function getJSModules(p, platform) {
const modules = p.xml["js-module"];
const platformModules = p.xml.platform.filter(function (item) { return item.$.name === platform; });
return modules.concat(platformModules[0]["js-module"]);
}

@@ -34,3 +34,3 @@ "use strict";

rootPath: rootPath,
xml: xmlMeta.plugin.platform
xml: xmlMeta.plugin
};

@@ -37,0 +37,0 @@ }

@@ -11,9 +11,21 @@ "use strict";

async function initCommand(config) {
common_1.log('\n');
common_1.log(`${chalk.bold(`⚡️ Initializing Capacitor project in ${chalk.blue(config.cli.rootDir)}`)} ⚡️`);
common_1.log('\n');
try {
// Prompt for new or existing project
const isNew = await promptNewProject(config);
// Initializing an existing app
if (!isNew) {
await printExistingProjectMessage(config);
return;
}
// Initialize a new project
// Get or create our config
await getOrCreateConfig(config);
!isNew && await getOrCreateWebDir(config);
// Create the web directory
await createWebDir(config);
// Add our package.json
await checkPackageJson(config);
isNew && await seedProject(config);
await seedProject(config);
await installDeps(config);

@@ -38,2 +50,9 @@ await addPlatforms(config);

}
async function printExistingProjectMessage(config) {
common_1.log('\n\n');
common_1.log(`🎈 ${chalk.bold('Adding Capacitor to an existing project is easy:')} 🎈`);
common_1.log(`\nnpm install --save @capacitor/cli @capacitor/core`);
common_1.log(`\nnpm run capacitor add ios android`);
common_1.log(`\nLearn more: https://ionic-team.github.io/capacitor/docs/getting-started/\n`);
}
/**

@@ -55,20 +74,2 @@ * Check for or create our main configuration file.

/**
* Check for or create the main web assets directory (i.e. public/)
* @param config
*/
async function getOrCreateWebDir(config) {
const inquirer = await Promise.resolve().then(() => require('inquirer'));
const answers = await inquirer.prompt([{
type: 'input',
name: 'webDir',
message: 'What directory will your built web assets be in?',
default: 'public'
}]);
const webDir = answers.webDir;
if (!await fs_1.existsAsync(config.app.webDir)) {
await createWebDir(config, webDir);
}
config.app.webDir = webDir;
}
/**
* Check for or create the main package.json file

@@ -94,3 +95,3 @@ * @param config

await common_1.runTask(`Downloading and installing seed project`, async () => {
const url = 'https://github.com/ionic-team/ionic-pwa-toolkit/archive/master.tar.gz';
const url = 'https://github.com/ionic-team/capacitor-starter/archive/master.tar.gz';
const ws = await archive_1.createTarExtraction({ cwd: config.app.rootDir, strip: 1 });

@@ -116,10 +117,16 @@ await http_1.download(url, ws, {});

*/
async function createWebDir(config, webDir) {
await fs_1.mkdirAsync(webDir);
await common_1.runTask(`Creating ${config.app.extConfigName}`, () => {
return common_1.writePrettyJSON(config.app.extConfigFilePath, {
webDir: webDir
async function createWebDir(config) {
const webDir = "public";
try {
await fs_1.mkdirAsync(webDir);
await common_1.runTask(`Creating ${config.app.extConfigName}`, () => {
return common_1.writePrettyJSON(config.app.extConfigFilePath, {
webDir: webDir
});
});
});
await copyAppTemplatePublicAssets(config, webDir);
await copyAppTemplatePublicAssets(config, webDir);
}
catch (e) {
common_1.logError(`Unable to create web directory "${webDir}." You'll need to create it yourself or configure webDir in capacitor.config.json`);
}
}

@@ -126,0 +133,0 @@ async function copyAppTemplatePublicAssets(config, webDir) {

@@ -18,1 +18,4 @@ "use strict";

exports.lstatAsync = util.promisify(fs.lstat);
exports.removeSync = fsExtra.removeSync;
exports.ensureDirSync = fsExtra.ensureDirSync;
exports.copySync = fsExtra.copySync;
{
"name": "@capacitor/cli",
"version": "0.0.12",
"version": "0.0.13",
"description": "Capacitor: Cross-platform apps with JavaScript and the web",

@@ -5,0 +5,0 @@ "homepage": "https://ionic-team.github.io/capacitor/",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc