Code file packaging method, device and equipment and computer storage medium
By determining the difference between the code file version identification when receiving the code file packaging instruction, and obtaining the target code file from the preset code repository for packaging, the difficulty of public code reuse and packaging in the packaging and maintenance of the device control page is solved. 工作量大的问题,实现了更高效的打包和维护。
Patent Information
- Application Number
- CN202410600706.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2025-02-14
AI Technical Summary
In the packaging and maintenance of device control pages, the existing technology has problems such as difficult to reuse, large packaging workload, long time and difficult to maintain, especially when the control pages of multiple devices need to be repackaged.
When receiving the code file packaging instruction, determine the difference code file information between the historical code file version identifier and the current code file version identifier, obtain the target code file corresponding to the difference code file from the preset code repository, and package it. This avoids packaging all resources.
It reduces packaging time, improves packaging efficiency, and is conducive to post-maintenance, avoiding the problems of difficulty in reusing public codes and large packaging workload.
Smart Images

Figure CN119440605A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a code file packaging method, device, equipment and computer storage medium. Background Art
[0002] With the development of science and technology, relevant technicians have developed electronic devices with various functions to meet people's various needs in different scenarios. However, electronic devices with different functions are controlled by their own control devices, which will inevitably cause inconvenience to users. Therefore, the control functions of different devices can be concentrated in one application (Application, APP) to achieve control of multiple devices.
[0003] At present, the device control page can be developed through HTML5 technology and embedded in the corresponding application to realize device control. In the related art, the control page of each device in the application can be put into a separate project for independent deployment and package maintenance. Alternatively, in the related art, the control pages of all devices involved in the application are put into the same project for package maintenance.
[0004] However, if a single device is an independent project, it may make it difficult to reuse common code. Moreover, if there are too many projects, it may cause problems such as excessive packaging workload, long time, and difficulty in maintenance. If the control pages of multiple or all devices are placed in the same project, when modifying the control pages of one or several devices, the control pages corresponding to multiple or all devices involved need to be repackaged, which is not conducive to operation. Therefore, how to maintain the control pages of the devices has become a difficult problem. Summary of the invention
[0005] The embodiments of the present application provide a code file packaging method, apparatus, device and computer storage medium. When a code file packaging instruction is received, the difference code file information between the historical code file version identifier and the current code file version identifier contained in the code packaging file is determined, and the first target code is obtained from a preset code repository according to the difference file information, and the first target code is packaged, thereby avoiding packaging of all resources, reducing packaging time, improving packaging efficiency, and facilitating later maintenance.
[0006] In a first aspect, an embodiment of the present application provides a code file packaging method, comprising: in response to receiving a code file packaging instruction, determining whether the code file packaging instruction includes a historical code file version identifier, wherein the project packaging command includes a current code file version identifier; when the code file packaging instruction includes a historical code file version identifier, determining difference code file information between the historical code file version identifier and the current code version identifier; obtaining a first target code file corresponding to the difference code file information from a preset code repository; and packaging the first target code file to obtain a packaged code file.
[0007] In one implementation, the first target code file includes a common code file, and packaging the first target code file includes: acquiring a first code file that has a dependency relationship with the common code file; and packaging the first code file.
[0008] In one implementation, the first target code file further includes a separate project file, and packaging the first target code file includes: packaging the separate project file.
[0009] In one embodiment, before packaging the first target code file, the method also includes: determining whether there is a historical code file package for the first target code file; if there is no historical code file package for the first target code file, constructing a first packaging text file, the first packaging text file at least including the storage address of the first target code file after packaging and a static file; and packaging the first target code file based on the first packaging text file.
[0010] In one embodiment, the method also includes: when a historical code file package exists in the first target code file, obtaining the storage address information of the historical code file package and deleting the historical code file package; constructing a first packaged text file; based on the first packaged text file, packaging the first target code file, and storing the packaged code file package to the storage address corresponding to the historical code file package.
[0011] In an embodiment of the present application, before receiving a code file packaging command, the method further includes: storing common code files and separate project files in a code repository, and establishing a dependency relationship between the common code files and the separate project files.
[0012] In one implementation, the method further includes: when the code file packaging instruction does not include a historical code file version identifier, obtaining a second target code file corresponding to the current code file version identifier from the code repository; and packaging the second target code file.
[0013] In one implementation, packaging the second target code file includes: constructing a second packaging text file, the second packaging text file at least including the storage address and static files of the project to be packaged after packaging; and packaging the second target code file based on the second packaging text file.
[0014] In one implementation, the method further includes: deploying the packaged code file package on a website service and a reverse proxy service.
[0015] In a second aspect, an embodiment of the present application provides a code file packaging device, including:
[0016] A first determination module is used to determine, in response to receiving a code file packaging instruction, whether the code file packaging instruction includes a historical code file version identifier, wherein the code file packaging instruction includes a current code file version identifier;
[0017] A second determination module is used to determine the difference code file information between the historical code file version identifier and the current code version identifier when the code file packaging instruction includes the historical code file version identifier;
[0018] An acquisition module, used for acquiring a first target code file corresponding to the difference code file information from a preset code repository;
[0019] The packaging module is used to package the first target code file to obtain a packaged code file.
[0020] In one implementation, the first target code file includes a common code file, and the packaging module packages the first target code file in the following manner: obtaining a first code file that has a dependency relationship with the common code file; and packaging the first code file.
[0021] In one implementation, the first target code file also includes a separate project file, and the packaging module packages the first target code file in the following manner: packaging the separate project file.
[0022] In one embodiment, before packaging the first target code file, the second determination module is also used to: determine whether there is a historical code file package for the first target code file; if there is no historical code file package for the first target code file, construct a first packaging text file, the first packaging text file at least including the storage address of the first target code file after packaging and a static file; and package the first target code file based on the first packaging text file.
[0023] In one embodiment, the second determination module is also used to: when a historical code file package exists in the first target code file, obtain the storage address information of the historical code file package and delete the historical code file package; construct a first packaged text file; based on the first packaged text file, package the first target code file, and store the packaged code file package to the storage address corresponding to the historical code file package.
[0024] In one embodiment, before receiving the code file packaging command, the device also includes a storage module for storing the common code files and the separate project files in the code repository and establishing a dependency relationship between the common code files and the separate project files.
[0025] In one embodiment, the acquisition module is also used to: when the code file packaging instruction does not include the historical code file version identifier, obtain the second target code file corresponding to the current code file version identifier from the code repository; the packaging module is also used to: package the second target code file.
[0026] In one implementation, the packaging module packages the second target code file in the following manner: construct a second packaging text file, the second packaging text file at least including the storage address and static files of the project to be packaged after packaging; based on the second packaging text file, the second target code file is packaged.
[0027] In one embodiment, the device also includes a deployment module for deploying the packaged code file package on the website service and the reverse proxy service.
[0028] In a third aspect, an embodiment of the present application provides a code file packaging device, characterized in that the device includes: a processor and a memory storing computer program instructions;
[0029] When the processor executes the computer program instructions, the code file packaging method in the first aspect or any one of the embodiments of the first aspect is implemented.
[0030] In a fourth aspect, a computer-readable storage medium is provided, characterized in that computer program instructions are stored on the computer-readable storage medium, and when the computer program instructions are executed by a processor, the code file packaging method in the first aspect or any one of the embodiments of the first aspect is implemented.
[0031] In a fifth aspect, an embodiment of the present application provides a computer program product, characterized in that when the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes a code file packaging method such as the first aspect or any one of the implementations of the first aspect.
[0032] The incremental resource packaging method, apparatus, device and computer storage medium of the embodiments of the present application, when receiving a code file packaging instruction, determine the difference code file information between the historical code file version identifier and the current code file version identifier contained in the code packaging file, and obtain the first target code from the preset code repository according to the difference file information, and package the first target code, thereby avoiding packaging of all resources, reducing packaging time, improving packaging efficiency, and facilitating later maintenance. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0034] Figure 1 A flow chart of a code file packaging method provided in one embodiment of the present application is shown.
[0035] Figure 2 A schematic diagram of an implementation method of S130 provided in an embodiment of the present application is shown.
[0036] Figure 3 A flow chart showing another implementation of a code file packaging method provided in an embodiment of the present application is shown.
[0037] Figure 4 A schematic diagram of a first target code file packaging method provided by an embodiment of the present application is shown.
[0038] Figure 5 A flow chart showing another implementation of a code file packaging method provided in an embodiment of the present application is shown.
[0039] Figure 6 A flow chart of another implementation of the code file packaging method provided in one embodiment of the present application is shown.
[0040] Figure 7 A schematic diagram showing an implementation method for packaging and deploying separate project code files provided by an embodiment of the present application.
[0041] Figure 8 A schematic diagram showing an implementation method for packaging and deploying multiple project code files provided by an embodiment of the present application.
[0042] Fig. 9 A schematic diagram of a preset code repository provided by an embodiment of the present application is shown.
[0043] Fig.10A flow chart of a code file packaging method provided in one embodiment of the present application is shown.
[0044] Fig.11 A schematic diagram of nginx service reverse proxy static resources provided by an embodiment of the present application is shown.
[0045] Fig.12 It is a structural diagram of a code file packaging device provided in another embodiment of the present application.
[0046] Fig.13 A hardware structure diagram of the code file packaging method provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0047] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0048] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0049] With the development of science and technology, people's requirements for various functions of electronic devices used in daily life are constantly increasing. However, with the increasing number of types of electronic devices, people need to control electronic devices through various electronic device control devices. However, too many control devices will inevitably cause inconvenience to people's daily lives. Therefore, how to coordinate the control of electronic devices with different functions has become a technical problem that relevant technical personnel need to solve.
[0050] In the related art, the control devices of different electronic devices can be associated with the mobile smart devices used in daily life, and the control of the electronic devices can be achieved by establishing the relevant control pages of the electronic devices on the mobile smart devices. Among them, the control of different devices can be achieved by establishing an APP on the mobile smart device and binding the APP with multiple different devices. In addition, different devices bound to the APP can have their own device details pages in the APP, so that users can control different functions of different devices. In addition, the control of a single device can be achieved by establishing multiple APPs and binding each APP to a single device.
[0051] However, with the increasing number of electronic devices, how to maintain and package the control pages of the devices has become a problem. In the related art, each electronic device can be treated as an independent project and packaged and maintained independently. Alternatively, in the related art, all electronic devices can be packaged and maintained as a project. However, a single device as an independent project may make it difficult to reuse common code, and if there are too many projects, it may cause problems such as excessive packaging workload, long time, and difficulty in maintenance. When multiple or all devices are treated as a project, when modifying the control page of one or several devices, the control pages corresponding to multiple or all devices involved need to be repackaged, which is not conducive to operation. Therefore, how to package and maintain the control pages of the device has become a problem.
[0052] In order to solve the problems of the prior art, the embodiments of the present application provide a code file packaging method, device, equipment and computer storage medium. The code file packaging method provided by the embodiments of the present application is first introduced below.
[0053] Figure 1 FIG. 1 is a flow chart of a code file packaging method provided by an embodiment of the present application. Figure 1 As shown, the code file packaging method includes the following steps:
[0054] S110: In response to receiving a code file packaging instruction, determine whether the code file packaging instruction includes a historical code file version identifier.
[0055] S120: When the code file packaging instruction includes a historical code file version identifier, determine the difference code file information between the historical code file version identifier and the current code version identifier.
[0056] S130: Obtain a first target code file corresponding to the difference code file information from a preset code repository.
[0057] S140: Pack the first target code file to obtain a packaged code file.
[0058] In an embodiment of the present application, the code file packaging instruction may include a current code file version identifier. The code file version identifier may be used to determine the information of the code file that needs to be modified. In one example, the code file version identifier may be the open source distributed version control system Git submission record version number included in the code file packaging instruction.
[0059] In an embodiment of the present application, the difference code file information can be determined by the historical code file version identifier and the current code version identifier. Among them, the difference code file information can be used to indicate the code file that needs to be modified. In one example, the difference code file information that needs to be repackaged can be determined by obtaining the Git version numbers of the two submissions. Among them, the difference code file information can be the name information of the code file that needs to be repackaged.
[0060] In an embodiment of the present application, a first target code file corresponding to the difference code file information can be obtained from a preset code repository. In one example, the name information of the difference code file can be determined to obtain the first target code file corresponding to the name information from the preset code repository.
[0061] The preset code repository may store common code files, separate project files, and dependencies between the common code files and the separate project code files.
[0062] In the embodiment of the present application, the code warehouse can be pre-established in the following manner: create a separate project code file and a common code file, and uniformly name the separate project file and the common code file. And establish a dependency relationship between the separate project code file and the common code file. Store the separate project code file, the common code file, and the dependency relationship between the separate project code file and the common code file in the code warehouse, thereby obtaining a preset code warehouse.
[0063] The individual project code files may be codes corresponding to different functions of different electronic devices, and the common code files may be codes corresponding to the same function of different electronic devices.
[0064] In the embodiment of the present application, the difference code file information determined by the historical code file version identifier and the current code version identifier can be a separate project file, or the difference code file information determined by the historical code file version identifier and the current code version identifier can also be a common code file.
[0065] In the case where the difference code file information is one or more separate project files, the one or more separate project files may be marked and packaged.
[0066] Among them, when the difference code file information is a common code file, the separate project file that establishes a dependency relationship with the common code file can be determined through the dependency relationship stored in the preset code repository, and the separate project file that establishes a dependency relationship with the common code file can be marked as the first code file, and the first code file can be packaged.
[0067] In the embodiment of the present application, it is understandable that the difference file information may also include both the individual project code files and the common code files. The individual project files and the individual project files that are dependent on the common code files may be packaged at the same time.
[0068] In one example, Figure 2 FIG. 1 is a schematic diagram showing an implementation of S130 provided by an embodiment of the present application. Figure 2 As shown, after obtaining the version number of the current Git submission and the version number of the historical Git submission through step S210, the list of code files modified by the two submission records is obtained based on the version numbers of the two submissions in S220. According to the path corresponding to the modified code file list, the modified project code file is determined through S230, and the corresponding first target code file is determined in the preset code repository. Through S240, it is judged that the first target code file is a device project package, that is, a separate project file, and S250 is executed to mark the device project package as needing to be repackaged, that is, the device project package is used as the first target code file. Through S260, it is judged that the first target code file is a public package, that is, a public code file, and through the pre-stored dependency, the device project package that references the public package is determined, and it is marked as needing to be repackaged, that is, the marked device project package is used as the first target code file. Among them, it can be understood that the public package can be marked as needing to be repackaged, or the public package can be not marked as needing to be repackaged. Through step S280, all code packages that need to be repackaged are merged, and the corresponding package names are output.
[0069] In an embodiment of the present application, the code files that need to be repackaged can be obtained through the difference files, and then based on the preset code repository, the files that need to be repackaged can be retrieved, thereby ensuring that only the modified code files need to be packaged, reducing the packaging time, improving the packaging efficiency, reducing the workload of online verification, and facilitating later maintenance.
[0070] In an embodiment of the present application, when a code file packaging instruction is received, the difference code file information between the historical code file version identifier and the current code file version identifier contained in the code packaging file is determined. It can be understood that the difference code file information can be understood as an incremental code file. According to the difference file information, the first target code is obtained from the preset code repository, and the first target code is packaged, that is, only the incremental code file is packaged, avoiding the packaging of all resources, reducing the packaging time, improving the packaging efficiency, and facilitating later maintenance.
[0071] In order to simplify the code file management version and reduce the storage space occupied, as another implementation method of the present application, the present application also provides another implementation method of the code file packaging method, please refer to the following embodiments for details.
[0072] See also Figure 3 , Figure 3 FIG. 1 is a flow chart showing another implementation of a code file packaging method provided by an embodiment of the present application. Figure 3 As shown, the code file packaging method includes the following steps:
[0073] S310: In response to receiving a code file packaging instruction, determine whether the code file packaging instruction includes a historical code file version identifier.
[0074] S320: When the code file packaging instruction includes a historical code file version identifier, determine the difference code file information between the historical code file version identifier and the current code version identifier.
[0075] S330: Obtain a first target code file corresponding to the difference code file information from a preset code repository.
[0076] S340, determine whether there is a historical code file package in the first target code file, if so, execute S350, otherwise, execute S370.
[0077] S350: Obtain storage address information of the historical code file package, and delete the historical code file package.
[0078] S360: construct a first packaged text file, package the first target code file based on the first packaged text file, and store the packaged code file package to a storage address corresponding to the historical code file package.
[0079] S370: Construct a first packaged text file, and package the first target code file based on the first packaged text file to obtain a packaged code file.
[0080] In the embodiment of the present application, steps S310-S330 are consistent with steps S110-S130 and will not be described in detail here.
[0081] In an embodiment of the present application, after obtaining the first target code file, it is possible to determine whether there is a historical code file package for the first target code file, that is, to determine whether the first target code file has been packaged, thereby determining how to package the first target code file.
[0082] In the embodiment of the present application, when there is a historical code package in the first target code file, the storage address of the historical code file package is obtained, and the historical code file package is deleted. By constructing a packaged text file corresponding to the first target code file, the first target code file is packaged, and the packaged file is stored in the storage address of the historical code file package.
[0083] In the embodiment of the present application, when there is a historical code package in the first target code file, the storage address of the historical code file package is obtained, and the historical code file package is deleted. By constructing a packaged text file corresponding to the first target code file, the first target code file is packaged, and the packaged file is stored in the storage address of the historical code file package.
[0084] In one example, Figure 4 FIG. 1 is a schematic diagram showing a packaging method of a first target code file provided by an embodiment of the present application. Figure 4 As shown, the name of the project package to be packaged is obtained through S410. It can be understood that the first target code file is determined through S410, wherein the first target code file can be obtained through the package name of the first target code file. The image address of the last package is obtained through S420. It can be understood that the storage address of the historical code file package is obtained through S420. The program for generating a text file is constructed through S430, wherein the text file can be a Dockerfile file. Through S440, the project package passed in by S410 is packaged in the node image, and a static file is generated. Through step S450, it is determined whether the storage address of the historical code file package is passed in S420. If not, step S460 is executed to copy the generated static file to the corresponding file. If so, step S470 is executed to delete the static file generated by the last package in the image address of the last package, and store the static file generated this time to the address. Step S480, output the packaged text file, and generate the corresponding image based on the packaged text file.
[0085] In an embodiment of the present application, after obtaining the first target code file, it is determined whether there is a historical code file package for the first target code file, so as to determine how to package the first target code file. On the one hand, for the first code file that does not have a historical code file package, the code file can be stored in a corresponding directory to more accurately determine the address information of the code file package; on the other hand, for the first code file that has a historical code file package, the original code file package can be deleted, and the code package corresponding to the first target code file can be stored at the original address, thereby simplifying the code file management version and reducing the storage space occupied.
[0086] In order to realize the packaging of one or more separate project files, as another implementation method of the present application, the present application also provides another implementation method of the code file packaging method, please refer to the following embodiments for details.
[0087] See also Figure 5 , Figure 5 FIG. 1 is a flow chart showing another implementation of a code file packaging method provided by an embodiment of the present application. Figure 5 As shown, the code file packaging method includes the following steps:
[0088] S510: In response to receiving a code file packaging instruction, determine whether the code file packaging instruction includes a historical code file version identifier.
[0089] In the embodiment of the present application, the code file packaging instruction may contain a current code file version identifier, and the code file to be packaged is determined by the current code file version identifier.
[0090] S520: When the code file packaging instruction does not include a historical code file version identifier, obtain a second target code file corresponding to the current code file version identifier from the code repository.
[0091] In the embodiment of the present application, it is possible to determine whether there is a historical code file version identifier by determining the code file packaging instruction, thereby determining whether to perform incremental code packaging on the code file in the code packaging instruction.
[0092] In the embodiment of the present application, if the code file packaging instruction contains a historical code file version identifier, it can be determined that the code file packaging of the incremental code file is required. If the code file packaging instruction does not contain a historical code file version identifier, only the code files in the code file packaging instruction can be packaged.
[0093] In an embodiment of the present application, when the code file packaging instruction does not include a historical code file version identifier, a code file with a current code file version identifier can be obtained from the code repository as the second target code file.
[0094] In one example, the name information of the code file to be packaged can be obtained through the current code file version identifier, and the second target code file can be obtained through a preset database.
[0095] S530: Pack the second target code file to obtain a packed code file.
[0096] In the embodiment of the present application, the determined second target code file can be packaged. This can be done by constructing a second packaged text file. The second packaged text file at least contains information such as the storage address and static files of the packaged second target code file. The second target code file is packaged based on the second packaged text file.
[0097] In the embodiment of the present application, for the determined second target code file, it can be determined whether there is a packaged code file package in the second target code file, so as to determine how to package the second target code file.
[0098] In the embodiment of the present application, when there is a historical code package in the second target code file, the storage address of the historical code file package is obtained, and the historical code file package is deleted. By constructing a packaged text file corresponding to the second target code file, the second target code file is packaged, and the packaged file is stored in the storage address of the historical code file package.
[0099] In the embodiment of the present application, when there is a historical code package in the second target code file, the storage address of the historical code file package is obtained, and the historical code file package is deleted. By constructing a packaged text file corresponding to the second target code file, the second target code file is packaged, and the packaged file is stored in the storage address of the historical code file package.
[0100] In the embodiment of the present application, the second target code file may be one or more code files.
[0101] In an embodiment of the present application, when the code file packaging instruction does not include a historical code file version identifier, a second target code file corresponding to the current code file version identifier can be obtained from the code repository, and the second target code file can be packaged, thereby realizing the packaging of one or more codes, expanding the application scenarios of the code file package, and avoiding the situation where one or more code files cannot be deployed separately.
[0102] In order to realize the application of the code file package, as another implementation method of the present application, the present application also provides another implementation method of the code file packaging method, please refer to the following embodiments for details.
[0103] See also Figure 6, Figure 6 FIG. 1 is a flow chart showing another implementation of a code file packaging method provided by an embodiment of the present application. Figure 6 As shown, the code file packaging method includes the following steps:
[0104] S610: In response to receiving a code file packaging instruction, determine whether the code file packaging instruction includes a historical code file version identifier.
[0105] S620: When the code file packaging instruction includes a historical code file version identifier, determine the difference code file information between the historical code file version identifier and the current code version identifier.
[0106] S630: Obtain a first target code file corresponding to the difference code file information from a preset code repository.
[0107] S640: Pack the first target code file to obtain a packaged code file.
[0108] S650. Deploy the packaged code file package on the website service and reverse proxy service.
[0109] In the embodiment of the present application, steps S610-S640 are consistent with steps S110-S140 and will not be described in detail here.
[0110] In the embodiment of the present application, the website service and the reverse proxy service may include an Nginx service. Furthermore, the packaged code file package may be deployed on the Nginx service.
[0111] In the embodiment of the present application, a separate code file may be packaged and deployed, or multiple or all code files stored in a code repository may be packaged and deployed.
[0112] In an example, Figure 7 As shown, Figure 7 A schematic diagram of an implementation method of packaging and deploying a single project code file provided by an embodiment of the present application is shown. For packaging and deploying a single project code file, the name information of the single project code file can be passed into the text file generation program to obtain a text file of the single project code, and an image is generated based on the text file, that is, a packaged single project code file package is obtained, and a docker container is created, and the Nginx service is started to complete the deployment of the code file.
[0113] In an example, Figure 8 As shown, Figure 8A schematic diagram of an implementation method of packaging and deploying multiple project code files provided by an embodiment of the present application is shown. For packaging and deploying multiple project code files, the name information of the multiple project code files involved can be passed into the text file generation program to obtain a text file corresponding to the multiple project codes, and an image is generated based on the text file, that is, a packaged code file package is obtained, and the deployment of the code file is completed by creating a docker container and starting the Nginx service.
[0114] In the embodiment of the present application, before the code file is deployed, the relevant mounting configuration files and the like may also be modified.
[0115] In an embodiment of the present application, the packaged code files can be deployed on website services and reverse proxy services, thereby realizing the application of the code files.
[0116] In the embodiments of the present application, the code file packaging method is described in combination with the following examples.
[0117] In the embodiment of the present application, before the code files are packaged, a code file library can be pre-established. In this case, a common code file and a separate project code file can be created, and a dependency relationship between the common code file and the separate project file can be established. The common code file, the separate project file and the dependency relationship are stored in the code repository to obtain a preset code repository. In one example, Fig. 9 FIG. 1 shows a schematic diagram of a preset code repository provided by an embodiment of the present application. Fig. 9As shown, the established individual project files and common code files can be uniformly stored in the package package in Monorepo and uniformly named, for example, individual project file A can be named packageA, individual project file B can be named packageB, and common code file react can be named common-react, etc. In addition, the dependencies between individual project code files and common code files can be stored in the root directory of Monorepo. In one example, the dependencies between individual project code files and common code files can be stored in the package.json file in the root directory of Monorepo, and the common configuration file can also be stored in the root directory. For example, each device project package name can be set to @detail / xxx, and the project folder name is xxx, such as @detail / packageA, and the project folder name is packageA. And each project can provide a build packaging command, and when pnpm run build is executed, static files are packaged and generated in the / packages / packageA / dist folder. Create a common code project, that is, establish a common code file. Among them, the public project code can be placed in the packages package, and the package name is @detail / common-xxx, and the project folder name is common-xxx. Furthermore, the device project can add public package dependencies to the device project through pnpminstall@detail / common-xxx, and soft link the code under common-xxx to the sub-project node_modules, so that the public package code can be updated and the sub-project can be updated in real time.
[0118] Furthermore, code files may be packaged based on a code file packaging command. Fig.10 FIG. 1 is a flow chart of a code file packaging method provided by an embodiment of the present application. Fig.10As shown, through step S1010, when a code file packaging instruction is received, the code file packaging instruction is executed. In one example, all device projects can be completely packaged by adding the pnpm run pre-build-all--git-version git-version1 git-version2 command; or, code files including separate project file A, separate project file B, and separate project file C can be packaged by adding the pnpm run pre-build--package packageA, packageB, packageC command. Among them, the packaging instruction can include the version number submitted by Git, for example, git-version can be the new Git submission record version number, and git-version2 is the Git submission record version number of the last packaging.
[0119] By executing step S1020, it can be determined whether the version number submitted by Git is passed in. If there is a version number submitted by Git, step S1050 can be executed to determine the project package name that needs to be repackaged through the two version numbers submitted by Git. Execute step S1060, call the program that generates the tarball file, pass in the project package name that needs to be packaged, and the address information of the historical project package, and output the text file through S1070. In one example, when it is determined that the git-version parameter is passed in, it can be understood that incremental packaging is required. The program code that calculates the modifications between two git submission records can be called first, and the output package name that needs to be repackaged and the image address generated by the last packaging are passed into the program that generates the Dockerfile file, thereby outputting the Dockerfile file. Among them, according to the parameters, it can be obtained that the last image is device-detail__git-version2.
[0120] If there is no Git submitted version number, step S1030 can be executed to call the program for generating text files and pass in an empty array, and step S1040 can be executed to output the text file. In one example, if the submission record version number is not passed, it is understood by default that all packages are repackaged; the program code for generating the Dockerfile file is called, an empty array is passed in, and a fully packaged Dockerfile file is generated.
[0121] Further, execute S1080 to perform packaging according to the text file to obtain a packaged code file. That is, execute the docker built instruction to generate a docker image. In one example, you can execute the docker built-t device-detail__current-git-version command in the path where the Dockerfile is located to package and generate a docker image package. Among them, current-git-version identifies the current git submission version number. Further, execute S1090 to deploy the packaged code file. In one example, deploy the docker image through the docker command or docker-compose file, modify the corresponding mount configuration file, etc., you can create a docker container to start the nginx service to complete the deployment, such as Fig.11 As shown, Fig.11 A schematic diagram of nginx service reverse proxy static resources provided by an embodiment of the present application is shown.
[0122] Based on the code file packaging method provided in the above embodiment, the present application also provides a specific implementation of a code file packaging device. Please refer to the following embodiment.
[0123] See first Fig.12 , Fig.12 1 is a schematic diagram of the structure of a code file packaging device 1200 provided in another embodiment of the present application. The code file packaging device provided in the embodiment of the present application includes the following units:
[0124] A first determining module 1201 is configured to, in response to receiving a code file packaging instruction, determine whether the code file packaging instruction includes a historical code file version identifier, wherein the code file packaging instruction includes a current code file version identifier;
[0125] The second determining module 1202 is used to determine the difference code file information between the historical code file version identifier and the current code version identifier when the code file packaging instruction includes the historical code file version identifier;
[0126] The acquisition module 1203 is used to acquire the first target code file corresponding to the difference code file information from a preset code repository;
[0127] The packaging module 1204 is used to package the first target code file to obtain a packaged code file.
[0128] When a code file packaging instruction is received, the difference code file information between the historical code file version identifier and the current code file version identifier contained in the code packaging file is determined, and the first target code is obtained from the preset code repository according to the difference file information, and the first target code is packaged, thereby avoiding packaging of all resources, reducing packaging time, improving packaging efficiency, and facilitating later maintenance.
[0129] As an implementation method of the present application, in order to realize the packaging of common code files, the first target code file includes the common code file, and the packaging module 1204 in the above-mentioned device packages the first target code file in the following manner: obtaining a first code file that has a dependency relationship with the common code file; and packaging the first code file.
[0130] As an implementation method of the present application, in order to realize the packaging of separate project files, the first target code file also includes separate project files. The packaging module 1204 in the above device packages the first target code file in the following manner: packaging the separate project files.
[0131] As an implementation method of the present application, before packaging the first target code file, the second determination module 1202 is also used to: determine whether there is a historical code file package for the first target code file; if there is no historical code file package for the first target code file, construct a first packaged text file, the first packaged text file at least containing the storage address of the first target code file after packaging and a static file; and package the first target code file based on the first packaged text file.
[0132] As an implementation method of the present application, the second determination module 1202 in the above-mentioned device is also used to: when there is a historical code file package in the first target code file, obtain the storage address information of the historical code file package and delete the historical code file package; construct a first packaged text file; based on the first packaged text file, package the first target code file, and store the packaged code file package to the storage address corresponding to the historical code file package.
[0133] As an implementation method of the present application, before receiving the code file packaging command, the above-mentioned device also includes a storage module for storing common code files and separate project files in a code repository and establishing a dependency relationship between the common code files and the separate project files.
[0134] As an implementation method of the present application, the acquisition module 1203 in the above-mentioned device is also used to: when the code file packaging instruction does not include the historical code file version identifier, obtain the second target code file corresponding to the current code file version identifier from the code repository; the packaging module is also used to: package the second target code file.
[0135] As an implementation method of the present application, in the above-mentioned device, the packaging module 1204 packages the second target code file in the following manner: construct a second packaging text file, which at least contains the storage address and static files of the project to be packaged after packaging; based on the second packaging text file, the second target code file is packaged.
[0136] As an implementation method of the present application, in order to realize the application of the code package, the device in the above-mentioned device also includes a deployment module, which is used to deploy the packaged code file package on the website service and the reverse proxy service.
[0137] Fig.13 A hardware structure diagram of the code file packaging method provided in an embodiment of the present application is shown.
[0138] The code file packaging device may include a processor 1301 and a memory 1302 storing computer program instructions.
[0139] Specifically, the processor 1301 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0140] The memory 1302 may include a large capacity memory for data or instructions. By way of example and not limitation, the memory 1302 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 1302 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 1302 may be inside or outside the integrated gateway disaster recovery device. In a specific embodiment, the memory 1302 is a non-volatile solid-state memory.
[0141] The memory may include read-only memory (ROM), random access memory (RAM), magnetic disk storage media devices, optical storage media devices, flash memory devices, electrical, optical or other physical / tangible memory storage devices. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.
[0142] The processor 1301 implements any one of the code file packaging methods in the above embodiments by reading and executing computer program instructions stored in the memory 1302 .
[0143] In one example, the code file packaging device may further include a communication interface 1303 and a bus 1310. Fig.13 As shown, the processor 1301, the memory 1302, and the communication interface 1303 are connected via a bus 1310 and communicate with each other.
[0144] The communication interface 1303 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0145] Bus 1310 includes hardware, software or both, and the parts of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 1310 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the application considers any suitable bus or interconnection.
[0146] The code file packaging device can execute the code file packaging method in the embodiment of the present application based on the historical code file version identifier and the current code file version identifier, thereby realizing the combination of Figure 1 and Fig.12 A method and apparatus for packaging in code files is described.
[0147] In addition, in combination with the online data traffic billing method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the online data traffic billing methods in the above embodiment is implemented.
[0148] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0149] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0150] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0151] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0152] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A code file packaging method, characterized in that: include: In response to receiving a code file packaging instruction, determining whether the code file packaging instruction includes a historical code file version identifier, wherein the code file packaging includes a current code file version identifier; In the case where the code file packaging instruction includes a historical code file version identifier, determining the difference code file information between the historical code file version identifier and the current code version identifier; Obtaining a first target code file corresponding to the difference code file information from a preset code repository; The first target code file is packaged to obtain a packaged code file.
2. The method according to claim 1, characterized in that The first target code file includes a common code file, The packaging of the first target code file includes: Obtaining a first code file that has a dependency relationship with the common code file; The first code file is packaged.
3. The method according to claim 2, characterized in that The first object code file also includes a separate project file, The packaging of the first target code file includes: The individual project files are packaged.
4. The method according to any one of claims 1 to 3, characterized in that Before packaging the first target code file, the method further includes: Determine whether the first target code file has a historical code file package; In the case that the first target code file does not have a historical code file package, constructing a first packaged text file, wherein the first packaged text file at least includes a storage address of the first target code file after being packaged and a static file; The first target code file is packaged based on the first packaging text file.
5. The method according to claim 4, characterized in that The method further comprises: If the first target code file has a historical code file package, obtaining storage address information of the historical code file package and deleting the historical code file package; Build the first packaged text file; Based on the first packaging text file, the first target code file is packaged, and the packaged code file package is stored in the storage address corresponding to the historical code file package.
6. The code file packaging method according to claim 1, characterized in that: Before receiving the code file packaging command, the method further includes: The common code files and the individual project files are stored in a code repository, and a dependency relationship between the common code files and the individual project files is established.
7. The method according to claim 1, characterized in that The method further comprises: When the code file packaging instruction does not include a historical code file version identifier, obtaining a second target code file corresponding to the current code file version identifier from a preset code repository; The second target code file is packaged to obtain a packaged code file.
8. The method according to claim 7, characterized in that The packaging of the second target code file includes: Constructing a second packaged text file, wherein the second packaged text file at least includes a storage address and a static file after the second target code file is packaged; Based on the second packaging text file, the second target code file is packaged.
9. The method according to claim 1, characterized in that: The method further comprises: The packaged code file package is deployed on the website service and the reverse proxy service.
10. A code file packaging device, characterized in that: include: A first determination module is used to determine, in response to receiving a code file packaging instruction, whether the code file packaging instruction includes a historical code file version identifier, wherein the code file packaging instruction includes a current code file version identifier; A second determination module is used to determine the difference code file information between the historical code file version identifier and the current code version identifier when the code file packaging instruction includes the historical code file version identifier; An acquisition module, used for acquiring a first target code file corresponding to the difference code file information from a preset code repository; The packaging module is used to package the first target code file to obtain a packaged code file.
11. A code file packaging device, characterized in that: The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the code file packaging method as described in any one of claims 1 to 9 is implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the code file packaging method according to any one of claims 1 to 9 is implemented.
13. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the code file packaging method as described in any one of claims 1 to 9.
