Socket
Socket
Sign inDemoInstall

crex

Package Overview
Dependencies
95
Maintainers
3
Versions
60
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.8.0 to 2.0.0

bin/ce-create.js

12

bin/ce.js
#!/usr/bin/env node
var program = require('commander');
var program = require("commander");
program
.version(require('../package').version)
.usage('<command> [options]')
.command('import', 'import Creative Exchange package')
.command('export', 'export Creative Exchange package')
.parse(process.argv);
.version(require("../package").version)
.command("upload [options] <file>", "Upload Creative Exchange package")
.command("create [options]", "Create Creative Exchange package")
.command("download [options]", "Download Creative Exchange package")
.parse(process.argv);

@@ -1,131 +0,63 @@

var request = require('./request');
var api = {};
/**
* Get list of all Creative Exchange export packages. These packages contains package id
* which can later be used for accessing package status or downloading it
* @function CrEx#exportGetAllPackages
* @arg {Object} args
* @arg {number} [args.page] - Number of page containing 20 items
* @returns {Promise.<ExportGetPackageResults, Error.<RequestError>>}
*/
api.exportGetAllPackages = function (args) {
return this.request('GET', '/etc/creativeExchange/export/api.packages.json', args);
};
/**
* Get status of the package. During exporting package can have status IN_PROGRESS or DONE
* indicating if package is still exporting or if can be downloaded
* @function CrEx#exportGetPackageStatus
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.exportGetPackageStatus = function (args) {
return this.request('GET', '/etc/creativeExchange/export/api.status.json', args);
};
/**
* Download export package as .zip file.
* @function CrEx#exportDownloadPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.exportDownloadPackage = function (args) {
return this.request('DOWNLOAD', '/etc/creativeExchange/export/api.package.zip', args);
};
/**
* Creates Creative Exchange export package containing site content and referenced theme
* @function CrEx#exportCreatePackage
* @arg {Object} args
* @arg {Array.<string>} args.roots - Content roots
* @arg {boolean} args.force - Force
* @arg {string} args.engine - Engine
* @arg {boolean} [args.synchronous] -
* @returns {Promise}
*/
api.exportCreatePackage = function (args) {
return this.request('POST', '/etc/creativeExchange/export/api.create.json', args);
};
/**
* Removes package from instance
* @function CrEx#exportRemovePackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.exportRemovePackage = function (args) {
return this.request('DELETE', '/etc/creativeExchange/export/api.packages.json', args);
};
/**
* Get list of all import packages. These packages contains package id
* which can later be used for accessing package status, downloading it or installing
* @function CrEx#importGetAllPackages
* @arg {Object} args
* @arg {number} [args.page] - Number of page containing 20 items
* @returns {Promise.<ExportGetPackageResults, Error.<RequestError>>}
*/
api.importGetAllPackages = function (args) {
return this.request('GET', '/etc/creativeExchange/import/api.packages.json', args);
};
/**
* Get status of the package. During importing package can have status IN_PROGRESS or DONE
* indicating if package is still importing or if can be downloaded
* @function CrEx#importGetPackageStatus
* @function CrEx#getPackageStatus
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
* @arg {string} [args.packageId] - ID of the package. Must be a valid UUID string
* @returns {Promise, Error.<RequestError>>}
*/
api.importGetPackageStatus = function (args) {
return this.request('GET', '/etc/creativeExchange/import/api.status.json', args);
api.getPackageStatus = function (args) {
return this.request('GET', '/apps/creative-exchange/api/status.json', args);
};
/**
* Upload package to an instance
* @function CrEx#importUploadPackage
* Get list of all Creative Exchange packages. These packages contains package id
* which can later be used for accessing package status or downloading it
* @function CrEx#getAllPackages
* @arg {Object} args
* @arg {String} args.file - Binary representation of .zip package
* @returns {Promise}
* @arg {number} [args.page=1] - Desired page number
* @arg {number} [args.perPage=10] - Number of result per page
* @returns {Promise, Error.<RequestError>>}
*/
api.importUploadPackage = function (args) {
return this.request('UPLOAD', '/etc/creativeExchange/import/api.upload.json', args);
api.getPackageList = function (args) {
return this.request('GET', '/apps/creative-exchange/api/packages.json', args);
};
/**
* Download the import package as .zip file.
* @function CrEx#importDownloadPackage
* Create Creative Exchange packages.
* @function CrEx#createPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
* @arg {string} [args.rootPath] - Unique root path of the package
* @arg {string} [args.name=] - Custom name of the package
* @returns {Promise, Error.<RequestError>>}
*/
api.importDownloadPackage = function (args) {
return this.request('DOWNLOAD', '/etc/creativeExchange/import/api.package.zip', args);
api.createPackage = function (args) {
return this.request('POST', '/apps/creative-exchange/api/create.json', args);
};
/**
* Inspect package. Inspect allows for checking what changes will install make without actual
* change of theme or content or instance
* @function CrEx#importInspectPackage
* Trigger the package build process. Overwrites previously generated ZIP file for a package.
* Progress of the package build process should be checked using the CrEx#GetPackageStatus.
* @function CrEx#buildPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
* @arg {string} [args.packageId] - ID of the package. Must be a valid UUID string
* @arg {boolean} [args.synchronous=false] - Decides if the request should wait for the package build process to complete
* @returns {Promise, Error.<RequestError>>}
*/
api.importInspectPackage = function (args) {
return this.request('POST', '/etc/creativeExchange/import/api.inspect.json', args);
api.buildPackage = function (args) {
return this.request('POST', '/apps/creative-exchange/api/build.json', args);
};
/**
* Install package. Modifies theme and adds new variants.
* @function CrEx#importInstallPackage
* Download export package as .zip file.
* @function CrEx#downloadPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
* @arg {string} [args.packageId] - ID of the package. Must be a valid UUID string
* @returns {Promise, Error.<RequestError>>}
*/
api.importInstallPackage = function (args) {
return this.request('POST', '/etc/creativeExchange/import/api.install.json', args);
api.downloadPackage = function (args) {
return this.request('DOWNLOAD', '/apps/creative-exchange/api/download', args);
};

@@ -135,91 +67,33 @@

* Removes package from instance
* @function CrEx#importRemovePackage
* @function CrEx#deletePackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
* @arg {string} [args.packageId] - ID of the package. Must be a valid UUID string
* @returns {Promise, Error.<RequestError>>}
*/
api.importRemovePackage = function (args) {
return this.request('DELETE', '/etc/creativeExchange/import/api.packages.json', args);
api.deletePackage = function (args) {
return this.request('DELETE', '/apps/creative-exchange/api/package.json', args);
};
/**
* Get list of all themes.
* @function CrEx#themesGetAllThemes
* Upload package from instance
* @function CrEx#uploadPackage
* @arg {Object} args
* @arg {number} [args.page] - Number of page containing 20 items
* @returns {Promise}
* @arg {string} [args.file] - Package file as a ZIP. Must be a valid ZIP file.
* @returns {Promise, Error.<RequestError>>}
*/
api.themesGetAllThemes = function (args) {
return this.request('GET', '/etc/creativeExchange/themes/api.json', args);
api.uploadPackage = function (args) {
return this.request('UPLOAD', '/apps/creative-exchange/api/upload.json', args);
};
/**
* Returns progress of theme activation
* @function CrEx#themesCheckActivateProgress
* Install package. Modifies theme and adds new variants.
* @function CrEx#installPackage
* @arg {Object} args
* @arg {string} args.id - Theme id
* @returns {Promise}
* @arg {string} [args.packageId] - ID of the package. Must be a valid UUID string
* @returns {Promise, Error.<RequestError>>}
*/
api.themesCheckActivateProgress = function (args) {
return this.request('GET', '/etc/creativeExchange/themes/api.activate.json', args);
api.installPackage = function (args) {
return this.request('POST', '/apps/creative-exchange/api/install.json', args);
};
/**
* Activate selected themes to publish instance
* @function CrEx#themesActivateThemes
* @arg {Object} args
* @arg {Array.<string>} args.themes - Stringified list of theme paths
* @returns {Promise}
*/
api.themesActivateThemes = function (args) {
return this.request('POST', '/etc/creativeExchange/themes/api.activate.json', args);
};
/**
* Create new theme
* @function CrEx#themesCreateTheme
* @arg {Object} args
* @arg {string} args.themeName - Name of new theme
* @arg {string} [args.parentThemePath] - Parent theme
* @arg {boolean} [args.protectedTheme] - Protected theme
* @arg {boolean} [args.finalTheme] - Final theme
* @returns {Promise}
*/
api.themesCreateTheme = function (args) {
return this.request('POST', '/etc/creativeExchange/themes/api.create.json', args);
};
/**
* Removes themes from instance
* @function CrEx#themesDeleteTheme
* @arg {Object} args
* @arg {Array.<string>} args.themes - Theme paths
* @returns {Promise}
*/
api.themesDeleteThemes = function (args) {
return this.request('POST', '/etc/creativeExchange/themes/api.delete.json', args);
};
/**
* Downloads theme in CRX package format
* @function CrEx#themesExportThemes
* @arg {Object} args
* @arg {Array.<string>} args.themes - Theme paths
* @returns {Promise}
*/
api.themesExportThemes = function (args) {
return this.request('DOWNLOAD', '/etc/creativeExchange/themes/api.export.zip', args);
};
/**
* Get details about theme
* @function CrEx#themesGetDetails
* @arg {Object} args
* @arg {Array.<string>} args.name - Theme name
* @returns {Promise}
*/
api.themesGetDetails = function(args) {
return this.request('GET', '/etc/creativeExchange/themes/api.view.json', args);
};
module.exports = api;

@@ -1,6 +0,5 @@

var api = require('./api');
var request = require('./request');
var assign = require('object-assign');
const api = require('./api');
const request = require('./request');
var DEFAULTS = {
const DEFAULTS = {
user: 'admin',

@@ -23,53 +22,55 @@ password: 'admin',

*/
var CrEx = function (options) {
options = assign({}, DEFAULTS, options) || {};
this.user = options.user;
this.password = options.password;
this.url = options.url;
this.port = options.port;
this.proxy = options.proxy;
};
CrEx.prototype.getAddress = function () {
var url = this.url;
return (this.port !== '' ? url + ':' + this.port : url) + (this.proxy ? ' (proxy: ' + this.proxy + ')' : '');
};
class CrEx {
constructor(options) {
options = Object.assign({}, DEFAULTS, options) || {};
this.user = options.user;
this.password = options.password;
this.url = options.url;
this.port = options.port;
this.proxy = options.proxy;
CrEx.prototype.setTarget = function (target) {
var credentials = target.substr(0, target.lastIndexOf('@')).split(':');
var address = target.substr(target.lastIndexOf('@') + 1).split(':');
this.user = credentials[0];
this.password = credentials[1];
this.url = address[0];
this.port = address.length > 1 ? address[1] : '';
};
Object.assign(this, api);
}
CrEx.prototype.request = function(method, url, args) {
var req = null;
url = this.getAddress() + url;
request(method, url, args) {
let req = null;
url = this.getAddress() + url;
switch (method) {
case 'GET':
req = request.doGet;
break;
case 'POST':
req = request.doPost;
break;
case 'DELETE':
req = request.doDelete;
break;
case 'UPLOAD':
req = request.doUpload;
break;
case 'DOWNLOAD':
req = request.doDownload;
break;
}
switch (method) {
case 'GET':
req = request.doGet;
break;
case 'POST':
req = request.doPost;
break;
case 'DELETE':
req = request.doDelete;
break;
case 'UPLOAD':
req = request.doUpload;
break;
case 'DOWNLOAD':
req = request.doDownload;
break;
}
return req(url, args, this);
};
return req(url, args, this);
};
setTarget(target) {
var credentials = target.substr(0, target.lastIndexOf('@')).split(':');
var address = target.substr(target.lastIndexOf('@') + 1).split(':');
this.user = credentials[0];
this.password = credentials[1];
this.url = address[0];
this.port = address.length > 1 ? address[1] : '';
};
CrEx.prototype = assign(CrEx.prototype, api);
getAddress() {
return (this.port !== '' ? `${this.url}:${this.port}` : this.url) || '';
};
}
module.exports = CrEx;

@@ -1,3 +0,3 @@

var CrEx = require('./crex');
const CrEx = require('./crex');
module.exports = CrEx;

@@ -1,26 +0,22 @@

var request = require('superagent');
require('superagent-proxy')(request);
const request = require('superagent');
var checkProxy = function(req, proxy) {
return proxy ? req.proxy(proxy) : req;
};
var nodeBinaryParser = function (res, done) {
const nodeBinaryParser = (res, done) => {
res.setEncoding('binary');
res.text = '';
res.on('data', function (chunk) {
res.on('data', (chunk) => {
res.text += chunk;
});
res.on('end', function () {
done(null, Buffer.from(res.text, 'binary'));
res.on('end', () => {
done(null, new Buffer(res.text, 'binary'));
});
};
var doGet = function (url, args, config) {
return new Promise(function (resolve, reject) {
checkProxy(request.get(url), config.proxy)
const doGet = (url, args, config) => {
return new Promise((resolve, reject) => {
request.get(url)
.connect(config.proxy)
.auth(config.user, config.password)
.query(args)
.buffer(true)
.end(function (err, res) {
.end((err, res) => {
if (err || !res || !Object.keys(res.body).length) {

@@ -34,13 +30,14 @@ reject(err);

}
});
})
});
};
var doPost = function(url, args, config) {
return new Promise(function (resolve, reject) {
checkProxy(request.post(url), config.proxy)
const doPost = (url, args, config) => {
return new Promise((resolve, reject) => {
request.post(url)
.connect(config.proxy)
.auth(config.user, config.password)
.type('form')
.query(args)
.end(function (err, res) {
.end((err, res) => {
if (err || !res) {

@@ -58,8 +55,9 @@ reject(err);

var doDelete = function(url, args, config) {
return new Promise(function (resolve, reject) {
checkProxy(request.delete(url), config.proxy)
const doDelete = (url, args, config) => {
return new Promise((resolve, reject) => {
request.delete(url)
.connect(config.proxy)
.auth(config.user, config.password)
.query(args)
.end(function (err, res) {
.end((err, res) => {
if (err || !res) {

@@ -77,8 +75,9 @@ reject(err);

var doUpload = function(url, args, config) {
return new Promise(function (resolve, reject) {
checkProxy(request.post(url), config.proxy)
const doUpload = (url, args, config) => {
return new Promise((resolve, reject) => {
request.post(url)
.connect(config.proxy)
.auth(config.user, config.password)
.attach('file', args['file'])
.end(function (err, res) {
.end((err, res) => {
if (err || !res) {

@@ -96,5 +95,6 @@ reject(err);

var doDownload = function(url, args, config) {
return new Promise(function (resolve, reject) {
checkProxy(request.get(url), config.proxy)
const doDownload = (url, args, config) => {
return new Promise((resolve, reject) => {
request.get(url)
.connect(config.proxy)
.auth(config.user, config.password)

@@ -104,3 +104,3 @@ .query(args)

.parse(nodeBinaryParser)
.end(function (err, res) {
.end((err, res) => {
if (err || !res) {

@@ -107,0 +107,0 @@ reject(err);

/**
* @typedef {string} PackageStatus - Export or import status. Has value of "IN_PROGRESS", "ABORTED" or "DONE"
*/
/**
* @typedef {string} RootPagePath - Path to exported package content. Must be at least on language level.

@@ -11,29 +7,2 @@ */

* @typedef {Object} RequestError - Superagent request error
*/
/**
* @typedef {Object} ExportGetPackageResults
* @property {Array.<ExportGetPackageResult>} packages
*/
/**
* @typedef {Object} ExportGetPackageResult
* @property {string} id - Package id
* @property {Array.<RootPagePath>} rootPagePaths - Content source of the package
* @property {string} engineName - Export engine. Zen Garden provides "Simple" other can be created as extensions
* @property {string} siteGroup - Selected Site Group
* @property {string} lastModified - Last modified date
* @proprety {string} lastModifiedBy - Username who last modified
* @property {PackageStatus} status - Package status
* @property {string} packagePath - Absolute path to package in CRX repository
*/
/**
* @typedef {Object} ThemeDetails
* @property {Array.<string>} hierarchy
* @property {Object} mainTheme
* @property {string} mainTheme.path
* @property {string} mainTheme.name
* @property {string} mainTheme.title
* @property {boolean} mainTheme.protectedTheme
*/
{
"name": "crex",
"version": "1.8.0",
"version": "2.0.0",
"description": "Creative Exchange SDK for Javascript",

@@ -13,3 +13,3 @@ "author": "Mateusz Luczak <mateusz.luczak@outlook.com>",

"engines": {
"node": ">=6.10.0"
"node": ">=8.11.1"
},

@@ -26,4 +26,5 @@ "homepage": "http://www.cognifide.com/our-technology/zengarden",

"ce": "bin/ce.js",
"ce-import": "bin/ce-import.js",
"ce-export": "bin/ce-export.js"
"ce-upload": "bin/ce-upload.js",
"ce-download": "bin/ce-download.js",
"ce-create": "bin/ce-create.js"
},

@@ -43,26 +44,20 @@ "scripts": {

],
"dependencies": {
"adm-zip": "^0.4.13",
"archiver": "^3.0.0",
"chalk": "^2.4.2",
"commander": "^2.20.0",
"ora": "^3.4.0",
"superagent": "^5.0.2"
},
"devDependencies": {
"banner-webpack-plugin": "^0.2.3",
"chai": "^3.5.0",
"chai-as-promised": "^6.0.0",
"gh-pages": "^0.12.0",
"ink-docstrap": "^1.3.0",
"jsdoc": "^3.4.3",
"mocha": "^3.3.0",
"socks-proxy-agent": "^3.0.1",
"webpack": "^2.4.1"
},
"dependencies": {
"adm-zip": "0.4.7",
"archiver": "^1.3.0",
"chalk": "^1.1.3",
"commander": "^2.9.0",
"object-assign": "^4.1.1",
"ora": "^1.2.0",
"promise-poller": "^1.5.2",
"superagent": "^3.5.2",
"superagent-proxy": "^1.0.2",
"theme-bump": "^1.3.0",
"yazl": "^2.4.2"
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"gh-pages": "^2.0.1",
"ink-docstrap": "^1.3.2",
"jsdoc": "^3.5.5",
"mocha": "^6.1.3",
"webpack": "^4.30.0",
"webpack-cli": "^3.3.0"
}
}

@@ -28,3 +28,3 @@ ![Cognifide logo](http://cognifide.github.io/images/cognifide-logo.png)

var crex = new CrEx();
crex.exportGetAllPackages()
crex.getPackageList()
.then((packages) => console.log(packages))

@@ -52,5 +52,7 @@ .catch((err) => console.log(err));

Full documentation can be found here:
<https://github.com/Cognifide/crex-sdk/wiki/CLI-Usage>
1. For v1: [CrEx CLI Documentation v1](docs/crex-sdk-cli-v1.md)
2. For v2: [CrEx CLI Documentation v2](docs/crex-sdk-cli-v2.md)
## License
MIT

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc