Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

WIP: Add prepublish and postpublish scripts support to apm publish #376

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Glavin001
Copy link

See #372

I need some help writing the specs:

  • Should I run git init to make the temporary directory a Git repository and then it would no longer error with Package must be in a Git repository before publishing...?
  • How do I get past Package must pushed up to GitHub before publishing?
  • To confirm, once I get past the above, I can safely run publish and it will not attempt to publish to the global apm API because ATOM_API_URL is set to http://localhost:3000/api?

TODO:

@Glavin001
Copy link
Author

Would some of the maintainers of Atom / apm be able to give me some points on the questions above? Thanks in advance!

@kevinsawicki
Copy link
Contributor

Should I run git init to make the temporary directory a Git repository and then it would no longer error with Package must be in a Git repository before publishing...?

How do I get past Package must pushed up to GitHub before publishing?

For both of these, you can create a repository locally that satisfies these conditions, and check it in to spec/fixtures and then you can just copy it to a temp folder and use it in the specs.

To confirm, once I get past the above, I can safely run publish and it will not attempt to publish to the global apm API because ATOM_API_URL is set to http://localhost:3000/api?

Yup, as long as ATOM_API_URL is set to a localhost address no calls will go out to atom.io

@Glavin001
Copy link
Author

How do I get past Package must pushed up to GitHub before publishing?

For both of these, you can create a repository locally that satisfies these conditions, and check it in to spec/fixtures and then you can just copy it to a temp folder and use it in the specs.

So in the case of the Package being on GitHub, wouldn't a new tag be pushed every single time the tests are successfully run?
See https://github.com/Glavin001/apm/blob/master/src/publish.coffee#L445-L448 calling @pushVersion and @waitForTagToBeAvailable.
This does not sound ideal for testing to me.
Also, I believe that it would even error on the second run because the Git repo in spec/fixtures has the tag, say v1.0, and that version tag has already been previously pushed to GitHub, so it will fail this second time.

I was thinking along the lines of giving the repo a fake upstreamUrl and then mocking pushVersion and waitForTagToBeAvailable functions such that they callback successfully without actually sending requests to GitHub.
Thoughts on this implementation?

@bronson
Copy link
Contributor

bronson commented Jul 7, 2015

Question about potential usage... Any chance I could write a prepublish script that would use git log to fake up a new entry in the CHANGELOG and open it in an editor? Then, when I save the changelog entry, the package would be published as usual.

@Glavin001
Copy link
Author

@bronson: Absolutely! This will wait until the prepublish script returns with it's exit code and will only continue afterwards if it was successful. That's a good use case. Personally, I will be using this for running a task for documentation generation before publishing.

@iam4x
Copy link

iam4x commented Dec 1, 2015

Hey @Glavin001 any update on this? Do you need help?

@steelbrain
Copy link
Contributor

Just a side question: Why are we using the callback-hell when promises are available?

@Glavin001
Copy link
Author

@iam4x : I have not made any progress since my last commit. Any help would be appreciated. Unfortunately, I am now studying for my university final exams and will not have much time to work on this in the next few weeks.

@steelbrain : I would definitely prefer to use promises! 👍

@danielbayley
Copy link

Shouldn't this be expanded to include all relevant hooks? For example preversion/postversion

@idleberg
Copy link

I have noticed that Visual Studio Code prefixes its prepublish script in the manifest. I wondered if it should be considered a good practice to use atom:prepublish instead to differentiate from npm's script – not that I could think of a real life conflicting situation.

@aminya
Copy link
Contributor

aminya commented Apr 1, 2020

Could you fix the conflicts? This seems like a very critical feature that is missing from apm. Other features can be added in a separate PR.

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

Successfully merging this pull request may close these issues.

None yet

9 participants