Socket
Socket
Sign inDemoInstall

crex

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

crex - npm Package Compare versions

Comparing version 0.7.3 to 0.8.0

lib/types.js

17

bin/ce-export.js
#!/usr/bin/env node
var fs = require('fs');
var ora = require('ora');
var util = require('util');
var chalk = require('chalk');

@@ -9,3 +10,9 @@ var program = require('commander');

var CrEx = require('../lib/index');
var auth = {};
try {
auth = fs.readFileSync('auth.json', 'utf-8');
auth = JSON.parse(auth);
} catch (err) { }
program

@@ -21,4 +28,8 @@ .usage('<path>')

if (Object.keys(auth).length > 0) {
console.log(chalk.underline('Auth file found'));
}
var path = program.args[0];
var crex = new CrEx();
var crex = new CrEx(auth);
var name = null;

@@ -80,5 +91,5 @@ var spinner = ora('Exporting package...').start();

});
spinner.succeed('Package ' + chalk.blue(package) + ' downloaded and extracted to ' + chalk.blue(dest));
spinner.succeed(util.format('Package %s downloaded from %s and extracted to %s', chalk.green(package), chalk.green(crex.getAddress()), chalk.green(dest)));
} else {
spinner.succeed('Package ' + chalk.blue(package) + ' downloaded');
spinner.succeed(util.format('Package %s downloaded from %s', chalk.green(package), chalk.green(crex.getAddress())));
}

