New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

crosswalk-app-tools

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crosswalk-app-tools - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

android/lib/AndroidManifest.js

406

android/lib/AndroidPlatform.js

@@ -6,9 +6,12 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var FS = require("fs");
var Path = require('path');
var AdmZip = require("adm-zip");
var Path = require('path');
var ShellJS = require("shelljs");
var AndroidDependencies = require("./AndroidDependencies");
var AndroidManifest = require("./AndroidManifest");
var AndroidSDK = require("./AndroidSDK");
var CrosswalkZip = require("./CrosswalkZip");
var JavaActivity = require("./JavaActivity");
var XmlTheme = require("./XmlTheme");

@@ -21,6 +24,5 @@ /**

* @param {PlatformData} baseData Init data passed to the platform
* @param {Object} args Platform-specific args, only if specified and actually given
* @throws {@link AndroidSDK~SDKNotFoundError} If the Android SDK was not found in the environment.
*/
function AndroidPlatform(PlatformBase, baseData, args) {
function AndroidPlatform(PlatformBase, baseData) {

@@ -46,2 +48,5 @@ // Create base instance.

/**
* Accessor function for platform-specific command-line argument spec.
*/
AndroidPlatform.getArgs =

@@ -58,2 +63,12 @@ function() {

/**
* Accessor function for platform-specific environment variables spec.
*/
AndroidPlatform.getEnv =
function() {
return {
CROSSWALK_APP_TOOLS_CACHE_DIR: "Keep downloaded files in this dir"
};
};
/**
* Fill template files and put them into the project skeleton.

@@ -74,3 +89,3 @@ * @param {String} apiTarget Android API target (greater android-14)

"packageId" : this.packageId,
"packageName" : packageName,
"packageName" : this.packageId,
"apiTarget" : apiTarget

@@ -101,76 +116,2 @@ };

AndroidPlatform.prototype.writeActivityJava =
function(zipEntry) {
var output = this.application.output;
var templateData = zipEntry.getData().toString();
if (!templateData) {
output.error("Java main activity file could not be extracted");
return false;
}
// Change package name
var templatePackage = "org.xwalk.app.template";
var index = templateData.search(templatePackage);
if (index < 0) {
output.error("Failed to find template package '" + templatePackage + "' in " + zipEntry.name);
return false;
}
templateData = templateData.replace(templatePackage, this.packageId);
// Change class name
var templateClass = "AppTemplateActivity";
index = templateData.search(templateClass);
if (index < 0) {
output.error("Failed to find template class '" + templateClass + "' in " + zipEntry.name);
return false;
}
templateData = templateData.replace(templateClass, "MainActivity");
// Create target directory
var activityDirPath = Path.join(this.platformPath,
"src",
this.packageId.replace(/\./g, Path.sep));
ShellJS.mkdir("-p", activityDirPath);
if (!ShellJS.test("-d", activityDirPath)) {
output.error("Failed to create activity dir " + activityDirPath);
return false;
}
// Do not overwrite activity file because it may contain app-specific code
// FIXME we should be smarter about this:
// 1 - check if file is different from new content
// 2 - if yes, create a ".new" file
var activityFilePath = Path.join(activityDirPath, "MainActivity.java");
if (ShellJS.test("-f", activityFilePath)) {
// HACK force newline because we're in the midst of a progress indication
output.write("\n");
output.warning("File already exists: " + activityFilePath);
var activityBackupFilename;
var activityBackupPath;
var i = 0;
do {
activityBackupFilename = "MainActivity.java.orig-" + i;
activityBackupPath = Path.join(activityDirPath, activityBackupFilename);
i++;
} while (ShellJS.test("-f", activityBackupPath));
ShellJS.mv(activityFilePath, activityBackupPath);
output.warning("Existing activity file rename to: " + activityBackupPath);
output.warning("Please port any custom java code to the new MainActivity.java");
}
// Write activity file
FS.writeFileSync(activityFilePath, templateData);
if (!ShellJS.test("-f", activityFilePath)) {
output.error("Failed to write main activity " + activityFilePath);
return false;
}
return true;
};
/**

@@ -187,20 +128,3 @@ * Import Crosswalk libraries and auxiliary files into the project.

// Derive root entry from file name.
var parts = crosswalkPath.split(Path.sep);
var filename = parts[parts.length - 1];
var base = filename.substring(0, filename.length - ".zip".length);
// Extract version
var version = base.split("-")[1];
var numbers = version.split(".");
var major = numbers[0];
if (major < 8) {
output.error("Crosswalk version " + major + " not supported. Use 8+.");
return null;
} else if (major > 13) {
output.warning("This tool has not been tested with Crosswalk " + major + ".");
}
var indicator = output.createFiniteProgress("Extracting " + crosswalkPath);
indicator.update(0.1);

@@ -210,3 +134,3 @@ // Extract contents

try {
zip = new AdmZip(crosswalkPath);
zip = new CrosswalkZip(crosswalkPath);
} catch (e) {

@@ -221,8 +145,14 @@ // HACK we're in the midst of a progress display, force line break

indicator.update(0.3);
indicator.update(0.2);
var root = base + "/";
var entry = zip.getEntry(root);
if (zip.version.major < 9) {
output.error("Crosswalk version " + zip.version.major + " not supported. Use 8+.");
return null;
} else if (zip.version.major > 15) {
output.warning("This tool has not been tested with Crosswalk " + zip.version.major + ".");
}
var entry = zip.getEntry(zip.root);
if (!entry) {
output.error("Failed to find root entry " + root);
output.error("Failed to find root entry " + zip.root);
return null;

@@ -235,3 +165,3 @@ }

var path;
var name = root + "xwalk_core_library/";
var name = zip.root + "xwalk_core_library/";
entry = zip.getEntry(name);

@@ -243,3 +173,3 @@ if (entry) {

ShellJS.mkdir(path);
zip.extractEntryTo(entry, path, false, true);
zip.extractEntryTo(entry, path);
} else {

@@ -253,20 +183,8 @@ output.error("Failed to find entry " + name);

if (major === 8) {
// Only for Version 8.
name = root + "template/libs/xwalk_runtime_java.jar";
entry = zip.getEntry(name);
if (entry) {
zip.extractEntryTo(entry, platformPath + Path.sep + "libs", false, true);
} else {
output.error("Failed to find entry " + name);
return null;
}
}
indicator.update(0.6);
name = root + "template/libs/xwalk_app_runtime_java.jar";
name = zip.root + "template/libs/xwalk_app_runtime_java.jar";
entry = zip.getEntry(name);
if (entry) {
zip.extractEntryTo(entry, platformPath + Path.sep + "libs", false, true);
zip.extractEntryTo(entry, platformPath + Path.sep + "libs");
} else {

@@ -280,7 +198,17 @@ output.error("Failed to find entry " + name);

// Extract main activity java file
name = root + "template/src/org/xwalk/app/template/AppTemplateActivity.java";
name = zip.root + "template/src/org/xwalk/app/template/AppTemplateActivity.java";
entry = zip.getEntry(name);
if (entry) {
if (!this.writeActivityJava(entry))
// Create path
var activityDirPath = JavaActivity.pathForPackage(platformPath, this.packageId);
ShellJS.mkdir("-p", activityDirPath);
if (!ShellJS.test("-d", activityDirPath)) {
output.error("Failed to create activity dir " + activityDirPath);
return false;
}
var activity = new JavaActivity(output,
Path.join(activityDirPath, "MainActivity.java"));
if (!activity.importFromZip(entry, this.packageId))
return null;

@@ -296,6 +224,6 @@

// Extract res
name = root + "template/res/";
name = zip.root + "template/res/";
entry = zip.getEntry(name);
if (entry) {
zip.extractEntryTo(entry, platformPath + Path.sep + "res", false, true);
zip.extractEntryTo(entry, platformPath + Path.sep + "res");
} else {

@@ -309,3 +237,3 @@ output.error("Failed to find entry " + name);

return version;
return zip.version.toString();
};

@@ -400,2 +328,7 @@

// Remove _* from the default set of assets that are ignored
// see sdk/tools/ant/build.xml for more info
// the following is the default, without '_*'
'aapt.ignore.assets = "!.svn:!.git:.*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~"\n'.toEnd(path + Path.sep + 'ant.properties');
var versionSpec = null;

@@ -589,9 +522,6 @@ if (args.crosswalk) {

var apkInPath = ShellJS.ls("bin" + Path.sep + apkInPattern)[0];
if (!apkInPath) {
output.error("APK bin" + Path.sep + apkInPattern + " not found");
return null;
}
ShellJS.pushd("bin");
var apkInName = ShellJS.ls(apkInPattern)[0];
ShellJS.popd();
var apkInName = apkInPath.split(Path.sep)[1];
if (!ShellJS.test("-f", "bin" + Path.sep + apkInName)) {

@@ -616,2 +546,81 @@ output.error("APK bin" + Path.sep + apkInName + " not found");

/**
* Generate versionCode for AndroidManifest.xml
* @param {String} abi ABI to create the code for
* @returns {String} Version code or null on failure.
* @private
* @static
*/
AndroidPlatform.prototype.generateVersionCode =
function(output, appVersion, abi) {
function zeropad(string, length) {
var str = (typeof string === "string") ? string : "";
var padLen = length - str.length;
var pad = Array(padLen + 1).join("0");
return pad + str;
}
var abiCodes = {
"armeabi-v7a": 2,
// "arm64": 3, TODO check name
"x86": 6
// "x86_64": 7, TODO check name
};
var versionNums = appVersion.split(".");
var abiCode = abiCodes[abi];
if (!abiCode) {
output.error("Unsupported ABI code '" + abi + "'");
return null;
}
// The format for versionCode is "ammiiccc", where
// a .. abi
// m .. major release number (optional, or 0)
// i .. minor release number (optional, or 0)
// c .. micro release number
// This is a simplified version of
// https://software.intel.com/en-us/blogs/2012/11/12/how-to-publish-your-apps-on-google-play-for-x86-based-android-devices-using
//
// We build the array holding the numbers in a reverse fashion,
// that's easier with the optional parts.
var reversedCode = ["000", "00", "00", "0"];
var reversedVersion = versionNums.reverse();
reversedCode[0] = zeropad(reversedVersion[0], 3);
reversedCode[1] = zeropad(reversedVersion[1], 2);
reversedCode[2] = zeropad(reversedVersion[2], 2);
reversedCode[3] = abiCode;
return reversedCode.reverse().join("");
};
/**
* Update versionCode in AndroidManifest.xml for ABI
* @param {String} abi ABI to generate the versionCode for
* @returns {Boolean} true on success, false on failure.
*/
AndroidPlatform.prototype.updateVersionCode =
function(abi) {
var output = this.application.output;
var manifest = new AndroidManifest(this.application.output,
Path.join(this.platformPath, "AndroidManifest.xml"));
var versionCode = this.generateVersionCode(this.application.output,
this.application.manifest.appVersion,
abi);
output.info("Using android:versionCode '" + versionCode + "'");
manifest.versionCode = versionCode;
return true;
};
/**
* Build APK for one ABI. This method is calling itself recursively, until

@@ -669,2 +678,5 @@ * all ABIs are built.

// Update versionCode in AndroidManifest.xml
this.updateVersionCode(abi);
// Build for ABI.

@@ -707,2 +719,130 @@ this._sdk.buildProject(closure.release, function(success) {

/**
* Update icons from the manifest.
*/
AndroidPlatform.prototype.updateManifest =
function(callback) {
var output = this.application.output;
var manifest = new AndroidManifest(output,
Path.join(this.platformPath, "AndroidManifest.xml"));
// Renaming package is not supported.
if (manifest.package !== this.application.manifest.packageId) {
callback("Renaming of package not supported (" +
manifest.package + "/" + this.application.manifest.packageId + ")");
return;
}
manifest.versionName = this.application.manifest.appVersion;
manifest.applicationLabel = this.application.manifest.name;
// Update icons
// See http://iconhandbook.co.uk/reference/chart/android/
var sizes = {
"ldpi": 47,
"mdpi": 71,
"hdpi": 95,
"xhdpi": 143,
"xxhdpi": 191,
"xxxhdpi": 511, // whatever, this is default for even bigger icons.
match: function(size) {
// Default to "hdpi", android will scale.
if (size === "any")
return "hdpi";
// Match size as per categories above.
for (var prop in this) {
if (this[prop] >= size) {
return prop;
}
}
return "xxxhdpi";
}
};
var iconFilename = "crosswalk_icon";
// Add icons from manifest
var icons = this.application.manifest.icons;
if (icons && icons.length > 0) {
// Remove existing icons, so we don't have stale ones around
// FIXME check that no icon was added manually.
ShellJS.rm("-rf", Path.join(this.platformPath, "res", "mipmap-*"));
for (var i = 0; i < icons.length; i++) {
var icon = icons[i];
var size = icon.sizes ? +icon.sizes.split("x")[0] : "any";
var density = sizes.match(size);
// Copy icon into place
// Icon will always be named crosswalk-icon.<ext>
// Because android:icon has no way to refer to different sizes.
var src = Path.join(this.appPath, icon.src);
var dstPath = Path.join(this.platformPath, "res", "mipmap-" + density);
var dst = Path.join(dstPath, iconFilename + Path.extname(icon.src));
ShellJS.mkdir(dstPath);
ShellJS.cp(src, dst);
}
manifest.applicationIcon = "@mipmap/" + iconFilename;
} else {
output.warning("No icons found in manifest.json");
// Fall back to the default icon
manifest.applicationIcon = "@drawable/crosswalk";
}
};
/**
* Update java activity file for build config.
* @param {Boolean} release True if release build, false if debug
* @returns {Boolean} True if successful, otherwise false.
*/
AndroidPlatform.prototype.updateJavaActivity =
function(release) {
var output = this.application.output;
var ret = true;
// Update java
var config = release ? "release" : "debug";
output.info("Updating java activity for '" + config + "' configuration");
var dir = JavaActivity.pathForPackage(this.platformPath, this.packageId);
var path = Path.join(dir, "MainActivity.java");
var activity = new JavaActivity(output, path);
// Enable remote debugging for debug builds.
ret = activity.enableRemoteDebugging(!release);
if (!ret)
return false;
// Animatable view
ret = activity.enableAnimatableView(this.application.manifest.androidAnimatableView);
if (!ret)
return false;
// Fullscreen
var fullscreen = this.application.manifest.display === "fullscreen";
ret = activity.enableFullscreen(fullscreen);
if (!ret)
return false;
output.info("Updating theme.xml for display mode (fullscreen: " + (fullscreen ? "yes" : "no") + ")");
var theme = new XmlTheme(output,
Path.join(this.platformPath, "res", "values-v14", "theme.xml"));
theme.fullscreen = fullscreen;
// "Keep screen on"
ret = activity.enableKeepScreenOn(this.application.manifest.androidKeepScreenOn);
if (!ret)
return false;
return ret;
};
/**
* Implements {@link PlatformBase.build}

@@ -718,2 +858,5 @@ */

this.updateManifest(callback);
this.updateJavaActivity(configId === "release");
var closure = {

@@ -726,4 +869,7 @@ abis: ["armeabi-v7a", "x86"], // TODO export option

if (!errormsg) {
if (!errormsg &&
closure.apks.length > 0) {
output.highlight(" * Built package(s):");
for (var i = 0; i < closure.apks.length; i++) {

@@ -735,3 +881,3 @@

output.highlight(" pkg/" + closure.apks[i]);
output.highlight(" + " + closure.apks[i]);
}

@@ -738,0 +884,0 @@ }

@@ -10,2 +10,3 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var AndroidTargets = require("./AndroidTargets");
var JavaActivity = require("./JavaActivity");

@@ -61,2 +62,40 @@

/**
* Filter known messages from stderr buffer
* @param {String} buffer Input buffer
* @returns {String} Filtered output buffer
* @private
*/
AndroidSDK.prototype.filterErrorLog =
function(buffer) {
var prefixes = [
"Picked up _JAVA_OPTIONS",
"Picked up JAVA_TOOL_OPTIONS" ];
var filtered = "";
var lines = buffer.split("\n");
for (var i = 0; i < lines.length; i++) {
var line = lines[i].trim();
if (line.length > 0) {
var filter = false;
for (var j = 0; j < prefixes.length; j++) {
var prefix = prefixes[j];
if (line.substring(0, prefix.length) === prefix) {
// skip
filter = true;
continue;
}
}
if (!filter)
filtered += line + "\n";
}
}
return filtered;
};
/**
* Query for lowest API target that supports apiLevel.

@@ -132,2 +171,3 @@ * @param {Number} apiLevel Minimum supported API level

errlog = this.filterErrorLog(errlog);
if (errlog && !errmsg) {

@@ -138,6 +178,15 @@ // Pass back errlog output as error message.

// Delete stub activity, we extract the crosswalk one later on.
var javaActivityPath = Path.join(JavaActivity.pathForPackage(path, packageId),
"MainActivity.java");
if (ShellJS.test("-f", javaActivityPath)) {
ShellJS.rm("-f", javaActivityPath);
} else {
output.warning("File not found: " + javaActivityPath);
}
indicator.done();
callback(path, stdlog, errmsg);
return;
});
}.bind(this));
};

@@ -168,4 +217,4 @@

var exitStatus = { "code" : 0 };
var args = [ release ? "release" : "debug" ];
var child = ChildProcess.execFile(ant, args);
ant += release ? " release" : " debug";
var child = ChildProcess.exec(ant);

@@ -180,4 +229,7 @@ child.stdout.on("data", function(data) {

child.stderr.on("data", function(data) {
output.warning(data, true);
});
data = this.filterErrorLog(data);
if (data) {
output.warning(data, true);
}
}.bind(this));

@@ -184,0 +236,0 @@ child.on("exit", function(code, signal) {

@@ -76,3 +76,47 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

});
},
generateVersionCode: function(test) {
var versions = [
"1",
"1.1",
"1.1.1",
"11.1.1",
"11.11.1",
"11.11.11",
"11.11.111"
];
var codes = [
"60000001",
"60001001",
"60101001",
"61101001",
"61111001",
"61111011",
"61111111"
];
test.expect(versions.length);
var application = Util.createTmpApplication("com.example.foo");
var platformData = {
application: application,
platformId: "android"
};
var android = new AndroidPlatform(PlatformBase, platformData);
for (var i = 0; i < versions.length; i++) {
var versionCode = android.generateVersionCode(application.output,
versions[i],
"x86");
test.equal(versionCode, codes[i]);
}
Util.deleteTmpApplication(application);
test.done();
}
};

@@ -92,3 +92,17 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

});
},
filterErrorLog: function(test) {
test.expect(1);
var buffer = "" +
"Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar" + "\n" +
"foo" + "\n" +
"Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true";
var filtered = AndroidSDK.prototype.filterErrorLog(buffer);
test.equal(filtered, "foo\n");
test.done();
}
};

@@ -34,3 +34,3 @@ module.exports = function(grunt) {

dist : {
src: ['src/**/*.js'],
src: ['src/**/*.js', 'android/lib/*.js'],
options: {

@@ -37,0 +37,0 @@ destination: 'doc'

{
"name": "crosswalk-app-tools",
"version": "0.5.0",
"version": "0.6.0",
"description": "An APK packager for the Crosswalk Project -- http://crosswalk-project.org",

@@ -24,3 +24,4 @@ "author": "Robert Staudinger <robert.staudinger@intel.com>",

"mustache": "~0.8.2",
"shelljs": "~0.3.0"
"shelljs": "~0.3.0",
"xmldom": "~0.1.19"
},

@@ -52,2 +53,3 @@ "devDependencies": {

"package.json",
"manifest.md",
"README.md",

@@ -54,0 +56,0 @@ "src",

@@ -7,29 +7,41 @@ Crosswalk-app-tools

Crosswalk-app-tools is in early stages of development, and not suitable for use in a production environment. Preliminary releases and announcements are made available as a technology preview only. No packages are being published at this time, but git tags serve as reference points for release milestones.
Crosswalk-app-tools is our forthcoming packaging tool for creating Crosswalk applications. We are inviting early adopters to build their web applications using crosswalk-app-tools, and provide feedback for future improvements.
### Installation
Crosswalk-app-tools is cross-platform by virtue of being based on Node.js. However at this point most testing is done on Linux, so we expect the least number of hickups there. In any case we have seen reports of successful runs on Apple OS X, and are looking forward to hearing about adventurous individuals giving it a spin on Microsoft Windows as well.
Crosswalk-app-tools is cross-platform by virtue of being based on Node.js. We are supporting Microsoft Windows, Apple OS X and Linux (testing is mostly done on Fedora and Ubuntu distributions).
Prerequisites are functional
1. Android SDK
The following components are required
1. Android SDK with 5.0 (target-21) installed
2. Java JDK and Apache Ant
3. Node.js and NPM
on the system.
The best way to check if a machine has all the required dependencies is to create and build a plain empty Android app
on the system. If this does not work, then building Crosswalk apps will not succeed either.
In order to get the `crosswalk-app` script available everywhere, global npm installation is required. On most Linux distributions this can be achieved by using `sudo`.
```
sudo npm install -g crosswalk-app-tools
android create project -a MainActivity -k com.example.foo -p com.example.foo -t android-21
cd com.example.foo
ant debug
```
In order to get the `crosswalk-app` script available everywhere, global npm installation is required.
```
Microsoft Windows: npm install -g crosswalk-app-tools
Apple OS X and Linux: sudo npm install -g crosswalk-app-tools
```
### Usage
```
Crosswalk Application Project and Packaging Tool
Crosswalk Project Application Packaging Tool
crosswalk-app create <package-id> Create project <package-id>
crosswalk-app create <package-id> Create project <package-id>
--platforms=<target> Optional, e.g. "windows"
crosswalk-app build [release|debug] Build project to create packages
Defaults to debug when not given
crosswalk-app build [release|debug] [<dir>] Build project to create packages
Defaults to "debug" when not given
Tries to build in current dir by default

@@ -39,14 +51,16 @@ crosswalk-app update <channel>|<version> Update Crosswalk to latest in named

crosswalk-app help Display usage information
crosswalk-app platforms List available target platforms
crosswalk-app version Display version information
crosswalk-app help Display usage information
crosswalk-app version Display version information
Options for platform 'android'
For command 'create'
--android-crosswalk Channel name (stable/beta/canary)
or version number (w.x.y.z)
Environment Variables
--android-crosswalk Channel name (stable/beta/canary)
or version number (w.x.y.z)
Environment variables for platform 'android'
CROSSWALK_APP_TOOLS_CACHE_DIR Keep downloaded files in this dir
CROSSWALK_APP_TOOLS_CACHE_DIR Keep downloaded files in this dir
```

@@ -57,3 +71,3 @@ #### Example: Create App

#### Example: Build App
`cd com.example.foo` and then `crosswalk-app build` builds packages. The APKs can be found under pkg/ when done.
`cd com.example.foo` and then `crosswalk-app build` builds packages. The APKs can be found in the current directory when done.

@@ -63,5 +77,8 @@ #### Example: Update Crosswalk

### Limitations
* Android release packages will have to be signed manually before they are published on Google's Play Store, as that functionality is not yet integrated.
* This is alpha stage software and under continuous development. We encourage trying it and appreciate feedback, but use in a production environment is not supported at this point in time.
### Run development versions from git

@@ -68,0 +85,0 @@

@@ -5,2 +5,3 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var OS = require("os");
var Path = require('path');

@@ -14,2 +15,3 @@

var LogfileOutput = require("./LogfileOutput");
var Manifest = require("./Manifest");
var OutputTee = require("./OutputTee");

@@ -36,5 +38,5 @@ var TerminalOutput = require("./TerminalOutput");

if (!ShellJS.test("-d", cwd)) {
throw new InvalidPathException("Path does not exist: " + cwd);
throw new InvalidPathException("Path does not exist: " + cwd);
}
// PackageId is only passed when a new project is created.

@@ -45,27 +47,23 @@ if (packageId) {

initMembers.call(this, cwd);
// Check that dir not already exists
if (ShellJS.test("-d", this._rootPath)) {
throw new InvalidPathException("Failed to create project, path already exists: " + this._rootPath);
// Check that project dir not already exists
var rootPath = Path.join(cwd, this._packageId);
if (ShellJS.test("-d", rootPath)) {
throw new InvalidPathException("Failed to create project, path already exists: " + rootPath);
}
// Initialise project skeleton
ShellJS.mkdir(this._rootPath);
ShellJS.mkdir(this._appPath);
ShellJS.mkdir(this._logPath);
ShellJS.mkdir(this._pkgPath);
ShellJS.mkdir(this._prjPath);
initMembers.call(this, rootPath);
// Create Manifest
Manifest.create(Path.join(this._appPath, "manifest.json"), packageId);
} else {
// Get packageId from current directory
var basename = Path.basename(cwd);
this._packageId = CommandParser.validatePackageId(basename, this.output);
// Get packageId from manifest
var manifest = new Manifest(this._output, Path.join(cwd, "app", "manifest.json"));
this._packageId = manifest.packageId;
if (!this._packageId) {
throw new InvalidPathException("Path does not seem to be a project toplevel: " + cwd);
throw new InvalidPathException("Path does not seem to be a project toplevel: " + cwd);
}
initMembers.call(this, Path.dirname(cwd));
initMembers.call(this, cwd);
}

@@ -75,15 +73,15 @@

if (!ShellJS.test("-d", this._rootPath)) {
throw new InvalidPathException("Failed to load, invalid path: " + this._rootPath);
throw new InvalidPathException("Failed to load, invalid path: " + this._rootPath);
}
if (!ShellJS.test("-d", this._appPath)) {
throw new InvalidPathException("Failed to load, invalid path: " + this._appPath);
throw new InvalidPathException("Failed to load, invalid path: " + this._appPath);
}
if (!ShellJS.test("-d", this._logPath)) {
throw new InvalidPathException("Failed to load, invalid path: " + this._logPath);
throw new InvalidPathException("Failed to load, invalid path: " + this._logPath);
}
if (!ShellJS.test("-d", this._pkgPath)) {
throw new InvalidPathException("Failed to load, invalid path: " + this._pkgPath);
throw new InvalidPathException("Failed to load, invalid path: " + this._pkgPath);
}
if (!ShellJS.test("-d", this._prjPath)) {
throw new InvalidPathException("Failed to load, invalid path: " + this._prjPath);
throw new InvalidPathException("Failed to load, invalid path: " + this._prjPath);
}

@@ -99,15 +97,22 @@

this._output = new OutputTee(this._logfileOutput, TerminalOutput.getInstance());
this._manifest = new Manifest(this._output, Path.join(this._appPath, "manifest.json"));
}
function initMembers(basePath) {
function initMembers(rootPath) {
this._rootPath = basePath + Path.sep + this._packageId;
this._rootPath = rootPath;
ShellJS.mkdir(this._rootPath);
this._appPath = this._rootPath + Path.sep + "app";
ShellJS.mkdir(this._appPath);
this._logPath = this._rootPath + Path.sep + "log";
this._logPath = Path.join(OS.tmpdir(), "crosswalk-app-tools-" + this._packageId);
ShellJS.mkdir(this._logPath);
this._pkgPath = this._rootPath + Path.sep + "pkg";
// Packages end up in working dir
this._pkgPath = process.cwd();
this._prjPath = this._rootPath + Path.sep + "prj";
ShellJS.mkdir(this._prjPath);
}

@@ -188,2 +193,18 @@

/**
* Read-only {@link Manifest} object.
* @member {Manifest} manifest
* @throws {IllegalAccessException} If writing this property is attempted.
* @instance
* @memberOf Application
*/
Object.defineProperty(Application.prototype, "manifest", {
get: function() {
return this._manifest;
},
set: function(unused) {
throw new IllegalAccessException("Attempting to write read-only property Application.manifest");
}
});
/**
* Read-only {@link Config} object.

@@ -218,3 +239,3 @@ * @member {Config} config

set: function(platformLogfileOutput) {
if (platformLogfileOutput instanceof LogfileOutput) {

@@ -225,11 +246,11 @@

this.output.logfileOutput = platformLogfileOutput;
} else if (platformLogfileOutput === null) {
// Reset output to common logfile.
this._platformLogfileOutput = null;
this.output.logfileOutput = this._logfileOutput;
} else {
throw new IllegalAccessException("Attempting invalid write to property Application.platformLogfileOutput");

@@ -236,0 +257,0 @@ }

@@ -5,2 +5,4 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var Path = require("path");
var Minimist = require("minimist");

@@ -24,3 +26,2 @@

this._argv = argv;
this._createOptions = null;
}

@@ -35,16 +36,20 @@

return "" +
"\n" +
"Crosswalk Application Project and Packaging Tool\n" +
"\n" +
" crosswalk-app create <package-id>\t\tCreate project <package-id>\n" +
"\n" +
" crosswalk-app build [release|debug]\t\tBuild project to create packages\n" +
" \t\tDefaults to debug when not given\n" +
"\n" +
" crosswalk-app update <channel>|<version> Update Crosswalk to latest in named\n" +
" channel, or specific version\n" +
"\n" +
" crosswalk-app help\t\t\t\tDisplay usage information\n" +
"\n" +
" crosswalk-app version\t\t\tDisplay version information\n";
"\n" +
"Crosswalk Project Application Packaging Tool\n" +
"\n" +
" crosswalk-app create <package-id> Create project <package-id>\n" +
" --platforms=<target> Optional, e.g. \"windows\"\n" +
"\n" +
" crosswalk-app build [release|debug] [<dir>] Build project to create packages\n" +
" Defaults to \"debug\" when not given\n" +
" Tries to build in current dir by default\n" +
"\n" +
" crosswalk-app update <channel>|<version> Update Crosswalk to latest in named\n" +
" channel, or specific version\n" +
"\n" +
" crosswalk-app platforms List available target platforms\n" +
"\n" +
" crosswalk-app help Display usage information\n" +
"\n" +
" crosswalk-app version Display version information\n";
};

@@ -75,2 +80,3 @@

return type !== null ? cmd : null;
case "platforms":
case "help":

@@ -107,3 +113,3 @@ case "version":

if (["create", "update", "refresh", "build"].indexOf(command) > -1) {
if (["create", "update", "refresh", "build", "platforms"].indexOf(command) > -1) {
return command;

@@ -129,7 +135,2 @@ }

if (this._argv.length > 4) {
var options = this._argv.slice(4);
this._createOptions = Minimist(options);
}
return packageId;

@@ -194,2 +195,4 @@ };

return type;
} else {
return "debug";
}

@@ -201,2 +204,29 @@

/**
* Get project directory to build
* @returns {String} Absolute path to project directory
*/
CommandParser.prototype.buildGetDir =
function() {
// Default to current dir when no type given.
if (this._argv.length < 4) {
return Path.resolve(".");
}
if (this._argv.length === 4) {
if (["debug", "release"].indexOf(this._argv[3]) > -1) {
return Path.resolve(".");
} else {
return Path.resolve(this._argv[3]);
}
}
if (this._argv.length > 4) {
return Path.resolve(this._argv[4]);
}
return null;
};
/**
* Check whether packageId conforms to the naming scheme.

@@ -203,0 +233,0 @@ * @param {String} packageId Package ID to check

@@ -59,14 +59,21 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

* @returns {PlatformBase} Platform implementation instance or null on error.
* @private
* @static
*/
Main.prototype.instantiateProject =
Main.prototype.instantiatePlatform =
function() {
var output = this.output;
var errorDetail = null;
var mgr = new PlatformsManager(output);
var platformInfo = mgr.loadDefault();
var platformInfo = mgr.load(this.manifest.targetPlatforms,
function(errormsg) {
errorDetail = errormsg;
});
if (platformInfo) {
output.info("Loading '" + platformInfo.platformId + "' platform backend");
} else {
if (errorDetail)
output.error(errorDetail);
output.error("Failed to load '" + platformInfo.platformId + "' platform backend");

@@ -76,17 +83,4 @@ return null;

// See type PlatformData
var platformData = {
application: this,
platformId: platformInfo.platformId,
argSpec: platformInfo.argSpec
};
var platform = null;
var platform = platformInfo.create(this);
try {
platform = new platformInfo.Ctor(PlatformBase, platformData);
} catch (e) {
output.error("Failed to load '" + platformInfo.platformId + "' platform backend");
return null;
}
return platform;

@@ -129,2 +123,15 @@ };

// Handle "platform" arg to set default platform
// for new project.
var platform = extraArgs.platforms;
if (platform) {
try {
this.manifest.targetPlatforms = platform;
} catch (e) {
output.error("Invalid target platform '" + platform + "'");
callback(MAIN_EXIT_CODE_ERROR);
return;
}
}
// Copy sample web app content

@@ -140,3 +147,3 @@ var templatePath = Path.normalize(Path.join(__dirname, "..", "app-template"));

var project = this.instantiateProject();
var project = this.instantiatePlatform();
if (!project) {

@@ -158,2 +165,3 @@ callback(MAIN_EXIT_CODE_ERROR);

output.error(errormsg);
output.info("Logfiles at " + this.logPath);
callback(MAIN_EXIT_CODE_ERROR);

@@ -165,3 +173,3 @@ return;

}
});
}.bind(this));
};

@@ -181,3 +189,3 @@

var project = this.instantiateProject();
var project = this.instantiatePlatform();
if (!project) {

@@ -199,2 +207,3 @@ callback(MAIN_EXIT_CODE_ERROR);

output.error(errormsg);
output.info("Logfiles at " + this.logPath);
callback(MAIN_EXIT_CODE_ERROR);

@@ -206,3 +215,3 @@ return;

}
});
}.bind(this));
};

