Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (pkg === workingPackage) pkg = null; // can't delete self
if (!pkg) {
return done(new Error(packageId+' not frozen'));
}
// make sure the package is not under source control
isUnderSourceControl = SRC_DIRS.some(function(dirname) {
return CORE.fs.exists(CORE.path.join(pkg.path, dirname));
});
if (isUnderSourceControl) {
if (!force) {
return done(new Error(packageId+' is under source control. Use --force to override'));
} else {
CORE.verbose(packageId+" is under source control. Removing anyway");
}
}
CORE.verbose("Removing "+pkg.path);
CORE.fs.rm_r(pkg.path);
CORE.println("Unfroze "+packageId);
return done();
};
}
fetch: function(packageInfo, done) {
var path = this.tmproot();
var filepath = path + '.zip';
var url = packageInfo['link-asset'];
CORE.verbose('fetching ' + url);
this.download(filepath, url, function(err){
if (err) return done(err);
CORE.verbose('unzipping ' + filepath);
CORE.fs.exec('unzip ' +filepath+' -d '+path, function(err) {
if (err) return done(err);
CORE.fs.readdir_p(path, function(err, dirs) {
if (err) return done(err);
CORE.fs.rm_r(filepath, CORE.noop); // cleanup zipfile
if (!dirs || (dirs.length===0)) return done(null, null);
return done(null, CORE.path.join(path, dirs[0]));
});
});
});
},
logout: function(usernames, done) {
var remote = this;
if (!usernames || (usernames.length===0)) usernames = null;
if (!usernames) {
CORE.println("Removing all tokens for "+remote.url);
} else {
CORE.println("Removing tokens for "+usernames.join(',')+" on "+remote.url);
}
var tokens = remote.tokens();
var active = tokens[remote.url];
if (!active || (Object.keys(active).length===0)) {
CORE.verbose(" No login tokens found");
return done(); // nothing to do
}
active = CORE.mixin({}, active);
if (!usernames) usernames = Object.keys(active);
CORE.iter.each(usernames, function(username, done) {
var token = active[username];
if (token) {
delete active[username];
CORE.verbose(' Deleting '+username+' token '+token);
remote.request("DELETE", 'tokens/'+token, {}, function(err, status){
if (!err && (status<200) && (status>=300)) err = status;
if (err) return done(err);
done();
});
(function(done) {
if (!CORE.fs.exists(dstPath)) return done(); // nothing to do
if (!force) {
return done(new Error(packageId+' already exists in working package. Use --force to override'));
}
// delete package if it exists so we can replace it
CORE.verbose("Removing existing package at "+dstPath);
CORE.fs.rm_r(dstPath, CORE.err(done));
// if no error, do copy.
})(function(err) {
if (err) return done(err);
function endWrite() {
if (--level <= 0) {
CORE.verbose('download complete');
return done();
}
}
CORE.iter.parallel(paths, function(path, done) {
path = CORE.path.normalize(path);
var pkg = require.packageFor(path);
if (!pkg) return done(path + " is not a valid package");
CORE.println("Pushing "+pkg.get('name')+' '+pkg.get('version')+"...");
CORE.verbose(" Pushing to remote " + remote.url);
remote.push(pkg, username, CORE.err(done));
})(done);
})(function(err, workingPackage) {
if (err) return done(err);
CORE.verbose("Working package at "+workingPackage.path);
CORE.iter.each(packageIds,
freezePackage(workingPackage, version, force, dirname)
)(CORE.err(done));
});
};
CORE.iter.reduce(remotes, {}, function(ret, remote, done) {
CORE.verbose('Searching '+remote.url);
remote.list(opts, function(err, packages) {
if (!err && !packages) {
err = new Error("Server sent an invalid response");
}
if (err) return done(err);
packages.forEach(function(info) {
var name = info.name;
combinedPackages[name] = info;
if (!ret[name]) ret[name] = [];
if (ret[name].indexOf(info.version)<0) ret[name].push(info.version);
});
return done(null, ret);
});
})(done);
},