Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Np skipping the draft release step #442

Closed
Crowbrammer opened this issue Aug 9, 2019 · 7 comments
Closed

Np skipping the draft release step #442

Crowbrammer opened this issue Aug 9, 2019 · 7 comments

Comments

@Crowbrammer
Copy link

np's totally skipping the draft release step, and I don't know how I made it do that.

At first, it skipped pushing the tags because it "didn't detect an upstream branch". This was weird to me because it had to push the changes somehow. Then I type git push --set-upstream origin master, and that handled the tag pushing. Now it pushes the tags... but it skips the release draft step. I'm not using any flags, just np.

I do not know how to reproduce this. I've tried multiple projects; I've tried uninstalling and then reinstalling np, and the draft release step just isn't executing.

I've looked at:

Here's what my terminal (GNU bash, version 4.4.19(1)-release (x86_64-pc-msys)) looks like.

Publish a new version of testfordraftrelease (current: 1.0.1)

? No commits found since previous release, continue? (y/N) y
? No commits found since previous release, continue? Yes
? Select semver increment or specify new version (Use arrow keys)
? Select semver increment or specify new version patch  1.0.2

[02:51:34] Prerequisite check [started]
[02:51:34] Ping npm registry [started]
[02:51:36] Ping npm registry [completed]
[02:51:36] Check npm version [started]
[02:51:37] Check npm version [completed]
[02:51:37] Verify user is authenticated [started]
[02:51:41] Verify user is authenticated [completed]
[02:51:41] Check git version [started]
[02:51:41] Check git version [completed]
[02:51:41] Check git remote [started]
[02:51:43] Check git remote [completed]
[02:51:43] Validate version [started]
[02:51:43] Validate version [completed]
[02:51:43] Check for pre-release version [started]
[02:51:43] Check for pre-release version [completed]
[02:51:43] Check git tag existence [started]
[02:51:45] Check git tag existence [completed]
[02:51:45] Prerequisite check [completed]
[02:51:45] Git [started]
[02:51:45] Check current branch [started]
[02:51:45] Check current branch [completed]
[02:51:45] Check local working tree [started]
[02:51:45] Check local working tree [completed]
[02:51:45] Check remote history [started]
[02:51:45] Check remote history [completed]
[02:51:45] Git [completed]
[02:51:45] Cleanup [started]
[02:51:45] Cleanup [completed]
[02:51:45] Installing dependencies using npm [started]
[02:51:47] → npm WARN testfordraftrelease@1.0.1 No repository field.
[02:51:47] → up to date in 0.295s
[02:51:47] → found 0 vulnerabilities
[02:51:47] → [object Object]
[02:51:47] Installing dependencies using npm [completed]
[02:51:47] Running tests using npm [started]
[02:51:48] → > testfordraftrelease@1.0.1 test C:\Users\Choppy\Documents\Actual Documents\Coding\Actual Projects\Test
[02:51:48] → > echo 'Hi'
[02:51:48] → 'Hi'
[02:51:48] → [object Object]
[02:51:48] Running tests using npm [completed]
[02:51:48] Bumping version using npm [started]
[02:51:49] → v1.0.2
[02:51:49] → [object Object]
[02:51:49] Bumping version using npm [completed]
[02:51:49] Publishing package using npm [started]
[02:51:51] Publishing package using npm (waiting for input…) [title changed]
[02:51:51] → ? Enter OTP:
841029
? Enter OTP: 8
? Enter OTP: 84
? Enter OTP: 841
? Enter OTP: 8410
? Enter OTP: 84102
? Enter OTP: 841029
? Enter OTP: 841029
[02:51:55] → undefined
[02:51:55] Publishing package using npm [title changed]
[02:52:00] Publishing package using npm [completed]
[02:52:00] Pushing tags [started]
[02:52:04] Pushing tags [completed]

 testfordraftrelease 1.0.2 published 🎉

Expected behavior

I expected the draft release step to occur whenever I use np and no errors occur.

Environment

