Clarifications and adjustments

Now with extra safety.  Two modifications made copypasting safer for end users.
This commit is contained in:
justknow 2025-04-02 13:48:57 +00:00
parent dc1516d231
commit 58a93e9910

View file

@ -47,11 +47,12 @@ npm config set -- '//forgejo.example.com/api/packages/testuser/npm/:_authToken'
## Publish a package ## Publish a package
Publish a package by running the following command in your project: When publishing a package, npm uses configs and defaults if the arguments are not specified in the command or project. The following commands demonstrate a default publish, publishing to a specific registry, and a specific scope and registry:
```shell ```shell
npm publish npm publish
npm publish --scope=@{scope} --registry=${{github.SERVER_URL}}/api/packages/{owner}/npm/ npm publish --registry={SERVER_URL}/api/packages/{owner}/npm/
npm publish --scope=@{scope} --registry={SERVER_URL}/api/packages/{owner}/npm/
``` ```
You cannot publish a package if a package of the same name and version already exists. First, you must delete that version of the existing package, either in UI at `SERVER_URL/OWNER/-/packages/npm/PACKAGE_NAME/PACKAGE_VERSION/settings` or `unpublish` in CLI. You cannot publish a package if a package of the same name and version already exists. First, you must delete that version of the existing package, either in UI at `SERVER_URL/OWNER/-/packages/npm/PACKAGE_NAME/PACKAGE_VERSION/settings` or `unpublish` in CLI.
@ -74,7 +75,6 @@ For example:
```shell ```shell
npm unpublish @test/test_package npm unpublish @test/test_package
npm unpublish @test/test_package@1.0.0 npm unpublish @test/test_package@1.0.0
npm unpublish @test/test_package --force #After npm error code EUSAGE:Refusing to delete entire project.
``` ```
Note: This behavior is different than the public npm repository. Once you delete or unpublish a package, you can re-publish a package with the same name and version immediately. Note: This behavior is different than the public npm repository. Once you delete or unpublish a package, you can re-publish a package with the same name and version immediately.
@ -135,7 +135,7 @@ npm view
npm search npm search
``` ```
## When commands fail ## Troubleshooting
Run these commands before the command that fails: Run these commands before the command that fails:
@ -144,7 +144,7 @@ npm config set loglevel verbose #The default log level is notice
npm config ls -l #Lists the full config, including defaults. User config is at the bottom. npm config ls -l #Lists the full config, including defaults. User config is at the bottom.
``` ```
The [npm CLI Docs](https://docs.npmjs.com/cli) provide hints when something goes wrong. There's probably a config setting you need to use before running the failing one. Incorrect [Auth-related config](https://docs.npmjs.com/cli/configuring-npm/npmrc#auth-related-configuration) can silently/cryptically fail at the default log level. The [npm CLI Docs](https://docs.npmjs.com/cli) may help you find missing config settings required prior to the failing command. Incorrect [Auth-related config](https://docs.npmjs.com/cli/configuring-npm/npmrc#auth-related-configuration) can silently/cryptically fail at the default log level.
## Forgejo Actions Example ## Forgejo Actions Example
@ -169,10 +169,10 @@ jobs:
run: npm install run: npm install
- name: Build - name: Build
run: npm run build run: npm run build
- name: Only if using a self-signed cert # WARNING: The following commented step will override the default CA settings (null == only use known CAs) and prevent npm from communicating with the public npm registry
#WARNING: This will override the default CA settings (null == only use known CAs) and prevent npm from communicating with the public npm registry # To undo it, add another step: 'run: npm config set cafile='
# To reverse this, use: npm config set cafile= #- name: Only if using a self-signed cert
run: npm config set cafile {location of ca-cert.pem} # run: npm config set cafile {location of ca-cert.pem}
- name: Publish to registry - name: Publish to registry
run: npm publish --scope=@{scope} --registry=${{github.SERVER_URL}}/api/packages/{owner}/npm/ run: npm publish --scope=@{scope} --registry=${{github.SERVER_URL}}/api/packages/{owner}/npm/
``` ```