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

atom-package-manager

Package Overview
Dependencies
Maintainers
14
Versions
252
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atom-package-manager - npm Package Compare versions

Comparing version 2.5.2 to 2.6.0

27

lib/apm-cli.js

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

// Generated by CoffeeScript 1.12.7
(function() {
var _, colors, commandClass, commandClasses, commands, config, fs, getAtomVersion, getPythonVersion, git, i, j, len, len1, name, npm, parseOptions, path, printVersions, ref, ref1, setupTempDirectory, showHelp, spawn, wordwrap, yargs;
({spawn} = require('child_process'));
spawn = require('child_process').spawn;

@@ -18,3 +19,2 @@ path = require('path');

// Enable "require" scripts in asar archives
require('asar-require');

@@ -32,3 +32,2 @@

tempDirectory = require('os').tmpdir();
// Resolve ~ in tmp dir atom/atom#2271
tempDirectory = path.resolve(fs.absolute(tempDirectory));

@@ -57,9 +56,12 @@ temp.dir = tempDirectory;

parseOptions = function(args = []) {
parseOptions = function(args) {
var arg, index, k, len2, options;
if (args == null) {
args = [];
}
options = yargs(args).wrap(Math.min(100, yargs.terminalWidth()));
options.usage(`\napm - Atom Package Manager powered by https://atom.io\n\nUsage: apm <command>\n\nwhere <command> is one of:\n${wordwrap(4, 80)(Object.keys(commands).sort().join(', '))}.\n\nRun \`apm help <command>\` to see the more details about a specific command.`);
options.usage("\napm - Atom Package Manager powered by https://atom.io\n\nUsage: apm <command>\n\nwhere <command> is one of:\n" + (wordwrap(4, 80)(Object.keys(commands).sort().join(', '))) + ".\n\nRun `apm help <command>` to see the more details about a specific command.");
options.alias('v', 'version').describe('version', 'Print the apm version');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.boolean('color').default('color', true).describe('color', 'Enable colored output');
options.boolean('color')["default"]('color', true).describe('color', 'Enable colored output');
options.command = options.argv._[0];

@@ -123,6 +125,6 @@ for (index = k = 0, len2 = args.length; k < len2; index = ++k) {

}
versions = `${'apm'.red} ${apmVersion.red}\n${'npm'.green} ${npmVersion.green}\n${'node'.blue} ${nodeVersion.blue} ${process.arch.blue}\n${'atom'.cyan} ${atomVersion.cyan}\n${'python'.yellow} ${pythonVersion.yellow}\n${'git'.magenta} ${gitVersion.magenta}`;
versions = 'apm'.red + " " + apmVersion.red + "\n" + 'npm'.green + " " + npmVersion.green + "\n" + 'node'.blue + " " + nodeVersion.blue + " " + process.arch.blue + "\n" + 'atom'.cyan + " " + atomVersion.cyan + "\n" + 'python'.yellow + " " + pythonVersion.yellow + "\n" + 'git'.magenta + " " + gitVersion.magenta;
if (config.isWin32()) {
visualStudioVersion = (ref5 = config.getInstalledVisualStudioFlag()) != null ? ref5 : '';
versions += `\n${'visual studio'.cyan} ${visualStudioVersion.cyan}`;
versions += "\n" + 'visual studio'.cyan + " " + visualStudioVersion.cyan;
}

@@ -142,3 +144,3 @@ console.log(versions);

try {
({version} = (ref2 = require(path.join(resourcePath, 'package.json'))) != null ? ref2 : unknownVersion);
version = ((ref2 = require(path.join(resourcePath, 'package.json'))) != null ? ref2 : unknownVersion).version;
return callback(version);

@@ -184,5 +186,5 @@ } catch (error1) {

return spawned.on('close', function(code) {
var version;
var ref4, version;
if (code === 0) {
[name, version] = Buffer.concat(outputChunks).toString().split(' ');
ref4 = Buffer.concat(outputChunks).toString().split(' '), name = ref4[0], version = ref4[1];
version = version != null ? version.trim() : void 0;

@@ -225,3 +227,2 @@ }

if (message === 'canceled') {
// A prompt was canceled so just log an empty line
console.log();

@@ -256,3 +257,3 @@ } else if (message) {

} else {
return options.callback(`Unrecognized command: ${command}`);
return options.callback("Unrecognized command: " + command);
}

@@ -259,0 +260,0 @@ } else {

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

// Generated by CoffeeScript 1.12.7
(function() {
var child_process, fs, npm, path, semver;
var asarPath, child_process, fs, npm, path, semver;

@@ -14,2 +15,4 @@ child_process = require('child_process');

asarPath = null;
module.exports = {

@@ -38,3 +41,3 @@ getHomeDirectory: function() {

getResourcePath: function(callback) {
var apmFolder, appFolder, appLocation, asarPath;
var apmFolder, appFolder, asarPaths, glob, pattern;
if (process.env.ATOM_RESOURCE_PATH) {

@@ -45,6 +48,11 @@ return process.nextTick(function() {

}
if (asarPath) {
return process.nextTick(function() {
return callback(asarPath);
});
}
apmFolder = path.resolve(__dirname, '..');
appFolder = path.dirname(apmFolder);
if (path.basename(apmFolder) === 'apm' && path.basename(appFolder) === 'app') {
asarPath = `${appFolder}.asar`;
asarPath = appFolder + ".asar";
if (fs.existsSync(asarPath)) {

@@ -59,3 +67,3 @@ return process.nextTick(function() {

if (path.basename(apmFolder) === 'apm' && path.basename(appFolder) === 'app') {
asarPath = `${appFolder}.asar`;
asarPath = appFolder + ".asar";
if (fs.existsSync(asarPath)) {

@@ -69,6 +77,9 @@ return process.nextTick(function() {

case 'darwin':
return child_process.exec('mdfind "kMDItemCFBundleIdentifier == \'com.github.atom\'"', function(error, stdout = '', stderr) {
return child_process.exec('mdfind "kMDItemCFBundleIdentifier == \'com.github.atom\'"', function(error, stdout, stderr) {
var appLocation;
if (stdout == null) {
stdout = '';
}
if (!error) {
[appLocation] = stdout.split('\n');
appLocation = stdout.split('\n')[0];
}

@@ -78,12 +89,27 @@ if (!appLocation) {

}
return callback(`${appLocation}/Contents/Resources/app.asar`);
asarPath = appLocation + "/Contents/Resources/app.asar";
return process.nextTick(function() {
return callback(asarPath);
});
});
case 'linux':
appLocation = '/usr/local/share/atom/resources/app.asar';
if (!fs.existsSync(appLocation)) {
appLocation = '/usr/share/atom/resources/app.asar';
asarPath = '/usr/local/share/atom/resources/app.asar';
if (!fs.existsSync(asarPath)) {
asarPath = '/usr/share/atom/resources/app.asar';
}
return process.nextTick(function() {
return callback(appLocation);
return callback(asarPath);
});
case 'win32':
glob = require('glob');
pattern = "/Users/" + process.env.USERNAME + "/AppData/Local/atom/app-+([0-9]).+([0-9]).+([0-9])/resources/app.asar";
asarPaths = glob.sync(pattern, null);
asarPath = asarPaths[asarPaths.length - 1];
return process.nextTick(function() {
return callback(asarPath);
});
default:
return process.nextTick(function() {
return callback('');
});
}

@@ -101,3 +127,3 @@ },

var ref;
return (ref = process.env.ATOM_PACKAGES_URL) != null ? ref : `${this.getAtomApiUrl()}/packages`;
return (ref = process.env.ATOM_PACKAGES_URL) != null ? ref : (this.getAtomApiUrl()) + "/packages";
},

@@ -134,3 +160,2 @@ getAtomApiUrl: function() {

if (process.env.GYP_MSVS_VERSION) {
// Use the explictly-configured version when set
return process.env.GYP_MSVS_VERSION;

@@ -152,3 +177,3 @@ }

visualStudioIsInstalled: function(version) {
return fs.existsSync(path.join(this.x86ProgramFilesDirectory(), `Microsoft Visual Studio ${version}`, "Common7", "IDE"));
return fs.existsSync(path.join(this.x86ProgramFilesDirectory(), "Microsoft Visual Studio " + version, "Common7", "IDE"));
},

@@ -172,3 +197,3 @@ loadNpm: function(callback) {

try {
return fs.writeFileSync(this.getGlobalConfigPath(), `; This file is auto-generated and should not be edited since any\n; modifications will be lost the next time any apm command is run.\n;\n; You should instead edit your .apmrc config located in ~/.atom/.apmrc\ncache = ${this.getCacheDirectory()}\n; Hide progress-bar to prevent npm from altering apm console output.\nprogress = false`);
return fs.writeFileSync(this.getGlobalConfigPath(), "; This file is auto-generated and should not be edited since any\n; modifications will be lost the next time any apm command is run.\n;\n; You should instead edit your .apmrc config located in ~/.atom/.apmrc\ncache = " + (this.getCacheDirectory()) + "\n; Hide progress-bar to prevent npm from altering apm console output.\nprogress = false");
} catch (error1) {}

@@ -175,0 +200,0 @@ }

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -8,3 +9,2 @@ var error, keytar, tokenName;

error = error1;
// Gracefully handle keytar failing to load due to missing library on Linux
if (process.platform === 'linux') {

@@ -27,6 +27,2 @@ keytar = {

module.exports = {
// Get the Atom.io API token from the keychain.
// callback - A function to call with an error as the first argument and a
// string token as the second argument.
getToken: function(callback) {

@@ -39,3 +35,3 @@ return keytar.findPassword(tokenName).then(function(token) {

}
}).catch(function() {
})["catch"](function() {
var token;

@@ -49,5 +45,2 @@ if (token = process.env.ATOM_ACCESS_TOKEN) {

},
// Save the given token to the keychain.
// token - A string token to save.
saveToken: function(token) {

@@ -54,0 +47,0 @@ return keytar.setPassword(tokenName, 'atom.io', token);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Ci, Command, _, async, config, fs, path, yargs;
var Ci, Command, _, async, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;

@@ -18,85 +22,94 @@ path = require('path');

module.exports = Ci = (function() {
class Ci extends Command {
constructor() {
super();
this.atomDirectory = config.getAtomDirectory();
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
module.exports = Ci = (function(superClass) {
extend(Ci, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm ci\n\nInstall a package with a clean slate.\n\nIf you have an up-to-date package-lock.json file created by apm install,\napm ci will install its locked contents exactly. It is substantially\nfaster than apm install and produces consistently reproduceable builds,\nbut cannot be used to install new packages or dependencies.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.boolean('verbose').default('verbose', false).describe('verbose', 'Show verbose debug information');
Ci.commandNames = ['ci'];
function Ci() {
Ci.__super__.constructor.call(this);
this.atomDirectory = config.getAtomDirectory();
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
Ci.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm ci\n\nInstall a package with a clean slate.\n\nIf you have an up-to-date package-lock.json file created by apm install,\napm ci will install its locked contents exactly. It is substantially\nfaster than apm install and produces consistently reproduceable builds,\nbut cannot be used to install new packages or dependencies.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.boolean('verbose')["default"]('verbose', false).describe('verbose', 'Show verbose debug information');
};
Ci.prototype.installModules = function(options, callback) {
var env, installArgs, installOptions, vsArgs;
process.stdout.write('Installing locked modules');
if (options.argv.verbose) {
process.stdout.write('\n');
} else {
process.stdout.write(' ');
}
installModules(options, callback) {
var env, installArgs, installOptions, vsArgs;
process.stdout.write('Installing locked modules');
if (options.argv.verbose) {
process.stdout.write('\n');
} else {
process.stdout.write(' ');
}
installArgs = ['ci', '--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), ...this.getNpmBuildFlags()];
if (options.argv.verbose) {
installArgs.push('--verbose');
}
if (vsArgs = this.getVisualStudioFlags()) {
installArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
installOptions = {
env,
streaming: options.argv.verbose
installArgs = ['ci', '--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath()].concat(slice.call(this.getNpmBuildFlags()));
if (options.argv.verbose) {
installArgs.push('--verbose');
}
if (vsArgs = this.getVisualStudioFlags()) {
installArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
installOptions = {
env: env,
streaming: options.argv.verbose
};
return this.fork(this.atomNpmPath, installArgs, installOptions, (function(_this) {
return function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.logCommandResults.apply(_this, [callback].concat(slice.call(args)));
};
return this.fork(this.atomNpmPath, installArgs, installOptions, (...args) => {
return this.logCommandResults(callback, ...args);
});
}
})(this));
};
run(options) {
var callback, commands, iteratee, opts;
({callback} = options);
opts = this.parseOptions(options.commandArgs);
commands = [];
commands.push((callback) => {
return config.loadNpm((error, npm) => {
this.npm = npm;
Ci.prototype.run = function(options) {
var callback, commands, iteratee, opts;
callback = options.callback;
opts = this.parseOptions(options.commandArgs);
commands = [];
commands.push((function(_this) {
return function(callback) {
return config.loadNpm(function(error, npm) {
_this.npm = npm;
return callback(error);
});
});
commands.push((cb) => {
return this.loadInstalledAtomMetadata(cb);
});
commands.push((cb) => {
return this.installModules(opts, cb);
});
iteratee = function(item, next) {
return item(next);
};
return async.mapSeries(commands, iteratee, function(err) {
if (err) {
return callback(err);
}
return callback(null);
});
}
})(this));
commands.push((function(_this) {
return function(cb) {
return _this.loadInstalledAtomMetadata(cb);
};
})(this));
commands.push((function(_this) {
return function(cb) {
return _this.installModules(opts, cb);
};
})(this));
iteratee = function(item, next) {
return item(next);
};
return async.mapSeries(commands, iteratee, function(err) {
if (err) {
return callback(err);
}
return callback(null);
});
};
Ci.commandNames = ['ci'];
return Ci;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Clean, Command, _, async, config, fs, path, yargs;
var CSON, Clean, Command, _, async, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;

@@ -20,31 +24,34 @@ path = require('path');

module.exports = Clean = (function() {
class Clean extends Command {
constructor() {
super();
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
module.exports = Clean = (function(superClass) {
extend(Clean, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm clean\n\nDeletes all packages in the node_modules folder that are not referenced\nas a dependency in the package.json file.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
Clean.commandNames = ['clean', 'prune'];
run(options) {
process.stdout.write("Removing extraneous modules ");
return this.fork(this.atomNpmPath, ['prune'], (...args) => {
return this.logCommandResults(options.callback, ...args);
});
}
function Clean() {
Clean.__super__.constructor.call(this);
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
Clean.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm clean\n\nDeletes all packages in the node_modules folder that are not referenced\nas a dependency in the package.json file.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Clean.commandNames = ['clean', 'prune'];
Clean.prototype.run = function(options) {
process.stdout.write("Removing extraneous modules ");
return this.fork(this.atomNpmPath, ['prune'], (function(_this) {
return function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.logCommandResults.apply(_this, [options.callback].concat(slice.call(args)));
};
})(this));
};
return Clean;
}).call(this);
})(Command);
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -2,0 +3,0 @@ var apm;

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, _, child_process, config, git, path, semver;
var Command, _, child_process, config, git, path, semver,
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
slice = [].slice;

@@ -16,10 +19,11 @@ child_process = require('child_process');

module.exports = Command = class Command {
constructor() {
this.logCommandResults = this.logCommandResults.bind(this);
this.logCommandResultsIfFail = this.logCommandResultsIfFail.bind(this);
module.exports = Command = (function() {
function Command() {
this.logCommandResultsIfFail = bind(this.logCommandResultsIfFail, this);
this.logCommandResults = bind(this.logCommandResults, this);
}
spawn(command, args, ...remaining) {
var callback, errorChunks, onChildExit, options, outputChunks, spawned;
Command.prototype.spawn = function() {
var args, callback, command, errorChunks, onChildExit, options, outputChunks, remaining, spawned;
command = arguments[0], args = arguments[1], remaining = 3 <= arguments.length ? slice.call(arguments, 2) : [];
if (remaining.length >= 2) {

@@ -54,14 +58,19 @@ options = remaining.shift();

return spawned;
}
};
fork(script, args, ...remaining) {
Command.prototype.fork = function() {
var args, remaining, script;
script = arguments[0], args = arguments[1], remaining = 3 <= arguments.length ? slice.call(arguments, 2) : [];
args.unshift(script);
return this.spawn(process.execPath, args, ...remaining);
}
return this.spawn.apply(this, [process.execPath, args].concat(slice.call(remaining)));
};
packageNamesFromArgv(argv) {
Command.prototype.packageNamesFromArgv = function(argv) {
return this.sanitizePackageNames(argv._);
}
};
sanitizePackageNames(packageNames = []) {
Command.prototype.sanitizePackageNames = function(packageNames) {
if (packageNames == null) {
packageNames = [];
}
packageNames = packageNames.map(function(packageName) {

@@ -71,5 +80,5 @@ return packageName.trim();

return _.compact(_.uniq(packageNames));
}
};
logSuccess() {
Command.prototype.logSuccess = function() {
if (process.platform === 'win32') {

@@ -80,5 +89,5 @@ return process.stdout.write('done\n'.green);

}
}
};
logFailure() {
Command.prototype.logFailure = function() {
if (process.platform === 'win32') {

@@ -89,5 +98,11 @@ return process.stdout.write('failed\n'.red);

}
}
};
logCommandResults(callback, code, stderr = '', stdout = '') {
Command.prototype.logCommandResults = function(callback, code, stderr, stdout) {
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code === 0) {

@@ -98,7 +113,13 @@ this.logSuccess();

this.logFailure();
return callback(`${stdout}\n${stderr}`.trim());
return callback((stdout + "\n" + stderr).trim());
}
}
};
logCommandResultsIfFail(callback, code, stderr = '', stdout = '') {
Command.prototype.logCommandResultsIfFail = function(callback, code, stderr, stdout) {
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code === 0) {

@@ -108,9 +129,8 @@ return callback();

this.logFailure();
return callback(`${stdout}\n${stderr}`.trim());
return callback((stdout + "\n" + stderr).trim());
}
}
};
normalizeVersion(version) {
Command.prototype.normalizeVersion = function(version) {
if (typeof version === 'string') {
// Remove commit SHA suffix
return version.replace(/-.*$/, '');

@@ -120,36 +140,42 @@ } else {

}
}
};
loadInstalledAtomMetadata(callback) {
return this.getResourcePath((resourcePath) => {
var electronVersion, ref, ref1, version;
try {
({version, electronVersion} = (ref = require(path.join(resourcePath, 'package.json'))) != null ? ref : {});
version = this.normalizeVersion(version);
if (semver.valid(version)) {
this.installedAtomVersion = version;
Command.prototype.loadInstalledAtomMetadata = function(callback) {
return this.getResourcePath((function(_this) {
return function(resourcePath) {
var electronVersion, ref, ref1, ref2, version;
try {
ref1 = (ref = require(path.join(resourcePath, 'package.json'))) != null ? ref : {}, version = ref1.version, electronVersion = ref1.electronVersion;
version = _this.normalizeVersion(version);
if (semver.valid(version)) {
_this.installedAtomVersion = version;
}
} catch (error) {}
_this.electronVersion = (ref2 = process.env.ATOM_ELECTRON_VERSION) != null ? ref2 : electronVersion;
if (_this.electronVersion == null) {
throw new Error('Could not determine Electron version');
}
} catch (error) {}
this.electronVersion = (ref1 = process.env.ATOM_ELECTRON_VERSION) != null ? ref1 : electronVersion;
if (this.electronVersion == null) {
throw new Error('Could not determine Electron version');
}
return callback();
});
}
return callback();
};
})(this));
};
getResourcePath(callback) {
Command.prototype.getResourcePath = function(callback) {
if (this.resourcePath) {
return process.nextTick(() => {
return callback(this.resourcePath);
});
return process.nextTick((function(_this) {
return function() {
return callback(_this.resourcePath);
};
})(this));
} else {
return config.getResourcePath((resourcePath1) => {
this.resourcePath = resourcePath1;
return callback(this.resourcePath);
});
return config.getResourcePath((function(_this) {
return function(resourcePath1) {
_this.resourcePath = resourcePath1;
return callback(_this.resourcePath);
};
})(this));
}
}
};
addBuildEnvVars(env) {
Command.prototype.addBuildEnvVars = function(env) {
if (config.isWin32()) {

@@ -164,22 +190,22 @@ this.updateWindowsEnv(env);

env.npm_config_arch = config.getElectronArch();
return env.npm_config_target_arch = config.getElectronArch(); // for node-pre-gyp
}
return env.npm_config_target_arch = config.getElectronArch();
};
getVisualStudioFlags() {
Command.prototype.getVisualStudioFlags = function() {
var vsVersion;
if (vsVersion = config.getInstalledVisualStudioFlag()) {
return `--msvs_version=${vsVersion}`;
return "--msvs_version=" + vsVersion;
}
}
};
getNpmBuildFlags() {
return [`--target=${this.electronVersion}`, `--disturl=${config.getElectronUrl()}`, `--arch=${config.getElectronArch()}`];
}
Command.prototype.getNpmBuildFlags = function() {
return ["--target=" + this.electronVersion, "--disturl=" + (config.getElectronUrl()), "--arch=" + (config.getElectronArch())];
};
updateWindowsEnv(env) {
Command.prototype.updateWindowsEnv = function(env) {
env.USERPROFILE = env.HOME;
return git.addGitToEnv(env);
}
};
addNodeBinToEnv(env) {
Command.prototype.addNodeBinToEnv = function(env) {
var nodeBinFolder, pathKey;

@@ -189,9 +215,9 @@ nodeBinFolder = path.resolve(__dirname, '..', 'bin');

if (env[pathKey]) {
return env[pathKey] = `${nodeBinFolder}${path.delimiter}${env[pathKey]}`;
return env[pathKey] = "" + nodeBinFolder + path.delimiter + env[pathKey];
} else {
return env[pathKey] = nodeBinFolder;
}
}
};
addProxyToEnv(env) {
Command.prototype.addProxyToEnv = function(env) {
var httpProxy, httpsProxy, ref, useStrictSsl;

@@ -215,3 +241,2 @@ httpProxy = this.npm.config.get('proxy');

}
// node-gyp only checks HTTP_PROXY (as of node-gyp@4.0.0)
if (env.HTTP_PROXY == null) {

@@ -224,5 +249,2 @@ env.HTTP_PROXY = httpsProxy;

}
// node-gyp doesn't currently have an option for this so just set the
// environment variable to bypass strict SSL
// https://github.com/nodejs/node-gyp/issues/448
useStrictSsl = (ref = this.npm.config.get('strict-ssl')) != null ? ref : true;

@@ -232,6 +254,8 @@ if (!useStrictSsl) {

}
}
};
};
return Command;
})();
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Config, _, apm, path, yargs;
var Command, Config, _, apm, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -14,53 +17,60 @@ path = require('path');

module.exports = Config = (function() {
class Config extends Command {
constructor() {
var atomDirectory;
super();
atomDirectory = apm.getAtomDirectory();
this.atomNodeDirectory = path.join(atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
module.exports = Config = (function(superClass) {
extend(Config, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm config set <key> <value>\n apm config get <key>\n apm config delete <key>\n apm config list\n apm config edit\n");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
Config.commandNames = ['config'];
run(options) {
var callback, configArgs, configOptions, env;
({callback} = options);
options = this.parseOptions(options.commandArgs);
configArgs = ['--globalconfig', apm.getGlobalConfigPath(), '--userconfig', apm.getUserConfigPath(), 'config'];
configArgs = configArgs.concat(options.argv._);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: apm.getRustupHomeDirPath()
});
configOptions = {env};
return this.fork(this.atomNpmPath, configArgs, configOptions, function(code, stderr = '', stdout = '') {
if (code === 0) {
if (stdout) {
process.stdout.write(stdout);
}
return callback();
} else {
if (stderr) {
process.stdout.write(stderr);
}
return callback(new Error(`npm config failed: ${code}`));
}
});
}
function Config() {
var atomDirectory;
Config.__super__.constructor.call(this);
atomDirectory = apm.getAtomDirectory();
this.atomNodeDirectory = path.join(atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
Config.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm config set <key> <value>\n apm config get <key>\n apm config delete <key>\n apm config list\n apm config edit\n");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Config.commandNames = ['config'];
Config.prototype.run = function(options) {
var callback, configArgs, configOptions, env;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
configArgs = ['--globalconfig', apm.getGlobalConfigPath(), '--userconfig', apm.getUserConfigPath(), 'config'];
configArgs = configArgs.concat(options.argv._);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: apm.getRustupHomeDirPath()
});
configOptions = {
env: env
};
return this.fork(this.atomNpmPath, configArgs, configOptions, function(code, stderr, stdout) {
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code === 0) {
if (stdout) {
process.stdout.write(stdout);
}
return callback();
} else {
if (stderr) {
process.stdout.write(stderr);
}
return callback(new Error("npm config failed: " + code));
}
});
};
return Config;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Dedupe, _, async, config, fs, path, yargs;
var Command, Dedupe, _, async, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;

@@ -18,86 +22,95 @@ path = require('path');

module.exports = Dedupe = (function() {
class Dedupe extends Command {
constructor() {
super();
this.atomDirectory = config.getAtomDirectory();
this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages');
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
module.exports = Dedupe = (function(superClass) {
extend(Dedupe, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm dedupe [<package_name>...]\n\nReduce duplication in the node_modules folder in the current directory.\n\nThis command is experimental.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
Dedupe.commandNames = ['dedupe'];
dedupeModules(options, callback) {
process.stdout.write('Deduping modules ');
return this.forkDedupeCommand(options, (...args) => {
return this.logCommandResults(callback, ...args);
});
}
function Dedupe() {
Dedupe.__super__.constructor.call(this);
this.atomDirectory = config.getAtomDirectory();
this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages');
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
forkDedupeCommand(options, callback) {
var dedupeArgs, dedupeOptions, env, i, len, packageName, ref, vsArgs;
dedupeArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'dedupe'];
dedupeArgs.push(...this.getNpmBuildFlags());
if (options.argv.silent) {
dedupeArgs.push('--silent');
}
if (options.argv.quiet) {
dedupeArgs.push('--quiet');
}
if (vsArgs = this.getVisualStudioFlags()) {
dedupeArgs.push(vsArgs);
}
ref = options.argv._;
for (i = 0, len = ref.length; i < len; i++) {
packageName = ref[i];
dedupeArgs.push(packageName);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
dedupeOptions = {env};
if (options.cwd) {
dedupeOptions.cwd = options.cwd;
}
return this.fork(this.atomNpmPath, dedupeArgs, dedupeOptions, callback);
}
Dedupe.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm dedupe [<package_name>...]\n\nReduce duplication in the node_modules folder in the current directory.\n\nThis command is experimental.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
createAtomDirectories() {
fs.makeTreeSync(this.atomDirectory);
return fs.makeTreeSync(this.atomNodeDirectory);
}
Dedupe.prototype.dedupeModules = function(options, callback) {
process.stdout.write('Deduping modules ');
return this.forkDedupeCommand(options, (function(_this) {
return function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.logCommandResults.apply(_this, [callback].concat(slice.call(args)));
};
})(this));
};
run(options) {
var callback, commands, cwd;
({callback, cwd} = options);
options = this.parseOptions(options.commandArgs);
options.cwd = cwd;
this.createAtomDirectories();
commands = [];
commands.push((callback) => {
return this.loadInstalledAtomMetadata(callback);
});
commands.push((callback) => {
return this.dedupeModules(options, callback);
});
return async.waterfall(commands, callback);
Dedupe.prototype.forkDedupeCommand = function(options, callback) {
var dedupeArgs, dedupeOptions, env, i, len, packageName, ref, vsArgs;
dedupeArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'dedupe'];
dedupeArgs.push.apply(dedupeArgs, this.getNpmBuildFlags());
if (options.argv.silent) {
dedupeArgs.push('--silent');
}
if (options.argv.quiet) {
dedupeArgs.push('--quiet');
}
if (vsArgs = this.getVisualStudioFlags()) {
dedupeArgs.push(vsArgs);
}
ref = options.argv._;
for (i = 0, len = ref.length; i < len; i++) {
packageName = ref[i];
dedupeArgs.push(packageName);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
dedupeOptions = {
env: env
};
if (options.cwd) {
dedupeOptions.cwd = options.cwd;
}
return this.fork(this.atomNpmPath, dedupeArgs, dedupeOptions, callback);
};
Dedupe.prototype.createAtomDirectories = function() {
fs.makeTreeSync(this.atomDirectory);
return fs.makeTreeSync(this.atomNodeDirectory);
};
Dedupe.commandNames = ['dedupe'];
Dedupe.prototype.run = function(options) {
var callback, commands, cwd;
callback = options.callback, cwd = options.cwd;
options = this.parseOptions(options.commandArgs);
options.cwd = cwd;
this.createAtomDirectories();
commands = [];
commands.push((function(_this) {
return function(callback) {
return _this.loadInstalledAtomMetadata(callback);
};
})(this));
commands.push((function(_this) {
return function(callback) {
return _this.dedupeModules(options, callback);
};
})(this));
return async.waterfall(commands, callback);
};
return Dedupe;
}).call(this);
})(Command);
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -2,0 +3,0 @@ var deprecatedPackages, semver;

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Develop, Install, Link, _, async, config, fs, git, path, request, yargs;
var Command, Develop, Install, Link, _, async, config, fs, git, path, request, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;

@@ -26,42 +30,52 @@ fs = require('fs');

module.exports = Develop = (function() {
class Develop extends Command {
constructor() {
super();
this.atomDirectory = config.getAtomDirectory();
this.atomDevPackagesDirectory = path.join(this.atomDirectory, 'dev', 'packages');
}
module.exports = Develop = (function(superClass) {
extend(Develop, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm develop <package_name> [<directory>]\n\nClone the given package's Git repository to the directory specified,\ninstall its dependencies, and link it for development to\n~/.atom/dev/packages/<package_name>.\n\nIf no directory is specified then the repository is cloned to\n~/github/<package_name>. The default folder to clone packages into can\nbe overridden using the ATOM_REPOS_HOME environment variable.\n\nOnce this command completes you can open a dev window from atom using\ncmd-shift-o to run the package out of the newly cloned repository.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
Develop.commandNames = ['dev', 'develop'];
getRepositoryUrl(packageName, callback) {
var requestSettings;
requestSettings = {
url: `${config.getAtomPackagesUrl()}/${packageName}`,
json: true
};
return request.get(requestSettings, function(error, response, body = {}) {
var message, repositoryUrl;
if (error != null) {
return callback(`Request for package information failed: ${error.message}`);
} else if (response.statusCode === 200) {
if (repositoryUrl = body.repository.url) {
return callback(null, repositoryUrl);
} else {
return callback(`No repository URL found for package: ${packageName}`);
}
function Develop() {
Develop.__super__.constructor.call(this);
this.atomDirectory = config.getAtomDirectory();
this.atomDevPackagesDirectory = path.join(this.atomDirectory, 'dev', 'packages');
}
Develop.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm develop <package_name> [<directory>]\n\nClone the given package's Git repository to the directory specified,\ninstall its dependencies, and link it for development to\n~/.atom/dev/packages/<package_name>.\n\nIf no directory is specified then the repository is cloned to\n~/github/<package_name>. The default folder to clone packages into can\nbe overridden using the ATOM_REPOS_HOME environment variable.\n\nOnce this command completes you can open a dev window from atom using\ncmd-shift-o to run the package out of the newly cloned repository.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Develop.prototype.getRepositoryUrl = function(packageName, callback) {
var requestSettings;
requestSettings = {
url: (config.getAtomPackagesUrl()) + "/" + packageName,
json: true
};
return request.get(requestSettings, function(error, response, body) {
var message, repositoryUrl;
if (body == null) {
body = {};
}
if (error != null) {
return callback("Request for package information failed: " + error.message);
} else if (response.statusCode === 200) {
if (repositoryUrl = body.repository.url) {
return callback(null, repositoryUrl);
} else {
message = request.getErrorMessage(response, body);
return callback(`Request for package information failed: ${message}`);
return callback("No repository URL found for package: " + packageName);
}
});
} else {
message = request.getErrorMessage(response, body);
return callback("Request for package information failed: " + message);
}
});
};
Develop.prototype.cloneRepository = function(repoUrl, packageDirectory, options, callback) {
if (callback == null) {
callback = function() {};
}
cloneRepository(repoUrl, packageDirectory, options, callback = function() {}) {
return config.getSetting('git', (command) => {
return config.getSetting('git', (function(_this) {
return function(command) {
var args;

@@ -73,45 +87,52 @@ if (command == null) {

if (!options.argv.json) {
process.stdout.write(`Cloning ${repoUrl} `);
process.stdout.write("Cloning " + repoUrl + " ");
}
git.addGitToEnv(process.env);
return this.spawn(command, args, (...args) => {
return _this.spawn(command, args, function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
if (options.argv.json) {
return this.logCommandResultsIfFail(callback, ...args);
return _this.logCommandResultsIfFail.apply(_this, [callback].concat(slice.call(args)));
} else {
return this.logCommandResults(callback, ...args);
return _this.logCommandResults.apply(_this, [callback].concat(slice.call(args)));
}
});
});
};
})(this));
};
Develop.prototype.installDependencies = function(packageDirectory, options, callback) {
var installOptions;
if (callback == null) {
callback = function() {};
}
process.chdir(packageDirectory);
installOptions = _.clone(options);
installOptions.callback = callback;
return new Install().run(installOptions);
};
installDependencies(packageDirectory, options, callback = function() {}) {
var installOptions;
process.chdir(packageDirectory);
installOptions = _.clone(options);
installOptions.callback = callback;
return new Install().run(installOptions);
Develop.prototype.linkPackage = function(packageDirectory, options, callback) {
var linkOptions;
linkOptions = _.clone(options);
if (callback) {
linkOptions.callback = callback;
}
linkOptions.commandArgs = [packageDirectory, '--dev'];
return new Link().run(linkOptions);
};
linkPackage(packageDirectory, options, callback) {
var linkOptions;
linkOptions = _.clone(options);
if (callback) {
linkOptions.callback = callback;
}
linkOptions.commandArgs = [packageDirectory, '--dev'];
return new Link().run(linkOptions);
Develop.prototype.run = function(options) {
var packageDirectory, packageName, ref;
packageName = options.commandArgs.shift();
if (!((packageName != null ? packageName.length : void 0) > 0)) {
return options.callback("Missing required package name");
}
run(options) {
var packageDirectory, packageName, ref;
packageName = options.commandArgs.shift();
if (!((packageName != null ? packageName.length : void 0) > 0)) {
return options.callback("Missing required package name");
}
packageDirectory = (ref = options.commandArgs.shift()) != null ? ref : path.join(config.getReposDirectory(), packageName);
packageDirectory = path.resolve(packageDirectory);
if (fs.existsSync(packageDirectory)) {
return this.linkPackage(packageDirectory, options);
} else {
return this.getRepositoryUrl(packageName, (error, repoUrl) => {
packageDirectory = (ref = options.commandArgs.shift()) != null ? ref : path.join(config.getReposDirectory(), packageName);
packageDirectory = path.resolve(packageDirectory);
if (fs.existsSync(packageDirectory)) {
return this.linkPackage(packageDirectory, options);
} else {
return this.getRepositoryUrl(packageName, (function(_this) {
return function(error, repoUrl) {
var tasks;

@@ -122,25 +143,22 @@ if (error != null) {

tasks = [];
tasks.push((callback) => {
return this.cloneRepository(repoUrl, packageDirectory, options, callback);
tasks.push(function(callback) {
return _this.cloneRepository(repoUrl, packageDirectory, options, callback);
});
tasks.push((callback) => {
return this.installDependencies(packageDirectory, options, callback);
tasks.push(function(callback) {
return _this.installDependencies(packageDirectory, options, callback);
});
tasks.push((callback) => {
return this.linkPackage(packageDirectory, options, callback);
tasks.push(function(callback) {
return _this.linkPackage(packageDirectory, options, callback);
});
return async.waterfall(tasks, options.callback);
}
});
}
};
})(this));
}
};
Develop.commandNames = ['dev', 'develop'];
return Develop;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Disable, List, _, config, path, yargs;
var CSON, Command, Disable, List, _, config, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -18,47 +21,55 @@ _ = require('underscore-plus');

module.exports = Disable = (function() {
class Disable extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm disable [<package_name>]...\n\nDisables the named package(s).");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
module.exports = Disable = (function(superClass) {
extend(Disable, superClass);
getInstalledPackages(callback) {
var lister, options;
options = {
argv: {
theme: false,
bare: true
}
};
lister = new List();
return lister.listBundledPackages(options, function(error, core_packages) {
return lister.listDevPackages(options, function(error, dev_packages) {
return lister.listUserPackages(options, function(error, user_packages) {
return callback(null, core_packages.concat(dev_packages, user_packages));
});
function Disable() {
return Disable.__super__.constructor.apply(this, arguments);
}
Disable.commandNames = ['disable'];
Disable.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm disable [<package_name>]...\n\nDisables the named package(s).");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Disable.prototype.getInstalledPackages = function(callback) {
var lister, options;
options = {
argv: {
theme: false,
bare: true
}
};
lister = new List();
return lister.listBundledPackages(options, function(error, core_packages) {
return lister.listDevPackages(options, function(error, dev_packages) {
return lister.listUserPackages(options, function(error, user_packages) {
return callback(null, core_packages.concat(dev_packages, user_packages));
});
});
});
};
Disable.prototype.run = function(options) {
var callback, configFilePath, error, packageNames, settings;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
configFilePath = CSON.resolve(path.join(config.getAtomDirectory(), 'config'));
if (!configFilePath) {
callback("Could not find config.cson. Run Atom first?");
return;
}
run(options) {
var callback, configFilePath, error, packageNames, settings;
({callback} = options);
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
configFilePath = CSON.resolve(path.join(config.getAtomDirectory(), 'config'));
if (!configFilePath) {
callback("Could not find config.cson. Run Atom first?");
return;
}
try {
settings = CSON.readFileSync(configFilePath);
} catch (error1) {
error = error1;
callback(`Failed to load \`${configFilePath}\`: ${error.message}`);
return;
}
return this.getInstalledPackages((error, installedPackages) => {
try {
settings = CSON.readFileSync(configFilePath);
} catch (error1) {
error = error1;
callback("Failed to load `" + configFilePath + "`: " + error.message);
return;
}
return this.getInstalledPackages((function(_this) {
return function(error, installedPackages) {
var disabledPackages, installedPackageNames, keyPath, pkg, ref, result, uninstalledPackageNames;

@@ -77,8 +88,6 @@ if (error) {

})();
// uninstalledPackages = (name for name in packageNames when !installedPackageNames[name])
uninstalledPackageNames = _.difference(packageNames, installedPackageNames);
if (uninstalledPackageNames.length > 0) {
console.log(`Not Installed:\n ${uninstalledPackageNames.join('\n ')}`);
console.log("Not Installed:\n " + (uninstalledPackageNames.join('\n ')));
}
// only installed packages can be disabled
packageNames = _.difference(packageNames, uninstalledPackageNames);

@@ -97,19 +106,16 @@ if (packageNames.length === 0) {

error = error1;
callback(`Failed to save \`${configFilePath}\`: ${error.message}`);
callback("Failed to save `" + configFilePath + "`: " + error.message);
return;
}
console.log(`Disabled:\n ${packageNames.join('\n ')}`);
this.logSuccess();
console.log("Disabled:\n " + (packageNames.join('\n ')));
_this.logSuccess();
return callback();
});
}
};
})(this));
};
Disable.commandNames = ['disable'];
return Disable;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Docs, View, config, open, yargs;
var Docs, View, config, open, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -12,26 +15,34 @@ yargs = require('yargs');

module.exports = Docs = (function() {
class Docs extends View {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm docs [options] <package_name>\n\nOpen a package's homepage in the default browser.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.boolean('p').alias('p', 'print').describe('print', 'Print the URL instead of opening it');
}
module.exports = Docs = (function(superClass) {
extend(Docs, superClass);
openRepositoryUrl(repositoryUrl) {
return open(repositoryUrl);
function Docs() {
return Docs.__super__.constructor.apply(this, arguments);
}
Docs.commandNames = ['docs', 'home', 'open'];
Docs.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm docs [options] <package_name>\n\nOpen a package's homepage in the default browser.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.boolean('p').alias('p', 'print').describe('print', 'Print the URL instead of opening it');
};
Docs.prototype.openRepositoryUrl = function(repositoryUrl) {
return open(repositoryUrl);
};
Docs.prototype.run = function(options) {
var callback, packageName;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packageName = options.argv._[0];
if (!packageName) {
callback("Missing required package name");
return;
}
run(options) {
var callback, packageName;
({callback} = options);
options = this.parseOptions(options.commandArgs);
[packageName] = options.argv._;
if (!packageName) {
callback("Missing required package name");
return;
}
return this.getPackage(packageName, options, (error, pack) => {
return this.getPackage(packageName, options, (function(_this) {
return function(error, pack) {
var repository;

@@ -41,23 +52,20 @@ if (error != null) {

}
if (repository = this.getRepository(pack)) {
if (repository = _this.getRepository(pack)) {
if (options.argv.print) {
console.log(repository);
} else {
this.openRepositoryUrl(repository);
_this.openRepositoryUrl(repository);
}
return callback();
} else {
return callback(`Package "${packageName}" does not contain a repository URL`);
return callback("Package \"" + packageName + "\" does not contain a repository URL");
}
});
}
};
})(this));
};
Docs.commandNames = ['docs', 'home', 'open'];
return Docs;
}).call(this);
})(View);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Enable, _, config, path, yargs;
var CSON, Command, Enable, _, config, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,62 +19,64 @@ _ = require('underscore-plus');

module.exports = Enable = (function() {
class Enable extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm enable [<package_name>]...\n\nEnables the named package(s).");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
module.exports = Enable = (function(superClass) {
extend(Enable, superClass);
run(options) {
var callback, configFilePath, disabledPackages, error, errorPackages, keyPath, packageNames, ref, result, settings;
({callback} = options);
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
configFilePath = CSON.resolve(path.join(config.getAtomDirectory(), 'config'));
if (!configFilePath) {
callback("Could not find config.cson. Run Atom first?");
return;
}
try {
settings = CSON.readFileSync(configFilePath);
} catch (error1) {
error = error1;
callback(`Failed to load \`${configFilePath}\`: ${error.message}`);
return;
}
keyPath = '*.core.disabledPackages';
disabledPackages = (ref = _.valueForKeyPath(settings, keyPath)) != null ? ref : [];
errorPackages = _.difference(packageNames, disabledPackages);
if (errorPackages.length > 0) {
console.log(`Not Disabled:\n ${errorPackages.join('\n ')}`);
}
// can't enable a package that isn't disabled
packageNames = _.difference(packageNames, errorPackages);
if (packageNames.length === 0) {
callback("Please specify a package to enable");
return;
}
result = _.difference(disabledPackages, packageNames);
_.setValueForKeyPath(settings, keyPath, result);
try {
CSON.writeFileSync(configFilePath, settings);
} catch (error1) {
error = error1;
callback(`Failed to save \`${configFilePath}\`: ${error.message}`);
return;
}
console.log(`Enabled:\n ${packageNames.join('\n ')}`);
this.logSuccess();
return callback();
}
function Enable() {
return Enable.__super__.constructor.apply(this, arguments);
}
Enable.commandNames = ['enable'];
Enable.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm enable [<package_name>]...\n\nEnables the named package(s).");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Enable.commandNames = ['enable'];
Enable.prototype.run = function(options) {
var callback, configFilePath, disabledPackages, error, errorPackages, keyPath, packageNames, ref, result, settings;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
configFilePath = CSON.resolve(path.join(config.getAtomDirectory(), 'config'));
if (!configFilePath) {
callback("Could not find config.cson. Run Atom first?");
return;
}
try {
settings = CSON.readFileSync(configFilePath);
} catch (error1) {
error = error1;
callback("Failed to load `" + configFilePath + "`: " + error.message);
return;
}
keyPath = '*.core.disabledPackages';
disabledPackages = (ref = _.valueForKeyPath(settings, keyPath)) != null ? ref : [];
errorPackages = _.difference(packageNames, disabledPackages);
if (errorPackages.length > 0) {
console.log("Not Disabled:\n " + (errorPackages.join('\n ')));
}
packageNames = _.difference(packageNames, errorPackages);
if (packageNames.length === 0) {
callback("Please specify a package to enable");
return;
}
result = _.difference(disabledPackages, packageNames);
_.setValueForKeyPath(settings, keyPath, result);
try {
CSON.writeFileSync(configFilePath, settings);
} catch (error1) {
error = error1;
callback("Failed to save `" + configFilePath + "`: " + error.message);
return;
}
console.log("Enabled:\n " + (packageNames.join('\n ')));
this.logSuccess();
return callback();
};
return Enable;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Featured, _, config, request, tree, yargs;
var Command, Featured, _, config, request, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,55 +19,72 @@ _ = require('underscore-plus');

module.exports = Featured = (function() {
class Featured extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm featured\n apm featured --themes\n apm featured --compatible 0.49.0\n\nList the Atom packages and themes that are currently featured in the\natom.io registry.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('t', 'themes').boolean('themes').describe('themes', 'Only list themes');
options.alias('c', 'compatible').string('compatible').describe('compatible', 'Only list packages/themes compatible with this Atom version');
return options.boolean('json').describe('json', 'Output featured packages as JSON array');
module.exports = Featured = (function(superClass) {
extend(Featured, superClass);
function Featured() {
return Featured.__super__.constructor.apply(this, arguments);
}
Featured.commandNames = ['featured'];
Featured.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm featured\n apm featured --themes\n apm featured --compatible 0.49.0\n\nList the Atom packages and themes that are currently featured in the\natom.io registry.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('t', 'themes').boolean('themes').describe('themes', 'Only list themes');
options.alias('c', 'compatible').string('compatible').describe('compatible', 'Only list packages/themes compatible with this Atom version');
return options.boolean('json').describe('json', 'Output featured packages as JSON array');
};
Featured.prototype.getFeaturedPackagesByType = function(atomVersion, packageType, callback) {
var ref, requestSettings;
if (_.isFunction(atomVersion)) {
ref = [atomVersion, null], callback = ref[0], atomVersion = ref[1];
}
getFeaturedPackagesByType(atomVersion, packageType, callback) {
var requestSettings;
if (_.isFunction(atomVersion)) {
[callback, atomVersion] = [atomVersion, null];
}
requestSettings = {
url: `${config.getAtomApiUrl()}/${packageType}/featured`,
json: true
requestSettings = {
url: (config.getAtomApiUrl()) + "/" + packageType + "/featured",
json: true
};
if (atomVersion) {
requestSettings.qs = {
engine: atomVersion
};
if (atomVersion) {
requestSettings.qs = {
engine: atomVersion
};
}
return request.get(requestSettings, function(error, response, body) {
var message, packages;
if (body == null) {
body = [];
}
return request.get(requestSettings, function(error, response, body = []) {
var message, packages;
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
packages = body.filter(function(pack) {
var ref;
return (pack != null ? (ref = pack.releases) != null ? ref.latest : void 0 : void 0) != null;
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
packages = body.filter(function(pack) {
var ref1;
return (pack != null ? (ref1 = pack.releases) != null ? ref1.latest : void 0 : void 0) != null;
});
packages = packages.map(function(arg) {
var downloads, metadata, readme, stargazers_count;
readme = arg.readme, metadata = arg.metadata, downloads = arg.downloads, stargazers_count = arg.stargazers_count;
return _.extend({}, metadata, {
readme: readme,
downloads: downloads,
stargazers_count: stargazers_count
});
packages = packages.map(function({readme, metadata, downloads, stargazers_count}) {
return _.extend({}, metadata, {readme, downloads, stargazers_count});
});
packages = _.sortBy(packages, 'name');
return callback(null, packages);
} else {
message = request.getErrorMessage(response, body);
return callback(`Requesting packages failed: ${message}`);
}
});
}
});
packages = _.sortBy(packages, 'name');
return callback(null, packages);
} else {
message = request.getErrorMessage(response, body);
return callback("Requesting packages failed: " + message);
}
});
};
getAllFeaturedPackages(atomVersion, callback) {
return this.getFeaturedPackagesByType(atomVersion, 'packages', (error, packages) => {
Featured.prototype.getAllFeaturedPackages = function(atomVersion, callback) {
return this.getFeaturedPackagesByType(atomVersion, 'packages', (function(_this) {
return function(error, packages) {
if (error != null) {
return callback(error);
}
return this.getFeaturedPackagesByType(atomVersion, 'themes', function(error, themes) {
return _this.getFeaturedPackagesByType(atomVersion, 'themes', function(error, themes) {
if (error != null) {

@@ -75,53 +95,51 @@ return callback(error);

});
});
}
};
})(this));
};
run(options) {
var callback, listCallback;
({callback} = options);
options = this.parseOptions(options.commandArgs);
listCallback = function(error, packages) {
if (error != null) {
return callback(error);
Featured.prototype.run = function(options) {
var callback, listCallback;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
listCallback = function(error, packages) {
if (error != null) {
return callback(error);
}
if (options.argv.json) {
console.log(JSON.stringify(packages));
} else {
if (options.argv.themes) {
console.log('Featured Atom Themes'.cyan + " (" + packages.length + ")");
} else {
console.log('Featured Atom Packages'.cyan + " (" + packages.length + ")");
}
if (options.argv.json) {
console.log(JSON.stringify(packages));
} else {
if (options.argv.themes) {
console.log(`${'Featured Atom Themes'.cyan} (${packages.length})`);
} else {
console.log(`${'Featured Atom Packages'.cyan} (${packages.length})`);
tree(packages, function(arg) {
var description, downloads, label, name, stargazers_count, version;
name = arg.name, version = arg.version, description = arg.description, downloads = arg.downloads, stargazers_count = arg.stargazers_count;
label = name.yellow;
if (description) {
label += " " + (description.replace(/\s+/g, ' '));
}
tree(packages, function({name, version, description, downloads, stargazers_count}) {
var label;
label = name.yellow;
if (description) {
label += ` ${description.replace(/\s+/g, ' ')}`;
}
if (downloads >= 0 && stargazers_count >= 0) {
label += ` (${_.pluralize(downloads, 'download')}, ${_.pluralize(stargazers_count, 'star')})`.grey;
}
return label;
});
console.log();
console.log(`Use \`apm install\` to install them or visit ${'http://atom.io/packages'.underline} to read more about them.`);
console.log();
}
return callback();
};
if (options.argv.themes) {
return this.getFeaturedPackagesByType(options.argv.compatible, 'themes', listCallback);
} else {
return this.getAllFeaturedPackages(options.argv.compatible, listCallback);
if (downloads >= 0 && stargazers_count >= 0) {
label += (" (" + (_.pluralize(downloads, 'download')) + ", " + (_.pluralize(stargazers_count, 'star')) + ")").grey;
}
return label;
});
console.log();
console.log("Use `apm install` to install them or visit " + 'http://atom.io/packages'.underline + " to read more about them.");
console.log();
}
return callback();
};
if (options.argv.themes) {
return this.getFeaturedPackagesByType(options.argv.compatible, 'themes', listCallback);
} else {
return this.getAllFeaturedPackages(options.argv.compatible, listCallback);
}
};
Featured.commandNames = ['featured'];
return Featured;
}).call(this);
})(Command);
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -47,3 +48,3 @@ var _, fs, fsAdditions, ncp, path, rm, wrench;

} else {
wrench.mkdirSyncRecursive(path.dirname(destinationPath), 0o755);
wrench.mkdirSyncRecursive(path.dirname(destinationPath), 0x1ed);
return fs.rename(sourcePath, destinationPath, callback);

@@ -50,0 +51,0 @@ }

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

// Generated by CoffeeScript 1.12.7
(function() {
var _, addGitBashToEnv, addPortableGitToEnv, config, fs, npm, path, spawn;
({spawn} = require('child_process'));
spawn = require('child_process').spawn;

@@ -37,5 +38,5 @@ path = require('path');

if (env.Path) {
env.Path += `${path.delimiter}${cmdPath}${path.delimiter}${binPath}`;
env.Path += "" + path.delimiter + cmdPath + path.delimiter + binPath;
} else {
env.Path = `${cmdPath}${path.delimiter}${binPath}`;
env.Path = "" + cmdPath + path.delimiter + binPath;
}

@@ -62,5 +63,5 @@ break;

if (env.Path) {
return env.Path += `${path.delimiter}${cmdPath}${path.delimiter}${binPath}`;
return env.Path += "" + path.delimiter + cmdPath + path.delimiter + binPath;
} else {
return env.Path = `${cmdPath}${path.delimiter}${binPath}`;
return env.Path = "" + cmdPath + path.delimiter + binPath;
}

@@ -97,5 +98,5 @@ };

return spawned.on('close', function(code) {
var gitName, version, versionName;
var gitName, ref1, version, versionName;
if (code === 0) {
[gitName, versionName, version] = Buffer.concat(outputChunks).toString().split(' ');
ref1 = Buffer.concat(outputChunks).toString().split(' '), gitName = ref1[0], versionName = ref1[1], version = ref1[2];
version = version != null ? version.trim() : void 0;

@@ -102,0 +103,0 @@ }

@@ -0,4 +1,7 @@

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Init, fs, path, yargs,
indexOf = [].indexOf;
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -13,68 +16,78 @@ path = require('path');

module.exports = Init = (function() {
class Init extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage:\n apm init -p <package-name>\n apm init -p <package-name> --syntax <javascript-or-coffeescript>\n apm init -p <package-name> -c ~/Downloads/r.tmbundle\n apm init -p <package-name> -c https://github.com/textmate/r.tmbundle\n apm init -p <package-name> --template /path/to/your/package/template\n\n apm init -t <theme-name>\n apm init -t <theme-name> -c ~/Downloads/Dawn.tmTheme\n apm init -t <theme-name> -c https://raw.github.com/chriskempson/tomorrow-theme/master/textmate/Tomorrow-Night-Eighties.tmTheme\n apm init -t <theme-name> --template /path/to/your/theme/template\n\n apm init -l <language-name>\n\nGenerates code scaffolding for either a theme or package depending\non the option selected.");
options.alias('p', 'package').string('package').describe('package', 'Generates a basic package');
options.alias('s', 'syntax').string('syntax').describe('syntax', 'Sets package syntax to CoffeeScript or JavaScript');
options.alias('t', 'theme').string('theme').describe('theme', 'Generates a basic theme');
options.alias('l', 'language').string('language').describe('language', 'Generates a basic language package');
options.alias('c', 'convert').string('convert').describe('convert', 'Path or URL to TextMate bundle/theme to convert');
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.string('template').describe('template', 'Path to the package or theme template');
}
module.exports = Init = (function(superClass) {
extend(Init, superClass);
run(options) {
var callback, languageName, languagePath, packagePath, ref, ref1, ref2, syntax, templatePath, themePath;
({callback} = options);
options = this.parseOptions(options.commandArgs);
if (((ref = options.argv.package) != null ? ref.length : void 0) > 0) {
if (options.argv.convert) {
return this.convertPackage(options.argv.convert, options.argv.package, callback);
} else {
packagePath = path.resolve(options.argv.package);
syntax = options.argv.syntax || this.supportedSyntaxes[0];
if (indexOf.call(this.supportedSyntaxes, syntax) < 0) {
return callback(`You must specify one of ${this.supportedSyntaxes.join(', ')} after the --syntax argument`);
}
templatePath = this.getTemplatePath(options.argv, `package-${syntax}`);
this.generateFromTemplate(packagePath, templatePath);
return callback();
function Init() {
return Init.__super__.constructor.apply(this, arguments);
}
Init.commandNames = ['init'];
Init.prototype.supportedSyntaxes = ['coffeescript', 'javascript'];
Init.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage:\n apm init -p <package-name>\n apm init -p <package-name> --syntax <javascript-or-coffeescript>\n apm init -p <package-name> -c ~/Downloads/r.tmbundle\n apm init -p <package-name> -c https://github.com/textmate/r.tmbundle\n apm init -p <package-name> --template /path/to/your/package/template\n\n apm init -t <theme-name>\n apm init -t <theme-name> -c ~/Downloads/Dawn.tmTheme\n apm init -t <theme-name> -c https://raw.github.com/chriskempson/tomorrow-theme/master/textmate/Tomorrow-Night-Eighties.tmTheme\n apm init -t <theme-name> --template /path/to/your/theme/template\n\n apm init -l <language-name>\n\nGenerates code scaffolding for either a theme or package depending\non the option selected.");
options.alias('p', 'package').string('package').describe('package', 'Generates a basic package');
options.alias('s', 'syntax').string('syntax').describe('syntax', 'Sets package syntax to CoffeeScript or JavaScript');
options.alias('t', 'theme').string('theme').describe('theme', 'Generates a basic theme');
options.alias('l', 'language').string('language').describe('language', 'Generates a basic language package');
options.alias('c', 'convert').string('convert').describe('convert', 'Path or URL to TextMate bundle/theme to convert');
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.string('template').describe('template', 'Path to the package or theme template');
};
Init.prototype.run = function(options) {
var callback, languageName, languagePath, packagePath, ref, ref1, ref2, syntax, templatePath, themePath;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
if (((ref = options.argv["package"]) != null ? ref.length : void 0) > 0) {
if (options.argv.convert) {
return this.convertPackage(options.argv.convert, options.argv["package"], callback);
} else {
packagePath = path.resolve(options.argv["package"]);
syntax = options.argv.syntax || this.supportedSyntaxes[0];
if (indexOf.call(this.supportedSyntaxes, syntax) < 0) {
return callback("You must specify one of " + (this.supportedSyntaxes.join(', ')) + " after the --syntax argument");
}
} else if (((ref1 = options.argv.theme) != null ? ref1.length : void 0) > 0) {
if (options.argv.convert) {
return this.convertTheme(options.argv.convert, options.argv.theme, callback);
} else {
themePath = path.resolve(options.argv.theme);
templatePath = this.getTemplatePath(options.argv, 'theme');
this.generateFromTemplate(themePath, templatePath);
return callback();
}
} else if (((ref2 = options.argv.language) != null ? ref2.length : void 0) > 0) {
languagePath = path.resolve(options.argv.language);
languageName = path.basename(languagePath).replace(/^language-/, '');
languagePath = path.join(path.dirname(languagePath), `language-${languageName}`);
templatePath = this.getTemplatePath(options.argv, 'language');
this.generateFromTemplate(languagePath, templatePath, languageName);
templatePath = this.getTemplatePath(options.argv, "package-" + syntax);
this.generateFromTemplate(packagePath, templatePath);
return callback();
} else if (options.argv.package != null) {
return callback('You must specify a path after the --package argument');
} else if (options.argv.theme != null) {
return callback('You must specify a path after the --theme argument');
}
} else if (((ref1 = options.argv.theme) != null ? ref1.length : void 0) > 0) {
if (options.argv.convert) {
return this.convertTheme(options.argv.convert, options.argv.theme, callback);
} else {
return callback('You must specify either --package, --theme or --language to `apm init`');
themePath = path.resolve(options.argv.theme);
templatePath = this.getTemplatePath(options.argv, 'theme');
this.generateFromTemplate(themePath, templatePath);
return callback();
}
} else if (((ref2 = options.argv.language) != null ? ref2.length : void 0) > 0) {
languagePath = path.resolve(options.argv.language);
languageName = path.basename(languagePath).replace(/^language-/, '');
languagePath = path.join(path.dirname(languagePath), "language-" + languageName);
templatePath = this.getTemplatePath(options.argv, 'language');
this.generateFromTemplate(languagePath, templatePath, languageName);
return callback();
} else if (options.argv["package"] != null) {
return callback('You must specify a path after the --package argument');
} else if (options.argv.theme != null) {
return callback('You must specify a path after the --theme argument');
} else {
return callback('You must specify either --package, --theme or --language to `apm init`');
}
};
convertPackage(sourcePath, destinationPath, callback) {
var PackageConverter, converter;
if (!destinationPath) {
callback("Specify directory to create package in using --package");
return;
}
PackageConverter = require('./package-converter');
converter = new PackageConverter(sourcePath, destinationPath);
return converter.convert((error) => {
Init.prototype.convertPackage = function(sourcePath, destinationPath, callback) {
var PackageConverter, converter;
if (!destinationPath) {
callback("Specify directory to create package in using --package");
return;
}
PackageConverter = require('./package-converter');
converter = new PackageConverter(sourcePath, destinationPath);
return converter.convert((function(_this) {
return function(error) {
var templatePath;

@@ -86,17 +99,19 @@ if (error != null) {

templatePath = path.resolve(__dirname, '..', 'templates', 'bundle');
this.generateFromTemplate(destinationPath, templatePath);
_this.generateFromTemplate(destinationPath, templatePath);
return callback();
}
});
};
})(this));
};
Init.prototype.convertTheme = function(sourcePath, destinationPath, callback) {
var ThemeConverter, converter;
if (!destinationPath) {
callback("Specify directory to create theme in using --theme");
return;
}
convertTheme(sourcePath, destinationPath, callback) {
var ThemeConverter, converter;
if (!destinationPath) {
callback("Specify directory to create theme in using --theme");
return;
}
ThemeConverter = require('./theme-converter');
converter = new ThemeConverter(sourcePath, destinationPath);
return converter.convert((error) => {
ThemeConverter = require('./theme-converter');
converter = new ThemeConverter(sourcePath, destinationPath);
return converter.convert((function(_this) {
return function(error) {
var templatePath;

@@ -108,3 +123,3 @@ if (error != null) {

templatePath = path.resolve(__dirname, '..', 'templates', 'theme');
this.generateFromTemplate(destinationPath, templatePath);
_this.generateFromTemplate(destinationPath, templatePath);
fs.removeSync(path.join(destinationPath, 'styles', 'colors.less'));

@@ -114,51 +129,53 @@ fs.removeSync(path.join(destinationPath, 'LICENSE.md'));

}
});
};
})(this));
};
Init.prototype.generateFromTemplate = function(packagePath, templatePath, packageName) {
var childPath, contents, i, len, packageAuthor, ref, relativePath, results, sourcePath, templateChildPath;
if (packageName == null) {
packageName = path.basename(packagePath);
}
generateFromTemplate(packagePath, templatePath, packageName) {
var childPath, contents, i, len, packageAuthor, ref, relativePath, results, sourcePath, templateChildPath;
if (packageName == null) {
packageName = path.basename(packagePath);
packageAuthor = process.env.GITHUB_USER || 'atom';
fs.makeTreeSync(packagePath);
ref = fs.listRecursive(templatePath);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
childPath = ref[i];
templateChildPath = path.resolve(templatePath, childPath);
relativePath = templateChildPath.replace(templatePath, "");
relativePath = relativePath.replace(/^\//, '');
relativePath = relativePath.replace(/\.template$/, '');
relativePath = this.replacePackageNamePlaceholders(relativePath, packageName);
sourcePath = path.join(packagePath, relativePath);
if (fs.existsSync(sourcePath)) {
continue;
}
packageAuthor = process.env.GITHUB_USER || 'atom';
fs.makeTreeSync(packagePath);
ref = fs.listRecursive(templatePath);
results = [];
for (i = 0, len = ref.length; i < len; i++) {
childPath = ref[i];
templateChildPath = path.resolve(templatePath, childPath);
relativePath = templateChildPath.replace(templatePath, "");
relativePath = relativePath.replace(/^\//, '');
relativePath = relativePath.replace(/\.template$/, '');
relativePath = this.replacePackageNamePlaceholders(relativePath, packageName);
sourcePath = path.join(packagePath, relativePath);
if (fs.existsSync(sourcePath)) {
continue;
}
if (fs.isDirectorySync(templateChildPath)) {
results.push(fs.makeTreeSync(sourcePath));
} else if (fs.isFileSync(templateChildPath)) {
fs.makeTreeSync(path.dirname(sourcePath));
contents = fs.readFileSync(templateChildPath).toString();
contents = this.replacePackageNamePlaceholders(contents, packageName);
contents = this.replacePackageAuthorPlaceholders(contents, packageAuthor);
contents = this.replaceCurrentYearPlaceholders(contents);
results.push(fs.writeFileSync(sourcePath, contents));
} else {
results.push(void 0);
}
if (fs.isDirectorySync(templateChildPath)) {
results.push(fs.makeTreeSync(sourcePath));
} else if (fs.isFileSync(templateChildPath)) {
fs.makeTreeSync(path.dirname(sourcePath));
contents = fs.readFileSync(templateChildPath).toString();
contents = this.replacePackageNamePlaceholders(contents, packageName);
contents = this.replacePackageAuthorPlaceholders(contents, packageAuthor);
contents = this.replaceCurrentYearPlaceholders(contents);
results.push(fs.writeFileSync(sourcePath, contents));
} else {
results.push(void 0);
}
return results;
}
return results;
};
replacePackageAuthorPlaceholders(string, packageAuthor) {
return string.replace(/__package-author__/g, packageAuthor);
}
Init.prototype.replacePackageAuthorPlaceholders = function(string, packageAuthor) {
return string.replace(/__package-author__/g, packageAuthor);
};
replacePackageNamePlaceholders(string, packageName) {
var placeholderRegex;
placeholderRegex = /__(?:(package-name)|([pP]ackageName)|(package_name))__/g;
return string = string.replace(placeholderRegex, (match, dash, camel, underscore) => {
Init.prototype.replacePackageNamePlaceholders = function(string, packageName) {
var placeholderRegex;
placeholderRegex = /__(?:(package-name)|([pP]ackageName)|(package_name))__/g;
return string = string.replace(placeholderRegex, (function(_this) {
return function(match, dash, camel, underscore) {
if (dash) {
return this.dasherize(packageName);
return _this.dasherize(packageName);
} else if (camel) {

@@ -170,59 +187,54 @@ if (/[a-z]/.test(camel[0])) {

}
return this.camelize(packageName);
return _this.camelize(packageName);
} else if (underscore) {
return this.underscore(packageName);
return _this.underscore(packageName);
}
});
}
};
})(this));
};
replaceCurrentYearPlaceholders(string) {
return string.replace('__current_year__', new Date().getFullYear());
Init.prototype.replaceCurrentYearPlaceholders = function(string) {
return string.replace('__current_year__', new Date().getFullYear());
};
Init.prototype.getTemplatePath = function(argv, templateType) {
if (argv.template != null) {
return path.resolve(argv.template);
} else {
return path.resolve(__dirname, '..', 'templates', templateType);
}
};
getTemplatePath(argv, templateType) {
if (argv.template != null) {
return path.resolve(argv.template);
Init.prototype.dasherize = function(string) {
string = string[0].toLowerCase() + string.slice(1);
return string.replace(/([A-Z])|(_)/g, function(m, letter, underscore) {
if (letter) {
return "-" + letter.toLowerCase();
} else {
return path.resolve(__dirname, '..', 'templates', templateType);
return "-";
}
}
});
};
dasherize(string) {
string = string[0].toLowerCase() + string.slice(1);
return string.replace(/([A-Z])|(_)/g, function(m, letter, underscore) {
if (letter) {
return "-" + letter.toLowerCase();
} else {
return "-";
}
});
}
Init.prototype.camelize = function(string) {
return string.replace(/[_-]+(\w)/g, function(m) {
return m[1].toUpperCase();
});
};
camelize(string) {
return string.replace(/[_-]+(\w)/g, function(m) {
return m[1].toUpperCase();
});
}
underscore(string) {
string = string[0].toLowerCase() + string.slice(1);
return string.replace(/([A-Z])|(-)/g, function(m, letter, dash) {
if (letter) {
return "_" + letter.toLowerCase();
} else {
return "_";
}
});
}
Init.prototype.underscore = function(string) {
string = string[0].toLowerCase() + string.slice(1);
return string.replace(/([A-Z])|(-)/g, function(m, letter, dash) {
if (letter) {
return "_" + letter.toLowerCase();
} else {
return "_";
}
});
};
Init.commandNames = ['init'];
Init.prototype.supportedSyntaxes = ['coffeescript', 'javascript'];
return Init;
}).call(this);
})(Command);
}).call(this);

@@ -0,4 +1,8 @@

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Git, Install, RebuildModuleCache, _, assert, async, config, fs, hostedGitInfo, isDeprecatedPackage, path, request, semver, temp, yargs,
boundMethodCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } };
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;

@@ -35,70 +39,85 @@ assert = require('assert');

({isDeprecatedPackage} = require('./deprecated-packages'));
isDeprecatedPackage = require('./deprecated-packages').isDeprecatedPackage;
module.exports = Install = (function() {
class Install extends Command {
constructor() {
super();
this.installModules = this.installModules.bind(this);
this.installGitPackageDependencies = this.installGitPackageDependencies.bind(this);
this.atomDirectory = config.getAtomDirectory();
this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages');
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
this.repoLocalPackagePathRegex = /^file:(?!\/\/)(.*)/;
}
module.exports = Install = (function(superClass) {
extend(Install, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm install [<package_name>...]\n apm install <package_name>@<package_version>\n apm install <git_remote>\n apm install <github_username>/<github_project>\n apm install --packages-file my-packages.txt\n apm i (with any of the previous argument usage)\n\nInstall the given Atom package to ~/.atom/packages/<package_name>.\n\nIf no package name is given then all the dependencies in the package.json\nfile are installed to the node_modules folder in the current working\ndirectory.\n\nA packages file can be specified that is a newline separated list of\npackage names to install with optional versions using the\n`package-name@version` syntax.");
options.alias('c', 'compatible').string('compatible').describe('compatible', 'Only install packages/themes compatible with this Atom version');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('s', 'silent').boolean('silent').describe('silent', 'Set the npm log level to silent');
options.alias('q', 'quiet').boolean('quiet').describe('quiet', 'Set the npm log level to warn');
options.boolean('check').describe('check', 'Check that native build tools are installed');
options.boolean('verbose').default('verbose', false).describe('verbose', 'Show verbose debug information');
options.string('packages-file').describe('packages-file', 'A text file containing the packages to install');
return options.boolean('production').describe('production', 'Do not install dev dependencies');
Install.commandNames = ['install', 'i'];
function Install() {
this.installGitPackageDependencies = bind(this.installGitPackageDependencies, this);
this.installModules = bind(this.installModules, this);
Install.__super__.constructor.call(this);
this.atomDirectory = config.getAtomDirectory();
this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages');
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
this.repoLocalPackagePathRegex = /^file:(?!\/\/)(.*)/;
}
Install.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm install [<package_name>...]\n apm install <package_name>@<package_version>\n apm install <git_remote>\n apm install <github_username>/<github_project>\n apm install --packages-file my-packages.txt\n apm i (with any of the previous argument usage)\n\nInstall the given Atom package to ~/.atom/packages/<package_name>.\n\nIf no package name is given then all the dependencies in the package.json\nfile are installed to the node_modules folder in the current working\ndirectory.\n\nA packages file can be specified that is a newline separated list of\npackage names to install with optional versions using the\n`package-name@version` syntax.");
options.alias('c', 'compatible').string('compatible').describe('compatible', 'Only install packages/themes compatible with this Atom version');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('s', 'silent').boolean('silent').describe('silent', 'Set the npm log level to silent');
options.alias('q', 'quiet').boolean('quiet').describe('quiet', 'Set the npm log level to warn');
options.boolean('check').describe('check', 'Check that native build tools are installed');
options.boolean('verbose')["default"]('verbose', false).describe('verbose', 'Show verbose debug information');
options.string('packages-file').describe('packages-file', 'A text file containing the packages to install');
return options.boolean('production').describe('production', 'Do not install dev dependencies');
};
Install.prototype.installModule = function(options, pack, moduleURI, callback) {
var env, installArgs, installDirectory, installGlobally, installOptions, nodeModulesDirectory, ref, vsArgs;
installGlobally = (ref = options.installGlobally) != null ? ref : true;
installArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'install'];
installArgs.push(moduleURI);
installArgs.push.apply(installArgs, this.getNpmBuildFlags());
if (installGlobally) {
installArgs.push("--global-style");
}
installModule(options, pack, moduleURI, callback) {
var env, installArgs, installDirectory, installGlobally, installOptions, nodeModulesDirectory, ref, vsArgs;
installGlobally = (ref = options.installGlobally) != null ? ref : true;
installArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'install'];
installArgs.push(moduleURI);
installArgs.push(...this.getNpmBuildFlags());
if (installGlobally) {
installArgs.push("--global-style");
}
if (options.argv.silent) {
installArgs.push('--silent');
}
if (options.argv.quiet) {
installArgs.push('--quiet');
}
if (options.argv.production) {
installArgs.push('--production');
}
if (vsArgs = this.getVisualStudioFlags()) {
installArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
installOptions = {env};
if (this.verbose) {
installOptions.streaming = true;
}
if (installGlobally) {
installDirectory = temp.mkdirSync('apm-install-dir-');
nodeModulesDirectory = path.join(installDirectory, 'node_modules');
fs.makeTreeSync(nodeModulesDirectory);
installOptions.cwd = installDirectory;
}
return this.fork(this.atomNpmPath, installArgs, installOptions, (code, stderr = '', stdout = '') => {
if (options.argv.silent) {
installArgs.push('--silent');
}
if (options.argv.quiet) {
installArgs.push('--quiet');
}
if (options.argv.production) {
installArgs.push('--production');
}
if (options.argv.verbose) {
installArgs.push('--verbose');
}
if (vsArgs = this.getVisualStudioFlags()) {
installArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
installOptions = {
env: env
};
if (this.verbose) {
installOptions.streaming = true;
}
if (installGlobally) {
installDirectory = temp.mkdirSync('apm-install-dir-');
nodeModulesDirectory = path.join(installDirectory, 'node_modules');
fs.makeTreeSync(nodeModulesDirectory);
installOptions.cwd = installDirectory;
}
return this.fork(this.atomNpmPath, installArgs, installOptions, (function(_this) {
return function(code, stderr, stdout) {
var child, children, commands, destination, error, source;
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code === 0) {

@@ -113,18 +132,18 @@ if (installGlobally) {

source = path.join(nodeModulesDirectory, child);
destination = path.join(this.atomPackagesDirectory, child);
destination = path.join(_this.atomPackagesDirectory, child);
commands.push(function(next) {
return fs.cp(source, destination, next);
});
commands.push((next) => {
return this.buildModuleCache(pack.name, next);
commands.push(function(next) {
return _this.buildModuleCache(pack.name, next);
});
commands.push((next) => {
return this.warmCompileCache(pack.name, next);
commands.push(function(next) {
return _this.warmCompileCache(pack.name, next);
});
return async.waterfall(commands, (error) => {
return async.waterfall(commands, function(error) {
if (error != null) {
this.logFailure();
_this.logFailure();
} else {
if (!options.argv.json) {
this.logSuccess();
_this.logSuccess();
}

@@ -146,173 +165,166 @@ }

fs.removeSync(installDirectory);
this.logFailure();
_this.logFailure();
}
error = `${stdout}\n${stderr}`;
error = stdout + "\n" + stderr;
if (error.indexOf('code ENOGIT') !== -1) {
error = this.getGitErrorMessage(pack);
error = _this.getGitErrorMessage(pack);
}
return callback(error);
}
});
};
})(this));
};
Install.prototype.getGitErrorMessage = function(pack) {
var message;
message = "Failed to install " + pack.name + " because Git was not found.\n\nThe " + pack.name + " package has module dependencies that cannot be installed without Git.\n\nYou need to install Git and add it to your path environment variable in order to install this package.\n";
switch (process.platform) {
case 'win32':
message += "\nYou can install Git by downloading, installing, and launching GitHub for Windows: https://windows.github.com\n";
break;
case 'linux':
message += "\nYou can install Git from your OS package manager.\n";
}
message += "\nRun apm -v after installing Git to see what version has been detected.";
return message;
};
getGitErrorMessage(pack) {
var message;
message = `Failed to install ${pack.name} because Git was not found.\n\nThe ${pack.name} package has module dependencies that cannot be installed without Git.\n\nYou need to install Git and add it to your path environment variable in order to install this package.\n`;
switch (process.platform) {
case 'win32':
message += "\nYou can install Git by downloading, installing, and launching GitHub for Windows: https://windows.github.com\n";
break;
case 'linux':
message += "\nYou can install Git from your OS package manager.\n";
}
message += "\nRun apm -v after installing Git to see what version has been detected.";
return message;
Install.prototype.installModules = function(options, callback) {
if (!options.argv.json) {
process.stdout.write('Installing modules ');
}
installModules(options, callback) {
boundMethodCheck(this, Install);
if (!options.argv.json) {
process.stdout.write('Installing modules ');
}
return this.forkInstallCommand(options, (...args) => {
return this.forkInstallCommand(options, (function(_this) {
return function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
if (options.argv.json) {
return this.logCommandResultsIfFail(callback, ...args);
return _this.logCommandResultsIfFail.apply(_this, [callback].concat(slice.call(args)));
} else {
return this.logCommandResults(callback, ...args);
return _this.logCommandResults.apply(_this, [callback].concat(slice.call(args)));
}
});
};
})(this));
};
Install.prototype.forkInstallCommand = function(options, callback) {
var env, installArgs, installOptions, vsArgs;
installArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'install'];
installArgs.push.apply(installArgs, this.getNpmBuildFlags());
if (options.argv.silent) {
installArgs.push('--silent');
}
if (options.argv.quiet) {
installArgs.push('--quiet');
}
if (options.argv.production) {
installArgs.push('--production');
}
if (vsArgs = this.getVisualStudioFlags()) {
installArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
installOptions = {
env: env
};
if (options.cwd) {
installOptions.cwd = options.cwd;
}
if (this.verbose) {
installOptions.streaming = true;
}
return this.fork(this.atomNpmPath, installArgs, installOptions, callback);
};
forkInstallCommand(options, callback) {
var env, installArgs, installOptions, vsArgs;
installArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'install'];
installArgs.push(...this.getNpmBuildFlags());
if (options.argv.silent) {
installArgs.push('--silent');
Install.prototype.requestPackage = function(packageName, callback) {
var requestSettings;
requestSettings = {
url: (config.getAtomPackagesUrl()) + "/" + packageName,
json: true,
retries: 4
};
return request.get(requestSettings, function(error, response, body) {
var message;
if (body == null) {
body = {};
}
if (options.argv.quiet) {
installArgs.push('--quiet');
if (error != null) {
message = "Request for package information failed: " + error.message;
if (error.code) {
message += " (" + error.code + ")";
}
return callback(message);
} else if (response.statusCode !== 200) {
message = request.getErrorMessage(response, body);
return callback("Request for package information failed: " + message);
} else {
if (body.releases.latest) {
return callback(null, body);
} else {
return callback("No releases available for " + packageName);
}
}
if (options.argv.production) {
installArgs.push('--production');
}
if (vsArgs = this.getVisualStudioFlags()) {
installArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
installOptions = {env};
if (options.cwd) {
installOptions.cwd = options.cwd;
}
if (this.verbose) {
installOptions.streaming = true;
}
return this.fork(this.atomNpmPath, installArgs, installOptions, callback);
}
});
};
// Request package information from the atom.io API for a given package name.
// packageName - The string name of the package to request.
// callback - The function to invoke when the request completes with an error
// as the first argument and an object as the second.
requestPackage(packageName, callback) {
var requestSettings;
requestSettings = {
url: `${config.getAtomPackagesUrl()}/${packageName}`,
json: true,
retries: 4
};
return request.get(requestSettings, function(error, response, body = {}) {
var message;
if (error != null) {
message = `Request for package information failed: ${error.message}`;
if (error.code) {
message += ` (${error.code})`;
}
return callback(message);
} else if (response.statusCode !== 200) {
message = request.getErrorMessage(response, body);
return callback(`Request for package information failed: ${message}`);
} else {
if (body.releases.latest) {
return callback(null, body);
} else {
return callback(`No releases available for ${packageName}`);
}
}
});
Install.prototype.isPackageInstalled = function(packageName, packageVersion) {
var error, ref, version;
try {
version = ((ref = CSON.readFileSync(CSON.resolve(path.join('node_modules', packageName, 'package')))) != null ? ref : {}).version;
return packageVersion === version;
} catch (error1) {
error = error1;
return false;
}
};
// Is the package at the specified version already installed?
// * packageName: The string name of the package.
// * packageVersion: The string version of the package.
isPackageInstalled(packageName, packageVersion) {
var error, ref, version;
try {
({version} = (ref = CSON.readFileSync(CSON.resolve(path.join('node_modules', packageName, 'package')))) != null ? ref : {});
return packageVersion === version;
} catch (error1) {
error = error1;
return false;
Install.prototype.installRegisteredPackage = function(metadata, options, callback) {
var installGlobally, label, packageName, packageVersion, ref;
packageName = metadata.name;
packageVersion = metadata.version;
installGlobally = (ref = options.installGlobally) != null ? ref : true;
if (!installGlobally) {
if (packageVersion && this.isPackageInstalled(packageName, packageVersion)) {
callback(null, {});
return;
}
}
// Install the package with the given name and optional version
// metadata - The package metadata object with at least a name key. A version
// key is also supported. The version defaults to the latest if
// unspecified.
// options - The installation options object.
// callback - The function to invoke when installation completes with an
// error as the first argument.
installRegisteredPackage(metadata, options, callback) {
var installGlobally, label, packageName, packageVersion, ref;
packageName = metadata.name;
packageVersion = metadata.version;
installGlobally = (ref = options.installGlobally) != null ? ref : true;
if (!installGlobally) {
if (packageVersion && this.isPackageInstalled(packageName, packageVersion)) {
callback(null, {});
return;
}
label = packageName;
if (packageVersion) {
label += "@" + packageVersion;
}
if (!options.argv.json) {
process.stdout.write("Installing " + label + " ");
if (installGlobally) {
process.stdout.write("to " + this.atomPackagesDirectory + " ");
}
label = packageName;
if (packageVersion) {
label += `@${packageVersion}`;
}
if (!options.argv.json) {
process.stdout.write(`Installing ${label} `);
if (installGlobally) {
process.stdout.write(`to ${this.atomPackagesDirectory} `);
}
}
return this.requestPackage(packageName, (error, pack) => {
}
return this.requestPackage(packageName, (function(_this) {
return function(error, pack) {
var commands, ref1, ref2, tarball;
if (error != null) {
this.logFailure();
_this.logFailure();
return callback(error);
} else {
if (packageVersion == null) {
packageVersion = this.getLatestCompatibleVersion(pack);
packageVersion = _this.getLatestCompatibleVersion(pack);
}
if (!packageVersion) {
this.logFailure();
callback(`No available version compatible with the installed Atom version: ${this.installedAtomVersion}`);
_this.logFailure();
callback("No available version compatible with the installed Atom version: " + _this.installedAtomVersion);
return;
}
({tarball} = (ref1 = (ref2 = pack.versions[packageVersion]) != null ? ref2.dist : void 0) != null ? ref1 : {});
tarball = ((ref1 = (ref2 = pack.versions[packageVersion]) != null ? ref2.dist : void 0) != null ? ref1 : {}).tarball;
if (!tarball) {
this.logFailure();
callback(`Package version: ${packageVersion} not found`);
_this.logFailure();
callback("Package version: " + packageVersion + " not found");
return;
}
commands = [];
commands.push((next) => {
return this.installModule(options, pack, tarball, next);
commands.push(function(next) {
return _this.installModule(options, pack, tarball, next);
});

@@ -322,24 +334,28 @@ if (installGlobally && (packageName.localeCompare(pack.name, 'en', {

}) !== 0)) {
commands.push((newPack, next) => { // package was renamed; delete old package folder
fs.removeSync(path.join(this.atomPackagesDirectory, packageName));
commands.push(function(newPack, next) {
fs.removeSync(path.join(_this.atomPackagesDirectory, packageName));
return next(null, newPack);
});
}
commands.push(function({installPath}, next) {
var json;
commands.push(function(arg, next) {
var installPath, json;
installPath = arg.installPath;
if (installPath != null) {
metadata = JSON.parse(fs.readFileSync(path.join(installPath, 'package.json'), 'utf8'));
json = {installPath, metadata};
json = {
installPath: installPath,
metadata: metadata
};
return next(null, json);
} else {
return next(null, {}); // installed locally, no install path data
return next(null, {});
}
});
return async.waterfall(commands, (error, json) => {
return async.waterfall(commands, function(error, json) {
if (!installGlobally) {
if (error != null) {
this.logFailure();
_this.logFailure();
} else {
if (!options.argv.json) {
this.logSuccess();
_this.logSuccess();
}

@@ -351,187 +367,193 @@ }

}
});
}
};
})(this));
};
// Install the package with the given name and local path
// packageName - The name of the package
// packagePath - The local path of the package in the form "file:./packages/package-name"
// options - The installation options object.
// callback - The function to invoke when installation completes with an
// error as the first argument.
installLocalPackage(packageName, packagePath, options, callback) {
var commands;
if (!options.argv.json) {
process.stdout.write(`Installing ${packageName} from ${packagePath.slice('file:'.length)} `);
commands = [];
commands.push((next) => {
return this.installModule(options, {
Install.prototype.installLocalPackage = function(packageName, packagePath, options, callback) {
var commands;
if (!options.argv.json) {
process.stdout.write("Installing " + packageName + " from " + (packagePath.slice('file:'.length)) + " ");
commands = [];
commands.push((function(_this) {
return function(next) {
return _this.installModule(options, {
name: packageName
}, packagePath, next);
});
commands.push(function({installPath}, next) {
var json, metadata;
if (installPath != null) {
metadata = JSON.parse(fs.readFileSync(path.join(installPath, 'package.json'), 'utf8'));
json = {installPath, metadata};
return next(null, json);
} else {
return next(null, {}); // installed locally, no install path data
}
});
return async.waterfall(commands, (error, json) => {
};
})(this));
commands.push(function(arg, next) {
var installPath, json, metadata;
installPath = arg.installPath;
if (installPath != null) {
metadata = JSON.parse(fs.readFileSync(path.join(installPath, 'package.json'), 'utf8'));
json = {
installPath: installPath,
metadata: metadata
};
return next(null, json);
} else {
return next(null, {});
}
});
return async.waterfall(commands, (function(_this) {
return function(error, json) {
if (error != null) {
this.logFailure();
_this.logFailure();
} else {
if (!options.argv.json) {
this.logSuccess();
_this.logSuccess();
}
}
return callback(error, json);
});
}
};
})(this));
}
};
// Install all the package dependencies found in the package.json file.
// options - The installation options
// callback - The callback function to invoke when done with an error as the
// first argument.
installPackageDependencies(options, callback) {
var commands, name, ref, version;
options = _.extend({}, options, {
installGlobally: false
});
commands = [];
ref = this.getPackageDependencies();
for (name in ref) {
version = ref[name];
((name, version) => {
return commands.push((next) => {
if (this.repoLocalPackagePathRegex.test(version)) {
return this.installLocalPackage(name, version, options, next);
} else {
return this.installRegisteredPackage({name, version}, options, next);
}
});
})(name, version);
}
return async.series(commands, callback);
Install.prototype.installPackageDependencies = function(options, callback) {
var commands, fn, name, ref, version;
options = _.extend({}, options, {
installGlobally: false
});
commands = [];
ref = this.getPackageDependencies();
fn = (function(_this) {
return function(name, version) {
return commands.push(function(next) {
if (_this.repoLocalPackagePathRegex.test(version)) {
return _this.installLocalPackage(name, version, options, next);
} else {
return _this.installRegisteredPackage({
name: name,
version: version
}, options, next);
}
});
};
})(this);
for (name in ref) {
version = ref[name];
fn(name, version);
}
return async.series(commands, callback);
};
installDependencies(options, callback) {
var commands;
options.installGlobally = false;
commands = [];
commands.push((callback) => {
return this.installModules(options, callback);
});
commands.push((callback) => {
return this.installPackageDependencies(options, callback);
});
return async.waterfall(commands, callback);
}
Install.prototype.installDependencies = function(options, callback) {
var commands;
options.installGlobally = false;
commands = [];
commands.push((function(_this) {
return function(callback) {
return _this.installModules(options, callback);
};
})(this));
commands.push((function(_this) {
return function(callback) {
return _this.installPackageDependencies(options, callback);
};
})(this));
return async.waterfall(commands, callback);
};
// Get all package dependency names and versions from the package.json file.
getPackageDependencies() {
var dependencies, dependencyPath, error, filteredPackages, metadata, packageDependencies, packageDependencyPath, packageName, packageSpec, ref;
try {
metadata = fs.readFileSync('package.json', 'utf8');
({packageDependencies, dependencies} = (ref = JSON.parse(metadata)) != null ? ref : {});
if (!packageDependencies) {
return {};
}
if (!dependencies) {
return packageDependencies;
}
// This code filters out any `packageDependencies` that have an equivalent
// normalized repo-local package path entry in the `dependencies` section of
// `package.json`. Versioned `packageDependencies` are always returned.
filteredPackages = {};
for (packageName in packageDependencies) {
packageSpec = packageDependencies[packageName];
dependencyPath = this.getRepoLocalPackagePath(dependencies[packageName]);
packageDependencyPath = this.getRepoLocalPackagePath(packageSpec);
if (!(packageDependencyPath && dependencyPath === packageDependencyPath)) {
filteredPackages[packageName] = packageSpec;
}
}
return filteredPackages;
} catch (error1) {
error = error1;
Install.prototype.getPackageDependencies = function() {
var dependencies, dependencyPath, error, filteredPackages, metadata, packageDependencies, packageDependencyPath, packageName, packageSpec, ref, ref1;
try {
metadata = fs.readFileSync('package.json', 'utf8');
ref1 = (ref = JSON.parse(metadata)) != null ? ref : {}, packageDependencies = ref1.packageDependencies, dependencies = ref1.dependencies;
if (!packageDependencies) {
return {};
}
}
getRepoLocalPackagePath(packageSpec) {
var repoLocalPackageMatch;
if (!packageSpec) {
return void 0;
if (!dependencies) {
return packageDependencies;
}
repoLocalPackageMatch = packageSpec.match(this.repoLocalPackagePathRegex);
if (repoLocalPackageMatch) {
return path.normalize(repoLocalPackageMatch[1]);
} else {
return void 0;
filteredPackages = {};
for (packageName in packageDependencies) {
packageSpec = packageDependencies[packageName];
dependencyPath = this.getRepoLocalPackagePath(dependencies[packageName]);
packageDependencyPath = this.getRepoLocalPackagePath(packageSpec);
if (!(packageDependencyPath && dependencyPath === packageDependencyPath)) {
filteredPackages[packageName] = packageSpec;
}
}
return filteredPackages;
} catch (error1) {
error = error1;
return {};
}
};
createAtomDirectories() {
fs.makeTreeSync(this.atomDirectory);
fs.makeTreeSync(this.atomPackagesDirectory);
return fs.makeTreeSync(this.atomNodeDirectory);
Install.prototype.getRepoLocalPackagePath = function(packageSpec) {
var repoLocalPackageMatch;
if (!packageSpec) {
return void 0;
}
// Compile a sample native module to see if a useable native build toolchain
// is instlalled and successfully detected. This will include both Python
// and a compiler.
checkNativeBuildTools(callback) {
var buildArgs, buildOptions, env, vsArgs;
process.stdout.write('Checking for native build tools ');
buildArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'build'];
buildArgs.push(path.resolve(__dirname, '..', 'native-module'));
buildArgs.push(...this.getNpmBuildFlags());
if (vsArgs = this.getVisualStudioFlags()) {
buildArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
buildOptions = {env};
if (this.verbose) {
buildOptions.streaming = true;
}
fs.removeSync(path.resolve(__dirname, '..', 'native-module', 'build'));
return this.fork(this.atomNpmPath, buildArgs, buildOptions, (...args) => {
return this.logCommandResults(callback, ...args);
});
repoLocalPackageMatch = packageSpec.match(this.repoLocalPackagePathRegex);
if (repoLocalPackageMatch) {
return path.normalize(repoLocalPackageMatch[1]);
} else {
return void 0;
}
};
packageNamesFromPath(filePath) {
var packages;
filePath = path.resolve(filePath);
if (!fs.isFileSync(filePath)) {
throw new Error(`File '${filePath}' does not exist`);
}
packages = fs.readFileSync(filePath, 'utf8');
return this.sanitizePackageNames(packages.split(/\s/));
Install.prototype.createAtomDirectories = function() {
fs.makeTreeSync(this.atomDirectory);
fs.makeTreeSync(this.atomPackagesDirectory);
return fs.makeTreeSync(this.atomNodeDirectory);
};
Install.prototype.checkNativeBuildTools = function(callback) {
var buildArgs, buildOptions, env, vsArgs;
process.stdout.write('Checking for native build tools ');
buildArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'build'];
buildArgs.push(path.resolve(__dirname, '..', 'native-module'));
buildArgs.push.apply(buildArgs, this.getNpmBuildFlags());
if (vsArgs = this.getVisualStudioFlags()) {
buildArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
buildOptions = {
env: env
};
if (this.verbose) {
buildOptions.streaming = true;
}
fs.removeSync(path.resolve(__dirname, '..', 'native-module', 'build'));
return this.fork(this.atomNpmPath, buildArgs, buildOptions, (function(_this) {
return function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.logCommandResults.apply(_this, [callback].concat(slice.call(args)));
};
})(this));
};
buildModuleCache(packageName, callback) {
var packageDirectory, rebuildCacheCommand;
packageDirectory = path.join(this.atomPackagesDirectory, packageName);
rebuildCacheCommand = new RebuildModuleCache();
return rebuildCacheCommand.rebuild(packageDirectory, function() {
// Ignore cache errors and just finish the install
return callback();
});
Install.prototype.packageNamesFromPath = function(filePath) {
var packages;
filePath = path.resolve(filePath);
if (!fs.isFileSync(filePath)) {
throw new Error("File '" + filePath + "' does not exist");
}
packages = fs.readFileSync(filePath, 'utf8');
return this.sanitizePackageNames(packages.split(/\s/));
};
warmCompileCache(packageName, callback) {
var packageDirectory;
packageDirectory = path.join(this.atomPackagesDirectory, packageName);
return this.getResourcePath((resourcePath) => {
Install.prototype.buildModuleCache = function(packageName, callback) {
var packageDirectory, rebuildCacheCommand;
packageDirectory = path.join(this.atomPackagesDirectory, packageName);
rebuildCacheCommand = new RebuildModuleCache();
return rebuildCacheCommand.rebuild(packageDirectory, function() {
return callback();
});
};
Install.prototype.warmCompileCache = function(packageName, callback) {
var packageDirectory;
packageDirectory = path.join(this.atomPackagesDirectory, packageName);
return this.getResourcePath((function(_this) {
return function(resourcePath) {
var CompileCache, onDirectory, onFile;

@@ -543,5 +565,5 @@ try {

};
onFile = (filePath) => {
onFile = function(filePath) {
try {
return CompileCache.addPathToCache(filePath, this.atomDirectory);
return CompileCache.addPathToCache(filePath, _this.atomDirectory);
} catch (error1) {}

@@ -552,110 +574,118 @@ };

return callback(null);
});
}
};
})(this));
};
isBundledPackage(packageName, callback) {
return this.getResourcePath(function(resourcePath) {
var atomMetadata, error, ref;
try {
atomMetadata = JSON.parse(fs.readFileSync(path.join(resourcePath, 'package.json')));
} catch (error1) {
error = error1;
return callback(false);
}
return callback(atomMetadata != null ? (ref = atomMetadata.packageDependencies) != null ? ref.hasOwnProperty(packageName) : void 0 : void 0);
});
}
Install.prototype.isBundledPackage = function(packageName, callback) {
return this.getResourcePath(function(resourcePath) {
var atomMetadata, error, ref;
try {
atomMetadata = JSON.parse(fs.readFileSync(path.join(resourcePath, 'package.json')));
} catch (error1) {
error = error1;
return callback(false);
}
return callback(atomMetadata != null ? (ref = atomMetadata.packageDependencies) != null ? ref.hasOwnProperty(packageName) : void 0 : void 0);
});
};
getLatestCompatibleVersion(pack) {
var engine, latestVersion, metadata, ref, ref1, ref2, ref3, version;
if (!this.installedAtomVersion) {
if (isDeprecatedPackage(pack.name, pack.releases.latest)) {
return null;
} else {
return pack.releases.latest;
}
Install.prototype.getLatestCompatibleVersion = function(pack) {
var engine, latestVersion, metadata, ref, ref1, ref2, ref3, version;
if (!this.installedAtomVersion) {
if (isDeprecatedPackage(pack.name, pack.releases.latest)) {
return null;
} else {
return pack.releases.latest;
}
latestVersion = null;
ref1 = (ref = pack.versions) != null ? ref : {};
for (version in ref1) {
metadata = ref1[version];
if (!semver.valid(version)) {
continue;
}
if (!metadata) {
continue;
}
if (isDeprecatedPackage(pack.name, version)) {
continue;
}
engine = (ref2 = (ref3 = metadata.engines) != null ? ref3.atom : void 0) != null ? ref2 : '*';
if (!semver.validRange(engine)) {
continue;
}
if (!semver.satisfies(this.installedAtomVersion, engine)) {
continue;
}
if (latestVersion == null) {
latestVersion = version;
}
if (semver.gt(version, latestVersion)) {
latestVersion = version;
}
}
latestVersion = null;
ref1 = (ref = pack.versions) != null ? ref : {};
for (version in ref1) {
metadata = ref1[version];
if (!semver.valid(version)) {
continue;
}
return latestVersion;
if (!metadata) {
continue;
}
if (isDeprecatedPackage(pack.name, version)) {
continue;
}
engine = (ref2 = (ref3 = metadata.engines) != null ? ref3.atom : void 0) != null ? ref2 : '*';
if (!semver.validRange(engine)) {
continue;
}
if (!semver.satisfies(this.installedAtomVersion, engine)) {
continue;
}
if (latestVersion == null) {
latestVersion = version;
}
if (semver.gt(version, latestVersion)) {
latestVersion = version;
}
}
return latestVersion;
};
getHostedGitInfo(name) {
return hostedGitInfo.fromUrl(name);
}
Install.prototype.getHostedGitInfo = function(name) {
return hostedGitInfo.fromUrl(name);
};
installGitPackage(packageUrl, options, callback) {
var cloneDir, iteratee, tasks;
tasks = [];
cloneDir = temp.mkdirSync("atom-git-package-clone-");
tasks.push((data, next) => {
Install.prototype.installGitPackage = function(packageUrl, options, callback) {
var cloneDir, iteratee, tasks;
tasks = [];
cloneDir = temp.mkdirSync("atom-git-package-clone-");
tasks.push((function(_this) {
return function(data, next) {
var urls;
urls = this.getNormalizedGitUrls(packageUrl);
return this.cloneFirstValidGitUrl(urls, cloneDir, options, function(err) {
urls = _this.getNormalizedGitUrls(packageUrl);
return _this.cloneFirstValidGitUrl(urls, cloneDir, options, function(err) {
return next(err, data);
});
});
tasks.push((data, next) => {
return this.installGitPackageDependencies(cloneDir, options, function(err) {
};
})(this));
tasks.push((function(_this) {
return function(data, next) {
return _this.installGitPackageDependencies(cloneDir, options, function(err) {
return next(err, data);
});
});
tasks.push((data, next) => {
return this.getRepositoryHeadSha(cloneDir, function(err, sha) {
};
})(this));
tasks.push((function(_this) {
return function(data, next) {
return _this.getRepositoryHeadSha(cloneDir, function(err, sha) {
data.sha = sha;
return next(err, data);
});
};
})(this));
tasks.push(function(data, next) {
var metadataFilePath;
metadataFilePath = CSON.resolve(path.join(cloneDir, 'package'));
return CSON.readFile(metadataFilePath, function(err, metadata) {
data.metadataFilePath = metadataFilePath;
data.metadata = metadata;
return next(err, data);
});
tasks.push(function(data, next) {
var metadataFilePath;
metadataFilePath = CSON.resolve(path.join(cloneDir, 'package'));
return CSON.readFile(metadataFilePath, function(err, metadata) {
data.metadataFilePath = metadataFilePath;
data.metadata = metadata;
return next(err, data);
});
});
tasks.push(function(data, next) {
data.metadata.apmInstallSource = {
type: "git",
source: packageUrl,
sha: data.sha
};
return CSON.writeFile(data.metadataFilePath, data.metadata, function(err) {
return next(err, data);
});
tasks.push(function(data, next) {
data.metadata.apmInstallSource = {
type: "git",
source: packageUrl,
sha: data.sha
};
return CSON.writeFile(data.metadataFilePath, data.metadata, function(err) {
return next(err, data);
});
});
tasks.push((data, next) => {
});
tasks.push((function(_this) {
return function(data, next) {
var name, targetDir;
({name} = data.metadata);
targetDir = path.join(this.atomPackagesDirectory, name);
name = data.metadata.name;
targetDir = path.join(_this.atomPackagesDirectory, name);
if (!options.argv.json) {
process.stdout.write(`Moving ${name} to ${targetDir} `);
process.stdout.write("Moving " + name + " to " + targetDir + " ");
}
return fs.cp(cloneDir, targetDir, (err) => {
return fs.cp(cloneDir, targetDir, function(err) {
var json;

@@ -666,3 +696,3 @@ if (err) {

if (!options.argv.json) {
this.logSuccess();
_this.logSuccess();
}

@@ -676,95 +706,99 @@ json = {

});
});
iteratee = function(currentData, task, next) {
return task(currentData, next);
};
return async.reduce(tasks, {}, iteratee, callback);
}
})(this));
iteratee = function(currentData, task, next) {
return task(currentData, next);
};
return async.reduce(tasks, {}, iteratee, callback);
};
getNormalizedGitUrls(packageUrl) {
var packageInfo;
packageInfo = this.getHostedGitInfo(packageUrl);
if (packageUrl.indexOf('file://') === 0) {
return [packageUrl];
} else if (packageInfo.default === 'sshurl') {
return [packageInfo.toString()];
} else if (packageInfo.default === 'https') {
return [packageInfo.https().replace(/^git\+https:/, "https:")];
} else if (packageInfo.default === 'shortcut') {
return [packageInfo.https().replace(/^git\+https:/, "https:"), packageInfo.sshurl()];
}
Install.prototype.getNormalizedGitUrls = function(packageUrl) {
var packageInfo;
packageInfo = this.getHostedGitInfo(packageUrl);
if (packageUrl.indexOf('file://') === 0) {
return [packageUrl];
} else if (packageInfo["default"] === 'sshurl') {
return [packageInfo.toString()];
} else if (packageInfo["default"] === 'https') {
return [packageInfo.https().replace(/^git\+https:/, "https:")];
} else if (packageInfo["default"] === 'shortcut') {
return [packageInfo.https().replace(/^git\+https:/, "https:"), packageInfo.sshurl()];
}
};
cloneFirstValidGitUrl(urls, cloneDir, options, callback) {
return async.detectSeries(urls, (url, next) => {
return this.cloneNormalizedUrl(url, cloneDir, options, function(error) {
Install.prototype.cloneFirstValidGitUrl = function(urls, cloneDir, options, callback) {
return async.detectSeries(urls, (function(_this) {
return function(url, next) {
return _this.cloneNormalizedUrl(url, cloneDir, options, function(error) {
return next(!error);
});
}, function(result) {
var invalidUrls, invalidUrlsError;
if (!result) {
invalidUrls = `Couldn't clone ${urls.join(' or ')}`;
invalidUrlsError = new Error(invalidUrls);
return callback(invalidUrlsError);
} else {
return callback();
}
});
}
};
})(this), function(result) {
var invalidUrls, invalidUrlsError;
if (!result) {
invalidUrls = "Couldn't clone " + (urls.join(' or '));
invalidUrlsError = new Error(invalidUrls);
return callback(invalidUrlsError);
} else {
return callback();
}
});
};
cloneNormalizedUrl(url, cloneDir, options, callback) {
var Develop, develop;
// Require here to avoid circular dependency
Develop = require('./develop');
develop = new Develop();
return develop.cloneRepository(url, cloneDir, options, function(err) {
return callback(err);
});
}
Install.prototype.cloneNormalizedUrl = function(url, cloneDir, options, callback) {
var Develop, develop;
Develop = require('./develop');
develop = new Develop();
return develop.cloneRepository(url, cloneDir, options, function(err) {
return callback(err);
});
};
installGitPackageDependencies(directory, options, callback) {
boundMethodCheck(this, Install);
options.cwd = directory;
return this.installDependencies(options, callback);
}
Install.prototype.installGitPackageDependencies = function(directory, options, callback) {
options.cwd = directory;
return this.installDependencies(options, callback);
};
getRepositoryHeadSha(repoDir, callback) {
var err, repo, sha;
try {
repo = Git.open(repoDir);
sha = repo.getReferenceTarget("HEAD");
return callback(null, sha);
} catch (error1) {
err = error1;
return callback(err);
}
Install.prototype.getRepositoryHeadSha = function(repoDir, callback) {
var err, repo, sha;
try {
repo = Git.open(repoDir);
sha = repo.getReferenceTarget("HEAD");
return callback(null, sha);
} catch (error1) {
err = error1;
return callback(err);
}
};
run(options) {
var callback, commands, error, installPackage, iteratee, packageNames, packagesFilePath;
({callback} = options);
options = this.parseOptions(options.commandArgs);
packagesFilePath = options.argv['packages-file'];
this.createAtomDirectories();
if (options.argv.check) {
config.loadNpm((error, npm) => {
this.npm = npm;
return this.loadInstalledAtomMetadata(() => {
return this.checkNativeBuildTools(callback);
Install.prototype.run = function(options) {
var callback, commands, error, installPackage, iteratee, packageNames, packagesFilePath;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packagesFilePath = options.argv['packages-file'];
this.createAtomDirectories();
if (options.argv.check) {
config.loadNpm((function(_this) {
return function(error, npm) {
_this.npm = npm;
return _this.loadInstalledAtomMetadata(function() {
return _this.checkNativeBuildTools(callback);
});
});
return;
}
this.verbose = options.argv.verbose;
if (this.verbose) {
request.debug(true);
process.env.NODE_DEBUG = 'request';
}
installPackage = (name, nextInstallStep) => {
};
})(this));
return;
}
this.verbose = options.argv.verbose;
if (this.verbose) {
request.debug(true);
process.env.NODE_DEBUG = 'request';
}
installPackage = (function(_this) {
return function(name, nextInstallStep) {
var atIndex, gitPackageInfo, version;
gitPackageInfo = this.getHostedGitInfo(name);
gitPackageInfo = _this.getHostedGitInfo(name);
if (gitPackageInfo || name.indexOf('file://') === 0) {
return this.installGitPackage(name, options, nextInstallStep);
return _this.installGitPackage(name, options, nextInstallStep);
} else if (name === '.') {
return this.installDependencies(options, nextInstallStep); // is registered package
return _this.installDependencies(options, nextInstallStep);
} else {

@@ -776,66 +810,70 @@ atIndex = name.indexOf('@');

}
return this.isBundledPackage(name, (isBundledPackage) => {
return _this.isBundledPackage(name, function(isBundledPackage) {
if (isBundledPackage) {
console.error(`The ${name} package is bundled with Atom and should not be explicitly installed.\nYou can run \`apm uninstall ${name}\` to uninstall it and then the version bundled\nwith Atom will be used.`.yellow);
console.error(("The " + name + " package is bundled with Atom and should not be explicitly installed.\nYou can run `apm uninstall " + name + "` to uninstall it and then the version bundled\nwith Atom will be used.").yellow);
}
return this.installRegisteredPackage({name, version}, options, nextInstallStep);
return _this.installRegisteredPackage({
name: name,
version: version
}, options, nextInstallStep);
});
}
};
if (packagesFilePath) {
try {
packageNames = this.packageNamesFromPath(packagesFilePath);
} catch (error1) {
error = error1;
return callback(error);
}
} else {
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
packageNames.push('.');
}
})(this);
if (packagesFilePath) {
try {
packageNames = this.packageNamesFromPath(packagesFilePath);
} catch (error1) {
error = error1;
return callback(error);
}
commands = [];
commands.push((callback) => {
return config.loadNpm((error, npm) => {
this.npm = npm;
} else {
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
packageNames.push('.');
}
}
commands = [];
commands.push((function(_this) {
return function(callback) {
return config.loadNpm(function(error, npm) {
_this.npm = npm;
return callback(error);
});
});
commands.push((callback) => {
return this.loadInstalledAtomMetadata(function() {
};
})(this));
commands.push((function(_this) {
return function(callback) {
return _this.loadInstalledAtomMetadata(function() {
return callback();
});
};
})(this));
packageNames.forEach(function(packageName) {
return commands.push(function(callback) {
return installPackage(packageName, callback);
});
packageNames.forEach(function(packageName) {
return commands.push(function(callback) {
return installPackage(packageName, callback);
});
});
iteratee = function(item, next) {
return item(next);
};
return async.mapSeries(commands, iteratee, function(err, installedPackagesInfo) {
if (err) {
return callback(err);
}
installedPackagesInfo = _.compact(installedPackagesInfo);
installedPackagesInfo = installedPackagesInfo.filter(function(item, idx) {
return packageNames[idx] !== ".";
});
iteratee = function(item, next) {
return item(next);
};
return async.mapSeries(commands, iteratee, function(err, installedPackagesInfo) {
if (err) {
return callback(err);
}
installedPackagesInfo = _.compact(installedPackagesInfo);
installedPackagesInfo = installedPackagesInfo.filter(function(item, idx) {
return packageNames[idx] !== ".";
});
if (options.argv.json) {
console.log(JSON.stringify(installedPackagesInfo, null, " "));
}
return callback(null);
});
}
if (options.argv.json) {
console.log(JSON.stringify(installedPackagesInfo, null, " "));
}
return callback(null);
});
};
Install.commandNames = ['install', 'i'];
return Install;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Link, config, fs, path, yargs;
var CSON, Command, Link, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,58 +19,61 @@ path = require('path');

module.exports = Link = (function() {
class Link extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm link [<package_path>] [--name <package_name>]\n\nCreate a symlink for the package in ~/.atom/packages. The package in the\ncurrent working directory is linked if no path is given.\n\nRun `apm links` to view all the currently linked packages.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.alias('d', 'dev').boolean('dev').describe('dev', 'Link to ~/.atom/dev/packages');
}
module.exports = Link = (function(superClass) {
extend(Link, superClass);
run(options) {
var callback, error, linkPath, packageName, packagePath, ref, ref1, targetPath;
({callback} = options);
options = this.parseOptions(options.commandArgs);
packagePath = (ref = (ref1 = options.argv._[0]) != null ? ref1.toString() : void 0) != null ? ref : '.';
linkPath = path.resolve(process.cwd(), packagePath);
packageName = options.argv.name;
try {
if (!packageName) {
packageName = CSON.readFileSync(CSON.resolve(path.join(linkPath, 'package'))).name;
}
} catch (error1) {}
function Link() {
return Link.__super__.constructor.apply(this, arguments);
}
Link.commandNames = ['link', 'ln'];
Link.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm link [<package_path>] [--name <package_name>]\n\nCreate a symlink for the package in ~/.atom/packages. The package in the\ncurrent working directory is linked if no path is given.\n\nRun `apm links` to view all the currently linked packages.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.alias('d', 'dev').boolean('dev').describe('dev', 'Link to ~/.atom/dev/packages');
};
Link.prototype.run = function(options) {
var callback, error, linkPath, packageName, packagePath, ref, ref1, targetPath;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packagePath = (ref = (ref1 = options.argv._[0]) != null ? ref1.toString() : void 0) != null ? ref : '.';
linkPath = path.resolve(process.cwd(), packagePath);
packageName = options.argv.name;
try {
if (!packageName) {
packageName = path.basename(linkPath);
packageName = CSON.readFileSync(CSON.resolve(path.join(linkPath, 'package'))).name;
}
if (options.argv.dev) {
targetPath = path.join(config.getAtomDirectory(), 'dev', 'packages', packageName);
} else {
targetPath = path.join(config.getAtomDirectory(), 'packages', packageName);
} catch (error1) {}
if (!packageName) {
packageName = path.basename(linkPath);
}
if (options.argv.dev) {
targetPath = path.join(config.getAtomDirectory(), 'dev', 'packages', packageName);
} else {
targetPath = path.join(config.getAtomDirectory(), 'packages', packageName);
}
if (!fs.existsSync(linkPath)) {
callback("Package directory does not exist: " + linkPath);
return;
}
try {
if (fs.isSymbolicLinkSync(targetPath)) {
fs.unlinkSync(targetPath);
}
if (!fs.existsSync(linkPath)) {
callback(`Package directory does not exist: ${linkPath}`);
return;
}
try {
if (fs.isSymbolicLinkSync(targetPath)) {
fs.unlinkSync(targetPath);
}
fs.makeTreeSync(path.dirname(targetPath));
fs.symlinkSync(linkPath, targetPath, 'junction');
console.log(`${targetPath} -> ${linkPath}`);
return callback();
} catch (error1) {
error = error1;
return callback(`Linking ${targetPath} to ${linkPath} failed: ${error.message}`);
}
fs.makeTreeSync(path.dirname(targetPath));
fs.symlinkSync(linkPath, targetPath, 'junction');
console.log(targetPath + " -> " + linkPath);
return callback();
} catch (error1) {
error = error1;
return callback("Linking " + targetPath + " to " + linkPath + " failed: " + error.message);
}
};
Link.commandNames = ['link', 'ln'];
return Link;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Links, config, fs, path, tree, yargs;
var Command, Links, config, fs, path, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,73 +19,72 @@ path = require('path');

module.exports = Links = (function() {
class Links extends Command {
constructor() {
super();
this.devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages');
this.packagesPath = path.join(config.getAtomDirectory(), 'packages');
}
module.exports = Links = (function(superClass) {
extend(Links, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm links\n\nList all of the symlinked atom packages in ~/.atom/packages and\n~/.atom/dev/packages.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
Links.commandNames = ['linked', 'links', 'lns'];
getDevPackagePath(packageName) {
return path.join(this.devPackagesPath, packageName);
}
function Links() {
Links.__super__.constructor.call(this);
this.devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages');
this.packagesPath = path.join(config.getAtomDirectory(), 'packages');
}
getPackagePath(packageName) {
return path.join(this.packagesPath, packageName);
}
Links.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm links\n\nList all of the symlinked atom packages in ~/.atom/packages and\n~/.atom/dev/packages.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
getSymlinks(directoryPath) {
var directory, i, len, ref, symlinkPath, symlinks;
symlinks = [];
ref = fs.list(directoryPath);
for (i = 0, len = ref.length; i < len; i++) {
directory = ref[i];
symlinkPath = path.join(directoryPath, directory);
if (fs.isSymbolicLinkSync(symlinkPath)) {
symlinks.push(symlinkPath);
}
}
return symlinks;
}
Links.prototype.getDevPackagePath = function(packageName) {
return path.join(this.devPackagesPath, packageName);
};
logLinks(directoryPath) {
var links;
links = this.getSymlinks(directoryPath);
console.log(`${directoryPath.cyan} (${links.length})`);
return tree(links, {
emptyMessage: '(no links)'
}, function(link) {
var error, realpath;
try {
realpath = fs.realpathSync(link);
} catch (error1) {
error = error1;
realpath = '???'.red;
}
return `${(path.basename(link).yellow)} -> ${realpath}`;
});
}
Links.prototype.getPackagePath = function(packageName) {
return path.join(this.packagesPath, packageName);
};
run(options) {
var callback;
({callback} = options);
this.logLinks(this.devPackagesPath);
this.logLinks(this.packagesPath);
return callback();
Links.prototype.getSymlinks = function(directoryPath) {
var directory, i, len, ref, symlinkPath, symlinks;
symlinks = [];
ref = fs.list(directoryPath);
for (i = 0, len = ref.length; i < len; i++) {
directory = ref[i];
symlinkPath = path.join(directoryPath, directory);
if (fs.isSymbolicLinkSync(symlinkPath)) {
symlinks.push(symlinkPath);
}
}
return symlinks;
};
Links.prototype.logLinks = function(directoryPath) {
var links;
links = this.getSymlinks(directoryPath);
console.log(directoryPath.cyan + " (" + links.length + ")");
return tree(links, {
emptyMessage: '(no links)'
}, function(link) {
var error, realpath;
try {
realpath = fs.realpathSync(link);
} catch (error1) {
error = error1;
realpath = '???'.red;
}
return (path.basename(link).yellow) + " -> " + realpath;
});
};
Links.commandNames = ['linked', 'links', 'lns'];
Links.prototype.run = function(options) {
var callback;
callback = options.callback;
this.logLinks(this.devPackagesPath);
this.logLinks(this.packagesPath);
return callback();
};
return Links;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, List, _, config, fs, getRepository, path, tree, yargs;
var CSON, Command, List, _, config, fs, getRepository, path, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -20,173 +23,179 @@ path = require('path');

({getRepository} = require("./packages"));
getRepository = require("./packages").getRepository;
module.exports = List = (function() {
class List extends Command {
constructor() {
var configPath, ref, ref1, ref2;
super();
this.userPackagesDirectory = path.join(config.getAtomDirectory(), 'packages');
this.devPackagesDirectory = path.join(config.getAtomDirectory(), 'dev', 'packages');
if (configPath = CSON.resolve(path.join(config.getAtomDirectory(), 'config'))) {
try {
this.disabledPackages = (ref = CSON.readFileSync(configPath)) != null ? (ref1 = ref['*']) != null ? (ref2 = ref1.core) != null ? ref2.disabledPackages : void 0 : void 0 : void 0;
} catch (error1) {}
}
if (this.disabledPackages == null) {
this.disabledPackages = [];
}
}
module.exports = List = (function(superClass) {
extend(List, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm list\n apm list --themes\n apm list --packages\n apm list --installed\n apm list --installed --enabled\n apm list --installed --bare > my-packages.txt\n apm list --json\n\nList all the installed packages and also the packages bundled with Atom.");
options.alias('b', 'bare').boolean('bare').describe('bare', 'Print packages one per line with no formatting');
options.alias('e', 'enabled').boolean('enabled').describe('enabled', 'Print only enabled packages');
options.alias('d', 'dev').boolean('dev').default('dev', true).describe('dev', 'Include dev packages');
options.boolean('disabled').describe('disabled', 'Print only disabled packages');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('i', 'installed').boolean('installed').describe('installed', 'Only list installed packages/themes');
options.alias('j', 'json').boolean('json').describe('json', 'Output all packages as a JSON object');
options.alias('l', 'links').boolean('links').default('links', true).describe('links', 'Include linked packages');
options.alias('t', 'themes').boolean('themes').describe('themes', 'Only list themes');
options.alias('p', 'packages').boolean('packages').describe('packages', 'Only list packages');
return options.alias('v', 'versions').boolean('versions').default('versions', true).describe('versions', 'Include version of each package');
}
List.commandNames = ['list', 'ls'];
isPackageDisabled(name) {
return this.disabledPackages.indexOf(name) !== -1;
function List() {
var configPath, ref, ref1, ref2;
List.__super__.constructor.call(this);
this.userPackagesDirectory = path.join(config.getAtomDirectory(), 'packages');
this.devPackagesDirectory = path.join(config.getAtomDirectory(), 'dev', 'packages');
if (configPath = CSON.resolve(path.join(config.getAtomDirectory(), 'config'))) {
try {
this.disabledPackages = (ref = CSON.readFileSync(configPath)) != null ? (ref1 = ref['*']) != null ? (ref2 = ref1.core) != null ? ref2.disabledPackages : void 0 : void 0 : void 0;
} catch (error1) {}
}
if (this.disabledPackages == null) {
this.disabledPackages = [];
}
}
logPackages(packages, options) {
var i, len, pack, packageLine, results;
if (options.argv.bare) {
results = [];
for (i = 0, len = packages.length; i < len; i++) {
pack = packages[i];
packageLine = pack.name;
if ((pack.version != null) && options.argv.versions) {
packageLine += `@${pack.version}`;
}
results.push(console.log(packageLine));
List.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm list\n apm list --themes\n apm list --packages\n apm list --installed\n apm list --installed --enabled\n apm list --installed --bare > my-packages.txt\n apm list --json\n\nList all the installed packages and also the packages bundled with Atom.");
options.alias('b', 'bare').boolean('bare').describe('bare', 'Print packages one per line with no formatting');
options.alias('e', 'enabled').boolean('enabled').describe('enabled', 'Print only enabled packages');
options.alias('d', 'dev').boolean('dev')["default"]('dev', true).describe('dev', 'Include dev packages');
options.boolean('disabled').describe('disabled', 'Print only disabled packages');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('i', 'installed').boolean('installed').describe('installed', 'Only list installed packages/themes');
options.alias('j', 'json').boolean('json').describe('json', 'Output all packages as a JSON object');
options.alias('l', 'links').boolean('links')["default"]('links', true).describe('links', 'Include linked packages');
options.alias('t', 'themes').boolean('themes').describe('themes', 'Only list themes');
options.alias('p', 'packages').boolean('packages').describe('packages', 'Only list packages');
return options.alias('v', 'versions').boolean('versions')["default"]('versions', true).describe('versions', 'Include version of each package');
};
List.prototype.isPackageDisabled = function(name) {
return this.disabledPackages.indexOf(name) !== -1;
};
List.prototype.logPackages = function(packages, options) {
var i, len, pack, packageLine, results;
if (options.argv.bare) {
results = [];
for (i = 0, len = packages.length; i < len; i++) {
pack = packages[i];
packageLine = pack.name;
if ((pack.version != null) && options.argv.versions) {
packageLine += "@" + pack.version;
}
return results;
} else {
tree(packages, (pack) => {
results.push(console.log(packageLine));
}
return results;
} else {
tree(packages, (function(_this) {
return function(pack) {
var ref, repo, shaLine;
packageLine = pack.name;
if ((pack.version != null) && options.argv.versions) {
packageLine += `@${pack.version}`;
packageLine += "@" + pack.version;
}
if (((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git') {
repo = getRepository(pack);
shaLine = `#${pack.apmInstallSource.sha.substr(0, 8)}`;
shaLine = "#" + (pack.apmInstallSource.sha.substr(0, 8));
if (repo != null) {
shaLine = repo + shaLine;
}
packageLine += ` (${shaLine})`.grey;
packageLine += (" (" + shaLine + ")").grey;
}
if (this.isPackageDisabled(pack.name) && !options.argv.disabled) {
if (_this.isPackageDisabled(pack.name) && !options.argv.disabled) {
packageLine += ' (disabled)';
}
return packageLine;
});
return console.log();
}
};
})(this));
return console.log();
}
};
checkExclusiveOptions(options, positive_option, negative_option, value) {
if (options.argv[positive_option]) {
return value;
} else if (options.argv[negative_option]) {
return !value;
} else {
return true;
}
List.prototype.checkExclusiveOptions = function(options, positive_option, negative_option, value) {
if (options.argv[positive_option]) {
return value;
} else if (options.argv[negative_option]) {
return !value;
} else {
return true;
}
};
isPackageVisible(options, manifest) {
return this.checkExclusiveOptions(options, 'themes', 'packages', manifest.theme) && this.checkExclusiveOptions(options, 'disabled', 'enabled', this.isPackageDisabled(manifest.name));
}
List.prototype.isPackageVisible = function(options, manifest) {
return this.checkExclusiveOptions(options, 'themes', 'packages', manifest.theme) && this.checkExclusiveOptions(options, 'disabled', 'enabled', this.isPackageDisabled(manifest.name));
};
listPackages(directoryPath, options) {
var child, i, len, manifest, manifestPath, packages, ref;
packages = [];
ref = fs.list(directoryPath);
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (!fs.isDirectorySync(path.join(directoryPath, child))) {
List.prototype.listPackages = function(directoryPath, options) {
var child, i, len, manifest, manifestPath, packages, ref;
packages = [];
ref = fs.list(directoryPath);
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (!fs.isDirectorySync(path.join(directoryPath, child))) {
continue;
}
if (child.match(/^\./)) {
continue;
}
if (!options.argv.links) {
if (fs.isSymbolicLinkSync(path.join(directoryPath, child))) {
continue;
}
if (child.match(/^\./)) {
continue;
}
if (!options.argv.links) {
if (fs.isSymbolicLinkSync(path.join(directoryPath, child))) {
continue;
}
}
manifest = null;
if (manifestPath = CSON.resolve(path.join(directoryPath, child, 'package'))) {
try {
manifest = CSON.readFileSync(manifestPath);
} catch (error1) {}
}
if (manifest == null) {
manifest = {};
}
manifest.name = child;
if (!this.isPackageVisible(options, manifest)) {
continue;
}
packages.push(manifest);
}
return packages;
manifest = null;
if (manifestPath = CSON.resolve(path.join(directoryPath, child, 'package'))) {
try {
manifest = CSON.readFileSync(manifestPath);
} catch (error1) {}
}
if (manifest == null) {
manifest = {};
}
manifest.name = child;
if (!this.isPackageVisible(options, manifest)) {
continue;
}
packages.push(manifest);
}
return packages;
};
listUserPackages(options, callback) {
var userPackages;
userPackages = this.listPackages(this.userPackagesDirectory, options).filter(function(pack) {
return !pack.apmInstallSource;
});
if (!(options.argv.bare || options.argv.json)) {
console.log(`Community Packages (${userPackages.length})`.cyan, `${this.userPackagesDirectory}`);
}
return typeof callback === "function" ? callback(null, userPackages) : void 0;
List.prototype.listUserPackages = function(options, callback) {
var userPackages;
userPackages = this.listPackages(this.userPackagesDirectory, options).filter(function(pack) {
return !pack.apmInstallSource;
});
if (!(options.argv.bare || options.argv.json)) {
console.log(("Community Packages (" + userPackages.length + ")").cyan, "" + this.userPackagesDirectory);
}
return typeof callback === "function" ? callback(null, userPackages) : void 0;
};
listDevPackages(options, callback) {
var devPackages;
if (!options.argv.dev) {
return typeof callback === "function" ? callback(null, []) : void 0;
List.prototype.listDevPackages = function(options, callback) {
var devPackages;
if (!options.argv.dev) {
return typeof callback === "function" ? callback(null, []) : void 0;
}
devPackages = this.listPackages(this.devPackagesDirectory, options);
if (devPackages.length > 0) {
if (!(options.argv.bare || options.argv.json)) {
console.log(("Dev Packages (" + devPackages.length + ")").cyan, "" + this.devPackagesDirectory);
}
devPackages = this.listPackages(this.devPackagesDirectory, options);
if (devPackages.length > 0) {
if (!(options.argv.bare || options.argv.json)) {
console.log(`Dev Packages (${devPackages.length})`.cyan, `${this.devPackagesDirectory}`);
}
}
return typeof callback === "function" ? callback(null, devPackages) : void 0;
}
return typeof callback === "function" ? callback(null, devPackages) : void 0;
};
listGitPackages(options, callback) {
var gitPackages;
gitPackages = this.listPackages(this.userPackagesDirectory, options).filter(function(pack) {
var ref;
return ((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git';
});
if (gitPackages.length > 0) {
if (!(options.argv.bare || options.argv.json)) {
console.log(`Git Packages (${gitPackages.length})`.cyan, `${this.userPackagesDirectory}`);
}
List.prototype.listGitPackages = function(options, callback) {
var gitPackages;
gitPackages = this.listPackages(this.userPackagesDirectory, options).filter(function(pack) {
var ref;
return ((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git';
});
if (gitPackages.length > 0) {
if (!(options.argv.bare || options.argv.json)) {
console.log(("Git Packages (" + gitPackages.length + ")").cyan, "" + this.userPackagesDirectory);
}
return typeof callback === "function" ? callback(null, gitPackages) : void 0;
}
return typeof callback === "function" ? callback(null, gitPackages) : void 0;
};
listBundledPackages(options, callback) {
return config.getResourcePath((resourcePath) => {
List.prototype.listBundledPackages = function(options, callback) {
return config.getResourcePath((function(_this) {
return function(resourcePath) {
var _atomPackages, metadata, metadataPath, packageName, packages;
try {
metadataPath = path.join(resourcePath, 'package.json');
({_atomPackages} = JSON.parse(fs.readFileSync(metadataPath)));
_atomPackages = JSON.parse(fs.readFileSync(metadataPath))._atomPackages;
} catch (error1) {}

@@ -200,3 +209,3 @@ if (_atomPackages == null) {

for (packageName in _atomPackages) {
({metadata} = _atomPackages[packageName]);
metadata = _atomPackages[packageName].metadata;
results.push(metadata);

@@ -206,41 +215,48 @@ }

})();
packages = packages.filter((metadata) => {
return this.isPackageVisible(options, metadata);
packages = packages.filter(function(metadata) {
return _this.isPackageVisible(options, metadata);
});
if (!(options.argv.bare || options.argv.json)) {
if (options.argv.themes) {
console.log(`${'Built-in Atom Themes'.cyan} (${packages.length})`);
console.log('Built-in Atom Themes'.cyan + " (" + packages.length + ")");
} else {
console.log(`${'Built-in Atom Packages'.cyan} (${packages.length})`);
console.log('Built-in Atom Packages'.cyan + " (" + packages.length + ")");
}
}
return typeof callback === "function" ? callback(null, packages) : void 0;
});
}
};
})(this));
};
listInstalledPackages(options) {
return this.listDevPackages(options, (error, packages) => {
List.prototype.listInstalledPackages = function(options) {
return this.listDevPackages(options, (function(_this) {
return function(error, packages) {
if (packages.length > 0) {
this.logPackages(packages, options);
_this.logPackages(packages, options);
}
return this.listUserPackages(options, (error, packages) => {
this.logPackages(packages, options);
return this.listGitPackages(options, (error, packages) => {
return _this.listUserPackages(options, function(error, packages) {
_this.logPackages(packages, options);
return _this.listGitPackages(options, function(error, packages) {
if (packages.length > 0) {
return this.logPackages(packages, options);
return _this.logPackages(packages, options);
}
});
});
});
};
})(this));
};
List.prototype.listPackagesAsJson = function(options, callback) {
var output;
if (callback == null) {
callback = function() {};
}
listPackagesAsJson(options, callback = function() {}) {
var output;
output = {
core: [],
dev: [],
git: [],
user: []
};
return this.listBundledPackages(options, (error, packages) => {
output = {
core: [],
dev: [],
git: [],
user: []
};
return this.listBundledPackages(options, (function(_this) {
return function(error, packages) {
if (error) {

@@ -250,3 +266,3 @@ return callback(error);

output.core = packages;
return this.listDevPackages(options, (error, packages) => {
return _this.listDevPackages(options, function(error, packages) {
if (error) {

@@ -256,3 +272,3 @@ return callback(error);

output.dev = packages;
return this.listUserPackages(options, (error, packages) => {
return _this.listUserPackages(options, function(error, packages) {
if (error) {

@@ -262,3 +278,3 @@ return callback(error);

output.user = packages;
return this.listGitPackages(options, function(error, packages) {
return _this.listGitPackages(options, function(error, packages) {
if (error) {

@@ -273,31 +289,30 @@ return callback(error);

});
});
}
};
})(this));
};
run(options) {
var callback;
({callback} = options);
options = this.parseOptions(options.commandArgs);
if (options.argv.json) {
return this.listPackagesAsJson(options, callback);
} else if (options.argv.installed) {
this.listInstalledPackages(options);
return callback();
} else {
return this.listBundledPackages(options, (error, packages) => {
this.logPackages(packages, options);
this.listInstalledPackages(options);
List.prototype.run = function(options) {
var callback;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
if (options.argv.json) {
return this.listPackagesAsJson(options, callback);
} else if (options.argv.installed) {
this.listInstalledPackages(options);
return callback();
} else {
return this.listBundledPackages(options, (function(_this) {
return function(error, packages) {
_this.logPackages(packages, options);
_this.listInstalledPackages(options);
return callback();
});
}
};
})(this));
}
};
List.commandNames = ['list', 'ls'];
return List;
}).call(this);
})(Command);
}).call(this);

@@ -0,4 +1,7 @@

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Login, Q, _, auth, open, read, yargs,
boundMethodCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } };
bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -19,102 +22,100 @@ _ = require('underscore-plus');

module.exports = Login = (function() {
class Login extends Command {
constructor() {
super(...arguments);
this.welcomeMessage = this.welcomeMessage.bind(this);
this.getToken = this.getToken.bind(this);
this.saveToken = this.saveToken.bind(this);
}
module.exports = Login = (function(superClass) {
extend(Login, superClass);
static getTokenOrLogin(callback) {
return auth.getToken(function(error, token) {
if (error != null) {
return new Login().run({
callback,
commandArgs: []
});
} else {
return callback(null, token);
}
});
}
function Login() {
this.saveToken = bind(this.saveToken, this);
this.getToken = bind(this.getToken, this);
this.welcomeMessage = bind(this.welcomeMessage, this);
return Login.__super__.constructor.apply(this, arguments);
}
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm login\n\nEnter your Atom.io API token and save it to the keychain. This token will\nbe used to identify you when publishing packages to atom.io.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.string('token').describe('token', 'atom.io API token');
}
run(options) {
var callback;
({callback} = options);
options = this.parseOptions(options.commandArgs);
return Q({
token: options.argv.token
}).then(this.welcomeMessage).then(this.openURL).then(this.getToken).then(this.saveToken).then(function(token) {
Login.getTokenOrLogin = function(callback) {
return auth.getToken(function(error, token) {
if (error != null) {
return new Login().run({
callback: callback,
commandArgs: []
});
} else {
return callback(null, token);
}).catch(callback);
}
}
});
};
prompt(options) {
var readPromise;
readPromise = Q.denodeify(read);
return readPromise(options);
}
Login.commandNames = ['login'];
welcomeMessage(state) {
var welcome;
boundMethodCheck(this, Login);
if (state.token) {
return Q(state);
}
welcome = `Welcome to Atom!\n\nBefore you can publish packages, you'll need an API token.\n\nVisit your account page on Atom.io ${'https://atom.io/account'.underline},\ncopy the token and paste it below when prompted.\n`;
console.log(welcome);
return this.prompt({
prompt: "Press [Enter] to open your account page on Atom.io."
});
Login.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm login\n\nEnter your Atom.io API token and save it to the keychain. This token will\nbe used to identify you when publishing packages to atom.io.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.string('token').describe('token', 'atom.io API token');
};
Login.prototype.run = function(options) {
var callback;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
return Q({
token: options.argv.token
}).then(this.welcomeMessage).then(this.openURL).then(this.getToken).then(this.saveToken).then(function(token) {
return callback(null, token);
})["catch"](callback);
};
Login.prototype.prompt = function(options) {
var readPromise;
readPromise = Q.denodeify(read);
return readPromise(options);
};
Login.prototype.welcomeMessage = function(state) {
var welcome;
if (state.token) {
return Q(state);
}
welcome = "Welcome to Atom!\n\nBefore you can publish packages, you'll need an API token.\n\nVisit your account page on Atom.io " + 'https://atom.io/account'.underline + ",\ncopy the token and paste it below when prompted.\n";
console.log(welcome);
return this.prompt({
prompt: "Press [Enter] to open your account page on Atom.io."
});
};
openURL(state) {
if (state.token) {
return Q(state);
}
return open('https://atom.io/account');
Login.prototype.openURL = function(state) {
if (state.token) {
return Q(state);
}
return open('https://atom.io/account');
};
getToken(state) {
boundMethodCheck(this, Login);
if (state.token) {
return Q(state);
}
return this.prompt({
prompt: 'Token>',
edit: true
}).spread(function(token) {
state.token = token;
return Q(state);
});
Login.prototype.getToken = function(state) {
if (state.token) {
return Q(state);
}
return this.prompt({
prompt: 'Token>',
edit: true
}).spread(function(token) {
state.token = token;
return Q(state);
});
};
saveToken({token}) {
boundMethodCheck(this, Login);
if (!token) {
throw new Error("Token is required");
}
process.stdout.write('Saving token to Keychain ');
auth.saveToken(token);
this.logSuccess();
return Q(token);
Login.prototype.saveToken = function(arg) {
var token;
token = arg.token;
if (!token) {
throw new Error("Token is required");
}
process.stdout.write('Saving token to Keychain ');
auth.saveToken(token);
this.logSuccess();
return Q(token);
};
Login.commandNames = ['login'];
return Login;
}).call(this);
})(Command);
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -16,3 +17,3 @@ var CSON, PackageConverter, ScopeSelector, _, fs, path, plist, request, tar, temp, url, zlib;

({ScopeSelector} = require('first-mate'));
ScopeSelector = require('first-mate').ScopeSelector;

@@ -27,5 +28,4 @@ tar = require('tar');

// Convert a TextMate bundle to an Atom package
module.exports = PackageConverter = class PackageConverter {
constructor(sourcePath1, destinationPath) {
module.exports = PackageConverter = (function() {
function PackageConverter(sourcePath1, destinationPath) {
this.sourcePath = sourcePath1;

@@ -41,5 +41,5 @@ this.destinationPath = path.resolve(destinationPath);

convert(callback) {
PackageConverter.prototype.convert = function(callback) {
var protocol;
({protocol} = url.parse(this.sourcePath));
protocol = url.parse(this.sourcePath).protocol;
if (protocol === 'http:' || protocol === 'https:') {

@@ -50,5 +50,5 @@ return this.downloadBundle(callback);

}
}
};
getDownloadUrl() {
PackageConverter.prototype.getDownloadUrl = function() {
var downloadUrl;

@@ -58,5 +58,5 @@ downloadUrl = this.sourcePath;

return downloadUrl += '/archive/master.tar.gz';
}
};
downloadBundle(callback) {
PackageConverter.prototype.downloadBundle = function(callback) {
var requestOptions, tempPath;

@@ -67,21 +67,25 @@ tempPath = temp.mkdirSync('atom-bundle-');

};
return request.createReadStream(requestOptions, (readStream) => {
readStream.on('response', function({headers, statusCode}) {
if (statusCode !== 200) {
return callback(`Download failed (${headers.status})`);
}
});
return readStream.pipe(zlib.createGunzip()).pipe(tar.Extract({
path: tempPath
})).on('error', function(error) {
return callback(error);
}).on('end', () => {
var sourcePath;
sourcePath = path.join(tempPath, fs.readdirSync(tempPath)[0]);
return this.copyDirectories(sourcePath, callback);
});
});
}
return request.createReadStream(requestOptions, (function(_this) {
return function(readStream) {
readStream.on('response', function(arg) {
var headers, statusCode;
headers = arg.headers, statusCode = arg.statusCode;
if (statusCode !== 200) {
return callback("Download failed (" + headers.status + ")");
}
});
return readStream.pipe(zlib.createGunzip()).pipe(tar.Extract({
path: tempPath
})).on('error', function(error) {
return callback(error);
}).on('end', function() {
var sourcePath;
sourcePath = path.join(tempPath, fs.readdirSync(tempPath)[0]);
return _this.copyDirectories(sourcePath, callback);
});
};
})(this));
};
copyDirectories(sourcePath, callback) {
PackageConverter.prototype.copyDirectories = function(sourcePath, callback) {
var packageName, ref;

@@ -99,11 +103,11 @@ sourcePath = path.resolve(sourcePath);

return callback();
}
};
filterObject(object) {
PackageConverter.prototype.filterObject = function(object) {
delete object.uuid;
return delete object.keyEquivalent;
}
};
convertSettings(settings) {
var editorProperties, i, len, name, ref, shellVariables, value;
PackageConverter.prototype.convertSettings = function(settings) {
var editorProperties, i, len, name, ref, ref1, shellVariables, value;
if (settings.shellVariables) {

@@ -113,3 +117,3 @@ shellVariables = {};

for (i = 0, len = ref.length; i < len; i++) {
({name, value} = ref[i]);
ref1 = ref[i], name = ref1.name, value = ref1.value;
shellVariables[name] = value;

@@ -132,5 +136,5 @@ }

}
}
};
readFileSync(filePath) {
PackageConverter.prototype.readFileSync = function(filePath) {
if (_.contains(this.plistExtensions, path.extname(filePath))) {

@@ -141,5 +145,8 @@ return plist.parseFileSync(filePath);

}
}
};
writeFileSync(filePath, object = {}) {
PackageConverter.prototype.writeFileSync = function(filePath, object) {
if (object == null) {
object = {};
}
this.filterObject(object);

@@ -149,8 +156,8 @@ if (Object.keys(object).length > 0) {

}
}
};
convertFile(sourcePath, destinationDir) {
PackageConverter.prototype.convertFile = function(sourcePath, destinationDir) {
var contents, destinationName, destinationPath, extension;
extension = path.extname(sourcePath);
destinationName = `${path.basename(sourcePath, extension)}.cson`;
destinationName = (path.basename(sourcePath, extension)) + ".cson";
destinationName = destinationName.toLowerCase();

@@ -164,5 +171,5 @@ destinationPath = path.join(destinationDir, destinationName);

return this.writeFileSync(destinationPath, contents);
}
};
normalizeFilenames(directoryPath) {
PackageConverter.prototype.normalizeFilenames = function(directoryPath) {
var child, childPath, convertedFileName, convertedPath, extension, i, len, ref, results, suffix;

@@ -177,3 +184,2 @@ if (!fs.isDirectorySync(directoryPath)) {

childPath = path.join(directoryPath, child);
// Invalid characters taken from http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
convertedFileName = child.replace(/[|?*<>:"\\\/]+/g, '-');

@@ -188,3 +194,3 @@ if (child === convertedFileName) {

extension = path.extname(convertedFileName);
convertedFileName = `${path.basename(convertedFileName, extension)}-${suffix}${extension}`;
convertedFileName = (path.basename(convertedFileName, extension)) + "-" + suffix + extension;
convertedPath = path.join(directoryPath, convertedFileName);

@@ -196,5 +202,5 @@ suffix++;

return results;
}
};
convertSnippets(packageName, source) {
PackageConverter.prototype.convertSnippets = function(packageName, source) {
var child, content, destination, e, extension, i, len, name, ref, ref1, scope, selector, snippet, snippetsBySelector, sourceSnippets, tabTrigger;

@@ -214,12 +220,8 @@ sourceSnippets = path.join(source, 'snippets');

snippet = (ref1 = this.readFileSync(path.join(sourceSnippets, child))) != null ? ref1 : {};
({scope, name, content, tabTrigger} = snippet);
scope = snippet.scope, name = snippet.name, content = snippet.content, tabTrigger = snippet.tabTrigger;
if (!(tabTrigger && content)) {
continue;
}
// Replace things like '${TM_C_POINTER: *}' with ' *'
content = content.replace(/\$\{TM_[A-Z_]+:([^}]+)}/g, '$1');
// Replace things like '${1:${TM_FILENAME/(\\w+)*/(?1:$1:NSObject)/}}'
// with '$1'
content = content.replace(/\$\{(\d)+:\s*\$\{TM_[^}]+\s*\}\s*\}/g, '$$1');
// Unescape escaped dollar signs $
content = content.replace(/\\\$/g, '$');

@@ -236,3 +238,3 @@ if (name == null) {

e = error1;
e.message = `In file ${e.fileName} at ${JSON.stringify(scope)}: ${e.message}`;
e.message = "In file " + e.fileName + " at " + (JSON.stringify(scope)) + ": " + e.message;
throw e;

@@ -251,8 +253,8 @@ }

}
this.writeFileSync(path.join(destination, `${packageName}.cson`), snippetsBySelector);
this.writeFileSync(path.join(destination, packageName + ".cson"), snippetsBySelector);
return this.normalizeFilenames(destination);
}
};
convertPreferences(packageName, source) {
var child, destination, e, i, key, len, preferencesBySelector, properties, ref, ref1, scope, selector, settings, sourcePreferences, value;
PackageConverter.prototype.convertPreferences = function(packageName, source) {
var child, destination, e, i, key, len, preferencesBySelector, properties, ref, ref1, ref2, scope, selector, settings, sourcePreferences, value;
sourcePreferences = path.join(source, 'preferences');

@@ -270,3 +272,3 @@ if (!fs.isDirectorySync(sourcePreferences)) {

child = ref[i];
({scope, settings} = (ref1 = this.readFileSync(path.join(sourcePreferences, child))) != null ? ref1 : {});
ref2 = (ref1 = this.readFileSync(path.join(sourcePreferences, child))) != null ? ref1 : {}, scope = ref2.scope, settings = ref2.settings;
if (!(scope && settings)) {

@@ -280,3 +282,3 @@ continue;

e = error1;
e.message = `In file ${e.fileName} at ${JSON.stringify(scope)}: ${e.message}`;
e.message = "In file " + e.fileName + " at " + (JSON.stringify(scope)) + ": " + e.message;
throw e;

@@ -297,7 +299,7 @@ }

}
this.writeFileSync(path.join(destination, `${packageName}.cson`), preferencesBySelector);
this.writeFileSync(path.join(destination, packageName + ".cson"), preferencesBySelector);
return this.normalizeFilenames(destination);
}
};
convertGrammars(source) {
PackageConverter.prototype.convertGrammars = function(source) {
var child, childPath, destination, i, len, ref, sourceSyntaxes;

@@ -321,6 +323,8 @@ sourceSyntaxes = path.join(source, 'syntaxes');

return this.normalizeFilenames(destination);
}
};
};
return PackageConverter;
})();
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -6,16 +7,13 @@ var url;

// Package helpers
module.exports = {
// Parse the repository in `name/owner` format from the package metadata.
// pack - The package metadata object.
// Returns a name/owner string or null if not parseable.
getRepository: function(pack = {}) {
var name, owner, ref, ref1, repoPath, repository;
getRepository: function(pack) {
var name, owner, ref, ref1, ref2, repoPath, repository;
if (pack == null) {
pack = {};
}
if (repository = (ref = (ref1 = pack.repository) != null ? ref1.url : void 0) != null ? ref : pack.repository) {
repoPath = url.parse(repository.replace(/\.git$/, '')).pathname;
[name, owner] = repoPath.split('/').slice(-2);
ref2 = repoPath.split('/').slice(-2), name = ref2[0], owner = ref2[1];
if (name && owner) {
return `${name}/${owner}`;
return name + "/" + owner;
}

@@ -25,8 +23,7 @@ }

},
// Determine remote from package metadata.
// pack - The package metadata object.
// Returns a the remote or 'origin' if not parseable.
getRemote: function(pack = {}) {
getRemote: function(pack) {
var ref;
if (pack == null) {
pack = {};
}
return ((ref = pack.repository) != null ? ref.url : void 0) || pack.repository || 'origin';

@@ -33,0 +30,0 @@ }

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Git, Login, Packages, Publish, config, fs, path, request, semver, url, yargs;
var Command, Git, Login, Packages, Publish, config, fs, path, request, semver, url, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty,
slice = [].slice;

@@ -26,131 +30,123 @@ path = require('path');

module.exports = Publish = (function() {
class Publish extends Command {
constructor() {
super();
this.userConfigPath = config.getUserConfigPath();
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
module.exports = Publish = (function(superClass) {
extend(Publish, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm publish [<newversion> | major | minor | patch | build]\n apm publish --tag <tagname>\n apm publish --rename <new-name>\n\nPublish a new version of the package in the current working directory.\n\nIf a new version or version increment is specified, then a new Git tag is\ncreated and the package.json file is updated with that new version before\nit is published to the apm registry. The HEAD branch and the new tag are\npushed up to the remote repository automatically using this option.\n\nIf a tag is provided via the --tag flag, it must have the form `vx.y.z`.\nFor example, `apm publish -t v1.12.0`.\n\nIf a new name is provided via the --rename flag, the package.json file is\nupdated with the new name and the package's name is updated on Atom.io.\n\nRun `apm featured` to see all the featured packages or\n`apm view <packagename>` to see information about your package after you\nhave published it.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('t', 'tag').string('tag').describe('tag', 'Specify a tag to publish. Must be of the form vx.y.z');
return options.alias('r', 'rename').string('rename').describe('rename', 'Specify a new name for the package');
}
Publish.commandNames = ['publish'];
// Create a new version and tag use the `npm version` command.
function Publish() {
Publish.__super__.constructor.call(this);
this.userConfigPath = config.getUserConfigPath();
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
// version - The new version or version increment.
// callback - The callback function to invoke with an error as the first
// argument and a the generated tag string as the second argument.
versionPackage(version, callback) {
var versionArgs;
process.stdout.write('Preparing and tagging a new version ');
versionArgs = ['version', version, '-m', 'Prepare v%s release'];
return this.fork(this.atomNpmPath, versionArgs, (code, stderr = '', stdout = '') => {
Publish.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm publish [<newversion> | major | minor | patch | build]\n apm publish --tag <tagname>\n apm publish --rename <new-name>\n\nPublish a new version of the package in the current working directory.\n\nIf a new version or version increment is specified, then a new Git tag is\ncreated and the package.json file is updated with that new version before\nit is published to the apm registry. The HEAD branch and the new tag are\npushed up to the remote repository automatically using this option.\n\nIf a tag is provided via the --tag flag, it must have the form `vx.y.z`.\nFor example, `apm publish -t v1.12.0`.\n\nIf a new name is provided via the --rename flag, the package.json file is\nupdated with the new name and the package's name is updated on Atom.io.\n\nRun `apm featured` to see all the featured packages or\n`apm view <packagename>` to see information about your package after you\nhave published it.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('t', 'tag').string('tag').describe('tag', 'Specify a tag to publish. Must be of the form vx.y.z');
return options.alias('r', 'rename').string('rename').describe('rename', 'Specify a new name for the package');
};
Publish.prototype.versionPackage = function(version, callback) {
var versionArgs;
process.stdout.write('Preparing and tagging a new version ');
versionArgs = ['version', version, '-m', 'Prepare v%s release'];
return this.fork(this.atomNpmPath, versionArgs, (function(_this) {
return function(code, stderr, stdout) {
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code === 0) {
this.logSuccess();
_this.logSuccess();
return callback(null, stdout.trim());
} else {
this.logFailure();
return callback(`${stdout}\n${stderr}`.trim());
_this.logFailure();
return callback((stdout + "\n" + stderr).trim());
}
});
}
};
})(this));
};
// Push a tag to the remote repository.
Publish.prototype.pushVersion = function(tag, pack, callback) {
var pushArgs;
process.stdout.write("Pushing " + tag + " tag ");
pushArgs = ['push', Packages.getRemote(pack), 'HEAD', tag];
return this.spawn('git', pushArgs, (function(_this) {
return function() {
var args;
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
return _this.logCommandResults.apply(_this, [callback].concat(slice.call(args)));
};
})(this));
};
// tag - The tag to push.
// pack - The package metadata.
// callback - The callback function to invoke with an error as the first
// argument.
pushVersion(tag, pack, callback) {
var pushArgs;
process.stdout.write(`Pushing ${tag} tag `);
pushArgs = ['push', Packages.getRemote(pack), 'HEAD', tag];
return this.spawn('git', pushArgs, (...args) => {
return this.logCommandResults(callback, ...args);
Publish.prototype.waitForTagToBeAvailable = function(pack, tag, callback) {
var interval, requestSettings, requestTags, retryCount;
retryCount = 5;
interval = 1000;
requestSettings = {
url: "https://api.github.com/repos/" + (Packages.getRepository(pack)) + "/tags",
json: true
};
requestTags = function() {
return request.get(requestSettings, function(error, response, tags) {
var i, index, len, name;
if (tags == null) {
tags = [];
}
if ((response != null ? response.statusCode : void 0) === 200) {
for (index = i = 0, len = tags.length; i < len; index = ++i) {
name = tags[index].name;
if (name === tag) {
return callback();
}
}
}
if (--retryCount <= 0) {
return callback();
} else {
return setTimeout(requestTags, interval);
}
});
}
};
return requestTags();
};
// Check for the tag being available from the GitHub API before notifying
// atom.io about the new version.
// The tag is checked for 5 times at 1 second intervals.
// pack - The package metadata.
// tag - The tag that was pushed.
// callback - The callback function to invoke when either the tag is available
// or the maximum numbers of requests for the tag have been made.
// No arguments are passed to the callback when it is invoked.
waitForTagToBeAvailable(pack, tag, callback) {
var interval, requestSettings, requestTags, retryCount;
retryCount = 5;
interval = 1000;
Publish.prototype.packageExists = function(packageName, callback) {
return Login.getTokenOrLogin(function(error, token) {
var requestSettings;
if (error != null) {
return callback(error);
}
requestSettings = {
url: `https://api.github.com/repos/${Packages.getRepository(pack)}/tags`,
json: true
url: (config.getAtomPackagesUrl()) + "/" + packageName,
json: true,
headers: {
authorization: token
}
};
requestTags = function() {
return request.get(requestSettings, function(error, response, tags = []) {
var i, index, len, name;
if ((response != null ? response.statusCode : void 0) === 200) {
for (index = i = 0, len = tags.length; i < len; index = ++i) {
({name} = tags[index]);
if (name === tag) {
return callback();
}
}
}
if (--retryCount <= 0) {
return callback();
} else {
return setTimeout(requestTags, interval);
}
});
};
return requestTags();
}
// Does the given package already exist in the registry?
// packageName - The string package name to check.
// callback - The callback function invoke with an error as the first
// argument and true/false as the second argument.
packageExists(packageName, callback) {
return Login.getTokenOrLogin(function(error, token) {
var requestSettings;
return request.get(requestSettings, function(error, response, body) {
if (body == null) {
body = {};
}
if (error != null) {
return callback(error);
} else {
return callback(null, response.statusCode === 200);
}
requestSettings = {
url: `${config.getAtomPackagesUrl()}/${packageName}`,
json: true,
headers: {
authorization: token
}
};
return request.get(requestSettings, function(error, response, body = {}) {
if (error != null) {
return callback(error);
} else {
return callback(null, response.statusCode === 200);
}
});
});
});
};
Publish.prototype.registerPackage = function(pack, callback) {
if (!pack.name) {
callback('Required name field in package.json not found');
return;
}
// Register the current repository with the package registry.
// pack - The package metadata.
// callback - The callback function.
registerPackage(pack, callback) {
if (!pack.name) {
callback('Required name field in package.json not found');
return;
}
return this.packageExists(pack.name, (error, exists) => {
return this.packageExists(pack.name, (function(_this) {
return function(error, exists) {
var repository;

@@ -167,7 +163,7 @@ if (error != null) {

}
process.stdout.write(`Registering ${pack.name} `);
return Login.getTokenOrLogin((error, token) => {
process.stdout.write("Registering " + pack.name + " ");
return Login.getTokenOrLogin(function(error, token) {
var requestSettings;
if (error != null) {
this.logFailure();
_this.logFailure();
callback(error);

@@ -186,4 +182,7 @@ return;

};
return request.post(requestSettings, (error, response, body = {}) => {
return request.post(requestSettings, function(error, response, body) {
var message;
if (body == null) {
body = {};
}
if (error != null) {

@@ -193,6 +192,6 @@ return callback(error);

message = request.getErrorMessage(response, body);
this.logFailure();
return callback(`Registering package in ${repository} repository failed: ${message}`);
_this.logFailure();
return callback("Registering package in " + repository + " repository failed: " + message);
} else {
this.logSuccess();
_this.logSuccess();
return callback(null, true);

@@ -202,159 +201,164 @@ }

});
});
}
};
})(this));
};
// Create a new package version at the given Git tag.
// packageName - The string name of the package.
// tag - The string Git tag of the new version.
// callback - The callback function to invoke with an error as the first
// argument.
createPackageVersion(packageName, tag, options, callback) {
return Login.getTokenOrLogin(function(error, token) {
var requestSettings;
Publish.prototype.createPackageVersion = function(packageName, tag, options, callback) {
return Login.getTokenOrLogin(function(error, token) {
var requestSettings;
if (error != null) {
callback(error);
return;
}
requestSettings = {
url: (config.getAtomPackagesUrl()) + "/" + packageName + "/versions",
json: true,
body: {
tag: tag,
rename: options.rename
},
headers: {
authorization: token
}
};
return request.post(requestSettings, function(error, response, body) {
var message;
if (body == null) {
body = {};
}
if (error != null) {
callback(error);
return;
return callback(error);
} else if (response.statusCode !== 201) {
message = request.getErrorMessage(response, body);
return callback("Creating new version failed: " + message);
} else {
return callback();
}
requestSettings = {
url: `${config.getAtomPackagesUrl()}/${packageName}/versions`,
json: true,
body: {
tag: tag,
rename: options.rename
},
headers: {
authorization: token
}
};
return request.post(requestSettings, function(error, response, body = {}) {
var message;
if (error != null) {
return callback(error);
} else if (response.statusCode !== 201) {
message = request.getErrorMessage(response, body);
return callback(`Creating new version failed: ${message}`);
} else {
return callback();
}
});
});
});
};
Publish.prototype.publishPackage = function() {
var callback, options, pack, remaining, tag;
pack = arguments[0], tag = arguments[1], remaining = 3 <= arguments.length ? slice.call(arguments, 2) : [];
if (remaining.length >= 2) {
options = remaining.shift();
}
// Publish the version of the package associated with the given tag.
// pack - The package metadata.
// tag - The Git tag string of the package version to publish.
// options - An options Object (optional).
// callback - The callback function to invoke when done with an error as the
// first argument.
publishPackage(pack, tag, ...remaining) {
var callback, options;
if (remaining.length >= 2) {
options = remaining.shift();
}
if (options == null) {
options = {};
}
callback = remaining.shift();
process.stdout.write(`Publishing ${options.rename || pack.name}@${tag} `);
return this.createPackageVersion(pack.name, tag, options, (error) => {
if (options == null) {
options = {};
}
callback = remaining.shift();
process.stdout.write("Publishing " + (options.rename || pack.name) + "@" + tag + " ");
return this.createPackageVersion(pack.name, tag, options, (function(_this) {
return function(error) {
if (error != null) {
this.logFailure();
_this.logFailure();
return callback(error);
} else {
this.logSuccess();
_this.logSuccess();
return callback();
}
});
}
};
})(this));
};
logFirstTimePublishMessage(pack) {
process.stdout.write('Congrats on publishing a new package!'.rainbow);
// :+1: :package: :tada: when available
if (process.platform === 'darwin') {
process.stdout.write(' \uD83D\uDC4D \uD83D\uDCE6 \uD83C\uDF89');
}
return process.stdout.write(`\nCheck it out at https://atom.io/packages/${pack.name}\n`);
Publish.prototype.logFirstTimePublishMessage = function(pack) {
process.stdout.write('Congrats on publishing a new package!'.rainbow);
if (process.platform === 'darwin') {
process.stdout.write(' \uD83D\uDC4D \uD83D\uDCE6 \uD83C\uDF89');
}
return process.stdout.write("\nCheck it out at https://atom.io/packages/" + pack.name + "\n");
};
loadMetadata() {
var error, metadataPath, pack;
metadataPath = path.resolve('package.json');
if (!fs.isFileSync(metadataPath)) {
throw new Error(`No package.json file found at ${process.cwd()}/package.json`);
}
try {
return pack = JSON.parse(fs.readFileSync(metadataPath));
} catch (error1) {
error = error1;
throw new Error(`Error parsing package.json file: ${error.message}`);
}
Publish.prototype.loadMetadata = function() {
var error, metadataPath, pack;
metadataPath = path.resolve('package.json');
if (!fs.isFileSync(metadataPath)) {
throw new Error("No package.json file found at " + (process.cwd()) + "/package.json");
}
try {
return pack = JSON.parse(fs.readFileSync(metadataPath));
} catch (error1) {
error = error1;
throw new Error("Error parsing package.json file: " + error.message);
}
};
saveMetadata(pack, callback) {
var metadataJson, metadataPath;
metadataPath = path.resolve('package.json');
metadataJson = JSON.stringify(pack, null, 2);
return fs.writeFile(metadataPath, `${metadataJson}\n`, callback);
Publish.prototype.saveMetadata = function(pack, callback) {
var metadataJson, metadataPath;
metadataPath = path.resolve('package.json');
metadataJson = JSON.stringify(pack, null, 2);
return fs.writeFile(metadataPath, metadataJson + "\n", callback);
};
Publish.prototype.loadRepository = function() {
var currentBranch, currentDirectory, remoteName, repo, upstreamUrl;
currentDirectory = process.cwd();
repo = Git.open(currentDirectory);
if (!(repo != null ? repo.isWorkingDirectory(currentDirectory) : void 0)) {
throw new Error('Package must be in a Git repository before publishing: https://help.github.com/articles/create-a-repo');
}
if (currentBranch = repo.getShortHead()) {
remoteName = repo.getConfigValue("branch." + currentBranch + ".remote");
}
if (remoteName == null) {
remoteName = repo.getConfigValue('branch.master.remote');
}
if (remoteName) {
upstreamUrl = repo.getConfigValue("remote." + remoteName + ".url");
}
if (upstreamUrl == null) {
upstreamUrl = repo.getConfigValue('remote.origin.url');
}
if (!upstreamUrl) {
throw new Error('Package must be pushed up to GitHub before publishing: https://help.github.com/articles/create-a-repo');
}
};
loadRepository() {
var currentBranch, currentDirectory, remoteName, repo, upstreamUrl;
currentDirectory = process.cwd();
repo = Git.open(currentDirectory);
if (!(repo != null ? repo.isWorkingDirectory(currentDirectory) : void 0)) {
throw new Error('Package must be in a Git repository before publishing: https://help.github.com/articles/create-a-repo');
Publish.prototype.renamePackage = function(pack, name, callback) {
var message;
if ((name != null ? name.length : void 0) > 0) {
if (pack.name === name) {
return callback('The new package name must be different than the name in the package.json file');
}
if (currentBranch = repo.getShortHead()) {
remoteName = repo.getConfigValue(`branch.${currentBranch}.remote`);
}
if (remoteName == null) {
remoteName = repo.getConfigValue('branch.master.remote');
}
if (remoteName) {
upstreamUrl = repo.getConfigValue(`remote.${remoteName}.url`);
}
if (upstreamUrl == null) {
upstreamUrl = repo.getConfigValue('remote.origin.url');
}
if (!upstreamUrl) {
throw new Error('Package must be pushed up to GitHub before publishing: https://help.github.com/articles/create-a-repo');
}
}
// Rename package if necessary
renamePackage(pack, name, callback) {
var message;
if ((name != null ? name.length : void 0) > 0) {
if (pack.name === name) {
return callback('The new package name must be different than the name in the package.json file');
}
message = `Renaming ${pack.name} to ${name} `;
process.stdout.write(message);
return this.setPackageName(pack, name, (error) => {
message = "Renaming " + pack.name + " to " + name + " ";
process.stdout.write(message);
return this.setPackageName(pack, name, (function(_this) {
return function(error) {
if (error != null) {
this.logFailure();
_this.logFailure();
return callback(error);
}
return config.getSetting('git', (gitCommand) => {
return config.getSetting('git', function(gitCommand) {
if (gitCommand == null) {
gitCommand = 'git';
}
return this.spawn(gitCommand, ['add', 'package.json'], (code, stderr = '', stdout = '') => {
return _this.spawn(gitCommand, ['add', 'package.json'], function(code, stderr, stdout) {
var addOutput;
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code !== 0) {
this.logFailure();
addOutput = `${stdout}\n${stderr}`.trim();
return callback(`\`git add package.json\` failed: ${addOutput}`);
_this.logFailure();
addOutput = (stdout + "\n" + stderr).trim();
return callback("`git add package.json` failed: " + addOutput);
}
return this.spawn(gitCommand, ['commit', '-m', message], (code, stderr = '', stdout = '') => {
return _this.spawn(gitCommand, ['commit', '-m', message], function(code, stderr, stdout) {
var commitOutput;
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code === 0) {
this.logSuccess();
_this.logSuccess();
return callback();
} else {
this.logFailure();
commitOutput = `${stdout}\n${stderr}`.trim();
return callback(`Failed to commit package.json: ${commitOutput}`);
_this.logFailure();
commitOutput = (stdout + "\n" + stderr).trim();
return callback("Failed to commit package.json: " + commitOutput);
}

@@ -364,109 +368,109 @@ });

});
});
} else {
// Just fall through if the name is empty
return callback();
}
};
})(this));
} else {
return callback();
}
};
setPackageName(pack, name, callback) {
pack.name = name;
return this.saveMetadata(pack, callback);
Publish.prototype.setPackageName = function(pack, name, callback) {
pack.name = name;
return this.saveMetadata(pack, callback);
};
Publish.prototype.validateSemverRanges = function(pack) {
var isValidRange, packageName, ref, ref1, ref2, semverRange;
if (!pack) {
return;
}
validateSemverRanges(pack) {
var isValidRange, packageName, ref, ref1, ref2, semverRange;
if (!pack) {
return;
isValidRange = function(semverRange) {
if (semver.validRange(semverRange)) {
return true;
}
isValidRange = function(semverRange) {
if (semver.validRange(semverRange)) {
try {
if (url.parse(semverRange).protocol.length > 0) {
return true;
}
try {
if (url.parse(semverRange).protocol.length > 0) {
return true;
}
} catch (error1) {}
return semverRange === 'latest';
};
if (((ref = pack.engines) != null ? ref.atom : void 0) != null) {
if (!semver.validRange(pack.engines.atom)) {
throw new Error(`The Atom engine range in the package.json file is invalid: ${pack.engines.atom}`);
}
} catch (error1) {}
return semverRange === 'latest';
};
if (((ref = pack.engines) != null ? ref.atom : void 0) != null) {
if (!semver.validRange(pack.engines.atom)) {
throw new Error("The Atom engine range in the package.json file is invalid: " + pack.engines.atom);
}
ref1 = pack.dependencies;
for (packageName in ref1) {
semverRange = ref1[packageName];
if (!isValidRange(semverRange)) {
throw new Error(`The ${packageName} dependency range in the package.json file is invalid: ${semverRange}`);
}
}
ref1 = pack.dependencies;
for (packageName in ref1) {
semverRange = ref1[packageName];
if (!isValidRange(semverRange)) {
throw new Error("The " + packageName + " dependency range in the package.json file is invalid: " + semverRange);
}
ref2 = pack.devDependencies;
for (packageName in ref2) {
semverRange = ref2[packageName];
if (!isValidRange(semverRange)) {
throw new Error(`The ${packageName} dev dependency range in the package.json file is invalid: ${semverRange}`);
}
}
ref2 = pack.devDependencies;
for (packageName in ref2) {
semverRange = ref2[packageName];
if (!isValidRange(semverRange)) {
throw new Error("The " + packageName + " dev dependency range in the package.json file is invalid: " + semverRange);
}
}
};
// Run the publish command with the given options
run(options) {
var callback, error, originalName, pack, rename, tag, version;
({callback} = options);
options = this.parseOptions(options.commandArgs);
({tag, rename} = options.argv);
[version] = options.argv._;
try {
pack = this.loadMetadata();
} catch (error1) {
error = error1;
return callback(error);
Publish.prototype.run = function(options) {
var callback, error, originalName, pack, ref, rename, tag, version;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
ref = options.argv, tag = ref.tag, rename = ref.rename;
version = options.argv._[0];
try {
pack = this.loadMetadata();
} catch (error1) {
error = error1;
return callback(error);
}
try {
this.validateSemverRanges(pack);
} catch (error1) {
error = error1;
return callback(error);
}
try {
this.loadRepository();
} catch (error1) {
error = error1;
return callback(error);
}
if ((version != null ? version.length : void 0) > 0 || (rename != null ? rename.length : void 0) > 0) {
if (!((version != null ? version.length : void 0) > 0)) {
version = 'patch';
}
try {
this.validateSemverRanges(pack);
} catch (error1) {
error = error1;
return callback(error);
if ((rename != null ? rename.length : void 0) > 0) {
originalName = pack.name;
}
try {
this.loadRepository();
} catch (error1) {
error = error1;
return callback(error);
}
if ((version != null ? version.length : void 0) > 0 || (rename != null ? rename.length : void 0) > 0) {
if (!((version != null ? version.length : void 0) > 0)) {
version = 'patch';
}
if ((rename != null ? rename.length : void 0) > 0) {
originalName = pack.name;
}
return this.registerPackage(pack, (error, firstTimePublishing) => {
return this.registerPackage(pack, (function(_this) {
return function(error, firstTimePublishing) {
if (error != null) {
return callback(error);
}
return this.renamePackage(pack, rename, (error) => {
return _this.renamePackage(pack, rename, function(error) {
if (error != null) {
return callback(error);
}
return this.versionPackage(version, (error, tag) => {
return _this.versionPackage(version, function(error, tag) {
if (error != null) {
return callback(error);
}
return this.pushVersion(tag, pack, (error) => {
return _this.pushVersion(tag, pack, function(error) {
if (error != null) {
return callback(error);
}
return this.waitForTagToBeAvailable(pack, tag, () => {
return _this.waitForTagToBeAvailable(pack, tag, function() {
if (originalName != null) {
// If we're renaming a package, we have to hit the API with the
// current name, not the new one, or it will 404.
rename = pack.name;
pack.name = originalName;
}
return this.publishPackage(pack, tag, {rename}, (error) => {
return _this.publishPackage(pack, tag, {
rename: rename
}, function(error) {
if (firstTimePublishing && (error == null)) {
this.logFirstTimePublishMessage(pack);
_this.logFirstTimePublishMessage(pack);
}

@@ -479,28 +483,27 @@ return callback(error);

});
});
} else if ((tag != null ? tag.length : void 0) > 0) {
return this.registerPackage(pack, (error, firstTimePublishing) => {
};
})(this));
} else if ((tag != null ? tag.length : void 0) > 0) {
return this.registerPackage(pack, (function(_this) {
return function(error, firstTimePublishing) {
if (error != null) {
return callback(error);
}
return this.publishPackage(pack, tag, (error) => {
return _this.publishPackage(pack, tag, function(error) {
if (firstTimePublishing && (error == null)) {
this.logFirstTimePublishMessage(pack);
_this.logFirstTimePublishMessage(pack);
}
return callback(error);
});
});
} else {
return callback('A version, tag, or new package name is required');
}
};
})(this));
} else {
return callback('A version, tag, or new package name is required');
}
};
Publish.commandNames = ['publish'];
return Publish;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, RebuildModuleCache, async, config, fs, path, yargs;
var Command, RebuildModuleCache, async, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,37 +19,45 @@ path = require('path');

module.exports = RebuildModuleCache = (function() {
class RebuildModuleCache extends Command {
constructor() {
super();
this.atomPackagesDirectory = path.join(config.getAtomDirectory(), 'packages');
}
module.exports = RebuildModuleCache = (function(superClass) {
extend(RebuildModuleCache, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm rebuild-module-cache\n\nRebuild the module cache for all the packages installed to\n~/.atom/packages\n\nYou can see the state of the module cache for a package by looking\nat the _atomModuleCache property in the package's package.json file.\n\nThis command skips all linked packages.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
RebuildModuleCache.commandNames = ['rebuild-module-cache'];
getResourcePath(callback) {
if (this.resourcePath) {
return process.nextTick(() => {
return callback(this.resourcePath);
});
} else {
return config.getResourcePath((resourcePath1) => {
this.resourcePath = resourcePath1;
return callback(this.resourcePath);
});
}
function RebuildModuleCache() {
RebuildModuleCache.__super__.constructor.call(this);
this.atomPackagesDirectory = path.join(config.getAtomDirectory(), 'packages');
}
RebuildModuleCache.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm rebuild-module-cache\n\nRebuild the module cache for all the packages installed to\n~/.atom/packages\n\nYou can see the state of the module cache for a package by looking\nat the _atomModuleCache property in the package's package.json file.\n\nThis command skips all linked packages.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
RebuildModuleCache.prototype.getResourcePath = function(callback) {
if (this.resourcePath) {
return process.nextTick((function(_this) {
return function() {
return callback(_this.resourcePath);
};
})(this));
} else {
return config.getResourcePath((function(_this) {
return function(resourcePath1) {
_this.resourcePath = resourcePath1;
return callback(_this.resourcePath);
};
})(this));
}
};
rebuild(packageDirectory, callback) {
return this.getResourcePath((resourcePath) => {
RebuildModuleCache.prototype.rebuild = function(packageDirectory, callback) {
return this.getResourcePath((function(_this) {
return function(resourcePath) {
var error;
try {
if (this.moduleCache == null) {
this.moduleCache = require(path.join(resourcePath, 'src', 'module-cache'));
if (_this.moduleCache == null) {
_this.moduleCache = require(path.join(resourcePath, 'src', 'module-cache'));
}
this.moduleCache.create(packageDirectory);
_this.moduleCache.create(packageDirectory);
} catch (error1) {

@@ -57,12 +68,14 @@ error = error1;

return callback();
});
}
};
})(this));
};
run(options) {
var callback, commands;
({callback} = options);
commands = [];
fs.list(this.atomPackagesDirectory).forEach((packageName) => {
RebuildModuleCache.prototype.run = function(options) {
var callback, commands;
callback = options.callback;
commands = [];
fs.list(this.atomPackagesDirectory).forEach((function(_this) {
return function(packageName) {
var packageDirectory;
packageDirectory = path.join(this.atomPackagesDirectory, packageName);
packageDirectory = path.join(_this.atomPackagesDirectory, packageName);
if (fs.isSymbolicLinkSync(packageDirectory)) {

@@ -74,9 +87,9 @@ return;

}
return commands.push((callback) => {
process.stdout.write(`Rebuilding ${packageName} module cache `);
return this.rebuild(packageDirectory, (error) => {
return commands.push(function(callback) {
process.stdout.write("Rebuilding " + packageName + " module cache ");
return _this.rebuild(packageDirectory, function(error) {
if (error != null) {
this.logFailure();
_this.logFailure();
} else {
this.logSuccess();
_this.logSuccess();
}

@@ -86,14 +99,11 @@ return callback(error);

});
});
return async.waterfall(commands, callback);
}
};
})(this));
return async.waterfall(commands, callback);
};
RebuildModuleCache.commandNames = ['rebuild-module-cache'];
return RebuildModuleCache;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Install, Rebuild, _, config, fs, path, yargs;
var Command, Install, Rebuild, _, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -18,49 +21,58 @@ path = require('path');

module.exports = Rebuild = (function() {
class Rebuild extends Command {
constructor() {
super();
this.atomDirectory = config.getAtomDirectory();
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
module.exports = Rebuild = (function(superClass) {
extend(Rebuild, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm rebuild [<name> [<name> ...]]\n\nRebuild the given modules currently installed in the node_modules folder\nin the current working directory.\n\nAll the modules will be rebuilt if no module names are specified.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
}
Rebuild.commandNames = ['rebuild'];
forkNpmRebuild(options, callback) {
var env, rebuildArgs, vsArgs;
process.stdout.write('Rebuilding modules ');
rebuildArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'rebuild'];
rebuildArgs.push(...this.getNpmBuildFlags());
rebuildArgs.push(...options.argv._);
if (vsArgs = this.getVisualStudioFlags()) {
rebuildArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
return this.fork(this.atomNpmPath, rebuildArgs, {env}, callback);
function Rebuild() {
Rebuild.__super__.constructor.call(this);
this.atomDirectory = config.getAtomDirectory();
this.atomNodeDirectory = path.join(this.atomDirectory, '.node-gyp');
this.atomNpmPath = require.resolve('npm/bin/npm-cli');
}
Rebuild.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm rebuild [<name> [<name> ...]]\n\nRebuild the given modules currently installed in the node_modules folder\nin the current working directory.\n\nAll the modules will be rebuilt if no module names are specified.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Rebuild.prototype.forkNpmRebuild = function(options, callback) {
var env, rebuildArgs, vsArgs;
process.stdout.write('Rebuilding modules ');
rebuildArgs = ['--globalconfig', config.getGlobalConfigPath(), '--userconfig', config.getUserConfigPath(), 'rebuild'];
rebuildArgs.push.apply(rebuildArgs, this.getNpmBuildFlags());
rebuildArgs.push.apply(rebuildArgs, options.argv._);
if (vsArgs = this.getVisualStudioFlags()) {
rebuildArgs.push(vsArgs);
}
fs.makeTreeSync(this.atomDirectory);
env = _.extend({}, process.env, {
HOME: this.atomNodeDirectory,
RUSTUP_HOME: config.getRustupHomeDirPath()
});
this.addBuildEnvVars(env);
return this.fork(this.atomNpmPath, rebuildArgs, {
env: env
}, callback);
};
run(options) {
var callback;
({callback} = options);
options = this.parseOptions(options.commandArgs);
return config.loadNpm((error, npm) => {
this.npm = npm;
return this.loadInstalledAtomMetadata(() => {
return this.forkNpmRebuild(options, (code, stderr = '') => {
Rebuild.prototype.run = function(options) {
var callback;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
return config.loadNpm((function(_this) {
return function(error, npm) {
_this.npm = npm;
return _this.loadInstalledAtomMetadata(function() {
return _this.forkNpmRebuild(options, function(code, stderr) {
if (stderr == null) {
stderr = '';
}
if (code === 0) {
this.logSuccess();
_this.logSuccess();
return callback();
} else {
this.logFailure();
_this.logFailure();
return callback(stderr);

@@ -70,13 +82,10 @@ }

});
});
}
};
})(this));
};
Rebuild.commandNames = ['rebuild'];
return Rebuild;
}).call(this);
})(Command);
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -28,3 +29,3 @@ var config, configureRequest, loadNpm, npm, request;

}
userAgent = (ref = npm.config.get('user-agent')) != null ? ref : `AtomApm/${(require('../package.json').version)}`;
userAgent = (ref = npm.config.get('user-agent')) != null ? ref : "AtomApm/" + (require('../package.json').version);
if (requestOptions.headers == null) {

@@ -55,3 +56,3 @@ requestOptions.headers = {};

if ((error != null ? error.message : void 0) && requestsMade > 1) {
error.message += ` (${requestsMade} attempts)`;
error.message += " (" + requestsMade + " attempts)";
}

@@ -58,0 +59,0 @@ return callback(error, response, body);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Search, _, config, isDeprecatedPackage, request, tree, yargs;
var Command, Search, _, config, isDeprecatedPackage, request, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,105 +19,120 @@ _ = require('underscore-plus');

({isDeprecatedPackage} = require('./deprecated-packages'));
isDeprecatedPackage = require('./deprecated-packages').isDeprecatedPackage;
module.exports = Search = (function() {
class Search extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm search <package_name>\n\nSearch for Atom packages/themes on the atom.io registry.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.boolean('json').describe('json', 'Output matching packages as JSON array');
options.boolean('packages').describe('packages', 'Search only non-theme packages').alias('p', 'packages');
return options.boolean('themes').describe('themes', 'Search only themes').alias('t', 'themes');
module.exports = Search = (function(superClass) {
extend(Search, superClass);
function Search() {
return Search.__super__.constructor.apply(this, arguments);
}
Search.commandNames = ['search'];
Search.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm search <package_name>\n\nSearch for Atom packages/themes on the atom.io registry.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.boolean('json').describe('json', 'Output matching packages as JSON array');
options.boolean('packages').describe('packages', 'Search only non-theme packages').alias('p', 'packages');
return options.boolean('themes').describe('themes', 'Search only themes').alias('t', 'themes');
};
Search.prototype.searchPackages = function(query, opts, callback) {
var qs, requestSettings;
qs = {
q: query
};
if (opts.packages) {
qs.filter = 'package';
} else if (opts.themes) {
qs.filter = 'theme';
}
searchPackages(query, opts, callback) {
var qs, requestSettings;
qs = {
q: query
};
if (opts.packages) {
qs.filter = 'package';
} else if (opts.themes) {
qs.filter = 'theme';
requestSettings = {
url: (config.getAtomPackagesUrl()) + "/search",
qs: qs,
json: true
};
return request.get(requestSettings, function(error, response, body) {
var message, packages;
if (body == null) {
body = {};
}
requestSettings = {
url: `${config.getAtomPackagesUrl()}/search`,
qs: qs,
json: true
};
return request.get(requestSettings, function(error, response, body = {}) {
var message, packages;
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
packages = body.filter(function(pack) {
var ref;
return ((ref = pack.releases) != null ? ref.latest : void 0) != null;
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
packages = body.filter(function(pack) {
var ref;
return ((ref = pack.releases) != null ? ref.latest : void 0) != null;
});
packages = packages.map(function(arg) {
var downloads, metadata, readme, stargazers_count;
readme = arg.readme, metadata = arg.metadata, downloads = arg.downloads, stargazers_count = arg.stargazers_count;
return _.extend({}, metadata, {
readme: readme,
downloads: downloads,
stargazers_count: stargazers_count
});
packages = packages.map(function({readme, metadata, downloads, stargazers_count}) {
return _.extend({}, metadata, {readme, downloads, stargazers_count});
});
packages = packages.filter(function({name, version}) {
return !isDeprecatedPackage(name, version);
});
return callback(null, packages);
} else {
message = request.getErrorMessage(response, body);
return callback(`Searching packages failed: ${message}`);
}
});
});
packages = packages.filter(function(arg) {
var name, version;
name = arg.name, version = arg.version;
return !isDeprecatedPackage(name, version);
});
return callback(null, packages);
} else {
message = request.getErrorMessage(response, body);
return callback("Searching packages failed: " + message);
}
});
};
Search.prototype.run = function(options) {
var callback, query, searchOptions;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
query = options.argv._[0];
if (!query) {
callback("Missing required search query");
return;
}
run(options) {
var callback, query, searchOptions;
({callback} = options);
options = this.parseOptions(options.commandArgs);
[query] = options.argv._;
if (!query) {
callback("Missing required search query");
searchOptions = {
packages: options.argv.packages,
themes: options.argv.themes
};
return this.searchPackages(query, searchOptions, function(error, packages) {
var heading;
if (error != null) {
callback(error);
return;
}
searchOptions = {
packages: options.argv.packages,
themes: options.argv.themes
};
return this.searchPackages(query, searchOptions, function(error, packages) {
var heading;
if (error != null) {
callback(error);
return;
}
if (options.argv.json) {
console.log(JSON.stringify(packages));
} else {
heading = `Search Results For '${query}'`.cyan;
console.log(`${heading} (${packages.length})`);
tree(packages, function({name, version, description, downloads, stargazers_count}) {
var label;
label = name.yellow;
if (description) {
label += ` ${description.replace(/\s+/g, ' ')}`;
}
if (downloads >= 0 && stargazers_count >= 0) {
label += ` (${_.pluralize(downloads, 'download')}, ${_.pluralize(stargazers_count, 'star')})`.grey;
}
return label;
});
console.log();
console.log(`Use \`apm install\` to install them or visit ${'http://atom.io/packages'.underline} to read more about them.`);
console.log();
}
return callback();
});
}
if (options.argv.json) {
console.log(JSON.stringify(packages));
} else {
heading = ("Search Results For '" + query + "'").cyan;
console.log(heading + " (" + packages.length + ")");
tree(packages, function(arg) {
var description, downloads, label, name, stargazers_count, version;
name = arg.name, version = arg.version, description = arg.description, downloads = arg.downloads, stargazers_count = arg.stargazers_count;
label = name.yellow;
if (description) {
label += " " + (description.replace(/\s+/g, ' '));
}
if (downloads >= 0 && stargazers_count >= 0) {
label += (" (" + (_.pluralize(downloads, 'download')) + ", " + (_.pluralize(stargazers_count, 'star')) + ")").grey;
}
return label;
});
console.log();
console.log("Use `apm install` to install them or visit " + 'http://atom.io/packages'.underline + " to read more about them.");
console.log();
}
return callback();
});
};
Search.commandNames = ['search'];
return Search;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Login, Packages, Star, _, async, config, fs, path, request, yargs;
var CSON, Command, Login, Packages, Star, _, async, config, fs, path, request, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -26,29 +29,41 @@ path = require('path');

module.exports = Star = (function() {
class Star extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm star <package_name>...\n\nStar the given packages on https://atom.io\n\nRun `apm stars` to see all your starred packages.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.boolean('installed').describe('installed', 'Star all packages in ~/.atom/packages');
module.exports = Star = (function(superClass) {
extend(Star, superClass);
function Star() {
return Star.__super__.constructor.apply(this, arguments);
}
Star.commandNames = ['star'];
Star.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm star <package_name>...\n\nStar the given packages on https://atom.io\n\nRun `apm stars` to see all your starred packages.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.boolean('installed').describe('installed', 'Star all packages in ~/.atom/packages');
};
Star.prototype.starPackage = function(packageName, arg, callback) {
var ignoreUnpublishedPackages, ref, requestSettings, token;
ref = arg != null ? arg : {}, ignoreUnpublishedPackages = ref.ignoreUnpublishedPackages, token = ref.token;
if (process.platform === 'darwin') {
process.stdout.write('\u2B50 ');
}
starPackage(packageName, {ignoreUnpublishedPackages, token} = {}, callback) {
var requestSettings;
if (process.platform === 'darwin') {
process.stdout.write('\u2B50 ');
process.stdout.write("Starring " + packageName + " ");
requestSettings = {
json: true,
url: (config.getAtomPackagesUrl()) + "/" + packageName + "/star",
headers: {
authorization: token
}
process.stdout.write(`Starring ${packageName} `);
requestSettings = {
json: true,
url: `${config.getAtomPackagesUrl()}/${packageName}/star`,
headers: {
authorization: token
};
return request.post(requestSettings, (function(_this) {
return function(error, response, body) {
var message;
if (body == null) {
body = {};
}
};
return request.post(requestSettings, (error, response, body = {}) => {
var message;
if (error != null) {
this.logFailure();
_this.logFailure();
return callback(error);

@@ -59,52 +74,54 @@ } else if (response.statusCode === 404 && ignoreUnpublishedPackages) {

} else if (response.statusCode !== 200) {
this.logFailure();
_this.logFailure();
message = request.getErrorMessage(response, body);
return callback(`Starring package failed: ${message}`);
return callback("Starring package failed: " + message);
} else {
this.logSuccess();
_this.logSuccess();
return callback();
}
});
}
};
})(this));
};
getInstalledPackageNames() {
var child, i, installedPackages, len, manifestPath, metadata, ref, ref1, userPackagesDirectory;
installedPackages = [];
userPackagesDirectory = path.join(config.getAtomDirectory(), 'packages');
ref = fs.list(userPackagesDirectory);
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (!fs.isDirectorySync(path.join(userPackagesDirectory, child))) {
continue;
}
if (manifestPath = CSON.resolve(path.join(userPackagesDirectory, child, 'package'))) {
try {
metadata = (ref1 = CSON.readFileSync(manifestPath)) != null ? ref1 : {};
if (metadata.name && Packages.getRepository(metadata)) {
installedPackages.push(metadata.name);
}
} catch (error1) {}
}
Star.prototype.getInstalledPackageNames = function() {
var child, i, installedPackages, len, manifestPath, metadata, ref, ref1, userPackagesDirectory;
installedPackages = [];
userPackagesDirectory = path.join(config.getAtomDirectory(), 'packages');
ref = fs.list(userPackagesDirectory);
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
if (!fs.isDirectorySync(path.join(userPackagesDirectory, child))) {
continue;
}
return _.uniq(installedPackages);
if (manifestPath = CSON.resolve(path.join(userPackagesDirectory, child, 'package'))) {
try {
metadata = (ref1 = CSON.readFileSync(manifestPath)) != null ? ref1 : {};
if (metadata.name && Packages.getRepository(metadata)) {
installedPackages.push(metadata.name);
}
} catch (error1) {}
}
}
return _.uniq(installedPackages);
};
run(options) {
var callback, packageNames;
({callback} = options);
options = this.parseOptions(options.commandArgs);
if (options.argv.installed) {
packageNames = this.getInstalledPackageNames();
if (packageNames.length === 0) {
callback();
return;
}
} else {
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
callback("Please specify a package name to star");
return;
}
Star.prototype.run = function(options) {
var callback, packageNames;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
if (options.argv.installed) {
packageNames = this.getInstalledPackageNames();
if (packageNames.length === 0) {
callback();
return;
}
return Login.getTokenOrLogin((error, token) => {
} else {
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
callback("Please specify a package name to star");
return;
}
}
return Login.getTokenOrLogin((function(_this) {
return function(error, token) {
var commands, starOptions;

@@ -118,19 +135,16 @@ if (error != null) {

};
commands = packageNames.map((packageName) => {
return (callback) => {
return this.starPackage(packageName, starOptions, callback);
commands = packageNames.map(function(packageName) {
return function(callback) {
return _this.starPackage(packageName, starOptions, callback);
};
});
return async.waterfall(commands, callback);
});
}
};
})(this));
};
Star.commandNames = ['star'];
return Star;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Install, Login, Stars, _, config, request, tree, yargs;
var Command, Install, Login, Stars, _, config, request, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -20,31 +23,39 @@ _ = require('underscore-plus');

module.exports = Stars = (function() {
class Stars extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm stars\n apm stars --install\n apm stars --user thedaniel\n apm stars --themes\n\nList or install starred Atom packages and themes.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('i', 'install').boolean('install').describe('install', 'Install the starred packages');
options.alias('t', 'themes').boolean('themes').describe('themes', 'Only list themes');
options.alias('u', 'user').string('user').describe('user', 'GitHub username to show starred packages for');
return options.boolean('json').describe('json', 'Output packages as a JSON array');
}
module.exports = Stars = (function(superClass) {
extend(Stars, superClass);
getStarredPackages(user, atomVersion, callback) {
var requestSettings;
requestSettings = {
json: true
function Stars() {
return Stars.__super__.constructor.apply(this, arguments);
}
Stars.commandNames = ['stars', 'starred'];
Stars.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm stars\n apm stars --install\n apm stars --user thedaniel\n apm stars --themes\n\nList or install starred Atom packages and themes.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('i', 'install').boolean('install').describe('install', 'Install the starred packages');
options.alias('t', 'themes').boolean('themes').describe('themes', 'Only list themes');
options.alias('u', 'user').string('user').describe('user', 'GitHub username to show starred packages for');
return options.boolean('json').describe('json', 'Output packages as a JSON array');
};
Stars.prototype.getStarredPackages = function(user, atomVersion, callback) {
var requestSettings;
requestSettings = {
json: true
};
if (atomVersion) {
requestSettings.qs = {
engine: atomVersion
};
if (atomVersion) {
requestSettings.qs = {
engine: atomVersion
};
}
if (user) {
requestSettings.url = `${config.getAtomApiUrl()}/users/${user}/stars`;
return this.requestStarredPackages(requestSettings, callback);
} else {
requestSettings.url = `${config.getAtomApiUrl()}/stars`;
return Login.getTokenOrLogin((error, token) => {
}
if (user) {
requestSettings.url = (config.getAtomApiUrl()) + "/users/" + user + "/stars";
return this.requestStarredPackages(requestSettings, callback);
} else {
requestSettings.url = (config.getAtomApiUrl()) + "/stars";
return Login.getTokenOrLogin((function(_this) {
return function(error, token) {
if (error != null) {

@@ -56,79 +67,97 @@ return callback(error);

};
return this.requestStarredPackages(requestSettings, callback);
});
}
return _this.requestStarredPackages(requestSettings, callback);
};
})(this));
}
};
requestStarredPackages(requestSettings, callback) {
return request.get(requestSettings, function(error, response, body = []) {
var message, packages;
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
packages = body.filter(function(pack) {
var ref;
return (pack != null ? (ref = pack.releases) != null ? ref.latest : void 0 : void 0) != null;
Stars.prototype.requestStarredPackages = function(requestSettings, callback) {
return request.get(requestSettings, function(error, response, body) {
var message, packages;
if (body == null) {
body = [];
}
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
packages = body.filter(function(pack) {
var ref;
return (pack != null ? (ref = pack.releases) != null ? ref.latest : void 0 : void 0) != null;
});
packages = packages.map(function(arg) {
var downloads, metadata, readme, stargazers_count;
readme = arg.readme, metadata = arg.metadata, downloads = arg.downloads, stargazers_count = arg.stargazers_count;
return _.extend({}, metadata, {
readme: readme,
downloads: downloads,
stargazers_count: stargazers_count
});
packages = packages.map(function({readme, metadata, downloads, stargazers_count}) {
return _.extend({}, metadata, {readme, downloads, stargazers_count});
});
packages = _.sortBy(packages, 'name');
return callback(null, packages);
} else {
message = request.getErrorMessage(response, body);
return callback(`Requesting packages failed: ${message}`);
}
});
}
installPackages(packages, callback) {
var commandArgs;
if (packages.length === 0) {
return callback();
});
packages = _.sortBy(packages, 'name');
return callback(null, packages);
} else {
message = request.getErrorMessage(response, body);
return callback("Requesting packages failed: " + message);
}
commandArgs = packages.map(function({name}) {
return name;
});
return new Install().run({commandArgs, callback});
}
});
};
logPackagesAsJson(packages, callback) {
console.log(JSON.stringify(packages));
Stars.prototype.installPackages = function(packages, callback) {
var commandArgs;
if (packages.length === 0) {
return callback();
}
commandArgs = packages.map(function(arg) {
var name;
name = arg.name;
return name;
});
return new Install().run({
commandArgs: commandArgs,
callback: callback
});
};
logPackagesAsText(user, packagesAreThemes, packages, callback) {
var label, userLabel;
userLabel = user != null ? user : 'you';
if (packagesAreThemes) {
label = `Themes starred by ${userLabel}`;
} else {
label = `Packages starred by ${userLabel}`;
Stars.prototype.logPackagesAsJson = function(packages, callback) {
console.log(JSON.stringify(packages));
return callback();
};
Stars.prototype.logPackagesAsText = function(user, packagesAreThemes, packages, callback) {
var label, userLabel;
userLabel = user != null ? user : 'you';
if (packagesAreThemes) {
label = "Themes starred by " + userLabel;
} else {
label = "Packages starred by " + userLabel;
}
console.log(label.cyan + " (" + packages.length + ")");
tree(packages, function(arg) {
var description, downloads, name, stargazers_count, version;
name = arg.name, version = arg.version, description = arg.description, downloads = arg.downloads, stargazers_count = arg.stargazers_count;
label = name.yellow;
if (process.platform === 'darwin') {
label = "\u2B50 " + label;
}
console.log(`${label.cyan} (${packages.length})`);
tree(packages, function({name, version, description, downloads, stargazers_count}) {
label = name.yellow;
if (process.platform === 'darwin') {
label = `\u2B50 ${label}`;
}
if (description) {
label += ` ${description.replace(/\s+/g, ' ')}`;
}
if (downloads >= 0 && stargazers_count >= 0) {
label += ` (${_.pluralize(downloads, 'download')}, ${_.pluralize(stargazers_count, 'star')})`.grey;
}
return label;
});
console.log();
console.log(`Use \`apm stars --install\` to install them all or visit ${'http://atom.io/packages'.underline} to read more about them.`);
console.log();
return callback();
}
if (description) {
label += " " + (description.replace(/\s+/g, ' '));
}
if (downloads >= 0 && stargazers_count >= 0) {
label += (" (" + (_.pluralize(downloads, 'download')) + ", " + (_.pluralize(stargazers_count, 'star')) + ")").grey;
}
return label;
});
console.log();
console.log("Use `apm stars --install` to install them all or visit " + 'http://atom.io/packages'.underline + " to read more about them.");
console.log();
return callback();
};
run(options) {
var callback, ref, user;
({callback} = options);
options = this.parseOptions(options.commandArgs);
user = (ref = options.argv.user) != null ? ref.toString().trim() : void 0;
return this.getStarredPackages(user, options.argv.compatible, (error, packages) => {
Stars.prototype.run = function(options) {
var callback, ref, user;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
user = (ref = options.argv.user) != null ? ref.toString().trim() : void 0;
return this.getStarredPackages(user, options.argv.compatible, (function(_this) {
return function(error, packages) {
if (error != null) {

@@ -138,3 +167,5 @@ return callback(error);

if (options.argv.themes) {
packages = packages.filter(function({theme}) {
packages = packages.filter(function(arg) {
var theme;
theme = arg.theme;
return theme;

@@ -144,19 +175,16 @@ });

if (options.argv.install) {
return this.installPackages(packages, callback);
return _this.installPackages(packages, callback);
} else if (options.argv.json) {
return this.logPackagesAsJson(packages, callback);
return _this.logPackagesAsJson(packages, callback);
} else {
return this.logPackagesAsText(user, options.argv.themes, packages, callback);
return _this.logPackagesAsText(user, options.argv.themes, packages, callback);
}
});
}
};
})(this));
};
Stars.commandNames = ['stars', 'starred'];
return Stars;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Test, fs, path, temp, yargs;
var Command, Test, fs, path, temp, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -14,78 +17,81 @@ path = require('path');

module.exports = Test = (function() {
class Test extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage:\n apm test\n\nRuns the package's tests contained within the spec directory (relative\nto the current working directory).");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.alias('p', 'path').string('path').describe('path', 'Path to atom command');
module.exports = Test = (function(superClass) {
extend(Test, superClass);
function Test() {
return Test.__super__.constructor.apply(this, arguments);
}
Test.commandNames = ['test'];
Test.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage:\n apm test\n\nRuns the package's tests contained within the spec directory (relative\nto the current working directory).");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.alias('p', 'path').string('path').describe('path', 'Path to atom command');
};
Test.prototype.run = function(options) {
var atomCommand, callback, env, logFile, logFilePath, packagePath, testArgs;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
env = process.env;
if (options.argv.path) {
atomCommand = options.argv.path;
}
run(options) {
var atomCommand, callback, env, logFile, logFilePath, packagePath, testArgs;
({callback} = options);
options = this.parseOptions(options.commandArgs);
({env} = process);
if (options.argv.path) {
atomCommand = options.argv.path;
}
if (!fs.existsSync(atomCommand)) {
atomCommand = 'atom';
if (process.platform === 'win32') {
atomCommand += '.cmd';
}
}
packagePath = process.cwd();
testArgs = ['--dev', '--test', path.join(packagePath, 'spec')];
if (!fs.existsSync(atomCommand)) {
atomCommand = 'atom';
if (process.platform === 'win32') {
logFile = temp.openSync({
suffix: '.log',
prefix: `${path.basename(packagePath)}-`
});
fs.closeSync(logFile.fd);
logFilePath = logFile.path;
testArgs.push(`--log-file=${logFilePath}`);
return this.spawn(atomCommand, testArgs, function(code) {
var loggedOutput;
try {
loggedOutput = fs.readFileSync(logFilePath, 'utf8');
if (loggedOutput) {
process.stdout.write(`${loggedOutput}\n`);
}
} catch (error) {}
if (code === 0) {
process.stdout.write('Tests passed\n'.green);
return callback();
} else if (code != null ? code.message : void 0) {
return callback(`Error spawning Atom: ${code.message}`);
} else {
return callback('Tests failed');
}
});
} else {
return this.spawn(atomCommand, testArgs, {
env,
streaming: true
}, function(code) {
if (code === 0) {
process.stdout.write('Tests passed\n'.green);
return callback();
} else if (code != null ? code.message : void 0) {
return callback(`Error spawning ${atomCommand}: ${code.message}`);
} else {
return callback('Tests failed');
}
});
atomCommand += '.cmd';
}
}
packagePath = process.cwd();
testArgs = ['--dev', '--test', path.join(packagePath, 'spec')];
if (process.platform === 'win32') {
logFile = temp.openSync({
suffix: '.log',
prefix: (path.basename(packagePath)) + "-"
});
fs.closeSync(logFile.fd);
logFilePath = logFile.path;
testArgs.push("--log-file=" + logFilePath);
return this.spawn(atomCommand, testArgs, function(code) {
var loggedOutput;
try {
loggedOutput = fs.readFileSync(logFilePath, 'utf8');
if (loggedOutput) {
process.stdout.write(loggedOutput + "\n");
}
} catch (error) {}
if (code === 0) {
process.stdout.write('Tests passed\n'.green);
return callback();
} else if (code != null ? code.message : void 0) {
return callback("Error spawning Atom: " + code.message);
} else {
return callback('Tests failed');
}
});
} else {
return this.spawn(atomCommand, testArgs, {
env: env,
streaming: true
}, function(code) {
if (code === 0) {
process.stdout.write('Tests passed\n'.green);
return callback();
} else if (code != null ? code.message : void 0) {
return callback("Error spawning " + atomCommand + ": " + code.message);
} else {
return callback('Tests failed');
}
});
}
};
Test.commandNames = ['test'];
return Test;
}).call(this);
})(Command);
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -8,6 +9,6 @@ var ScopeSelector, SyntaxVariablesTemplate, TextMateTheme, _, plist;

({ScopeSelector} = require('first-mate'));
ScopeSelector = require('first-mate').ScopeSelector;
module.exports = TextMateTheme = class TextMateTheme {
constructor(contents) {
module.exports = TextMateTheme = (function() {
function TextMateTheme(contents) {
this.contents = contents;

@@ -18,5 +19,5 @@ this.rulesets = [];

buildRulesets() {
var background, caret, foreground, i, invisibles, len, lineHighlight, name, ref, scope, selection, setting, settings, variableSettings;
({settings} = (ref = plist.parseStringSync(this.contents)) != null ? ref : {});
TextMateTheme.prototype.buildRulesets = function() {
var background, caret, foreground, i, invisibles, len, lineHighlight, name, ref, ref1, ref2, scope, selection, setting, settings, variableSettings;
settings = ((ref = plist.parseStringSync(this.contents)) != null ? ref : {}).settings;
if (settings == null) {

@@ -27,9 +28,7 @@ settings = [];

setting = settings[i];
({scope, name} = setting.settings);
ref1 = setting.settings, scope = ref1.scope, name = ref1.name;
if (scope || name) {
continue;
}
// Require all of these or invalid LESS will be generated if any required
// variable value is missing
({background, foreground, caret, selection, invisibles, lineHighlight} = setting.settings);
ref2 = setting.settings, background = ref2.background, foreground = ref2.foreground, caret = ref2.caret, selection = ref2.selection, invisibles = ref2.invisibles, lineHighlight = ref2.lineHighlight;
if (background && foreground && caret && selection && lineHighlight && invisibles) {

@@ -46,14 +45,14 @@ variableSettings = setting.settings;

return this.buildScopeSelectorRulesets(settings);
}
};
getStylesheet() {
var i, len, lines, name, properties, ref, selector, value;
TextMateTheme.prototype.getStylesheet = function() {
var i, len, lines, name, properties, ref, ref1, selector, value;
lines = ['@import "syntax-variables";', ''];
ref = this.getRulesets();
for (i = 0, len = ref.length; i < len; i++) {
({selector, properties} = ref[i]);
lines.push(`${selector} {`);
ref1 = ref[i], selector = ref1.selector, properties = ref1.properties;
lines.push(selector + " {");
for (name in properties) {
value = properties[name];
lines.push(` ${name}: ${value};`);
lines.push(" " + name + ": " + value + ";");
}

@@ -63,13 +62,13 @@ lines.push("}\n");

return lines.join('\n');
}
};
getRulesets() {
TextMateTheme.prototype.getRulesets = function() {
return this.rulesets;
}
};
getSyntaxVariables() {
TextMateTheme.prototype.getSyntaxVariables = function() {
return this.syntaxVariables;
}
};
buildSyntaxVariables(settings) {
TextMateTheme.prototype.buildSyntaxVariables = function(settings) {
var key, replaceRegex, value;

@@ -79,9 +78,9 @@ this.syntaxVariables = SyntaxVariablesTemplate;

value = settings[key];
replaceRegex = new RegExp(`\\{\\{${key}\\}\\}`, 'g');
replaceRegex = new RegExp("\\{\\{" + key + "\\}\\}", 'g');
this.syntaxVariables = this.syntaxVariables.replace(replaceRegex, this.translateColor(value));
}
return this.syntaxVariables;
}
};
buildGlobalSettingsRulesets(settings) {
TextMateTheme.prototype.buildGlobalSettingsRulesets = function(settings) {
this.rulesets.push({

@@ -150,9 +149,9 @@ selector: 'atom-text-editor',

});
}
};
buildScopeSelectorRulesets(scopeSelectorSettings) {
var i, len, name, results, scope, settings;
TextMateTheme.prototype.buildScopeSelectorRulesets = function(scopeSelectorSettings) {
var i, len, name, ref, results, scope, settings;
results = [];
for (i = 0, len = scopeSelectorSettings.length; i < len; i++) {
({name, scope, settings} = scopeSelectorSettings[i]);
ref = scopeSelectorSettings[i], name = ref.name, scope = ref.scope, settings = ref.settings;
if (!scope) {

@@ -168,10 +167,11 @@ continue;

return results;
}
};
translateScopeSelector(textmateScopeSelector) {
TextMateTheme.prototype.translateScopeSelector = function(textmateScopeSelector) {
return new ScopeSelector(textmateScopeSelector).toCssSyntaxSelector();
}
};
translateScopeSelectorSettings({foreground, background, fontStyle}) {
var fontStyles, properties;
TextMateTheme.prototype.translateScopeSelectorSettings = function(arg) {
var background, fontStyle, fontStyles, foreground, properties;
foreground = arg.foreground, background = arg.background, fontStyle = arg.fontStyle;
properties = {};

@@ -197,7 +197,7 @@ if (fontStyle) {

return properties;
}
};
translateColor(textmateColor) {
TextMateTheme.prototype.translateColor = function(textmateColor) {
var a, b, g, r;
textmateColor = `#${textmateColor.replace(/^#+/, '')}`;
textmateColor = "#" + (textmateColor.replace(/^#+/, ''));
if (textmateColor.length <= 7) {

@@ -211,7 +211,7 @@ return textmateColor;

a = Math.round((a / 255.0) * 100) / 100;
return `rgba(${r}, ${g}, ${b}, ${a})`;
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
}
}
};
parseHexColor(color) {
TextMateTheme.prototype.parseHexColor = function(color) {
var parsed;

@@ -224,8 +224,10 @@ parsed = Math.min(255, Math.max(0, parseInt(color, 16)));

}
}
};
};
return TextMateTheme;
})();
SyntaxVariablesTemplate = "// This defines all syntax variables that syntax themes must implement when they\n// include a syntax-variables.less file.\n\n// General colors\n@syntax-text-color: {{foreground}};\n@syntax-cursor-color: {{caret}};\n@syntax-selection-color: {{selection}};\n@syntax-background-color: {{background}};\n\n// Guide colors\n@syntax-wrap-guide-color: {{invisibles}};\n@syntax-indent-guide-color: {{invisibles}};\n@syntax-invisible-character-color: {{invisibles}};\n\n// For find and replace markers\n@syntax-result-marker-color: {{invisibles}};\n@syntax-result-marker-color-selected: {{foreground}};\n\n// Gutter colors\n@syntax-gutter-text-color: {{foreground}};\n@syntax-gutter-text-color-selected: {{foreground}};\n@syntax-gutter-background-color: {{background}};\n@syntax-gutter-background-color-selected: {{lineHighlight}};\n\n// For git diff info. i.e. in the gutter\n// These are static and were not extracted from your textmate theme\n@syntax-color-renamed: #96CBFE;\n@syntax-color-added: #A8FF60;\n@syntax-color-modified: #E9C062;\n@syntax-color-removed: #CC6666;";
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -14,5 +15,4 @@ var TextMateTheme, ThemeConverter, fs, path, request, url;

// Convert a TextMate theme to an Atom theme
module.exports = ThemeConverter = class ThemeConverter {
constructor(sourcePath1, destinationPath) {
module.exports = ThemeConverter = (function() {
function ThemeConverter(sourcePath1, destinationPath) {
this.sourcePath = sourcePath1;

@@ -22,5 +22,5 @@ this.destinationPath = path.resolve(destinationPath);

readTheme(callback) {
ThemeConverter.prototype.readTheme = function(callback) {
var protocol, requestOptions, sourcePath;
({protocol} = url.parse(this.sourcePath));
protocol = url.parse(this.sourcePath).protocol;
if (protocol === 'http:' || protocol === 'https:') {

@@ -30,14 +30,16 @@ requestOptions = {

};
return request.get(requestOptions, (error, response, body) => {
if (error != null) {
if (error.code === 'ENOTFOUND') {
error = `Could not resolve URL: ${this.sourcePath}`;
return request.get(requestOptions, (function(_this) {
return function(error, response, body) {
if (error != null) {
if (error.code === 'ENOTFOUND') {
error = "Could not resolve URL: " + _this.sourcePath;
}
return callback(error);
} else if (response.statusCode !== 200) {
return callback("Request to " + _this.sourcePath + " failed (" + response.headers.status + ")");
} else {
return callback(null, body);
}
return callback(error);
} else if (response.statusCode !== 200) {
return callback(`Request to ${this.sourcePath} failed (${response.headers.status})`);
} else {
return callback(null, body);
}
});
};
})(this));
} else {

@@ -48,27 +50,31 @@ sourcePath = path.resolve(this.sourcePath);

} else {
return callback(`TextMate theme file not found: ${sourcePath}`);
return callback("TextMate theme file not found: " + sourcePath);
}
}
}
};
convert(callback) {
return this.readTheme((error, themeContents) => {
var theme;
if (error != null) {
return callback(error);
}
try {
theme = new TextMateTheme(themeContents);
} catch (error1) {
error = error1;
return callback(error);
}
fs.writeFileSync(path.join(this.destinationPath, 'styles', 'base.less'), theme.getStylesheet());
fs.writeFileSync(path.join(this.destinationPath, 'styles', 'syntax-variables.less'), theme.getSyntaxVariables());
return callback();
});
}
ThemeConverter.prototype.convert = function(callback) {
return this.readTheme((function(_this) {
return function(error, themeContents) {
var theme;
if (error != null) {
return callback(error);
}
try {
theme = new TextMateTheme(themeContents);
} catch (error1) {
error = error1;
return callback(error);
}
fs.writeFileSync(path.join(_this.destinationPath, 'styles', 'base.less'), theme.getStylesheet());
fs.writeFileSync(path.join(_this.destinationPath, 'styles', 'syntax-variables.less'), theme.getSyntaxVariables());
return callback();
};
})(this));
};
};
return ThemeConverter;
})();
}).call(this);

@@ -0,1 +1,2 @@

// Generated by CoffeeScript 1.12.7
(function() {

@@ -6,4 +7,7 @@ var _;

module.exports = function(items, options = {}, callback) {
module.exports = function(items, options, callback) {
var emptyMessage, i, index, item, itemLine, len, ref, results;
if (options == null) {
options = {};
}
if (_.isFunction(options)) {

@@ -20,3 +24,3 @@ callback = options;

emptyMessage = (ref = options.emptyMessage) != null ? ref : '(empty)';
return console.log(`\u2514\u2500\u2500 ${emptyMessage}`);
return console.log("\u2514\u2500\u2500 " + emptyMessage);
} else {

@@ -31,3 +35,3 @@ results = [];

}
results.push(console.log(`${itemLine}${callback(item)}`));
results.push(console.log("" + itemLine + (callback(item))));
}

@@ -34,0 +38,0 @@ return results;

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Uninstall, async, auth, config, fs, path, request, yargs;
var CSON, Command, Uninstall, async, auth, config, fs, path, request, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -22,107 +25,115 @@ path = require('path');

module.exports = Uninstall = (function() {
class Uninstall extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm uninstall <package_name>...\n\nDelete the installed package(s) from the ~/.atom/packages directory.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('d', 'dev').boolean('dev').describe('dev', 'Uninstall from ~/.atom/dev/packages');
return options.boolean('hard').describe('hard', 'Uninstall from ~/.atom/packages and ~/.atom/dev/packages');
module.exports = Uninstall = (function(superClass) {
extend(Uninstall, superClass);
function Uninstall() {
return Uninstall.__super__.constructor.apply(this, arguments);
}
Uninstall.commandNames = ['deinstall', 'delete', 'erase', 'remove', 'rm', 'uninstall'];
Uninstall.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm uninstall <package_name>...\n\nDelete the installed package(s) from the ~/.atom/packages directory.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('d', 'dev').boolean('dev').describe('dev', 'Uninstall from ~/.atom/dev/packages');
return options.boolean('hard').describe('hard', 'Uninstall from ~/.atom/packages and ~/.atom/dev/packages');
};
Uninstall.prototype.getPackageVersion = function(packageDirectory) {
var error, ref;
try {
return (ref = CSON.readFileSync(path.join(packageDirectory, 'package.json'))) != null ? ref.version : void 0;
} catch (error1) {
error = error1;
return null;
}
};
getPackageVersion(packageDirectory) {
var error, ref;
try {
return (ref = CSON.readFileSync(path.join(packageDirectory, 'package.json'))) != null ? ref.version : void 0;
} catch (error1) {
error = error1;
return null;
}
Uninstall.prototype.registerUninstall = function(arg, callback) {
var packageName, packageVersion;
packageName = arg.packageName, packageVersion = arg.packageVersion;
if (!packageVersion) {
return callback();
}
registerUninstall({packageName, packageVersion}, callback) {
if (!packageVersion) {
return auth.getToken(function(error, token) {
var requestOptions;
if (!token) {
return callback();
}
return auth.getToken(function(error, token) {
var requestOptions;
if (!token) {
return callback();
requestOptions = {
url: (config.getAtomPackagesUrl()) + "/" + packageName + "/versions/" + packageVersion + "/events/uninstall",
json: true,
headers: {
authorization: token
}
requestOptions = {
url: `${config.getAtomPackagesUrl()}/${packageName}/versions/${packageVersion}/events/uninstall`,
json: true,
headers: {
authorization: token
}
};
return request.post(requestOptions, function(error, response, body) {
return callback();
});
};
return request.post(requestOptions, function(error, response, body) {
return callback();
});
});
};
Uninstall.prototype.run = function(options) {
var callback, devPackagesDirectory, error, i, len, packageDirectory, packageManifestPath, packageName, packageNames, packageVersion, packagesDirectory, uninstallError, uninstallsToRegister;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
callback("Please specify a package name to uninstall");
return;
}
run(options) {
var callback, devPackagesDirectory, error, i, len, packageDirectory, packageManifestPath, packageName, packageNames, packageVersion, packagesDirectory, uninstallError, uninstallsToRegister;
({callback} = options);
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
callback("Please specify a package name to uninstall");
return;
packagesDirectory = path.join(config.getAtomDirectory(), 'packages');
devPackagesDirectory = path.join(config.getAtomDirectory(), 'dev', 'packages');
uninstallsToRegister = [];
uninstallError = null;
for (i = 0, len = packageNames.length; i < len; i++) {
packageName = packageNames[i];
if (packageName === '.') {
packageName = path.basename(process.cwd());
}
packagesDirectory = path.join(config.getAtomDirectory(), 'packages');
devPackagesDirectory = path.join(config.getAtomDirectory(), 'dev', 'packages');
uninstallsToRegister = [];
uninstallError = null;
for (i = 0, len = packageNames.length; i < len; i++) {
packageName = packageNames[i];
if (packageName === '.') {
packageName = path.basename(process.cwd());
}
process.stdout.write(`Uninstalling ${packageName} `);
try {
if (!options.argv.dev) {
packageDirectory = path.join(packagesDirectory, packageName);
packageManifestPath = path.join(packageDirectory, 'package.json');
if (fs.existsSync(packageManifestPath)) {
packageVersion = this.getPackageVersion(packageDirectory);
fs.removeSync(packageDirectory);
if (packageVersion) {
uninstallsToRegister.push({packageName, packageVersion});
}
} else if (!options.argv.hard) {
throw new Error(`No package.json found at ${packageManifestPath}`);
process.stdout.write("Uninstalling " + packageName + " ");
try {
if (!options.argv.dev) {
packageDirectory = path.join(packagesDirectory, packageName);
packageManifestPath = path.join(packageDirectory, 'package.json');
if (fs.existsSync(packageManifestPath)) {
packageVersion = this.getPackageVersion(packageDirectory);
fs.removeSync(packageDirectory);
if (packageVersion) {
uninstallsToRegister.push({
packageName: packageName,
packageVersion: packageVersion
});
}
} else if (!options.argv.hard) {
throw new Error("No package.json found at " + packageManifestPath);
}
if (options.argv.hard || options.argv.dev) {
packageDirectory = path.join(devPackagesDirectory, packageName);
if (fs.existsSync(packageDirectory)) {
fs.removeSync(packageDirectory);
} else if (!options.argv.hard) {
throw new Error("Does not exist");
}
}
if (options.argv.hard || options.argv.dev) {
packageDirectory = path.join(devPackagesDirectory, packageName);
if (fs.existsSync(packageDirectory)) {
fs.removeSync(packageDirectory);
} else if (!options.argv.hard) {
throw new Error("Does not exist");
}
this.logSuccess();
} catch (error1) {
error = error1;
this.logFailure();
uninstallError = new Error(`Failed to delete ${packageName}: ${error.message}`);
break;
}
this.logSuccess();
} catch (error1) {
error = error1;
this.logFailure();
uninstallError = new Error("Failed to delete " + packageName + ": " + error.message);
break;
}
return async.eachSeries(uninstallsToRegister, this.registerUninstall.bind(this), function() {
return callback(uninstallError);
});
}
return async.eachSeries(uninstallsToRegister, this.registerUninstall.bind(this), function() {
return callback(uninstallError);
});
};
Uninstall.commandNames = ['deinstall', 'delete', 'erase', 'remove', 'rm', 'uninstall'];
return Uninstall;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var CSON, Command, Unlink, config, fs, path, yargs;
var CSON, Command, Unlink, config, fs, path, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,48 +19,60 @@ path = require('path');

module.exports = Unlink = (function() {
class Unlink extends Command {
constructor() {
super();
this.devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages');
this.packagesPath = path.join(config.getAtomDirectory(), 'packages');
}
module.exports = Unlink = (function(superClass) {
extend(Unlink, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm unlink [<package_path>]\n\nDelete the symlink in ~/.atom/packages for the package. The package in the\ncurrent working directory is unlinked if no path is given.\n\nRun `apm links` to view all the currently linked packages.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('d', 'dev').boolean('dev').describe('dev', 'Unlink package from ~/.atom/dev/packages');
options.boolean('hard').describe('hard', 'Unlink package from ~/.atom/packages and ~/.atom/dev/packages');
return options.alias('a', 'all').boolean('all').describe('all', 'Unlink all packages in ~/.atom/packages and ~/.atom/dev/packages');
}
Unlink.commandNames = ['unlink'];
getDevPackagePath(packageName) {
return path.join(this.devPackagesPath, packageName);
}
function Unlink() {
Unlink.__super__.constructor.call(this);
this.devPackagesPath = path.join(config.getAtomDirectory(), 'dev', 'packages');
this.packagesPath = path.join(config.getAtomDirectory(), 'packages');
}
getPackagePath(packageName) {
return path.join(this.packagesPath, packageName);
Unlink.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm unlink [<package_path>]\n\nDelete the symlink in ~/.atom/packages for the package. The package in the\ncurrent working directory is unlinked if no path is given.\n\nRun `apm links` to view all the currently linked packages.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('d', 'dev').boolean('dev').describe('dev', 'Unlink package from ~/.atom/dev/packages');
options.boolean('hard').describe('hard', 'Unlink package from ~/.atom/packages and ~/.atom/dev/packages');
return options.alias('a', 'all').boolean('all').describe('all', 'Unlink all packages in ~/.atom/packages and ~/.atom/dev/packages');
};
Unlink.prototype.getDevPackagePath = function(packageName) {
return path.join(this.devPackagesPath, packageName);
};
Unlink.prototype.getPackagePath = function(packageName) {
return path.join(this.packagesPath, packageName);
};
Unlink.prototype.unlinkPath = function(pathToUnlink) {
var error;
try {
process.stdout.write("Unlinking " + pathToUnlink + " ");
fs.unlinkSync(pathToUnlink);
return this.logSuccess();
} catch (error1) {
error = error1;
this.logFailure();
throw error;
}
};
unlinkPath(pathToUnlink) {
var error;
try {
process.stdout.write(`Unlinking ${pathToUnlink} `);
fs.unlinkSync(pathToUnlink);
return this.logSuccess();
} catch (error1) {
error = error1;
this.logFailure();
throw error;
Unlink.prototype.unlinkAll = function(options, callback) {
var child, error, i, j, len, len1, packagePath, ref, ref1;
try {
ref = fs.list(this.devPackagesPath);
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
packagePath = path.join(this.devPackagesPath, child);
if (fs.isSymbolicLinkSync(packagePath)) {
this.unlinkPath(packagePath);
}
}
}
unlinkAll(options, callback) {
var child, error, i, j, len, len1, packagePath, ref, ref1;
try {
ref = fs.list(this.devPackagesPath);
for (i = 0, len = ref.length; i < len; i++) {
child = ref[i];
packagePath = path.join(this.devPackagesPath, child);
if (!options.argv.dev) {
ref1 = fs.list(this.packagesPath);
for (j = 0, len1 = ref1.length; j < len1; j++) {
child = ref1[j];
packagePath = path.join(this.packagesPath, child);
if (fs.isSymbolicLinkSync(packagePath)) {

@@ -67,12 +82,24 @@ this.unlinkPath(packagePath);

}
if (!options.argv.dev) {
ref1 = fs.list(this.packagesPath);
for (j = 0, len1 = ref1.length; j < len1; j++) {
child = ref1[j];
packagePath = path.join(this.packagesPath, child);
if (fs.isSymbolicLinkSync(packagePath)) {
this.unlinkPath(packagePath);
}
}
}
}
return callback();
} catch (error1) {
error = error1;
return callback(error);
}
};
Unlink.prototype.unlinkPackage = function(options, callback) {
var error, linkPath, packageName, packagePath, ref, ref1, targetPath;
packagePath = (ref = (ref1 = options.argv._[0]) != null ? ref1.toString() : void 0) != null ? ref : '.';
linkPath = path.resolve(process.cwd(), packagePath);
try {
packageName = CSON.readFileSync(CSON.resolve(path.join(linkPath, 'package'))).name;
} catch (error1) {}
if (!packageName) {
packageName = path.basename(linkPath);
}
if (options.argv.hard) {
try {
this.unlinkPath(this.getDevPackagePath(packageName));
this.unlinkPath(this.getPackagePath(packageName));
return callback();

@@ -83,58 +110,33 @@ } catch (error1) {

}
}
unlinkPackage(options, callback) {
var error, linkPath, packageName, packagePath, ref, ref1, targetPath;
packagePath = (ref = (ref1 = options.argv._[0]) != null ? ref1.toString() : void 0) != null ? ref : '.';
linkPath = path.resolve(process.cwd(), packagePath);
} else {
if (options.argv.dev) {
targetPath = this.getDevPackagePath(packageName);
} else {
targetPath = this.getPackagePath(packageName);
}
try {
packageName = CSON.readFileSync(CSON.resolve(path.join(linkPath, 'package'))).name;
} catch (error1) {}
if (!packageName) {
packageName = path.basename(linkPath);
this.unlinkPath(targetPath);
return callback();
} catch (error1) {
error = error1;
return callback(error);
}
if (options.argv.hard) {
try {
this.unlinkPath(this.getDevPackagePath(packageName));
this.unlinkPath(this.getPackagePath(packageName));
return callback();
} catch (error1) {
error = error1;
return callback(error);
}
} else {
if (options.argv.dev) {
targetPath = this.getDevPackagePath(packageName);
} else {
targetPath = this.getPackagePath(packageName);
}
try {
this.unlinkPath(targetPath);
return callback();
} catch (error1) {
error = error1;
return callback(error);
}
}
}
};
run(options) {
var callback;
({callback} = options);
options = this.parseOptions(options.commandArgs);
if (options.argv.all) {
return this.unlinkAll(options, callback);
} else {
return this.unlinkPackage(options, callback);
}
Unlink.prototype.run = function(options) {
var callback;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
if (options.argv.all) {
return this.unlinkAll(options, callback);
} else {
return this.unlinkPackage(options, callback);
}
};
Unlink.commandNames = ['unlink'];
return Unlink;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Unpublish, auth, config, fs, path, readline, request, yargs;
var Command, Unpublish, auth, config, fs, path, readline, request, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -20,23 +23,31 @@ path = require('path');

module.exports = Unpublish = (function() {
class Unpublish extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm unpublish [<package_name>]\n apm unpublish <package_name>@<package_version>\n\nRemove a published package or package version from the atom.io registry.\n\nThe package in the current working directory will be used if no package\nname is specified.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.alias('f', 'force').boolean('force').describe('force', 'Do not prompt for confirmation');
module.exports = Unpublish = (function(superClass) {
extend(Unpublish, superClass);
function Unpublish() {
return Unpublish.__super__.constructor.apply(this, arguments);
}
Unpublish.commandNames = ['unpublish'];
Unpublish.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("Usage: apm unpublish [<package_name>]\n apm unpublish <package_name>@<package_version>\n\nRemove a published package or package version from the atom.io registry.\n\nThe package in the current working directory will be used if no package\nname is specified.");
options.alias('h', 'help').describe('help', 'Print this usage message');
return options.alias('f', 'force').boolean('force').describe('force', 'Do not prompt for confirmation');
};
Unpublish.prototype.unpublishPackage = function(packageName, packageVersion, callback) {
var packageLabel;
packageLabel = packageName;
if (packageVersion) {
packageLabel += "@" + packageVersion;
}
unpublishPackage(packageName, packageVersion, callback) {
var packageLabel;
packageLabel = packageName;
if (packageVersion) {
packageLabel += `@${packageVersion}`;
}
process.stdout.write(`Unpublishing ${packageLabel} `);
return auth.getToken((error, token) => {
process.stdout.write("Unpublishing " + packageLabel + " ");
return auth.getToken((function(_this) {
return function(error, token) {
var options;
if (error != null) {
this.logFailure();
_this.logFailure();
callback(error);

@@ -46,3 +57,3 @@ return;

options = {
uri: `${config.getAtomPackagesUrl()}/${packageName}`,
uri: (config.getAtomPackagesUrl()) + "/" + packageName,
headers: {

@@ -54,86 +65,88 @@ authorization: token

if (packageVersion) {
options.uri += `/versions/${packageVersion}`;
options.uri += "/versions/" + packageVersion;
}
return request.del(options, (error, response, body = {}) => {
return request.del(options, function(error, response, body) {
var message, ref, ref1;
if (body == null) {
body = {};
}
if (error != null) {
this.logFailure();
_this.logFailure();
return callback(error);
} else if (response.statusCode !== 204) {
this.logFailure();
_this.logFailure();
message = (ref = (ref1 = body.message) != null ? ref1 : body.error) != null ? ref : body;
return callback(`Unpublishing failed: ${message}`);
return callback("Unpublishing failed: " + message);
} else {
this.logSuccess();
_this.logSuccess();
return callback();
}
});
});
};
})(this));
};
Unpublish.prototype.promptForConfirmation = function(packageName, packageVersion, callback) {
var packageLabel, question;
packageLabel = packageName;
if (packageVersion) {
packageLabel += "@" + packageVersion;
}
promptForConfirmation(packageName, packageVersion, callback) {
var packageLabel, question;
packageLabel = packageName;
if (packageVersion) {
packageLabel += `@${packageVersion}`;
}
if (packageVersion) {
question = `Are you sure you want to unpublish '${packageLabel}'? (no) `;
} else {
question = `Are you sure you want to unpublish ALL VERSIONS of '${packageLabel}'? ` + "This will remove it from the apm registry, including " + "download counts and stars, and this action is irreversible. (no)";
}
return this.prompt(question, (answer) => {
if (packageVersion) {
question = "Are you sure you want to unpublish '" + packageLabel + "'? (no) ";
} else {
question = ("Are you sure you want to unpublish ALL VERSIONS of '" + packageLabel + "'? ") + "This will remove it from the apm registry, including " + "download counts and stars, and this action is irreversible. (no)";
}
return this.prompt(question, (function(_this) {
return function(answer) {
answer = answer ? answer.trim().toLowerCase() : 'no';
if (answer === 'y' || answer === 'yes') {
return this.unpublishPackage(packageName, packageVersion, callback);
return _this.unpublishPackage(packageName, packageVersion, callback);
} else {
return callback(`Cancelled unpublishing ${packageLabel}`);
return callback("Cancelled unpublishing " + packageLabel);
}
});
}
};
})(this));
};
prompt(question, callback) {
var prompt;
prompt = readline.createInterface(process.stdin, process.stdout);
return prompt.question(question, function(answer) {
prompt.close();
return callback(answer);
});
}
Unpublish.prototype.prompt = function(question, callback) {
var prompt;
prompt = readline.createInterface(process.stdin, process.stdout);
return prompt.question(question, function(answer) {
prompt.close();
return callback(answer);
});
};
run(options) {
var atIndex, callback, name, ref, version;
({callback} = options);
options = this.parseOptions(options.commandArgs);
[name] = options.argv._;
if ((name != null ? name.length : void 0) > 0) {
atIndex = name.indexOf('@');
if (atIndex !== -1) {
version = name.substring(atIndex + 1);
name = name.substring(0, atIndex);
}
Unpublish.prototype.run = function(options) {
var atIndex, callback, name, ref, version;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
name = options.argv._[0];
if ((name != null ? name.length : void 0) > 0) {
atIndex = name.indexOf('@');
if (atIndex !== -1) {
version = name.substring(atIndex + 1);
name = name.substring(0, atIndex);
}
if (!name) {
try {
name = (ref = JSON.parse(fs.readFileSync('package.json'))) != null ? ref.name : void 0;
} catch (error1) {}
}
if (!name) {
name = path.basename(process.cwd());
}
if (options.argv.force) {
return this.unpublishPackage(name, version, callback);
} else {
return this.promptForConfirmation(name, version, callback);
}
}
if (!name) {
try {
name = (ref = JSON.parse(fs.readFileSync('package.json'))) != null ? ref.name : void 0;
} catch (error1) {}
}
if (!name) {
name = path.basename(process.cwd());
}
if (options.argv.force) {
return this.unpublishPackage(name, version, callback);
} else {
return this.promptForConfirmation(name, version, callback);
}
};
Unpublish.commandNames = ['unpublish'];
return Unpublish;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Login, Unstar, async, config, request, yargs;
var Command, Login, Unstar, async, config, request, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -16,50 +19,63 @@ async = require('async');

module.exports = Unstar = (function() {
class Unstar extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm unstar <package_name>...\n\nUnstar the given packages on https://atom.io\n\nRun `apm stars` to see all your starred packages.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
module.exports = Unstar = (function(superClass) {
extend(Unstar, superClass);
function Unstar() {
return Unstar.__super__.constructor.apply(this, arguments);
}
Unstar.commandNames = ['unstar'];
Unstar.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm unstar <package_name>...\n\nUnstar the given packages on https://atom.io\n\nRun `apm stars` to see all your starred packages.");
return options.alias('h', 'help').describe('help', 'Print this usage message');
};
Unstar.prototype.starPackage = function(packageName, token, callback) {
var requestSettings;
if (process.platform === 'darwin') {
process.stdout.write('\uD83D\uDC5F \u2B50 ');
}
starPackage(packageName, token, callback) {
var requestSettings;
if (process.platform === 'darwin') {
process.stdout.write('\uD83D\uDC5F \u2B50 ');
process.stdout.write("Unstarring " + packageName + " ");
requestSettings = {
json: true,
url: (config.getAtomPackagesUrl()) + "/" + packageName + "/star",
headers: {
authorization: token
}
process.stdout.write(`Unstarring ${packageName} `);
requestSettings = {
json: true,
url: `${config.getAtomPackagesUrl()}/${packageName}/star`,
headers: {
authorization: token
};
return request.del(requestSettings, (function(_this) {
return function(error, response, body) {
var message, ref, ref1;
if (body == null) {
body = {};
}
};
return request.del(requestSettings, (error, response, body = {}) => {
var message, ref, ref1;
if (error != null) {
this.logFailure();
_this.logFailure();
return callback(error);
} else if (response.statusCode !== 204) {
this.logFailure();
_this.logFailure();
message = (ref = (ref1 = body.message) != null ? ref1 : body.error) != null ? ref : body;
return callback(`Unstarring package failed: ${message}`);
return callback("Unstarring package failed: " + message);
} else {
this.logSuccess();
_this.logSuccess();
return callback();
}
});
};
})(this));
};
Unstar.prototype.run = function(options) {
var callback, packageNames;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
callback("Please specify a package name to unstar");
return;
}
run(options) {
var callback, packageNames;
({callback} = options);
options = this.parseOptions(options.commandArgs);
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length === 0) {
callback("Please specify a package name to unstar");
return;
}
return Login.getTokenOrLogin((error, token) => {
return Login.getTokenOrLogin((function(_this) {
return function(error, token) {
var commands;

@@ -69,19 +85,16 @@ if (error != null) {

}
commands = packageNames.map((packageName) => {
return (callback) => {
return this.starPackage(packageName, token, callback);
commands = packageNames.map(function(packageName) {
return function(callback) {
return _this.starPackage(packageName, token, callback);
};
});
return async.waterfall(commands, callback);
});
}
};
})(this));
};
Unstar.commandNames = ['unstar'];
return Unstar;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, Git, Install, Packages, Upgrade, _, async, config, fs, git, path, read, request, semver, tree, yargs;
var Command, Git, Install, Packages, Upgrade, _, async, config, fs, git, path, read, request, semver, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -34,86 +37,97 @@ path = require('path');

module.exports = Upgrade = (function() {
class Upgrade extends Command {
constructor() {
super();
this.atomDirectory = config.getAtomDirectory();
this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages');
}
module.exports = Upgrade = (function(superClass) {
extend(Upgrade, superClass);
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm upgrade\n apm upgrade --list\n apm upgrade [<package_name>...]\n\nUpgrade out of date packages installed to ~/.atom/packages\n\nThis command lists the out of date packages and then prompts to install\navailable updates.");
options.alias('c', 'confirm').boolean('confirm').default('confirm', true).describe('confirm', 'Confirm before installing updates');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('l', 'list').boolean('list').describe('list', 'List but don\'t install the outdated packages');
options.boolean('json').describe('json', 'Output outdated packages as a JSON array');
options.string('compatible').describe('compatible', 'Only list packages/themes compatible with this Atom version');
return options.boolean('verbose').default('verbose', false).describe('verbose', 'Show verbose debug information');
}
Upgrade.commandNames = ['upgrade', 'outdated', 'update'];
getInstalledPackages(options) {
var i, len, name, pack, packageNames, packages, ref;
packages = [];
ref = fs.list(this.atomPackagesDirectory);
for (i = 0, len = ref.length; i < len; i++) {
name = ref[i];
if (pack = this.getIntalledPackage(name)) {
packages.push(pack);
}
function Upgrade() {
Upgrade.__super__.constructor.call(this);
this.atomDirectory = config.getAtomDirectory();
this.atomPackagesDirectory = path.join(this.atomDirectory, 'packages');
}
Upgrade.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm upgrade\n apm upgrade --list\n apm upgrade [<package_name>...]\n\nUpgrade out of date packages installed to ~/.atom/packages\n\nThis command lists the out of date packages and then prompts to install\navailable updates.");
options.alias('c', 'confirm').boolean('confirm')["default"]('confirm', true).describe('confirm', 'Confirm before installing updates');
options.alias('h', 'help').describe('help', 'Print this usage message');
options.alias('l', 'list').boolean('list').describe('list', 'List but don\'t install the outdated packages');
options.boolean('json').describe('json', 'Output outdated packages as a JSON array');
options.string('compatible').describe('compatible', 'Only list packages/themes compatible with this Atom version');
return options.boolean('verbose')["default"]('verbose', false).describe('verbose', 'Show verbose debug information');
};
Upgrade.prototype.getInstalledPackages = function(options) {
var i, len, name, pack, packageNames, packages, ref;
packages = [];
ref = fs.list(this.atomPackagesDirectory);
for (i = 0, len = ref.length; i < len; i++) {
name = ref[i];
if (pack = this.getIntalledPackage(name)) {
packages.push(pack);
}
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length > 0) {
packages = packages.filter(function({name}) {
return packageNames.indexOf(name) !== -1;
});
}
return packages;
}
packageNames = this.packageNamesFromArgv(options.argv);
if (packageNames.length > 0) {
packages = packages.filter(function(arg) {
var name;
name = arg.name;
return packageNames.indexOf(name) !== -1;
});
}
return packages;
};
getIntalledPackage(name) {
var metadata, packageDirectory;
packageDirectory = path.join(this.atomPackagesDirectory, name);
if (fs.isSymbolicLinkSync(packageDirectory)) {
return;
Upgrade.prototype.getIntalledPackage = function(name) {
var metadata, packageDirectory;
packageDirectory = path.join(this.atomPackagesDirectory, name);
if (fs.isSymbolicLinkSync(packageDirectory)) {
return;
}
try {
metadata = JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json')));
if ((metadata != null ? metadata.name : void 0) && (metadata != null ? metadata.version : void 0)) {
return metadata;
}
try {
metadata = JSON.parse(fs.readFileSync(path.join(packageDirectory, 'package.json')));
if ((metadata != null ? metadata.name : void 0) && (metadata != null ? metadata.version : void 0)) {
return metadata;
}
} catch (error1) {}
}
} catch (error1) {}
};
loadInstalledAtomVersion(options, callback) {
if (options.argv.compatible) {
return process.nextTick(() => {
Upgrade.prototype.loadInstalledAtomVersion = function(options, callback) {
if (options.argv.compatible) {
return process.nextTick((function(_this) {
return function() {
var version;
version = this.normalizeVersion(options.argv.compatible);
version = _this.normalizeVersion(options.argv.compatible);
if (semver.valid(version)) {
this.installedAtomVersion = version;
_this.installedAtomVersion = version;
}
return callback();
});
} else {
return this.loadInstalledAtomMetadata(callback);
}
};
})(this));
} else {
return this.loadInstalledAtomMetadata(callback);
}
};
folderIsRepo(pack) {
var repoGitFolderPath;
repoGitFolderPath = path.join(this.atomPackagesDirectory, pack.name, '.git');
return fs.existsSync(repoGitFolderPath);
}
Upgrade.prototype.folderIsRepo = function(pack) {
var repoGitFolderPath;
repoGitFolderPath = path.join(this.atomPackagesDirectory, pack.name, '.git');
return fs.existsSync(repoGitFolderPath);
};
getLatestVersion(pack, callback) {
var requestSettings;
requestSettings = {
url: `${config.getAtomPackagesUrl()}/${pack.name}`,
json: true
};
return request.get(requestSettings, (error, response, body = {}) => {
Upgrade.prototype.getLatestVersion = function(pack, callback) {
var requestSettings;
requestSettings = {
url: (config.getAtomPackagesUrl()) + "/" + pack.name,
json: true
};
return request.get(requestSettings, (function(_this) {
return function(error, response, body) {
var atomVersion, engine, latestVersion, message, metadata, ref, ref1, ref2, ref3, ref4, ref5, version;
if (body == null) {
body = {};
}
if (error != null) {
return callback(`Request for package information failed: ${error.message}`);
return callback("Request for package information failed: " + error.message);
} else if (response.statusCode === 404) {

@@ -123,5 +137,5 @@ return callback();

message = (ref = (ref1 = body.message) != null ? ref1 : body.error) != null ? ref : body;
return callback(`Request for package information failed: ${message}`);
return callback("Request for package information failed: " + message);
} else {
atomVersion = this.installedAtomVersion;
atomVersion = _this.installedAtomVersion;
latestVersion = pack.version;

@@ -148,3 +162,3 @@ ref3 = (ref2 = body.versions) != null ? ref2 : {};

}
if (latestVersion !== pack.version && this.hasRepo(pack)) {
if (latestVersion !== pack.version && _this.hasRepo(pack)) {
return callback(null, latestVersion);

@@ -155,9 +169,11 @@ } else {

}
});
}
};
})(this));
};
getLatestSha(pack, callback) {
var repoPath;
repoPath = path.join(this.atomPackagesDirectory, pack.name);
return config.getSetting('git', (command) => {
Upgrade.prototype.getLatestSha = function(pack, callback) {
var repoPath;
repoPath = path.join(this.atomPackagesDirectory, pack.name);
return config.getSetting('git', (function(_this) {
return function(command) {
var args;

@@ -169,6 +185,12 @@ if (command == null) {

git.addGitToEnv(process.env);
return this.spawn(command, args, {
return _this.spawn(command, args, {
cwd: repoPath
}, function(code, stderr = '', stdout = '') {
}, function(code, stderr, stdout) {
var repo, sha;
if (stderr == null) {
stderr = '';
}
if (stdout == null) {
stdout = '';
}
if (code !== 0) {

@@ -185,94 +207,110 @@ return callback(new Error('Exit code: ' + code + ' - ' + stderr));

});
});
}
};
})(this));
};
hasRepo(pack) {
return Packages.getRepository(pack) != null;
}
Upgrade.prototype.hasRepo = function(pack) {
return Packages.getRepository(pack) != null;
};
getAvailableUpdates(packages, callback) {
var getLatestVersionOrSha;
getLatestVersionOrSha = (pack, done) => {
Upgrade.prototype.getAvailableUpdates = function(packages, callback) {
var getLatestVersionOrSha;
getLatestVersionOrSha = (function(_this) {
return function(pack, done) {
var ref;
if (this.folderIsRepo(pack) && ((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git') {
return this.getLatestSha(pack, function(err, sha) {
return done(err, {pack, sha});
if (_this.folderIsRepo(pack) && ((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git') {
return _this.getLatestSha(pack, function(err, sha) {
return done(err, {
pack: pack,
sha: sha
});
});
} else {
return this.getLatestVersion(pack, function(err, latestVersion) {
return done(err, {pack, latestVersion});
return _this.getLatestVersion(pack, function(err, latestVersion) {
return done(err, {
pack: pack,
latestVersion: latestVersion
});
});
}
};
return async.mapLimit(packages, 10, getLatestVersionOrSha, function(error, updates) {
if (error != null) {
return callback(error);
})(this);
return async.mapLimit(packages, 10, getLatestVersionOrSha, function(error, updates) {
if (error != null) {
return callback(error);
}
updates = _.filter(updates, function(update) {
return (update.latestVersion != null) || (update.sha != null);
});
updates.sort(function(updateA, updateB) {
return updateA.pack.name.localeCompare(updateB.pack.name);
});
return callback(null, updates);
});
};
Upgrade.prototype.promptForConfirmation = function(callback) {
return read({
prompt: 'Would you like to install these updates? (yes)',
edit: true
}, function(error, answer) {
answer = answer ? answer.trim().toLowerCase() : 'yes';
return callback(error, answer === 'y' || answer === 'yes');
});
};
Upgrade.prototype.installUpdates = function(updates, callback) {
var fn, i, installCommands, latestVersion, len, pack, ref, verbose;
installCommands = [];
verbose = this.verbose;
fn = function(pack, latestVersion) {
return installCommands.push(function(callback) {
var commandArgs, ref;
if (((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git') {
commandArgs = [pack.apmInstallSource.source];
} else {
commandArgs = [pack.name + "@" + latestVersion];
}
updates = _.filter(updates, function(update) {
return (update.latestVersion != null) || (update.sha != null);
if (verbose) {
commandArgs.unshift('--verbose');
}
return new Install().run({
callback: callback,
commandArgs: commandArgs
});
updates.sort(function(updateA, updateB) {
return updateA.pack.name.localeCompare(updateB.pack.name);
});
return callback(null, updates);
});
};
for (i = 0, len = updates.length; i < len; i++) {
ref = updates[i], pack = ref.pack, latestVersion = ref.latestVersion;
fn(pack, latestVersion);
}
return async.waterfall(installCommands, callback);
};
promptForConfirmation(callback) {
return read({
prompt: 'Would you like to install these updates? (yes)',
edit: true
}, function(error, answer) {
answer = answer ? answer.trim().toLowerCase() : 'yes';
return callback(error, answer === 'y' || answer === 'yes');
});
Upgrade.prototype.run = function(options) {
var callback, command;
callback = options.callback, command = options.command;
options = this.parseOptions(options.commandArgs);
options.command = command;
this.verbose = options.argv.verbose;
if (this.verbose) {
request.debug(true);
process.env.NODE_DEBUG = 'request';
}
installUpdates(updates, callback) {
var i, installCommands, latestVersion, len, pack, verbose;
installCommands = [];
verbose = this.verbose;
for (i = 0, len = updates.length; i < len; i++) {
({pack, latestVersion} = updates[i]);
(function(pack, latestVersion) {
return installCommands.push(function(callback) {
var commandArgs, ref;
if (((ref = pack.apmInstallSource) != null ? ref.type : void 0) === 'git') {
commandArgs = [pack.apmInstallSource.source];
} else {
commandArgs = [`${pack.name}@${latestVersion}`];
}
if (verbose) {
commandArgs.unshift('--verbose');
}
return new Install().run({callback, commandArgs});
});
})(pack, latestVersion);
}
return async.waterfall(installCommands, callback);
}
run(options) {
var callback, command;
({callback, command} = options);
options = this.parseOptions(options.commandArgs);
options.command = command;
this.verbose = options.argv.verbose;
if (this.verbose) {
request.debug(true);
process.env.NODE_DEBUG = 'request';
}
return this.loadInstalledAtomVersion(options, () => {
if (this.installedAtomVersion) {
return this.upgradePackages(options, callback);
return this.loadInstalledAtomVersion(options, (function(_this) {
return function() {
if (_this.installedAtomVersion) {
return _this.upgradePackages(options, callback);
} else {
return callback('Could not determine current Atom version installed');
}
});
}
};
})(this));
};
upgradePackages(options, callback) {
var packages;
packages = this.getInstalledPackages(options);
return this.getAvailableUpdates(packages, (error, updates) => {
Upgrade.prototype.upgradePackages = function(options, callback) {
var packages;
packages = this.getInstalledPackages(options);
return this.getAvailableUpdates(packages, (function(_this) {
return function(error, updates) {
var packagesWithLatestVersionOrSha;

@@ -283,3 +321,5 @@ if (error != null) {

if (options.argv.json) {
packagesWithLatestVersionOrSha = updates.map(function({pack, latestVersion, sha}) {
packagesWithLatestVersionOrSha = updates.map(function(arg) {
var latestVersion, pack, sha;
pack = arg.pack, latestVersion = arg.latestVersion, sha = arg.sha;
if (latestVersion) {

@@ -295,6 +335,7 @@ pack.latestVersion = latestVersion;

} else {
console.log("Package Updates Available".cyan + ` (${updates.length})`);
tree(updates, function({pack, latestVersion, sha}) {
var apmInstallSource, name, ref, version;
({name, apmInstallSource, version} = pack);
console.log("Package Updates Available".cyan + (" (" + updates.length + ")"));
tree(updates, function(arg) {
var apmInstallSource, latestVersion, name, pack, ref, sha, version;
pack = arg.pack, latestVersion = arg.latestVersion, sha = arg.sha;
name = pack.name, apmInstallSource = pack.apmInstallSource, version = pack.version;
name = name.yellow;

@@ -309,3 +350,3 @@ if (sha != null) {

latestVersion = (latestVersion != null ? latestVersion.green : void 0) || (apmInstallSource != null ? (ref = apmInstallSource.sha) != null ? ref.green : void 0 : void 0);
return `${name} ${version} -> ${latestVersion}`;
return name + " " + version + " -> " + latestVersion;
});

@@ -324,3 +365,3 @@ }

if (options.argv.confirm) {
return this.promptForConfirmation((error, confirmed) => {
return _this.promptForConfirmation(function(error, confirmed) {
if (error != null) {

@@ -331,3 +372,3 @@ return callback(error);

console.log();
return this.installUpdates(updates, callback);
return _this.installUpdates(updates, callback);
} else {

@@ -338,15 +379,12 @@ return callback();

} else {
return this.installUpdates(updates, callback);
return _this.installUpdates(updates, callback);
}
});
}
};
})(this));
};
Upgrade.commandNames = ['upgrade', 'outdated', 'update'];
return Upgrade;
}).call(this);
})(Command);
}).call(this);

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

// Generated by CoffeeScript 1.12.7
(function() {
var Command, View, _, config, request, semver, tree, yargs;
var Command, View, _, config, request, semver, tree, yargs,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;

@@ -18,18 +21,26 @@ _ = require('underscore-plus');

module.exports = View = (function() {
class View extends Command {
parseOptions(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm view <package_name>\n\nView information about a package/theme in the atom.io registry.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.boolean('json').describe('json', 'Output featured packages as JSON array');
return options.string('compatible').describe('compatible', 'Show the latest version compatible with this Atom version');
}
module.exports = View = (function(superClass) {
extend(View, superClass);
loadInstalledAtomVersion(options, callback) {
return process.nextTick(() => {
function View() {
return View.__super__.constructor.apply(this, arguments);
}
View.commandNames = ['view', 'show'];
View.prototype.parseOptions = function(argv) {
var options;
options = yargs(argv).wrap(Math.min(100, yargs.terminalWidth()));
options.usage("\nUsage: apm view <package_name>\n\nView information about a package/theme in the atom.io registry.");
options.alias('h', 'help').describe('help', 'Print this usage message');
options.boolean('json').describe('json', 'Output featured packages as JSON array');
return options.string('compatible').describe('compatible', 'Show the latest version compatible with this Atom version');
};
View.prototype.loadInstalledAtomVersion = function(options, callback) {
return process.nextTick((function(_this) {
return function() {
var installedAtomVersion, version;
if (options.argv.compatible) {
version = this.normalizeVersion(options.argv.compatible);
version = _this.normalizeVersion(options.argv.compatible);
if (semver.valid(version)) {

@@ -40,62 +51,73 @@ installedAtomVersion = version;

return callback(installedAtomVersion);
});
}
};
})(this));
};
getLatestCompatibleVersion(pack, options, callback) {
return this.loadInstalledAtomVersion(options, function(installedAtomVersion) {
var engine, latestVersion, metadata, ref, ref1, ref2, ref3, version;
if (!installedAtomVersion) {
return callback(pack.releases.latest);
View.prototype.getLatestCompatibleVersion = function(pack, options, callback) {
return this.loadInstalledAtomVersion(options, function(installedAtomVersion) {
var engine, latestVersion, metadata, ref, ref1, ref2, ref3, version;
if (!installedAtomVersion) {
return callback(pack.releases.latest);
}
latestVersion = null;
ref1 = (ref = pack.versions) != null ? ref : {};
for (version in ref1) {
metadata = ref1[version];
if (!semver.valid(version)) {
continue;
}
latestVersion = null;
ref1 = (ref = pack.versions) != null ? ref : {};
for (version in ref1) {
metadata = ref1[version];
if (!semver.valid(version)) {
continue;
}
if (!metadata) {
continue;
}
engine = (ref2 = (ref3 = metadata.engines) != null ? ref3.atom : void 0) != null ? ref2 : '*';
if (!semver.validRange(engine)) {
continue;
}
if (!semver.satisfies(installedAtomVersion, engine)) {
continue;
}
if (latestVersion == null) {
latestVersion = version;
}
if (semver.gt(version, latestVersion)) {
latestVersion = version;
}
if (!metadata) {
continue;
}
return callback(latestVersion);
});
}
engine = (ref2 = (ref3 = metadata.engines) != null ? ref3.atom : void 0) != null ? ref2 : '*';
if (!semver.validRange(engine)) {
continue;
}
if (!semver.satisfies(installedAtomVersion, engine)) {
continue;
}
if (latestVersion == null) {
latestVersion = version;
}
if (semver.gt(version, latestVersion)) {
latestVersion = version;
}
}
return callback(latestVersion);
});
};
getRepository(pack) {
var ref, ref1, repository;
if (repository = (ref = (ref1 = pack.repository) != null ? ref1.url : void 0) != null ? ref : pack.repository) {
return repository.replace(/\.git$/, '');
}
View.prototype.getRepository = function(pack) {
var ref, ref1, repository;
if (repository = (ref = (ref1 = pack.repository) != null ? ref1.url : void 0) != null ? ref : pack.repository) {
return repository.replace(/\.git$/, '');
}
};
getPackage(packageName, options, callback) {
var requestSettings;
requestSettings = {
url: `${config.getAtomPackagesUrl()}/${packageName}`,
json: true
};
return request.get(requestSettings, (error, response, body = {}) => {
View.prototype.getPackage = function(packageName, options, callback) {
var requestSettings;
requestSettings = {
url: (config.getAtomPackagesUrl()) + "/" + packageName,
json: true
};
return request.get(requestSettings, (function(_this) {
return function(error, response, body) {
var message, ref, ref1;
if (body == null) {
body = {};
}
if (error != null) {
return callback(error);
} else if (response.statusCode === 200) {
return this.getLatestCompatibleVersion(body, options, function(version) {
return _this.getLatestCompatibleVersion(body, options, function(version) {
var downloads, metadata, name, pack, readme, ref, ref1, stargazers_count;
({name, readme, downloads, stargazers_count} = body);
metadata = (ref = (ref1 = body.versions) != null ? ref1[version] : void 0) != null ? ref : {name};
pack = _.extend({}, metadata, {readme, downloads, stargazers_count});
name = body.name, readme = body.readme, downloads = body.downloads, stargazers_count = body.stargazers_count;
metadata = (ref = (ref1 = body.versions) != null ? ref1[version] : void 0) != null ? ref : {
name: name
};
pack = _.extend({}, metadata, {
readme: readme,
downloads: downloads,
stargazers_count: stargazers_count
});
return callback(null, pack);

@@ -105,17 +127,19 @@ });

message = (ref = (ref1 = body.message) != null ? ref1 : body.error) != null ? ref : body;
return callback(`Requesting package failed: ${message}`);
return callback("Requesting package failed: " + message);
}
});
};
})(this));
};
View.prototype.run = function(options) {
var callback, packageName;
callback = options.callback;
options = this.parseOptions(options.commandArgs);
packageName = options.argv._[0];
if (!packageName) {
callback("Missing required package name");
return;
}
run(options) {
var callback, packageName;
({callback} = options);
options = this.parseOptions(options.commandArgs);
[packageName] = options.argv._;
if (!packageName) {
callback("Missing required package name");
return;
}
return this.getPackage(packageName, options, (error, pack) => {
return this.getPackage(packageName, options, (function(_this) {
return function(error, pack) {
var items, repository;

@@ -129,3 +153,3 @@ if (error != null) {

} else {
console.log(`${pack.name.cyan}`);
console.log("" + pack.name.cyan);
items = [];

@@ -135,3 +159,3 @@ if (pack.version) {

}
if (repository = this.getRepository(pack)) {
if (repository = _this.getRepository(pack)) {
items.push(repository.underline);

@@ -150,17 +174,14 @@ }

console.log();
console.log(`Run \`apm install ${pack.name}\` to install this package.`);
console.log("Run `apm install " + pack.name + "` to install this package.");
console.log();
}
return callback();
});
}
};
})(this));
};
View.commandNames = ['view', 'show'];
return View;
}).call(this);
})(Command);
}).call(this);
{
"name": "atom-package-manager",
"description": "Atom package manager",
"version": "2.5.2",
"version": "2.6.0",
"license": "MIT",

@@ -18,7 +18,12 @@ "repository": {

"scripts": {
"build": "node script/check-version.js && grunt",
"prepare": "grunt prepare",
"install": "node script/postinstall.js",
"test": "node script/check-version.js && grunt test",
"check-version": "node version.js"
"check-version": "node script/check-version.js",
"clean:bin": "shx rm -rf bin/node_darwin_x64 bin/node.exe bin/node",
"clean:lib": "shx rm -rf lib && shx mkdir -p lib",
"clean": "npm run clean:lib && npm run clean:bin",
"lint": "coffeelint src spec",
"coffee": "coffee --compile --output lib src",
"build": "npm run clean:lib && npm run coffee",
"prepare": "npm run build",
"postinstall": "node script/postinstall.js",
"test": "npm run check-version && npm run lint && jasmine-focused --captureExceptions --coffee spec"
},

@@ -33,2 +38,3 @@ "dependencies": {

"git-utils": "^5.6.2",
"glob": "^7.1.6",
"hosted-git-info": "^2.1.4",

@@ -54,11 +60,9 @@ "keytar": "^4.13.0",

"devDependencies": {
"coffee-script": "^1.8.0",
"coffee-script": "^1.12.7",
"coffeelint": "<2.0",
"express": "^4.16.3",
"grunt": "^1.0.3",
"grunt-cli": "^1.2.0",
"grunt-coffeelint": "0.0.16",
"grunt-contrib-coffee": "^2.0.0",
"grunt-shell": "^1.3.0",
"jasmine-focused": ">=1.0.7 <2.0"
"jasmine-focused": ">=1.0.7 <2.0",
"shx": "^0.3.2",
"node-gyp": "^5.1.1"
}
}
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