np - 5.0.3
Node.js - 10.16.0
npm - 6.10.2
Git - 2.16.2.windows.1
OS - Windows 8.1

@Crowbrammer
Copy link
Author

Tried adding a local .np-config.json file:

{
	"yarn": false,
	"releaseDraft": true
}

No avail. Trying to figure out how to configure np globally. (I have my global np directory open, I'll try sticking an .np-config.json file in there.)

@Crowbrammer
Copy link
Author

Sticking the .np-config.json file into .../npm/node_modules/np didn't work.

Also, I'm thinking that when I first used np, the release drafts just worked. So, this probably isn't a config issue.

@Crowbrammer
Copy link
Author

Crowbrammer commented Aug 9, 2019

Added .np-config.json to my root directory (~/.np-config.json), no avail.

@Crowbrammer
Copy link
Author

I tested changing :223-228 to make enabled: () => true instead of enabled: () => isOnGitHub === true

tasks.add({
		title: 'Creating release draft on GitHub',
		enabled: () => true, // was isOnGitHub === true,
		skip: () => !options.releaseDraft,
		task: () => releaseTaskHelper(options)
	});

The result is:

[15:31:04] Creating release draft on GitHub [started]
[15:31:04] Creating release draft on GitHub [failed]
[15:31:04] → You need to specify either the `repoUrl` option or both the `user` and `repo` options

× You need to specify either the `repoUrl` option or both the `user` and `repo` options

@Crowbrammer
Copy link
Author

In ui.js, I added a bunch of console.logs:

module.exports = async (options, pkg) => {
	const oldVersion = pkg.version;
	const extraBaseUrls = ['gitlab.com'];
	console.log()
	console.log("pkg.repository")
	console.log(pkg.repository)
	console.log("pkg.repository end")
	console.log()
	console.log("githubUrlFromGit(pkg.repository.url, {extraBaseUrls})")
	console.log(githubUrlFromGit(pkg.repository.url, {extraBaseUrls}))
	console.log("githubUrlFromGit(pkg.repository.url, {extraBaseUrls}) end")
	console.log()
	const repoUrl = pkg.repository && githubUrlFromGit(pkg.repository.url, {extraBaseUrls});
...

It resulted in

$ np

pkg.repository
undefined
pkg.repository end

githubUrlFromGit(pkg.repository.url, {extraBaseUrls})

× Cannot read property 'url' of undefined

@Crowbrammer
Copy link
Author

Crowbrammer commented Aug 9, 2019

After searching the util.js, cli.js, ui.js, and index.js, I learned that it (the release portion, at least) doesn't detect the GitHub repo through the git folder. It detects it through the package.json.

This means that if you npm init a package before git init, it won't add the GitHub repo to the package.json file. If you forget or don't know to add it manually, np will skip the release draft phase.

This requires either an update to get the repo info from git/the git directory, or an echo/console.log to have the user update their package.json file.

package.json where np did not draft a release:

{
  "name": "testfordraftrelease",
  "version": "1.0.11",
  "description": "Using this to test np",
  "main": "index.js",
  "scripts": {
    "test": "echo 'Hi'"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

package.json where np did draft a release:

{
  "name": "testfordraftrelease",
  "version": "1.0.11",
  "description": "Using this to test np",
  "main": "index.js",
  "scripts": {
    "test": "echo 'Hi'"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Crowbrammer/TestRepoForNP.git"
  },
  "bugs": {
    "url": "https://github.com/Crowbrammer/TestRepoForNP/issues"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

danoc added a commit to thumbtack/thumbprint-tokens that referenced this issue Nov 6, 2019
This will make the `np` package open a draft GitHub issue after it commits.

See this issue for more context on why this is needed:
sindresorhus/np#442
@elitan
Copy link

elitan commented Jun 16, 2020

Quick answer:

Add the following to package.json in order for np to create release draft on Github:

  "repository": {
    "type": "git",
    "url": "git+https://github.com/Crowbrammer/TestRepoForNP.git"
  },
  "bugs": {
    "url": "https://github.com/Crowbrammer/TestRepoForNP/issues"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants