fix: convert git+https URL in package.json to https
				
					
				
			This commit is contained in:
		
							parent
							
								
									6f74dcbd4a
								
							
						
					
					
						commit
						b0b4fc82de
					
				| @ -2,6 +2,7 @@ const {castArray, pickBy, isUndefined, isNull, isString, isPlainObject} = requir | |||||||
| const readPkgUp = require('read-pkg-up'); | const readPkgUp = require('read-pkg-up'); | ||||||
| const cosmiconfig = require('cosmiconfig'); | const cosmiconfig = require('cosmiconfig'); | ||||||
| const resolveFrom = require('resolve-from'); | const resolveFrom = require('resolve-from'); | ||||||
|  | const gitUrlParse = require('git-url-parse'); | ||||||
| const debug = require('debug')('semantic-release:config'); | const debug = require('debug')('semantic-release:config'); | ||||||
| const {repoUrl, verifyAuth} = require('./git'); | const {repoUrl, verifyAuth} = require('./git'); | ||||||
| const PLUGINS_DEFINITIONS = require('./definitions/plugins'); | const PLUGINS_DEFINITIONS = require('./definitions/plugins'); | ||||||
| @ -61,6 +62,13 @@ module.exports = async (opts, logger) => { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| async function pkgRepoUrl() { | async function pkgRepoUrl() { | ||||||
|   const {pkg} = await readPkgUp(); |   const {pkg} = await readPkgUp({normalize: false}); | ||||||
|   return pkg && pkg.repository ? pkg.repository.url : undefined; |   const repositoryUrl = pkg && (isPlainObject(pkg.repository) ? pkg.repository.url : pkg.repository); | ||||||
|  | 
 | ||||||
|  |   if (repositoryUrl) { | ||||||
|  |     const {protocols} = gitUrlParse(repositoryUrl); | ||||||
|  |     return `${gitUrlParse(repositoryUrl).toString( | ||||||
|  |       protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : undefined | ||||||
|  |     )}${protocols.includes('https') || protocols.includes('http') ? '.git' : ''}`;
 | ||||||
|  |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -604,17 +604,17 @@ test.serial('Exit with 1 if missing permission to push to the remote repository' | |||||||
|   // Create a git repository, set the current working directory at the root of the repo
 |   // Create a git repository, set the current working directory at the root of the repo
 | ||||||
|   t.log('Create git repository'); |   t.log('Create git repository'); | ||||||
|   await gitbox.createRepo(packageName); |   await gitbox.createRepo(packageName); | ||||||
|   await writeJson('./package.json', { |   await writeJson('./package.json', {name: packageName, version: '0.0.0-dev'}); | ||||||
|     name: packageName, |  | ||||||
|     version: '0.0.0-dev', |  | ||||||
|     repository: {url: 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'}, |  | ||||||
|   }); |  | ||||||
| 
 | 
 | ||||||
|   /* Initial release */ |   /* Initial release */ | ||||||
|   t.log('Commit a feature'); |   t.log('Commit a feature'); | ||||||
|   await gitCommits(['feat: Initial commit']); |   await gitCommits(['feat: Initial commit']); | ||||||
|   t.log('$ semantic-release'); |   t.log('$ semantic-release'); | ||||||
|   const {stdout, code} = await execa(cli, [], {env: {...env, ...{GH_TOKEN: 'user:wrong_pass'}}, reject: false}); |   const {stdout, code} = await execa( | ||||||
|  |     cli, | ||||||
|  |     ['--repository-url', 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'], | ||||||
|  |     {env: {...env, ...{GH_TOKEN: 'user:wrong_pass'}}, reject: false} | ||||||
|  |   ); | ||||||
|   // Verify the type and message are logged
 |   // Verify the type and message are logged
 | ||||||
|   t.regex(stdout, /EGITNOPERMISSION/); |   t.regex(stdout, /EGITNOPERMISSION/); | ||||||
|   t.is(code, 1); |   t.is(code, 1); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user