Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
// TODO: Remove sometime far in the future
if (options.skipCleanup) {
options.cleanup = false;
}
const pkg = util.readPkg();
const runTests = options.tests && !options.yolo;
const runCleanup = options.cleanup && !options.yolo;
const runPublish = options.publish && !pkg.private;
const pkgManager = options.yarn === true ? 'yarn' : 'npm';
const pkgManagerName = options.yarn === true ? 'Yarn' : 'npm';
const rootDir = pkgDir.sync();
const hasLockFile = fs.existsSync(path.resolve(rootDir, options.yarn ? 'yarn.lock' : 'package-lock.json')) || fs.existsSync(path.resolve(rootDir, 'npm-shrinkwrap.json'));
const isOnGitHub = options.repoUrl && (hostedGitInfo.fromUrl(options.repoUrl) || {}).type === 'github';
let publishStatus = 'UNKNOWN';
const rollback = onetime(async () => {
console.log('\nPublish failed. Rolling back to the previous state…');
const tagVersionPrefix = await util.getTagVersionPrefix(options);
const latestTag = await git.latestTag();
const versionInLatestTag = latestTag.slice(tagVersionPrefix.length);
try {
if (versionInLatestTag === util.readPkg().version &&
versionInLatestTag !== pkg.version) { // Verify that the package's version has been bumped before deleting the last tag and commit.
await git.deleteTag(latestTag);
await git.removeLastCommit();
// reformat uri before parsing with hosted-git-info. Allows for further syntax support.
Object.keys(REPLACEMENTS).forEach(replacement => {
if(uri.indexOf(replacement) === 0) uri = uri.replace(replacement, REPLACEMENTS[replacement]);
});
hgi = hostedGitInfo.fromUrl(uri);
if (!hgi || hgi.user.includes('#')) {
let templateAndBranch = uri.split('#');
if (templateAndBranch.length === 1) {
fallback = true;
embarkVersion = semver(require(embarkPath('package.json')).version);
templateAndBranch.push(`${embarkVersion.major}.${embarkVersion.minor}`);
}
templateAndBranch[0] = `embark-framework/embark-${templateAndBranch[0]}-template`;
hgi = hostedGitInfo.fromUrl(templateAndBranch.join('#'));
if (fallback) {
hgi_fallback = hostedGitInfo.fromUrl(templateAndBranch[0]);
}
}
if(!hgi) { throw new Error('Unsupported template name or git host URL'); }
url = hgi.tarball();
if (fallback) {
url_fallback = hgi_fallback.tarball();
folder_fallback = `${hgi_fallback.user}/${hgi_fallback.project}/master`;
}
const returnObject = {
url,
browse: decodeURIComponent(hgi.browse()),
url_fallback,
filePath_fallback: fallback && joinPath(".embark/templates/", folder_fallback, "archive.zip"),
browse_fallback: fallback && decodeURIComponent(hgi_fallback.browse()),
embarkVersion
};
npm.load(conf, function (er) {
if (er)
throw er;
var parsed = hostedFromURL(package);
if (parsed) {
console.log("Installing dependency", parsed.path());
git = require('npm/lib/utils/git');
var install_path = 'fuse_modules/' + parsed.path();
var stats;
try {
stats = fs.statSync(install_path);
}
catch (e) {
}
if (stats && stats.isDirectory()) {
return postInstall(package, fn, install_path);
}
cloneRemote(parsed.path(), parsed.toString(), install_path, function (error) {
if (error) throw error;
postInstall(package, fn, install_path);
, fixBugsField: function(data) {
if (!data.bugs && data.repository && data.repository.url) {
var hosted = hostedGitInfo.fromUrl(data.repository.url)
if(hosted && hosted.bugs()) {
data.bugs = {url: hosted.bugs()}
}
}
else if(data.bugs) {
var emailRe = /^.+@.*\..+$/
if(typeof data.bugs == "string") {
if(emailRe.test(data.bugs))
data.bugs = {email:data.bugs}
else if(url.parse(data.bugs).protocol)
data.bugs = {url: data.bugs}
else
this.warn("nonEmailUrlBugsString")
}
else {
bugsTypos(data.bugs, this.warn)
, fixBugsField: function(data) {
if (!data.bugs && data.repository && data.repository.url) {
var hosted = hostedGitInfo.fromUrl(data.repository.url)
if(hosted && hosted.bugs()) {
data.bugs = {url: hosted.bugs()}
}
}
else if(data.bugs) {
var emailRe = /^.+@.*\..+$/
if(typeof data.bugs == "string") {
if(emailRe.test(data.bugs))
data.bugs = {email:data.bugs}
else if(url.parse(data.bugs).protocol)
data.bugs = {url: data.bugs}
else
this.warn("nonEmailUrlBugsString")
}
else {
bugsTypos(data.bugs, this.warn)
config(env, baseConfig) {
let pkg = this.parent.pkg;
if (this._documentingAddonAt()) {
pkg = require(path.join(this._documentingAddonAt(), 'package.json'));
}
let repo = pkg.repository;
let info = require('hosted-git-info').fromUrl(repo.url || repo);
let userConfig = this._readUserConfig();
let docsAppPathInRepo = path.relative(
this._getRepoRoot(),
path.join(
path.resolve(path.dirname(this.project.configPath()), '..'),
'app'
)
);
let addonPathInRepo = this._documentingAddonAt()
? path.relative(this._getRepoRoot(), path.join(this._documentingAddonAt(), 'addon'))
: path.relative(this._getRepoRoot(), path.join(this.project.root, 'addon'));
let config = {
'ember-cli-addon-docs': {
function getGitRepoInfoFromPackage(pkg) {
normalize(pkg);
if (pkg.repository && pkg.repository.type === "git") {
return hostedGitInfo.fromUrl(pkg.repository.url);
}
return null;
}
export async function createPublisher(packager: Packager, options: BuildOptions): Promise {
const repo = packager.devMetadata.repository || packager.metadata.repository
let info: Info = null
if (repo == null) {
let url = process.env.TRAVIS_REPO_SLUG || process.env.APPVEYOR_PROJECT_SLUG
if (url == null) {
url = await getGitUrlFromGitConfig()
}
if (url != null) {
info = parseRepositoryUrl(url)
}
if (info == null) {
log("Cannot detect repository by .git/config")
throw new Error("Please specify 'repository' in the dev package.json ('" + packager.devPackageFile + "')")
}
}
else {
info = parseRepositoryUrl(typeof repo === "string" ? repo : repo.url)
}
return new GitHubPublisher(info.user, info.project, packager.metadata.version, options.githubToken)
}
function parseRepositoryUrl(url: string): Info {
const info: any = fromUrl(url)
if (info != null) {
delete info.protocols
delete info.treepath
delete info.filetemplate
delete info.bugstemplate
delete info.gittemplate
delete info.tarballtemplate
delete info.sshtemplate
delete info.sshurltemplate
delete info.browsetemplate
delete info.docstemplate
delete info.httpstemplate
delete info.shortcuttemplate
delete info.pathtemplate
delete info.pathmatch
delete info.protocols_re
fixRepositoryField: function(data) {
if (data.repositories) {
this.warn("repositories");
data.repository = data.repositories[0]
}
if (!data.repository) return this.warn("missingRepository")
if (typeof data.repository === "string") {
data.repository = {
type: "git",
url: data.repository
}
}
var r = data.repository.url || ""
if (r) {
var hosted = hostedGitInfo.fromUrl(r)
if (hosted) {
r = data.repository.url
= hosted.getDefaultRepresentation() == "shortcut" ? hosted.https() : hosted.toString()
}
}
if (r.match(/github.com\/[^\/]+\/[^\/]+\.git\.git$/)) {
this.warn("brokenGitUrl", r)
}
}