Search

CN-121996238-A - Automatic management method and device for private npm package, electronic equipment and storage medium

CN121996238ACN 121996238 ACN121996238 ACN 121996238ACN-121996238-A

Abstract

The invention provides a private npm package automation management method, a private npm package automation management device, electronic equipment and a storage medium, and relates to the technical field of front-end construction automation. The method comprises the steps of monitoring an import operation and a deletion operation of a private npm packet in source codes of front-end projects in real time, checking whether an import target private npm packet exists in a node_ modules folder when the import operation is monitored, pulling a target private npm packet from a preset private npm source and automatically installing the target private npm packet if the import target private npm packet does not exist, not processing the target private npm packet, importing the target private npm packet into the source codes through a packaging tool, executing hot update and refreshing web pages, or deleting the target private npm packet in the node_ modules folder after the scanning global source codes confirm unassociated references when the deletion operation is monitored, removing codes corresponding to the target private npm packet through the packaging tool, executing hot update and refreshing the web pages. And the automation processing of introducing and deleting the private npm packets is realized, and the packet management efficiency and safety are improved.

Inventors

  • SHU WEI
  • GUO MANLI
  • CHEN JUNHONG

Assignees

  • 广州心娱网络科技有限公司

Dates

Publication Date
20260508
Application Date
20251231

Claims (10)

  1. 1. A private npm package automation management method, comprising: monitoring the introducing operation and deleting operation of a private npm packet in the source code of the front-end project in real time; When the import operation is monitored, checking whether an import target private npm packet exists in a node_ modules folder of the front-end item; If the target private npm package does not exist, pulling the target private npm package from a preset private npm source and automatically installing the target private npm package; Introducing the target private npm package into the source code through a packaging tool, executing hot update of the front-end item and refreshing a web page; Or alternatively When the deleting operation is monitored, after the global source code of the front-end project is scanned to confirm that no associated reference exists, deleting the target private npm package in the node_ modules folder; And removing codes corresponding to the target private npm package through the packaging tool, executing hot updating of the front-end item and refreshing a web page.
  2. 2. The private npm package automation management method of claim 1, further comprising: after the target private npm package finishes introducing installation or deleting, synchronously updating the construction dependency graph of the front-end item, and marking effective dependency and redundant dependency; And automatically filtering and clearing redundant dependency based on the updated construction dependency graph.
  3. 3. The automated private npm package management method according to claim 1, wherein the target private npm package is a private npm package published by a designated person and stored in a private npm package storage repository.
  4. 4. The automated private npm package management method according to claim 3, wherein the step of publishing the private npm package includes: receiving a private npm packet release request initiated by a user; Acquiring a token carried by the private npm packet release request; Verifying the validity and the validity period of the token through an encryption algorithm; If the token is valid and not expired, resolving a unique user identifier from the token, and inquiring npm package operation authority configuration corresponding to the user from an enterprise authority database according to the unique user identifier; comparing the package file of the private npm package to be issued with npm package operation authority configuration corresponding to the user, and judging whether the user has the write authority of the private npm package to be issued; If the user has the write permission, uploading the private npm package to be distributed to the private npm package storage warehouse, and updating the package version record.
  5. 5. The private npm package automation management method of claim 1, further comprising: Periodically checking the versions of all private npm packages in the front-end project; If a private npm packet with version conflict is detected, automatically outputting a conflict prompt and providing a version unification suggestion.
  6. 6. The automated private npm package management method according to claim 1, wherein when the import operation is monitored, checking whether there is an import target private npm package in a node_ modules folder of the front-end item includes: When the import operation is monitored, acquiring a unique identifier and a first version number of a target private npm packet of the import operation request; Calling an API (application program interface) of the preset private npm source to acquire all historical version lists of the target private npm package; Screening out a second version number of the latest version conforming to the first version number constraint from the all historical version list based on npm version specifications; Based on the unique identification and the second version number, it is checked whether there is a corresponding target private npm package in the node_ modules folder.
  7. 7. The automated private npm package management method according to claim 1, wherein when the import operation is monitored, checking whether there is an import target private npm package in a node_ modules folder of the front-end item includes: When the import operation is monitored, acquiring a unique identifier of the target private npm packet of the import operation request; calling an API interface of the preset private npm source to obtain a third version number of the latest version of the target private npm packet; Based on the third version number of the latest version, it is checked whether there is a corresponding target private npm package in the node_ modules folder.
  8. 8. A proprietary npm packet automation management device, comprising: the dependence monitoring module is used for monitoring the introducing operation and deleting operation of the private npm packet in the source code of the front-end project in real time; An automatic processing module for checking if there is an imported target private npm package in the node_ modules folder of the front-end item when the import operation is monitored, pulling the target private npm package from a preset private npm source and automatically installing if there is no target private npm package, if there is no, not processing, importing the target private npm package into the source code by a packaging tool, performing a hot update of the front-end item and refreshing a web page, or When the deleting operation is monitored, after the global source code of the front-end item is scanned to confirm that no associated reference exists, deleting the target private npm package in the node_ modules folder, removing codes corresponding to the target private npm package through the packaging tool, executing hot updating of the front-end item and refreshing a web page.
  9. 9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the proprietary npm packet automation management method of any one of claims 1 to 7 when the program is executed by the processor.
  10. 10. A non-transitory computer readable storage medium having stored thereon a computer program, wherein the computer program when executed by a processor implements the private npm package automation management method of any one of claims 1 to 7.

