Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init: function() {
CoreObject.prototype.init.apply(this, arguments);
if (!this.config) {
return Promise.reject(new SilentError('You have to pass a config!'));
}
var config = this.config.assets;
// be transparant to either passing a connectionString or the storageAccount + storageAccessKey
if(config.connectionString) {
this.client = azure.createBlobService(config.connectionString);
} else if (config.storageAccount && config.storageAccessKey) {
this.client = azure.createBlobService(config.storageAccount, config.storageAccessKey);
} else {
console.error("No connection string or storage account plus access key set for this Azure deployment.");
return Promise.reject(new SilentError('No connection string or storage account plus access key set for this Azure deployment.'));
}
// if a storage container name is defined in the config, use it instead of the default
if(config.containerName) {
AZURE_CONTAINER_NAME = config.containerName;
}
},
.then(function(base64) {
// Prevent duplicate screenshots.
if (base64 === previousScreenshot[browser]) {
return Promise.reject('Duplicate.')
}
previousScreenshot[browser] = base64;
return base64;
})
.then(function(base64) {
config = config || {};
var indexConfig = config.index;
var defaultIndexConfig = {
host: 'localhost',
port: '6379',
password: null
};
if (!config.distDir) {
config.distDir = 'dist';
}
if (!indexConfig) {
var message = chalk.yellow(errorMessage.replace('{0}', 'index'));
return Promise.reject(new SilentError(message));
}
for (var prop in defaultIndexConfig) {
if (!indexConfig.hasOwnProperty(prop) || indexConfig[prop] == null) {
indexConfig[prop] = defaultIndexConfig[prop];
}
}
return Promise.resolve(config);
};
module.exports = function(project, platform, application) {
var projectPath, command;
if (platform === 'ios') {
projectPath = path.join(project.root, 'cordova', 'platforms/ios/*.xcodeproj');
} else if (platform === 'android') {
projectPath = path.join(project.root, 'cordova', 'platforms/android/.project');
} else {
return Promise.reject(new Error('The ' + platform + ' platform is not supported. Please use "ios" or "android"'));
}
var command = getOpenCommand(projectPath, application);
return runCommand(command, 'Opening ' + platform + ' project with the default application');
};
S3Uploader.prototype.uploadFile = function(options) {
options = options || {};
var bucket = this.bucket;
var filePath = options.filePath;
var fullPath = options.cwd + '/' + filePath;
if (!fs.existsSync(fullPath)) {
var message = chalk.red('File at path: \'' + fullPath + '\' does not exist\n');
return Promise.reject(message);
}
var data = fs.readFileSync(fullPath);
var contentType = mime.lookup(fullPath);
var params = {
Bucket: bucket,
ACL: 'public-read',
Body: data,
ContentType: contentType,
Key: filePath
};
var client = this.client;
return new Promise(function(resolve, reject) {
read: function(){
var self = this;
var configResult;
try {
configResult = require(this.pathToConfig)(this.environment);
} catch(e) {
this.ui.writeError(e);
return Promise.reject(new Error('Cannot load configuration file \'' + this.pathToConfig + '\'. Note that the default location of the ember-cli-deploy config file is now \''+ self.defaultConfigPath + '\''));
}
return Promise.resolve(configResult).then(function(config){
if (!Object.keys(config).length) {
throw new SilentError('You are using the `' + self.environment + '` environment but have not specified any configuration.' +
'\n\nPlease add a `' + self.environment + '` section to your `config/deploy.js` file.' +
'\n\nFor more information, go to: `https://github.com/ember-cli/ember-cli-deploy#config-file`');
}
return new Config({
project: self.project,
rawConfig: config
});
});
}
});
beforeInstall: function(options) {
var ui = this.ui;
var code = this.localeCodeFor(options);
var locale = this.localeFor(code);
if (!this.isSupportedLocale(locale)) {
return Promise.reject(new SilentError('The locale `' + code + '` is not supported.'));
}
var displayPath = this.dataDisplayPath(code);
var fullPath = path.join(this.project.root, displayPath);
var contents = 'export default ' + serialize(locale) + ';';
return writeFile(fullPath, contents).then(function() {
ui.writeLine(' ' + chalk.green('create') + ' ' + displayPath);
});
},
}, function(err) {
ui.writeLine(chalk.red('Upload error: ') + fullPath);
return Promise.reject(err);
})
.finally(function() {
_printErrorMessage: function(message) {
return Promise.reject(new SilentError(message));
},
return this.ui.prompt([disclaimer]).then(function(results) {
if (results.understand) {
return Promise.resolve();
} else {
return Promise.reject('deploy/config.js file not created.');
}
});
},