当前位置:网站首页>Teach you to release a DeNO module hand in hand

Teach you to release a DeNO module hand in hand

2022-07-06 12:34:00 Ji Qingyun

Node.js Your package management tool is npm, And for deno for , Any resource server can be the provider of resources , Generally speaking , It's a CDN Website .
In addition to the well-known ones used for conversion node Bag https://cdn.skypack.dev/ and https://esm.sh/ outside , Official CDN The address is here :https://deno.land/x.

How to publish modules

How to publish a deno Module ?
The operation is actually very simple .

  1. The premise is that you have a github account number , Build a new project open to the outside world .
  2. Before release , In your project , It is best to configure labels and descriptions first . Labels are used to deno.land Mid search , Description is convenient for other developers to understand your drawings .

image.png

  1. go back to https://deno.land/x page .image.png Click on Publish a module, The following pop-up window appears :

image.png

  1. Click next image.png
  2. Fill in a unique module name , such as xx_test. If there is no repetition , You can click next .
  3. Fill in the folder path in the project to be published , In general, we are the root directory , Just leave it blank .

image.png

  1. The next step is the prompt page image.png
  2. You can complete it step by step according to the prompt in the previous step . Let me be more detailed here , To our github engineering , Find settings -Webhooks, Click to increase webhook Button .image.png
  3. Fill in Payload URL Is the address of the prompt page ; modify Content-type by application/json.image.png
  4. choice Which events would you like to trigger this webhook? The last item of . Check only the first one .image.png
  5. Click on Add webhook Button image.png
  6. The page will automatically return here , See a record .image.png
  7. Click edit , There will be 2 individual tab page , The first is the page you just configured , The second is what you will have in the future hooks The state of . If it fails , You can see the details here .image.png
  8. Your project uses git tagging , Such as git tag -a v0.0.1 -m "feat: xxx", Pushed to the github, It will trigger hooks.
  9. go back to https://deno.land/x, You can see your new push module below .image.png
  10. Click on your project with version number , You can see the pop-up address is https://deno.land/x/[email protected]. Every new tag Push of , There will be a new version .
One thing to note is that ,deno The number of individual release modules is limited to 15 individual , You need to send an email to the administrator ( [email protected]) apply , So don't send garbage bags if you have nothing to do , Cancellation also needs to be applied to the administrator , And it may not pass .

Fast release

In general , We need to create a README.md, Explain your module function and usage .
With my project oak_nest For example , There are usually examples of segment usage :

import {
  Body,
  Context,
  UseGuards,
} from "https://deno.land/x/[email protected]/mod.ts";

There is your module address in the example , The version number of this address should be manually modified every time it is released , That would be too much trouble .

Install a command globally :

deno install --allow-read --allow-write --allow-run --unstable -n deno_tag -f https://deno.land/x/[email protected]/cli/tag/mod.ts

Create a scripts.yml file , The content is as follows :

version: 0.0.1
name: xx_test

It can be used later deno_tag To update the version , And push it to the server . See here .

Version update

Use the command of version number update patch/minor/major, And npm The same as .

deno_tag
deno_tag patch #  The same thing as above 
deno_tag minor
deno_tag major

Will update the scripts.yml Document and README.md, If the latter is used scripts.yml Configured in name, Will be replaced accordingly .
For example, the name of the project is [email protected], Then perform deno_tag after ,README.md in [email protected] Will be correspondingly replaced with [email protected]
If you execute deno_tag minor after ,README.md in [email protected] Will be correspondingly replaced with [email protected]
If you execute deno_tag major after ,README.md in [email protected] Will be correspondingly replaced with [email protected]

Version number does not begin with v start

Suppose you push tag The version number does not want to be v start , Then you can add a parameter -L perhaps --local:

deno_tag patch -L

Add custom information

When labeling, the default submission information is the version number , If you want to customize the information , have access to -M perhaps --msg:

deno_tag minor -M "feat: change some"

Update all directories README.md file

If you want to update all directories README.md file , have access to -D perhaps --deep:

deno_tag -D

Local debugging

If you use this module in another project , You may encounter debugging problems , If you push every release , That's unreasonable ( Although you can do this ,github Of hooks It's also second level ).
You can start a server locally .

  1. Global installation file_server

    deno install --allow-net --allow-read https://deno.land/[email protected]/http/file_server.ts
  2. In your module directory , Carry out orders :

    $ file_server .
    Downloading https://deno.land/[email protected]/http/file_server.ts...
    [...]
    HTTP server listening on http://0.0.0.0:4507/
  3. Open it like this http://0.0.0.0:4507/ You can see the files in the current directory .
  4. You can debug by using this address in another project . One thing to note is that , This is how you used to run the code :

    deno run -A aa.ts 

    Now we need to change to :

    deno run -A --reload=http://localhost:4507/ aa.ts 

    Otherwise, always use the old code .

summary

This article introduces how to use github Of hooks To post a deno Module to deno.land On , How to update the version quickly , How to debug locally .

原网站

版权声明
本文为[Ji Qingyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131531013324.html