Description

Automatic management method and device for private npm package, electronic equipment and storage medium Technical Field The invention relates to the technical field of front-end construction automation, in particular to a private npm package automation management method, a device, electronic equipment and a storage medium. Background In modern front-end development, a proprietary npm (Node PACKAGE MANAGER ) package is widely used for a plurality of business modules (e.g., an enterprise internal component library, a tool kit, etc.) inside an enterprise because of being capable of implementing code multiplexing and unified technical standards. However, the management method of the traditional private npm package is completely dependent on manual installation, quotation and cleaning of a developer, so that the problems that the package is not installed correctly or is wrong in version, the redundancy dependence is not cleared, the abandoned package is still reserved in the node_ modules after the quotation is deleted and the like are easily caused, and the construction volume and efficiency are affected. Disclosure of Invention The invention provides a method, a device, electronic equipment and a storage medium for automatically managing a private npm packet, which are used for solving the defects that the prior art depends on manual operation and is easy to depend on errors or redundancy, realizing the automatic processing of introducing and deleting the private npm packet, and improving the packet management efficiency and safety. The invention provides a private npm package automation management method, which comprises the following steps: monitoring the introducing operation and deleting operation of a private npm packet in the source code of the front-end project in real time; When the import operation is monitored, checking whether an import target private npm packet exists in a node_ modules folder of the front-end item; If the target private npm package does not exist, pulling the target private npm package from a preset private npm source and automatically installing the target private npm package; Introducing the target private npm package into the source code through a packaging tool, executing hot update of the front-end item and refreshing a web page; Or alternatively When the deleting operation is monitored, after the global source code of the front-end project is scanned to confirm that no associated reference exists, deleting the target private npm package in the node_ modules folder; And removing codes corresponding to the target private npm package through the packaging tool, executing hot updating of the front-end item and refreshing a web page. The automatic management method for the private npm package provided by the invention further comprises the following steps: after the target private npm package finishes introducing installation or deleting, synchronously updating the construction dependency graph of the front-end item, and marking effective dependency and redundant dependency; And automatically filtering and clearing redundant dependency based on the updated construction dependency graph. According to the private npm package automation management method provided by the invention, the target private npm package is a private npm package which is released by appointed personnel and stored in a private npm package storage warehouse. According to the method for automatically managing the private npm package, the publishing step of the private npm package comprises the following steps: receiving a private npm packet release request initiated by a user; Acquiring a token carried by the private npm packet release request; Verifying the validity and the validity period of the token through an encryption algorithm; If the token is valid and not expired, resolving a unique user identifier from the token, and inquiring npm package operation authority configuration corresponding to the user from an enterprise authority database according to the unique user identifier; comparing the package file of the private npm package to be issued with npm package operation authority configuration corresponding to the user, and judging whether the user has the write authority of the private npm package to be issued; If the user has the write permission, uploading the private npm package to be distributed to the private npm package storage warehouse, and updating the package version record. The automatic management method for the private npm package provided by the invention further comprises the following steps: Periodically checking the versions of all private npm packages in the front-end project; If a private npm packet with version conflict is detected, automatically outputting a conflict prompt and providing a version unification suggestion. According to the method for automatically managing the private npm package provided by the invention, when the import operation is monitored, whether the imported t