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

Semantic Release - TypeError: Cannot read properties of null (reading 'length') #805

Closed
ygorluiz opened this issue Aug 17, 2022 · 5 comments

Comments

@ygorluiz
Copy link

Hi Jerome,
I'm trying to make the release and I have this problem, Could you tell me what i'm doing wrong ?

BTW thanks for your great work

/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]/node_modules/grapheme-splitter/index.js:188
		if(index >= string.length - 1){
		                   ^

TypeError: Cannot read properties of null (reading 'length')
    at GraphemeSplitter.nextBreak (/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]/node_modules/grapheme-splitter/index.js:188:22)
    at GraphemeSplitter.splitGraphemes (/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]/node_modules/grapheme-splitter/index.js:214:21)
    at U (/home/runner/work/packages/packages/packages/conventional-gitmoji/dist/index.cjs:1:11034)
    at transform (/home/runner/work/packages/packages/packages/conventional-gitmoji/dist/index.cjs:1:11492)
    at N (/home/runner/work/packages/packages/packages/release-notes-generator/dist/index.cjs:22:274)
    at /home/runner/work/packages/packages/packages/release-notes-generator/dist/index.cjs:22:1716
    at Array.map (<anonymous>)
    at zt (/home/runner/work/packages/packages/packages/release-notes-generator/dist/index.cjs:22:1690)
    at async validator (/home/runner/work/packages/packages/node_modules/.pnpm/[email protected]/node_modules/semantic-release/lib/plugins/normalize.js:34:24)
    at async /home/runner/work/packages/packages/node_modules/.pnpm/[email protected]/node_modules/semantic-release/lib/plugins/pipeline.js:37:34
undefined
/home/runner/work/packages/packages/packages/design-system:
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with exit code 1: npx --no-install semantic-release -e semantic-release-monorepo
@JeromeFitz
Copy link
Owner

👋🏻 Hi @ygorluiz , thanks for the kind words.

Not 100% sure but within this repo, that package is used via:

For the string being passed to it, the error looks like it is technically not considered a string. So most likely null or -1 🤔 (Seeing 📝 notes like @note rewrite types would help with this, if that rewrite happened, I digress, haha.)

It may mean the type is not being found in the commit info passed to the transformer for semantic-release. I know this is a massive hack to try and get emojis to work for semver. 😜

One other thought is maybe the commits are not using gitmoji?

This is definitely counter-intuitive, however, if this is your first release you may need to choose a type that has a semver attached to it. In the case of 🔖 release I don't believe it does -- whereas 🎉 init does.

  • The "reason" release does not have a semver (at least in its current context) is that it was initially to be used as a cosmetic commit. And would not want it to bump a version for the sake of it.

I wonder if squash/re-setting the commit in that manner may do the trick. It's hacky for sure, or maybe gets to the next 🔍 thing to look at.

Let me know your thoughts, and if any other ideas come to mind if you've been keeping at it.

@ygorluiz
Copy link
Author

@JeromeFitz thanks I'll take a look and do some tests, just one more question how do I do the init release of all packages

you rock !!

@JeromeFitz
Copy link
Owner

JeromeFitz commented Aug 17, 2022

In theory, once you get passed the error you are experiencing semantic-release should be able to discern that it's being run for the first time and that there are no previous tags.

Then in this particular process it will check if it should create a release, and if so:

  • Create Tag + Update Repo
  • Create Publishable Package + Publish to NPM
  • Send Release Notes to GitHub Releases

You'll need tokens for NPM set up (if that is where you are publishing), as well as GitHub for the CI/CD stuff if you are using GitHub Actions.

--

The thing you may be experiencing, and this is all kind of trial and error at the beginning until things get into the perpetual motion machine is that the via semantic-release-monorepo for each Package it will need its own commit that would generate a release.

So for that, you can kind of test that out by choosing a package (or individually for all of them 😅 ) and ensuring it has a commit type associated within its particular git structure that would generate a release.

In this case any commit type that has a non-null semver:

Update Be wary of GitHub Merge Commit, Subject Titles:

  • If you want to squash commits (like this repo does) that's great, however, you'll have to manually write out the GitHub Commit Subject so it picks it up appropriately. Otherwise you're conventional commits get squashed into a manner that semantic-release may not pick up.

@ygorluiz
Copy link
Author

Hey @JeromeFitz,

I found a solution changed the repository url to SSH and boom
🎉 Thx, can be closed 🎉

@JeromeFitz
Copy link
Owner

wh00t! congrats on getting it up and running @ygorluiz !!

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