CN117311792A - Version number updating method, device, equipment and storage medium - Google Patents
Version number updating method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN117311792A CN117311792A CN202311318808.XA CN202311318808A CN117311792A CN 117311792 A CN117311792 A CN 117311792A CN 202311318808 A CN202311318808 A CN 202311318808A CN 117311792 A CN117311792 A CN 117311792A
- Authority
- CN
- China
- Prior art keywords
- version number
- vite
- plug
- updating
- target
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 68
- 238000010276 construction Methods 0.000 claims abstract description 34
- 230000006870 function Effects 0.000 claims description 118
- 238000001514 detection method Methods 0.000 claims description 8
- 238000004891 communication Methods 0.000 claims description 6
- 239000008186 active pharmaceutical agent Substances 0.000 claims 4
- 238000012423 maintenance Methods 0.000 abstract description 15
- 238000013461 design Methods 0.000 description 20
- 238000011161 development Methods 0.000 description 7
- 230000003287 optical effect Effects 0.000 description 5
- 238000012545 processing Methods 0.000 description 5
- 238000004590 computer program Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000000694 effects Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000001419 dependent effect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000000802 evaporation-induced self-assembly Methods 0.000 description 1
- 238000000605 extraction Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 239000013307 optical fiber Substances 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000004044 response Effects 0.000 description 1
- 238000012216 screening Methods 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
- 230000001960 triggered effect Effects 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/445—Program loading or initiating
- G06F9/44521—Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
- G06F9/44526—Plug-ins; Add-ons
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Security & Cryptography (AREA)
- Stored Programmes (AREA)
Abstract
The scheme can utilize a plug-in configuration function provided by Vite to pre-configure a target Vite plug-in, and then realize automatic update of version numbers in an HTML file during construction of a source code file by a Vite server through the target Vite plug-in. Therefore, a developer is not required to manually maintain the version number, and the maintenance efficiency and the maintenance accuracy of the version number can be improved. Specifically, the method may include: detecting an execution instruction of the plug-in a construction stage aiming at a target source code file; and calling a pre-configured target Vite plugin to acquire each HTML file of the target source code file under the condition that the plugin execution instruction is determined to be detected, and updating the version number of each HTML file based on the current version number.
Description
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a version number updating method, device, apparatus, and storage medium.
Background
In the software project development process, the source code of the project needs to be built (build) to generate executable programs/libraries. When there is a need for a new business function or an error is found in the software test process, the source code of the project needs to be modified, and the modified source code needs to be built again to generate a new executable program/library.
In order to facilitate management of executable programs/libraries of different versions of the same item, and to facilitate a user to more clearly understand the software functions currently used by the user, whether software upgrading is required, etc., currently, the version numbers of source codes corresponding to the executable programs/libraries are recorded in the executable programs/libraries.
In the prior art, a developer may manually maintain and update the version number of the source code before the source code is built or after the executable program/library is built and generated, so that the version number of the corresponding source code is recorded in the final executable program/library. However, the existing manual maintenance of the version number by the developer is not only inefficient in maintenance but also prone to error.
Disclosure of Invention
The application provides a version number updating method, device, equipment and storage medium, which can improve the maintenance efficiency and maintenance accuracy of the version number.
In order to achieve the above purpose, the present application adopts the following technical scheme:
in a first aspect, the present application provides a method for updating a version number, where the method may be applied to a Vite server, and the method may include: detecting an execution instruction of the plug-in a construction stage aiming at a target source code file; and calling a pre-configured target Vite plugin to acquire each HTML file of the target source code file under the condition that the plugin execution instruction is determined to be detected, and updating the version number of each HTML file based on the current version number.
In the technical scheme provided by the application, because the Vite server needs to process the HTML file during the construction of the source code file and the version number is generally recorded in the HTML file, the application can obtain a target Vite plug-in by pre-configuration based on the plug-in configuration function provided by Vite. Specifically, the target Vite plug-in can trigger the call based on the plug-in execution instruction in the construction stage of the source code file, and the target Vite plug-in can realize the following functions when being called: and acquiring each HTML file of the source code file currently being constructed, and automatically updating the version number of each HTML file. After the configuration of the target Vite plugin is completed, the target Vite plugin can be inserted into the construction life cycle of the Vite server, and when the Vite server needs to construct the target source code file, plugin execution instructions can be detected in the construction stage aiming at the target source code file; if the plug-in execution instruction is detected, the target Vite plug-in can be called to acquire all HTML files of the target source code file, and version number updating is carried out on all HTML files based on the current version number. It can be seen that in the technical solution provided in the present application, a target Vite plug-in may be preconfigured by using a plug-in configuration function provided by Vite, and then automatic update of a version number in an HTML file during construction of a source code file by the Vite server is implemented through the target Vite plug-in. Therefore, a developer is not required to manually maintain the version number, and the maintenance efficiency and the maintenance accuracy of the version number can be improved.
Optionally, in one possible design manner, the target Vite plug-in includes a preconfigured Vite hook function and a preconfigured auxiliary function, and invoking the preconfigured target Vite plug-in to obtain each HTML file of the target source code file, and updating a version number of each HTML file based on the current version number includes:
acquiring each HTML file through a Vite hook function, and transmitting each HTML file to an auxiliary function to call the auxiliary function; and acquiring the current version number through an auxiliary function, and updating the version number of each HTML file based on the current version number.
Alternatively, in another possible design, the transferring each HTML file to the auxiliary function to call the auxiliary function includes: transmitting each HTML file and an access address for the pre-configured version API to the auxiliary function to call the auxiliary function;
the current version number is obtained through an auxiliary function, and version number updating is carried out on each HTML file based on the current version number, and the method comprises the following steps: acquiring a current version number from a preconfigured version API based on an access address through an auxiliary function; and updating the version number of each HTML file based on the current version number.
Alternatively, in another possible design, the obtaining, by the auxiliary function, the current version number from the preconfigured version API based on the access address includes:
Acquiring version number information in a preset format from a preset version API based on an access address through an auxiliary function; converting version number information in a preset format into version number information in a target format; and determining the current version number from the version number information of the target format.
Optionally, in another possible design manner, before detecting the plug-in execution instruction in the building stage of the target source code file, the method for updating the version number provided in the present application may further include:
acquiring custom configuration information aiming at a target Vite plug-in; the custom configuration information at least comprises a plug-in name, a plug-in application stage and plug-in execution time; the plug-in application stage is a construction stage; and completing the configuration of the target Vite plugin based on the self-defined configuration information, and adding the configured target Vite plugin into a plugin array of the Vite configuration file.
Alternatively, in another possible design, the plug-in execution timing is after the execution of the other plug-ins in the build phase is completed.
Optionally, in another possible design manner, updating the version number of each HTML file based on the current version number includes:
Inquiring a publication number field from each HTML file based on a predetermined regular expression; and updating the field value of the version number field to the current version number.
In a second aspect, the present application provides a version number updating apparatus, including: the device comprises a detection module and an updating module;
specifically, the detection module is used for detecting the execution instruction of the plug-in unit in the construction stage aiming at the target source code file; and the updating module is used for calling a pre-configured target Vite plugin to acquire each HTML file of the target source code file under the condition that the plugin execution instruction is determined to be detected, and updating the version number of each HTML file based on the current version number.
Optionally, in one possible design manner, the target Vite plug-in includes a preconfigured Vite hook function and a preconfigured auxiliary function, and the update module is specifically configured to:
under the condition that the plug-in execution instruction is detected, a target Vite plug-in is called, all HTML files are obtained through a Vite hook function, and all the HTML files are transmitted to an auxiliary function to call the auxiliary function; and acquiring the current version number through an auxiliary function, and updating the version number of each HTML file based on the current version number.
Optionally, in another possible design manner, the updating module is specifically further configured to:
transmitting each HTML file and an access address for the pre-configured version API to the auxiliary function to call the auxiliary function; acquiring a current version number from a preconfigured version API based on an access address through an auxiliary function; and updating the version number of each HTML file based on the current version number.
Optionally, in another possible design manner, the updating module is specifically further configured to:
acquiring version number information in a preset format from a preset version API based on an access address through an auxiliary function; converting version number information in a preset format into version number information in a target format; and determining the current version number from the version number information of the target format.
Optionally, in another possible design manner, the updating device of the version number provided in the application further includes an obtaining module and a configuration module;
the acquisition module is used for acquiring the custom configuration information of the target Vite plugin before the detection module detects the plugin execution instruction in the construction stage of the target source code file; the custom configuration information at least comprises a plug-in name, a plug-in application stage and plug-in execution time; the plug-in application stage is a construction stage;
The configuration module is used for completing the configuration of the target Vite plugin based on the self-defined configuration information and adding the configured target Vite plugin into a plugin array of the Vite configuration file.
Alternatively, in another possible design, the plug-in execution timing is after the execution of the other plug-ins in the build phase is completed.
Optionally, in another possible design manner, the updating module is specifically further configured to:
inquiring a publication number field from each HTML file based on a predetermined regular expression; and updating the field value of the version number field to the current version number.
In a third aspect, the present application provides an update apparatus for a version number, including a memory, a processor, a bus, and a communication interface; the memory is used for storing computer execution instructions, and the processor is connected with the memory through a bus; when the version number updating device is running, the processor executes computer-executable instructions stored in the memory to cause the version number updating device to perform the version number updating method as provided in the first aspect described above.
In a fourth aspect, the present application provides a computer-readable storage medium having instructions stored therein that, when executed by a computer, cause the computer to perform the method of updating a version number as provided in the first aspect.
In a fifth aspect, the present application provides a computer program product comprising computer instructions which, when run on a computer, cause the computer to perform the method of updating a version number as provided in the first aspect.
It should be noted that the above-mentioned computer instructions may be stored in whole or in part on a computer-readable storage medium. The computer readable storage medium may be packaged together with the processor of the version number updating device, or may be packaged separately from the processor of the version number updating device, which is not limited in this application.
The description of the second, third, fourth and fifth aspects of the present application may refer to the detailed description of the first aspect; further, the advantageous effects described in the second aspect, the third aspect, the fourth aspect, and the fifth aspect may refer to the advantageous effect analysis of the first aspect, and are not described herein.
In the present application, the names of the above-mentioned devices or functional modules are not limited, and in actual implementation, these devices or functional modules may appear under other names. Insofar as the function of each device or function module is similar to the present application, it is within the scope of the present application and the equivalents thereof.
These and other aspects of the present application will be more readily apparent from the following description.
Drawings
Fig. 1 is a flow chart of a version number updating method provided in an embodiment of the present application;
fig. 2 is a flow chart of another version number updating method according to an embodiment of the present application;
fig. 3 is a flowchart of another version number updating method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an updating device for version numbers according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an update device with a version number according to an embodiment of the present application.
Detailed Description
The following describes in detail a version number updating method, device, equipment and storage medium provided in the embodiments of the present application with reference to the accompanying drawings.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms "first" and "second" and the like in the description and in the drawings are used for distinguishing between different objects or for distinguishing between different processes of the same object and not for describing a particular sequential order of objects.
Furthermore, references to the terms "comprising" and "having" and any variations thereof in the description of the present application are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed but may optionally include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be noted that, in the embodiments of the present application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the description of the present application, unless otherwise indicated, the meaning of "a plurality" means two or more.
In addition, the technical scheme of the application is used for acquiring, storing, using, processing and the like data, and the data are in accordance with relevant regulations of national laws and regulations.
In the prior art, a developer may manually maintain and update the version number of the source code before the source code is built or after the executable program/library is built and generated, so that the version number of the corresponding source code is recorded in the final executable program/library. However, the existing manual maintenance of the version number by the developer is not only inefficient in maintenance but also prone to error.
In view of the foregoing problems in the prior art, embodiments of the present application provide a version number updating method, which may pre-configure a target Vite plug-in with a plug-in configuration function provided by Vite, and then implement, by using the target Vite plug-in, automatic updating of a version number in a hypertext markup language (Hyper Text Markup Language, HTML) file during building of a source code file by a Vite server. Therefore, a developer is not required to manually maintain the version number, and the maintenance efficiency and the maintenance accuracy of the version number can be improved.
The version number updating method provided by the embodiment of the application can be executed by the version number updating device provided by the embodiment of the application, and the device can be realized in a software and/or hardware mode and is integrated in updating equipment for executing the version number of the method. Specifically, in the embodiment of the present application, the update device of the version number may be a Vite server.
The method for updating the version number provided by the embodiment of the application is described in detail below with reference to the accompanying drawings.
Referring to fig. 1, the method for updating version numbers provided in the embodiment of the present application includes S101-S102:
s101, detecting an execution instruction of the plug-in a construction stage aiming at a target source code file.
Vite is a next generation front-end development and build tool that can be oriented to JavaScript (abbreviated JS, a lightweight, interpreted or just-in-time compiled programming language with functional preference) and TypeScript (a strongly typed programming language built based on JavaScript) developers, and can help front-end developers develop applications more quickly by providing an experience of quick build, compile and deploy. Specifically, vite may provide source code in a native ESM manner using the browser's support for a native ES (a standardized scripting programming language) Module (M), thereby enabling the browser to take over part of the wrapper. Therefore, the Vite only needs to convert and provide the source codes according to the requirements when the browser requests the source codes, so that the starting speed of the Vite in the development environment can be greatly improved. Thus, vite is the most widely used front-end development building tool at present. Based on this, in the embodiment of the application, the source code file may be constructed through Vite. Illustratively, each life cycle of the build phase is recorded in a server corresponding to Vite (i.e., the Vite server in the embodiment of the application), and the Vite server can complete the build of the source code file based on the life cycle.
Because the Vite provides rich plug-in interface capability, so that a developer can develop various plug-ins in the project development process to widen the project function, in the embodiment of the application, a target Vite plug-in can be obtained by pre-configuring based on the plug-in configuration function provided by the Vite, and the automatic update of the version number is realized through the target Vite plug-in. Considering that the Vite server needs to process the HTML file during the construction of the source code file, and the version number is generally recorded in the HTML file, in this embodiment of the present application, the calling occasion of the target Vite plug-in may be configured at the construction stage of the source code file, and specifically, the target Vite plug-in may be called by triggering the plug-in execution instruction.
In one possible implementation, the plug-in execution instruction may be an instruction that is forced to insert in the middle of each lifecycle of the build phase. For example, if there is a node a in each lifecycle of the build phase that needs to process the HTML file, the plug-in execution instruction may be forcedly inserted into the node a; during construction, the Vite server can monitor the workflow of the construction stage through a hook function of Vite, and when the monitored execution node is node A, the execution instruction of the plug-in unit can be automatically triggered.
In addition, in the embodiment of the present application, the target source code file may be a source code file for a certain software item, or may be a source code file for a certain functional module in a certain software item. Thus, when a user modifies the source code only for a certain functional module in a certain software project, the embodiment of the application can adaptively update the version number of the source code of the part.
S102, calling a pre-configured target Vite plugin to acquire all HTML files of a target source code file under the condition that the plugin execution instruction is detected, and updating the version numbers of all HTML files based on the current version numbers.
Since the Vite server needs to process the HTML file during the construction of the source code file, and the version number is generally recorded in the HTML file, in the embodiment of the present application, the plug-in function of the target Vite plug-in may be configured as follows: when the method is called, each HTML file of the source code file currently being constructed is acquired, and version number updating operation is automatically carried out on each HTML file.
Wherein the current version number may be a version number corresponding to the target source code file. The current version number may be a version number that is generated in advance for the target source code file by a preset version number generation rule; the preset version number generation rule may be a predetermined rule for generating a version number.
Optionally, before detecting the plug-in execution instruction in the building stage of the target source code file, the update method of the version number provided in the embodiment of the present application further includes: acquiring custom configuration information aiming at a target Vite plug-in; and completing the configuration of the target Vite plugin based on the self-defined configuration information, and adding the configured target Vite plugin into a plugin array of the Vite configuration file.
The custom configuration information at least comprises a plug-in name, a plug-in application stage and plug-in execution time; the plug-in application phase is the build phase.
After completing the configuration of the target Vite plugin, in order to achieve binding of the target Vite plugin and the Vite server, and thus achieve calling of the target Vite plugin during the process that the Vite server builds the source code file, the configured target Vite plugin can be added into a plugin array of the Vite configuration file.
For example, a "plug-in" array may be set in a Vite configuration file (e.g., a Vite. Config. Js file) and then the configured target Vite plug-in may be added to the "plug-in" array.
In addition, in the embodiment of the application, the user can be supported to carry out the self-defined configuration on the plug-in name, the plug-in application stage and the plug-in execution time of the target Vite plug-in, so that the personalized development requirements of different users on different projects can be met.
Optionally, in this embodiment of the present application, the execution opportunity of the plugin is after the execution of the other plugins in the construction stage is completed.
During the construction of the source code file, the Vite server may also need to call other plugins (non-target Vite plugins) to execute corresponding plugin functions, so when configuring the target Vite plugins, the embodiment of the application needs to configure not only the plugin application stage of the target Vite plugin, but also the specific plugin execution time of the plugin application stage to determine the order of calling the target Vite plugin and other plugins.
In the actual software project development process, some project version numbers are written in js files, and during construction, js files are converted into HTML files by calling other plug-ins. Based on this, in the embodiment of the present application, the execution timing of the plug-in of the target Vite plug-in may be set after the execution of other plug-ins is completed, so that the obtained HTML file may be ensured to include information related to the version number, so that the version number may be successfully updated automatically.
Optionally, the target Vite plug-in includes a preconfigured Vite hook function and a preconfigured auxiliary function, and the method includes calling the preconfigured target Vite plug-in to obtain each HTML file of the target source code file, and updating version numbers of each HTML file based on the current version number, including: acquiring each HTML file through a Vite hook function, and transmitting each HTML file to an auxiliary function to call the auxiliary function; and acquiring the current version number through an auxiliary function, and updating the version number of each HTML file based on the current version number.
In this embodiment of the present application, two functions, namely, a Vite hook function and an auxiliary function, may be preconfigured for the target Vite plug-in, and when the target Vite plug-in is called, the Vite hook function may perform the following functions: screening all the HTML files, storing the screened HTML files in an array, traversing the HTML files in the array, and transmitting the file contents as parameters to an auxiliary function. The auxiliary function may perform the following functions: when each HTML file transmitted by the Vite hook function is received, the current version number can be obtained, and then the version number of each HTML file is updated based on the current version number.
Optionally, passing each HTML file to an auxiliary function to call the auxiliary function, including: transmitting each HTML file, and an access address for a preconfigured version application program interface (Application Program Interface, API), to the auxiliary function to call the auxiliary function; the current version number is obtained through an auxiliary function, and version number updating is carried out on each HTML file based on the current version number, and the method comprises the following steps: acquiring a current version number from a preconfigured version API based on an access address through an auxiliary function; and updating the version number of each HTML file based on the current version number.
Wherein the pre-configured version API may be a pre-generated interface that may be used to access files/databases that have the latest version number recorded. Illustratively, the preconfigured version API may be a REST API (a type of API) type of API.
In one possible implementation, the auxiliary function may call a fetch function (browser's request method) to send an HTTP request, obtaining the current version number from the preconfigured version API.
Illustratively, the access address of the preconfigured version API may be a uniform resource location system (uniform resource locator, URL) of the preconfigured version API.
Optionally, obtaining, by the auxiliary function, the current version number from the preconfigured version API based on the access address, including: acquiring version number information in a preset format from a preset version API based on an access address through an auxiliary function; converting version number information in a preset format into version number information in a target format; and determining the current version number from the version number information of the target format.
The preset format and the target format may be two different file formats that are determined in advance, for example, the preset format may be promise (a data format), and the target format may be json (a data format).
Because the current network request and the interface request are both json format requests, and the version number information acquired from the pre-configured version API by calling the fetch function is in a promiscuous format, after the version number information in the promiscuous format is acquired, the version number information needs to be converted into the version number information in the json format, so that the current version number can be determined from the version number information in the json format.
Optionally, updating the version number of each HTML file based on the current version number includes: inquiring a publication number field from each HTML file based on a predetermined regular expression; and updating the field value of the version number field to the current version number.
For example, if the predetermined regular expression is x.x.x, a version number field corresponding to x.x.x may be queried in each HTML file, and then a field value of the version number field may be replaced with a current version number, so as to implement updating of the version number.
In view of the above, in the version number updating method provided in the embodiment of the present application, because the Vite server needs to process the HTML file during the construction of the source code file, and the version number is generally recorded in the HTML file, the embodiment of the present application may be preconfigured to obtain a target Vite plug-in based on the plug-in configuration function provided by Vite. Specifically, the target Vite plug-in can trigger the call based on the plug-in execution instruction in the construction stage of the source code file, and the target Vite plug-in can realize the following functions when being called: and acquiring each HTML file of the source code file currently being constructed, and automatically updating the version number of each HTML file. After the configuration of the target Vite plugin is completed, the target Vite plugin can be inserted into the construction life cycle of the Vite server, and when the Vite server needs to construct the target source code file, plugin execution instructions can be detected in the construction stage aiming at the target source code file; if the plug-in execution instruction is detected, the target Vite plug-in can be called to acquire all HTML files of the target source code file, and version number updating is carried out on all HTML files based on the current version number. It can be seen that in the technical solution provided in the embodiments of the present application, a target Vite plug-in may be preconfigured by using a plug-in configuration function provided by Vite, and then automatic update of a version number in an HTML file during construction of a source code file by a Vite server is implemented through the target Vite plug-in. Therefore, a developer is not required to manually maintain the version number, the maintenance efficiency of the version number can be improved, the maintenance accuracy can be improved, and the situation that software is wrong in the running process due to the fact that the version number is updated wrongly or the developer forgets to update the version number is avoided. In addition, since maintenance efficiency for version numbers can be improved, expansion of project functions by modifying source code expansion is facilitated.
Optionally, as shown in fig. 2, the embodiment of the present application further provides a version number updating method, which may include S201-S204:
s201, acquiring custom configuration information aiming at a target Vite plug-in.
S202, completing configuration of the target Vite plugin based on the self-defined configuration information, and adding the configured target Vite plugin into a plugin array of the Vite configuration file.
S203, detecting the execution instruction of the plug-in the construction stage aiming at the target source code file.
S204, calling a pre-configured target Vite plugin to acquire all HTML files of a target source code file under the condition that the plugin execution instruction is detected, and updating the version numbers of all HTML files based on the current version numbers.
Optionally, as shown in fig. 3, the embodiment of the present application further provides a version number updating method, which may include S301-S306:
s301, acquiring custom configuration information aiming at a target Vite plug-in.
S302, completing configuration of the target Vite plugin based on the self-defined configuration information, and adding the configured target Vite plugin into a plugin array of the Vite configuration file.
S303, detecting the execution instruction of the plug-in the construction stage aiming at the target source code file.
S304, calling a pre-configured target Vite plugin under the condition that the plugin execution instruction is determined, acquiring each HTML file through a Vite hook function of the target Vite plugin, and transmitting each HTML file and an access address aiming at a pre-configured version API to an auxiliary function of the target Vite plugin so as to call the auxiliary function.
S305, acquiring the current version number from the pre-configured version API based on the access address through the auxiliary function.
S306, inquiring a version number field from each HTML file based on a predetermined regular expression, and updating the field value of the version number field to the current version number.
In order to more clearly describe the technical solution provided by the embodiments of the present application, a complete example is used to describe the configuration process of the target Vite plug-in related to the embodiments of the present application in detail below.
The target Vite plug-in may be implemented by a vitepluginpdatewebversion function, which is implemented as follows:
as can be seen from the implementation code of the viteplukedatewebversion function, the function returns an object named update-web-version, which has three properties, namely name (corresponding to the plug-in name in the embodiment of the application), apply (corresponding to the plug-in application stage in the embodiment of the application), and performance (corresponding to the plug-in execution opportunity in the embodiment of the application). In this example, the plugin name is "update-web-version"; the plug-in application stage is "build", which means that the target Vite plug-in is called in the construction stage; the plug-in execution time is "post", which means that the target Vite plug-in can be executed after the execution of other plug-ins is completed.
In addition, the object also includes a method named generateBundle, which is the Vite hook function in the embodiment of the application. The generateblende method can be used for acquiring HTML (i.e. each HTML file in the embodiment of the application), and transmitting HTML and apiUrl (i.e. the access address of the pre-configured version API in the embodiment of the application) to an updateWebVersion function (i.e. the auxiliary function in the embodiment of the application), so that the updateWebVersion function can be called to acquire the latest version number, and the update of the version number of the HTML file is completed. Exemplary, the implementation code of the updateWebVersion function is as follows:
as can be seen from the implementation code of the updateWebVersion function, the input parameters of the updateWebVersion function are html and apiUrl which are transmitted by the generateBundle, after the updateWebVersion function receives the input parameters, the latest version number can be obtained from apiUrl by using the fetch function, the fetch function returns version number information in a process format, and the response can be converted into version number information in a json format after waiting for resolve by using an await keyword. Thereafter, the current version number may be extracted from the json-format version number information based on the regular expression. If the extraction is wrong, the error can be captured and recorded, and the HTML file before being updated is returned.
After the target Vite plug-in is implemented by the Vite plugin update webversion function, the target Vite plug-in can be inserted into the Vite configuration file (i.e., vite.config.js) by the following code:
it can be seen that the parameter passed to the vitepluginupdatebversion function is apiUrl.
In addition, in practical application, a node-fetch packet is also required to be installed as a dependent item to normally use the target Vite plug-in. For example, an npminstall node-fetch or a yarn add node-fetch command may be used for installation.
As shown in fig. 4, the embodiment of the present application further provides an updating apparatus for version numbers, where the apparatus may include: a detection module 11, and an update module 21.
Wherein the detection module 11 performs S101 in the above-described method embodiment, and the update module 21 performs S102 in the above-described method embodiment.
Specifically, the detection module 11 is configured to detect, in a construction stage for a target source code file, an instruction for executing a plug-in unit; and the updating module 21 is used for calling a preconfigured target Vite plug-in to acquire each HTML file of the target source code file and updating the version number of each HTML file based on the current version number under the condition that the plug-in execution instruction is detected.
Optionally, in one possible design manner, the target Vite plug-in includes a preconfigured Vite hook function and a preconfigured auxiliary function, and the updating module 21 is specifically configured to:
under the condition that the plug-in execution instruction is detected, a target Vite plug-in is called, all HTML files are obtained through a Vite hook function, and all the HTML files are transmitted to an auxiliary function to call the auxiliary function; and acquiring the current version number through an auxiliary function, and updating the version number of each HTML file based on the current version number.
Optionally, in another possible design, the updating module 21 is specifically further configured to:
transmitting each HTML file and an access address for the pre-configured version API to the auxiliary function to call the auxiliary function; acquiring a current version number from a preconfigured version API based on an access address through an auxiliary function; and updating the version number of each HTML file based on the current version number.
Optionally, in another possible design, the updating module 21 is specifically further configured to:
acquiring version number information in a preset format from a preset version API based on an access address through an auxiliary function; converting version number information in a preset format into version number information in a target format; and determining the current version number from the version number information of the target format.
Optionally, in another possible design manner, the updating device of the version number provided in the application further includes an obtaining module and a configuration module;
the acquisition module is used for acquiring the custom configuration information of the target Vite plugin before the detection module 11 detects the plugin execution instruction in the construction stage of the target source code file; the custom configuration information at least comprises a plug-in name, a plug-in application stage and plug-in execution time; the plug-in application stage is a construction stage;
the configuration module is used for completing the configuration of the target Vite plugin based on the self-defined configuration information and adding the configured target Vite plugin into a plugin array of the Vite configuration file.
Alternatively, in another possible design, the plug-in execution timing is after the execution of the other plug-ins in the build phase is completed.
Optionally, in another possible design, the updating module 21 is specifically further configured to:
inquiring a publication number field from each HTML file based on a predetermined regular expression; and updating the field value of the version number field to the current version number.
Optionally, the updating device of the version number may further include a storage module, where the storage module is configured to store program codes of the updating device of the version number, and so on.
As shown in fig. 5, the embodiment of the present application further provides an update device for version numbers, including a memory 41, a processor (such as 42-1 and 42-2 in fig. 5), a bus 43, and a communication interface 44; the memory 41 is used for storing computer-executed instructions, and the processor is connected with the memory 41 through the bus 43; when the version number updating device is operated, the processor executes computer-executable instructions stored in the memory 41 to cause the version number updating device to execute the version number updating method as provided in the above-described embodiment.
In a particular implementation, the processor may include, as one embodiment, one or more central processing units (central processing unit, CPU), such as CPU0 and CPU1 shown in fig. 5. And as one example, the version number updating device may include multiple processors, such as processor 42-1 and processor 42-2 shown in fig. 5. Each of these processors may be a single-Core Processor (CPU) or a multi-core processor (multi-CPU). A processor herein may refer to one or more devices, circuits, and/or processing cores for processing data (e.g., computer program instructions).
The memory 41 may be, but is not limited to, a read-only memory 41 (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a compact disc read-only memory (compact disc read-only memory) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and that can be accessed by a computer. The memory 41 may be stand alone and be connected to the processor via a bus 43. The memory 41 may also be integrated with the processor.
In a specific implementation, the memory 41 is used for storing data in the application and computer-executable instructions corresponding to executing a software program of the application. The processor may update various functions of the device by running or executing a software program stored in the memory 41 and invoking data stored in the memory 41 for version numbers.
Communication interface 44, using any transceiver-like device, is used to communicate with other devices or communication networks, such as a control system, a radio access network (radio access network, RAN), a wireless local area network (wireless local area networks, WLAN), etc. The communication interface 44 may include a receiving unit to implement a receiving function and a transmitting unit to implement a transmitting function.
Bus 43 may be an industry standard architecture (industry standard architecture, ISA) bus, an external device interconnect (peripheral component interconnect, PCI) bus, or an extended industry standard architecture (extended industry standard architecture, EISA) bus, among others. The bus 43 may be classified into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in fig. 5, but not only one bus or one type of bus.
As an example, in connection with fig. 4, the update module in the version number update device performs the same function as the processor implementation in fig. 5. When the version number updating device comprises a memory module, the function realized by the memory module is the same as that realized by the memory in fig. 5; when the version number updating device includes an acquisition module, the function implemented by the acquisition module is the same as the function implemented by the receiving unit in fig. 5.
The explanation of the related content in this embodiment may refer to the above method embodiment, and will not be repeated here.
From the foregoing description of the embodiments, it will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of functional modules is illustrated, and in practical application, the above-described functional allocation may be implemented by different functional modules, that is, the internal structure of the device is divided into different functional modules, so as to implement all or part of the functions described above. The specific working processes of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which are not described herein again.
The embodiment of the application also provides a computer readable storage medium, in which instructions are stored, which when executed by a computer, cause the computer to execute the version number updating method provided in the above embodiment.
The computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a RAM, a ROM, an erasable programmable read-only memory (erasable programmable read only memory, EPROM), a register, a hard disk, an optical fiber, a CD-ROM, an optical storage device, a magnetic storage device, or any suitable combination of the foregoing, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an application specific integrated circuit (application specific integrated circuit, ASIC). In the context of the present application, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The foregoing is merely a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims (10)
1. A method for updating a version number, applied to a Vite server, comprising:
detecting an execution instruction of the plug-in a construction stage aiming at a target source code file;
and calling a preconfigured target Vite plug-in to acquire each HTML file of the target source code file under the condition that the plug-in execution instruction is detected, and updating the version number of each HTML file based on the current version number.
2. The method for updating version numbers according to claim 1, wherein the target Vite plug-in includes a preconfigured Vite hook function and a preconfigured auxiliary function, and the calling the preconfigured target Vite plug-in to obtain each HTML file of the target source code file and update version numbers of each HTML file based on a current version number includes:
Acquiring the HTML files through the Vite hook function, and transmitting the HTML files to the auxiliary function to call the auxiliary function;
and acquiring the current version number through the auxiliary function, and updating the version number of each HTML file based on the current version number.
3. The method for updating version numbers according to claim 2, wherein said transferring the HTML files to the auxiliary function to call the auxiliary function comprises: transmitting the HTML files and access addresses for the pre-configured version APIs to the auxiliary function to call the auxiliary function;
the obtaining the current version number through the auxiliary function, and updating the version number of each HTML file based on the current version number, includes: acquiring the current version number from the pre-configured version API based on the access address through the auxiliary function; and updating the version numbers of the HTML files based on the current version numbers.
4. A method of updating a version number according to claim 3, wherein said obtaining, by said auxiliary function, said current version number from said preconfigured version API based on said access address, comprises:
Acquiring version number information in a preset format from the preset version API based on the access address through the auxiliary function;
converting the version number information of the preset format into version number information of a target format;
and determining the current version number from the version number information of the target format.
5. The method of updating version numbers according to claim 1, wherein before detecting plug-in execution instructions for a build phase of a target source code file, the method further comprises:
acquiring custom configuration information aiming at the target Vite plug-in; the custom configuration information at least comprises a plug-in name, a plug-in application stage and plug-in execution time; wherein the plug-in application stage is the build stage;
and completing the configuration of the target Vite plugin based on the self-defined configuration information, and adding the configured target Vite plugin into a plugin array of a Vite configuration file.
6. The method of updating version numbers according to claim 5, wherein the plug-in execution timing is after other plug-ins in the build phase are executed.
7. The method for updating version numbers according to any one of claims 1 to 6, wherein the updating of version numbers of the HTML files based on the current version number comprises:
inquiring a publication number field from each HTML file based on a predetermined regular expression;
and updating the field value of the version number field to the current version number.
8. An updating device for version numbers, which is configured in a Vite server, comprising:
the detection module is used for detecting the execution instruction of the plug-in unit in the construction stage aiming at the target source code file;
and the updating module is used for calling a pre-configured target Vite plug-in to acquire all HTML files of the target source code file under the condition that the plug-in execution instruction is detected, and updating the version number of each HTML file based on the current version number.
9. An updating device for version numbers is characterized by comprising a memory, a processor, a bus and a communication interface; the memory is used for storing computer execution instructions, and the processor is connected with the memory through the bus;
when the version number updating device runs, a processor executes the computer-executed instructions stored in the memory, so that the version number updating device executes the version number updating method according to any one of claims 1 to 7.
10. A computer readable storage medium having instructions stored therein, which when executed by a computer, cause the computer to perform the version number updating method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311318808.XA CN117311792A (en) | 2023-10-11 | 2023-10-11 | Version number updating method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202311318808.XA CN117311792A (en) | 2023-10-11 | 2023-10-11 | Version number updating method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN117311792A true CN117311792A (en) | 2023-12-29 |
Family
ID=89242315
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202311318808.XA Pending CN117311792A (en) | 2023-10-11 | 2023-10-11 | Version number updating method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN117311792A (en) |
-
2023
- 2023-10-11 CN CN202311318808.XA patent/CN117311792A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110874236B (en) | Cross-platform application device, terminal and storage medium | |
CN107635027B (en) | Domain name resolution method, medium, device and computing equipment | |
CN106325847B (en) | Method and device for acquiring application program function based on iOS platform | |
US10191751B2 (en) | Information processing device for generating application programming interface information | |
CN110365724B (en) | Task processing method and device and electronic equipment | |
CN108540509B (en) | Processing method and device of terminal browser, server and intelligent terminal | |
CN106648755B (en) | Method and device for dynamically loading dex in android art environment | |
CN110221877B (en) | Application program running method and device, electronic equipment and storage medium | |
CN112527459B (en) | Log analysis method and device based on Kubernetes cluster | |
CN113050984A (en) | Resource calling method and device, electronic equipment and storage medium | |
CN116523457A (en) | Workflow processing method, device, equipment and storage medium based on business process | |
CN113885920A (en) | Method and device for hot updating of machine learning model, electronic equipment and storage medium | |
CN112416612A (en) | Service calling method and device, computer equipment and readable storage medium | |
US11689630B2 (en) | Request processing method and apparatus, electronic device, and computer storage medium | |
CN106502707B (en) | Code generation method and device | |
CN109086059B (en) | Code loading updating method, device and server | |
CN111488286B (en) | Method and device for independently developing Android modules | |
CN110297639B (en) | Method and apparatus for detecting code | |
CN112114871A (en) | Code sharing method, device, server, terminal and medium | |
KR20130108855A (en) | Method and system for deciding harmfulness of software application | |
CN117311792A (en) | Version number updating method, device, equipment and storage medium | |
EP3785777B1 (en) | Information processing system, information processing method, and program for development apparatus | |
CN114329260A (en) | Page jump method, device, terminal and storage medium | |
US20220283789A1 (en) | Methods and apparatuses for providing a function as a service platform | |
CN112445498B (en) | Program installation method and device, electronic equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
CB02 | Change of applicant information |
Country or region after: China Address after: Room 6416, Building 13, No. 723 Tongxin Road, Hongkou District, Shanghai 200080 Applicant after: Shanghai Dewu Information Group Co.,Ltd. Address before: Room B6-2005, No. 121 Zhongshan North 1st Road, Hongkou District, Shanghai Applicant before: SHANGHAI SHIZHUANG INFORMATION TECHNOLOGY Co.,Ltd. Country or region before: China |