@@ -85,0 +96,0 @@ }).catch((err) => {

@@ -5,2 +5,3 @@ #!/usr/bin/env node

var fs = require('fs');
var util = require('util');
var chalk = require('chalk');

@@ -10,3 +11,9 @@ var path = require('path');

var CrEx = require('../lib/index');
var auth = {};
try {
auth = fs.readFileSync('auth.json', 'utf-8');
auth = JSON.parse(auth);
} catch (err) { }
function list(val) {

@@ -26,5 +33,9 @@ return val.split(',');

if (Object.keys(auth).length > 0) {
console.log(chalk.underline('Auth file found'));
}
var name = program.args[0];
var spinner = ora('Compressing package...').start();
var crex = new CrEx();
var crex = new CrEx(auth);

@@ -71,5 +82,5 @@ if (program.target) {

}).then(() => {
spinner.succeed('Package ' + chalk.blue(name) + ' installed');
spinner.succeed(util.format('Package %s installed on %s', chalk.green(name), chalk.green(crex.getAddress())));
}).catch((err) => {
spinner.fail(err);
spinner.fail(chalk.red(err));
});
var request = require('./request');
var api = {};
api.exportGetAllPackages = function () {
return this.request('GET', '/etc/creativeExchange/export/api.packages.json');
/**
* 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) {

@@ -12,2 +28,9 @@ 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) {

@@ -17,2 +40,12 @@ 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) {

@@ -22,2 +55,9 @@ 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) {

@@ -27,6 +67,22 @@ return this.request('DELETE', '/etc/creativeExchange/export/api.packages.json', args);

api.importGetAllPackages = function () {
return this.request('GET', '/etc/creativeExchange/import/api.packages.json');
/**
* 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
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.importGetPackageStatus = function (args) {

@@ -36,2 +92,9 @@ return this.request('GET', '/etc/creativeExchange/import/api.status.json', args);

/**
* Upload package to an instance
* @function CrEx#importUploadPackage
* @arg {Object} args
* @arg {String} args.file - Binary representation of .zip package
* @returns {Promise}
*/
api.importUploadPackage = function (args) {

@@ -41,2 +104,9 @@ return this.request('UPLOAD', '/etc/creativeExchange/import/api.upload.json', args);

/**
* Download the import package as .zip file.
* @function CrEx#importDownloadPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.importDownloadPackage = function (args) {

@@ -46,2 +116,10 @@ return this.request('DOWNLOAD', '/etc/creativeExchange/import/api.package.zip', args);

/**
* Inspect package. Inspect allows for checking what changes will install make without actual
* change of theme or content or instance
* @function CrEx#importInspectPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.importInspectPackage = function (args) {

@@ -51,6 +129,9 @@ return this.request('POST', '/etc/creativeExchange/import/api.inspect.json', args);

api.importDryRunPackage = function (args) {
return this.request('POST', '/etc/creativeExchange/import/api.dry_run.json', args);
};
/**
* Install package. Modifies theme and adds new variants.
* @function CrEx#importInstallPackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.importInstallPackage = function (args) {

@@ -60,2 +141,9 @@ return this.request('POST', '/etc/creativeExchange/import/api.install.json', args);

/**
* Removes package from instance
* @function CrEx#importRemovePackage
* @arg {Object} args
* @arg {String} args.id - Package id
* @returns {Promise}
*/
api.importRemovePackage = function (args) {

@@ -65,2 +153,9 @@ return this.request('DELETE', '/etc/creativeExchange/import/api.packages.json', args);

/**
* Get list of all themes.
* @function CrEx#themesGetAllThemes
* @arg {Object} args
* @arg {number} [args.page] - Number of page containing 20 items
* @returns {Promise}
*/
api.themesGetAllThemes = function (args) {

@@ -70,6 +165,71 @@ return this.request('GET', '/etc/creativeExchange/themes/api.json', args);

api.themesCheckProgress = function (args) {
return this.request('GET', '/etc/creativeExchange/themes/api.json', args);
/**
* Returns progress of theme activation
* @function CrEx#themesCheckActivateProgress
* @arg {Object} args
* @arg {string} args.id - Theme id
* @returns {Promise}
*/
api.themesCheckActivateProgress = function (args) {
return this.request('GET', '/etc/creativeExchange/themes/api.activate.json', args);
};
/**
* Activate selected themes to publish instance
* @function CrEx#themesActivateThemes
* @arg {Object} args
* @arg {Array.<string>} args.themes - 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;

@@ -12,4 +12,14 @@ var api = require('./api');

/**
* @class CrEx
* @classdesc The Creative Exchange SDK class that provides methods to export, import
* packages and access theme information
* @arg {Object} options
* @arg {String} [options.url=localhost] - AEM instance address
* @arg {String} [options.port=4502] - AEM instance port
* @arg {String} [options.user=admin] - Username to access AEM instance
* @arg {String} [options.password=admin] - Password for username
*/
var CrEx = function (options) {
options = assign(DEFAULTS, options) || {};
options = assign({}, DEFAULTS, options) || {};
this.user = options.user;

@@ -25,6 +35,10 @@ this.password = options.password;

this.full = url;
}
};
CrEx.prototype.getUrl = function () {
return this.full;
};
CrEx.prototype.getAddress = function () {
return this.url + ':' + this.port;
}

@@ -31,0 +45,0 @@

6

lib/request.js

@@ -16,3 +16,3 @@ var request = require('superagent');

return new Promise(function (resolve, reject) {
var r = request
request
.get(url)

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

.end(function (err, res) {
if (err) reject(err);
if (err || !res) reject(err);
resolve(res.body);

@@ -36,3 +36,3 @@ });

.end(function (err, res) {
if (err) reject(err);
if (err || !res) reject(err);
resolve(res.body);

@@ -39,0 +39,0 @@ });

{
"name": "crex",
"version": "0.7.3",
"version": "0.8.0",
"description": "Creative Exchange SDK for Javascript",

@@ -22,2 +22,4 @@ "author": "Mateusz Luczak <mateusz.luczak@outlook.com>",

"build:browser": "webpack -p --config webpack.config.umd.js",
"jsdoc": "jsdoc -c ./conf.json -d generated-docs -t ./node_modules/ink-docstrap/template -R docs/README.md -r ./lib",
"publish-docs": "rm -rf generated-docs && npm run jsdoc && gh-pages -d generated-docs",
"test": "mocha test/**/*.js"

@@ -32,7 +34,10 @@ },

"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",
"webpack": "^2.4.1",
"banner-webpack-plugin": "^0.2.3"
"webpack": "^2.4.1"
},

@@ -39,0 +44,0 @@ "dependencies": {

<img width="250px" src="http://zg.cognifide.com/galaxite/img/zg_logo.svg">
<br>
## Creative Exchange SDK
Zen Garden Creative Exchange SDK for Javascript
## Zen Garden Creative Exchange SDK for Javascript
<a href="https://www.npmjs.com/package/crex"><img src="https://img.shields.io/npm/v/crex.svg" alt="Version"></a>
<a href="https://www.npmjs.com/package/crex"><img src="https://img.shields.io/npm/l/crex.svg" alt="License"></a>
## SDK
Creative Exchange SDK simplifies automation of Zen Garden theme development workflow.
It works both in Nodejs and in the browser, so it can be foundation for command line tools, electron apps, code editor plugins, browser monitoring tools and any other solutions that will make theme development easier for your organisation.
## SDK Quickstart
```bash

@@ -13,3 +16,3 @@ $ npm install crex --save

Use with node.js or module bundler like Webpack
Use with Node or module bundler like Webpack

@@ -20,10 +23,12 @@ ```js

var crex = new CrEx();
crex.exportGetAllPackages()
.then((packages) => console.log(packages))
.catch((err) => console.log(err))
.catch((err) => console.log(err));
```
Full docummentation and examples can be found here
## Documentation
Full documentation can be found here:
<https://mateuszluczak.github.io/crex-sdk>
## CLI

@@ -37,3 +42,3 @@

### Exporting package
#### Exporting package

@@ -44,3 +49,3 @@ ```bash

### Importing package
#### Importing package

@@ -51,5 +56,3 @@ ```bash

Full documentation of available commands and options can be found here
## License
MIT
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