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

Error in version 7.0.1: createPreset is not a function. #70

Open
eagerestwolf opened this issue Sep 5, 2023 · 16 comments
Open

Error in version 7.0.1: createPreset is not a function. #70

eagerestwolf opened this issue Sep 5, 2023 · 16 comments

Comments

@eagerestwolf
Copy link

Version 7.0.1 of this plugin has a bug that prevents release-it from running at all. When running release-it (presumably in the after:bump hook where this plugin should be running) an error will be thrown, saying that createPreset is not a function. This error exists on my local machine as well as Girhub Actions. I know the issue is this plugin because release-it was working correctly until this plugin was installed. For reference, I have included the package.json, .release-it.json, and release workflow yaml from one of my projects, as well as the output from release-it

package.json

{
  "name": "@garavest/prettier-config",
  "version": "1.0.0",
  "description": "This package contains Garavest LLC's prettier config, used for internal and shared projects.",
  "keywords": [
    "prettier",
    "config",
    "svelte",
    "tailwindcss"
  ],
  "repository": {
    "type": "git",
    "url": "git+https://github.com/garavest/prettier-config.git"
  },
  "license": "MIT",
  "author": {
    "name": "Seth Murphy",
    "email": "seth.murphy@garavest.com",
    "url": "https://garavest.com"
  },
  "type": "module",
  "main": "index.js",
  "scripts": {
    "lint": "npm run lint:code && npm run lint:format",
    "lint:code": "eslint .",
    "lint:format": "prettier -c .",
    "release": "release-it"
  },
  "dependencies": {
    "prettier": "^3.0.1",
    "prettier-plugin-svelte": "^3.0.3",
    "prettier-plugin-tailwindcss": "^0.5.3"
  },
  "devDependencies": {
    "@commitlint/cli": "^17.6.7",
    "@commitlint/config-conventional": "^17.6.7",
    "@garavest/eslint-config": "^1.0.2",
    "@release-it/conventional-changelog": "^7.0.1",
    "eslint": "^8.48.0",
    "husky": "^8.0.3",
    "lint-staged": "^14.0.1",
    "markdownlint": "^0.30.0",
    "markdownlint-cli": "^0.36.0",
    "release-it": "^16.1.5"
  }
}

.release-it.json

{
  "git": {
    "commitMessage": "chore: release v${version}",
    "requireBranch": "main"
  },
  "github": {
    "release": true
  },
  "hooks": {
    "before:init": ["git pull", "npm run lint"]
  },
  "npm": {
    "publish": true,
    "versionArgs": ["--allow-same-version"]
  },
  "plugins": {
    "@release-it/conventional-changelog": {
      "preset": "angular",
      "infile": "CHANGELOG.md"
    }
  },
  "publishConfig": {
    "access": "public"
  }
}

.github/workflows/release.yml

name: Release & Publish to NPM
on: workflow_dispatch
permissions:
  contents: write
jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Setup Node 18
        uses: actions/setup-node@v3
        with:
          node-version: "18.x"
          registry-url: "https://registry.npmjs.org"
      - name: Initialize git user
        run: |
          git config --global user.email "seth.murphy@garavest.com"
          git config --global user.name "Release Workflow"
      - name: Initialize NPM config
        run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
        env:
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      - name: Install the dependencies
        run: npm ci
      - name: Do the release
        run: npm run release --ci
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

release-it output

This is from Github Actions, but I get an idential error on my local machine.

Run npm run release --ci
  npm run release --ci
  shell: /usr/bin/bash -e {0}
  env:
    NPM_CONFIG_USERCONFIG: /home/runner/work/_temp/.npmrc
    NODE_AUTH_TOKEN: XXXXX-XXXXX-XXXXX-XXXXX
    GITHUB_TOKEN: ***
    NPM_TOKEN: ***
  
> @garavest/prettier-config@1.0.0 release
> release-it
- git pull
✔ git pull
- npm run lint
✔ npm run lint
ERROR createPreset is not a function
Error: Process completed with exit code 1.

For the time being, I will try reverting to version 7.0.0 and just ignore the PRs from Dependabot. I mainly just wanted to bring this to your attention.

@webpro
Copy link
Contributor

webpro commented Sep 5, 2023

Does using "preset": { "name": "angular" } (instead of "preset": "angular") help?

@eagerestwolf
Copy link
Author

It does not. The error persists. Also, I pinned npm's version to 7.0.0, and the bug is not present in that version.

prettier-config on  main [!] is 📦 v1.0.0 via  v18.17.0 took 11s
❯ npm run release -- --changelog

> @garavest/prettier-config@1.0.0 release
> release-it --changelog

✔ git pull
✔ npm run lint
WARNING Environment variable "GITHUB_TOKEN" is required for automated GitHub Releases.
WARNING Falling back to web-based GitHub Release.
ERROR createPreset is not a function

@eagerestwolf
Copy link
Author

So, looking over the code, it would appear this isn't an issue with your plugin. I wonder if the issue lies with conventional-changelog? That's the only external import that would be using a preset to the best of my knowledge. Let me check out their issues.

@eagerestwolf
Copy link
Author

Found it. Sorry for the comment spam. There is a bug in conventional-changelog. They had an open issue for this. Apparently, it was resolved in a later version.

conventional-changelog/conventional-changelog#1114

@webpro
Copy link
Contributor

webpro commented Sep 21, 2023

If anyone could open a PR for this plugin and update the relevant (or all) dependencies that would be great!

@silversonicaxel
Copy link
Contributor

Could this help #75 ?

@webpro
Copy link
Contributor

webpro commented Sep 21, 2023

Released v7.0.2, hth!

@schorfES
Copy link

schorfES commented Oct 9, 2023

Hi, even though we updated to the latest version 7.0.2, we are still facing this issue.

Installed deps:

my-app
└─┬ @release-it/conventional-changelog@7.0.2
  └── conventional-changelog@5.1.0

Error:

ERROR The "angular" preset does not export a function. Maybe you are using an old version of the preset. Please upgrade.

@webpro
Copy link
Contributor

webpro commented Oct 9, 2023

Did you go from "preset": "angular" to "preset": { "name": "angular" }?

@schorfES
Copy link

schorfES commented Oct 9, 2023

Yes, we did. We are using yaml, but tried both yaml and json with the name prop you've mentioned.

@eagerestwolf
Copy link
Author

eagerestwolf commented Oct 10, 2023 via email

@silversonicaxel
Copy link
Contributor

silversonicaxel commented Oct 10, 2023

From a small test, I also see now that in our code in the .yaml file, this code works:

plugins:
  '@release-it/conventional-changelog':
    preset:
      name: conventionalcommits

But this code fails:

plugins:
  '@release-it/conventional-changelog':
    preset:
      name: angular

returning the error ERROR The "angular" preset does not export a function. Maybe you are using an old version of the preset. Please upgrade.

@schorfES
Copy link

Thank you @silversonicaxel, this is exactly the issue.

@mattfelten
Copy link

mattfelten commented Nov 17, 2023

So is the angular preset not usable anymore? I can also confirm the ERROR The "angular" preset does not export a function error and that swapping from angular to conventionalcommits does make it go away.

EDIT: I guess we're waiting on this conventional-changelog/commitlint#3698

@silversonicaxel
Copy link
Contributor

Hello @eagerestwolf, release https://github.com/conventional-changelog/commitlint/releases/tag/v18.4.3 should have fixed your issue!

@webpro
Copy link
Contributor

webpro commented Feb 15, 2024

If I understand correctly, the original issue is still not resolved, right? Unfortunately not seeing updates from relevant dependencies atm.

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

5 participants