@@ -231,3 +240,3 @@

var project = this.instantiateProject(null);
var project = this.instantiatePlatform();
if (!project) {

@@ -250,2 +259,3 @@ callback(MAIN_EXIT_CODE_ERROR);

output.error(errormsg);
output.info("Logfiles at " + this.logPath);
callback(MAIN_EXIT_CODE_ERROR);

@@ -257,15 +267,30 @@ return;

}
});
}.bind(this));
};
/**
* Display available backends.
* @param {OutputIface} output Output to write to
* @static
*/
Main.prototype.listPlatforms =
function(output) {
var mgr = new PlatformsManager(output);
var backends = mgr.loadAll();
for (var i = 0; i < backends.length; i++) {
output.write(" * " + backends[i].platformId + "\n");
}
};
/**
* Display usage information.
* @param {CommandParser} parser Parser instance
* @param {OutputIface} output Output to write to
* @static
*/
Main.prototype.printHelp =
function(parser) {
function(parser, output) {
var output = TerminalOutput.getInstance();
// Builtin args

@@ -277,22 +302,29 @@ var buf = parser.help();

var mgr = new PlatformsManager(output);
var platformInfo = mgr.loadDefault();
if (!platformInfo) {
output.error("Failed to load platform backend");
return;
}
var infos = mgr.loadAll();
for (var i = 0; i < infos.length; i++) {
if (platformInfo.argSpec) {
output.write("Options for platform '" + platformInfo.platformId + "'\n");
for (var cmd in platformInfo.argSpec) {
output.write("\n For command '" + cmd + "'\n");
var cmdArgs = platformInfo.argSpec[cmd];
for (var arg in cmdArgs) {
output.write(" " + arg + " " + cmdArgs[arg] + "\n");
var platformInfo = infos[i];
// Print args
if (Object.keys(platformInfo.argSpec).length > 0) {
output.write("Options for platform '" + platformInfo.platformId + "'\n");
for (var cmd in platformInfo.argSpec) {
output.write("\n For command '" + cmd + "'\n");
var cmdArgs = platformInfo.argSpec[cmd];
for (var arg in cmdArgs) {
output.write(" " + arg + " " + cmdArgs[arg] + "\n");
}
}
}
// Print environment variables
if (Object.keys(platformInfo.envSpec).length > 0) {
output.write("Environment variables for platform '" + platformInfo.platformId + "'\n\n");
for (var env in platformInfo.envSpec) {
output.write(" " + env + " " + platformInfo.envSpec[env] + "\n");
}
}
output.write("\n");
}
output.write("Environment Variables\n\n");
output.write(" CROSSWALK_APP_TOOLS_CACHE_DIR\t\tKeep downloaded files in this dir\n");
output.write("\n");
};

@@ -302,11 +334,11 @@

* Display version information.
* @param {OutputIface} output Output to write to
* @static
*/
Main.prototype.printVersion =
function() {
function(output) {
var Package = require("../package.json");
// Do not use output infrastructure because this is
// a static method, so the parent is not initialised.
console.log(Package.version + "\n");
output.write(Package.version + "\n");
};

@@ -325,6 +357,7 @@

var parser = new CommandParser(output, process.argv);
var app = new Main();
if (process.argv.length < 3) {
// No command given, print help and exit without error code.
this.printHelp(parser);
app.printHelp(parser, output);
callback(MAIN_EXIT_CODE_OK);

@@ -347,6 +380,11 @@ return;

// Chain up the constructor.
Application.call(this, process.cwd(), packageId);
this.create(packageId, extraArgs, callback);
try {
// Chain up the constructor.
Application.call(app, process.cwd(), packageId);
app.create(packageId, extraArgs, callback);
} catch (e) {
output.error("Failed to initialize");
output.error("Ensure directory '" + packageId + "' does not already exist");
callback(MAIN_EXIT_CODE_ERROR);
}
break;

@@ -357,6 +395,11 @@

// Chain up the constructor.
Application.call(this, process.cwd(), null);
this.update(version, extraArgs, callback);
try {
// Chain up the constructor.
Application.call(app, process.cwd(), null);
app.update(version, extraArgs, callback);
} catch (e) {
output.error("Failed to initialize");
output.error("Ensure to invoke 'crosswalk-app-tools' from a toplevel project directory");
callback(MAIN_EXIT_CODE_ERROR);
}
break;

@@ -366,15 +409,25 @@

var type = parser.buildGetType();
var rootDir = parser.buildGetDir();
// Chain up the constructor.
Application.call(this, process.cwd(), null);
try {
// Chain up the constructor.
Application.call(app, rootDir, null);
app.build(type, extraArgs, callback);
} catch (e) {
output.error("Failed to initialize");
output.error("Ensure to invoke 'crosswalk-app-tools' from a toplevel project directory");
callback(MAIN_EXIT_CODE_ERROR);
}
break;
this.build(type, extraArgs, callback);
case "platforms":
app.listPlatforms(output);
break;
case "help":
this.printHelp(parser);
app.printHelp(parser, output);
break;
case "version":
this.printVersion();
app.printVersion(output);
break;

@@ -386,6 +439,4 @@

}
callback(MAIN_EXIT_CODE_OK);
};
module.exports = new Main();

@@ -5,2 +5,4 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var PlatformInfo = require("./PlatformInfo");
/**

@@ -10,3 +12,2 @@ * Class that manages platform backends.

* @param {OutputIface} Output instance
* @private
*/

@@ -18,10 +19,10 @@ function PlatformsManager(output) {

/**
* @typedef PlatformInfo
* @type {Object}
* @property {Function} Ctor Constructor for the associated {@link PlatformBase} subclass
* @property {String} platformId Name for backend (android, ios, ...)
* @property {Object} argSpec Platform-specific command-line argument definitions
* @memberOf PlatformsManager
*/
PlatformsManager._implementations = {
"ios": "crosswalk-app-tools-backend-ios",
"deb": "crosswalk-app-tools-backend-deb",
"demo": "crosswalk-app-tools-backend-demo",
"test": "crosswalk-app-tools-backend-test",
"android": "../android/index.js",
"windows": "../windows/index.js"
};

@@ -37,39 +38,13 @@ /**

var implementations = [
"crosswalk-app-tools-backend-ios",
"crosswalk-app-tools-backend-deb",
"crosswalk-app-tools-backend-demo",
"crosswalk-app-tools-backend-test",
"../android/index.js"
];
var platformInfo = null;
var warnings = [];
for (var i = 0; i < implementations.length; i++) {
for (var platformId in PlatformsManager._implementations) {
try {
var Ctor = require(implementations[i]);
var prefix = "crosswalk-app-tools-backend-";
var platformId = null;
if (implementations[i].substring(0, prefix.length) == prefix) {
// Extract last part after common prefix.
platformId = implementations[i].substring(prefix.length);
} else if (implementations[i] == "../android/index.js") {
// Special case built-in android backend, so we get a conforming name.
platformId = "android";
} else {
throw new Error("Unhandled platform name " + implementations[i]);
}
platformInfo = this.buildInfo(Ctor, platformId);
// If we get here there backend has been instantiated successfully.
platformInfo = this.load(platformId);
if (platformInfo) {
break;
} catch (e) {
} else {
// Accumulate warnings, only emit them if no backend was found.
warnings.push("Loading backend " + implementations[i] + " failed (" + e + ")");
warnings.push("Loading platform '" + platformId + "' failed");
}

@@ -88,33 +63,48 @@ }

/**
* Load platform by constructor.
* @param {Function} PlatformImplCtor Constructor for a {@link PlatformBase} subclass
* @param {String} platformId Identifier for platform (android, ios, ...)
* @returns {PlatformInfo}
* @protected
* Load default backend.
* @returns {PlatformInfo} Metadata object for loaded platform.
*/
PlatformsManager.prototype.buildInfo =
function(PlatformImplCtor, platformId) {
PlatformsManager.prototype.loadAll =
function() {
var platformInfo = null;
var output = this._output;
// Prefix all platform-specific args with the platform name
var platformArgSpec = {};
if (PlatformImplCtor.getArgs) {
var argSpec = PlatformImplCtor.getArgs();
for (var cmd in argSpec) {
var cmdArgSpec = argSpec[cmd];
var platformCmdArgSpec = {};
for (var key in cmdArgSpec) {
platformCmdArgSpec["--" + platformId + "-" + key] = cmdArgSpec[key];
}
platformArgSpec[cmd] = platformCmdArgSpec;
var backends = [];
for (var platformId in PlatformsManager._implementations) {
platformInfo = this.load(platformId);
if (platformInfo) {
backends.push(platformInfo);
}
}
platformInfo = {
Ctor: PlatformImplCtor,
platformId: platformId,
argSpec: platformArgSpec
};
return backends;
};
/**
* Load backend by name.
* @param {String} platformId Unique platform name
* @param {Function} callback Callback carrying error message on failure
* @returns {PlatformInfo} Metadata object or null if platform could not be loaded.
*/
PlatformsManager.prototype.load =
function(platformId, callback) {
if (!callback)
callback = function(errormsg) {};
var platformInfo = null;
try {
var moduleName = PlatformsManager._implementations[platformId];
var Ctor = require(moduleName);
platformInfo = new PlatformInfo(Ctor, platformId);
} catch (e) {
callback(e.message);
}
return platformInfo;

@@ -121,0 +111,0 @@ };

@@ -162,6 +162,10 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

this._stream.on("finish", function() {
// All data flushed.
callback(null);
});
this._stream.end();
this._stream = null;
this._url = null;
callback(null);

@@ -168,0 +172,0 @@ }.bind(this));

@@ -52,2 +52,8 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

TestPlatformScope.getEnv = function() {
return {
CROSSWALK_APP_TOOL_TEST_FOO: "Another create option added by the platform"
};
};
module.exports = TestPlatformScope;

@@ -14,2 +14,3 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var LogfileOutput = require("../src/LogfileOutput");
var Manifest = require("../src/Manifest");
var OutputTee = require("../src/OutputTee");

@@ -61,2 +62,49 @@ var Util = require("../test-util/Util.js");

renameDir: function(test) {
test.expect(1);
var application = Util.createTmpApplication("com.example.foo");
var path = application.rootPath;
var path2 = Path.join(Path.dirname(path), "foo");
ShellJS.mv(path, path2);
try {
application = new Application(path2, null);
test.equal(application.packageId, "com.example.foo");
} catch (error) {
// Just catch error, missing test assertion makes test case fail.
}
// Clean up manually, so it also works in case of error.
// Util.createTmpApplication() always works inside a random named dir
// so go one level up and remove.
ShellJS.rm("-rf", Path.dirname(path2));
test.done();
},
getManifest: function(test) {
test.expect(2);
var application = Util.createTmpApplication("com.example.foo");
var manifest = application.manifest;
test.equal(manifest instanceof Manifest, true);
test.equal(manifest.appVersion, "1");
Util.deleteTmpApplication(application);
test.done();
},
setManifest: function(test) {
test.expect(1);
var application = Util.createTmpApplication("com.example.foo");
try {
application.manifest = null;
} catch (e) {
test.equal(e instanceof IllegalAccessException, true);
}
Util.deleteTmpApplication(application);
test.done();
},
getConfig: function(test) {

@@ -63,0 +111,0 @@

@@ -5,2 +5,4 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var Path = require("path");
// Run tests silently to avoid spew from tests failing on purpose.

@@ -198,13 +200,44 @@ require("../src/Config").getInstance().setSilentConsole(true);

// Bad test, unknown type
// Test dir
var argv4 = ["node", "foo", "build", "foo"];
var cp4 = new CommandParser(_output, argv4);
test.equal(cp4.getCommand(), null);
test.equal(cp4.getCommand(), "build");
var type4 = cp4.buildGetType();
test.equal(type4, null);
test.equal(type4, "debug");
test.done();
},
buildGetDir: function(test) {
test.expect(6);
// Test default "debug"
var argv = ["node", "foo", "build", "foo"];
var cp = new CommandParser(_output, argv);
test.equal(cp.getCommand(), "build");
var type = cp.buildGetType();
test.equal(type, "debug");
var dir = cp.buildGetDir();
test.equal(Path.basename(dir), "foo");
// Test "release"
var argv1 = ["node", "foo", "build", "release", "foo"];
var cp1 = new CommandParser(_output, argv1);
test.equal(cp1.getCommand(), "build");
var type1 = cp1.buildGetType();
test.equal(type1, "release");
var dir1 = cp1.buildGetDir();
test.equal(Path.basename(dir1), "foo");
test.done();
}
};

@@ -10,2 +10,3 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var CommandParser = require("../src/CommandParser");
var TerminalOutput = require("../src/TerminalOutput");
var Util = require("../test-util/Util.js");

@@ -44,3 +45,3 @@

Application.call(app, tmpdir, _packageId);
app.create(_packageId, null, function(errno) {
app.create(_packageId, {}, function(errno) {

@@ -66,3 +67,3 @@ test.equal(errno, 0);

Application.call(app, tmpdir, _packageId);
app.create(_packageId, null, function(errno) {
app.create(_packageId, {}, function(errno) {

@@ -99,3 +100,3 @@ if (!errno) {

// Create
app.create(_packageId, null, function(errno) {
app.create(_packageId, {}, function(errno) {

@@ -133,2 +134,13 @@ if (!errno) {

listPlatforms: function(test) {
// Prints to stdout, so just run the code to see if it breaks.
test.expect(0);
var app = require("../src/Main");
app.listPlatforms(TerminalOutput.getInstance());
test.done();
},
printHelp: function(test) {

@@ -140,4 +152,4 @@

var app = require("../src/Main");
var parser = new CommandParser(app.output, process.argv);
app.printHelp(parser);
var parser = new CommandParser(TerminalOutput.getInstance(), process.argv);
app.printHelp(parser, TerminalOutput.getInstance());

@@ -153,3 +165,3 @@ test.done();

var app = require("../src/Main");
app.printVersion();
app.printVersion(TerminalOutput.getInstance());

@@ -156,0 +168,0 @@ test.done();

@@ -12,2 +12,3 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var PlatformBase = require("../src/PlatformBase");
var PlatformInfo = require("../src/PlatformInfo");
var PlatformsManager = require("../src/PlatformsManager");

@@ -31,3 +32,3 @@

var platformInfo = mgr.buildInfo(TestPlatform, _platformId);
var platformInfo = new PlatformInfo(TestPlatform, _platformId);

@@ -49,3 +50,3 @@ var platformData = {

test.equal(platform.packageId, _packageId);
test.equal(platform.pkgPath, Path.join(basePath, _packageId, "pkg"));
test.equal(platform.pkgPath, process.cwd());
test.equal(platform.platformId, _platformId);

@@ -52,0 +53,0 @@ test.equal(platform.platformPath, Path.join(basePath, _packageId, "prj", _platformId));

@@ -6,4 +6,4 @@ // Copyright © 2014 Intel Corporation. All rights reserved.

var PlatformBase = require("../src/PlatformBase");
var PlatformInfo = require("../src/PlatformInfo");
var PlatformsManager = require("../src/PlatformsManager");
var TestPlatform = require("../test-util/TestPlatform");

@@ -16,16 +16,21 @@ var _output = require("../src/TerminalOutput").getInstance();

test.expect(3);
test.expect(1);
var mgr = new PlatformsManager(_output);
var platformInfo = mgr.buildInfo(TestPlatform, "test");
var platformInfo = mgr.loadDefault();
test.equal(platformInfo instanceof PlatformInfo, true);
var createArgs = platformInfo.argSpec.create;
test.equal(typeof createArgs["--test-foo"], "string");
test.equal(typeof createArgs["--test-bar"], "string");
test.done();
},
var updateArgs = platformInfo.argSpec.update;
test.equal(typeof updateArgs["--test-baz"], "string");
loadAll: function(test) {
test.expect(1);
var mgr = new PlatformsManager(_output);
var backends = mgr.loadAll();
test.equal(backends.length > 0, true);
test.done();
}
};

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

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