build: use npm prepare instead of prepublishOnly

In NPM, the `prepublishOnly` script is run only before running
`npm publish`. However, this means that people trying to use the git
version of of this project
(i.e. with `npm install ferdikoomen/openapi-typescript-codegen`)
won't get a working version of this project, since there will be
nothing in the `dist/` folder.

[NPM (since v4.0.0)][1] supports a `prepack` script, that is called:

> * Runs BEFORE the package is packed
> * Runs BEFORE the package is published
> * Runs on local `npm install` without any arguments
> * Run AFTER `prepublish`, but BEFORE `prepublishOnly`
> * NOTE: If a package being installed through git contains a `prepare`
>   script, its `dependencies` and `devDependencies` will be installed,
>   and the prepare script will be run, before the package is packaged
>   and installed.

[1]: https://docs.npmjs.com/cli/v6/using-npm/scripts#life-cycle-scripts
This commit is contained in:
Alois Klink 2023-05-15 21:21:02 +01:00
parent 6c75c80eb2
commit b44d413ec4

View File

@ -55,7 +55,7 @@
"test:e2e": "jest --selectProjects E2E --runInBand --verbose",
"eslint": "eslint .",
"eslint:fix": "eslint . --fix",
"prepublishOnly": "npm run clean && npm run release",
"prepare": "npm run clean && npm run release",
"codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b",
"docker": "docker build -t eeelenbaas/openapi-typescript-codegen ."
},