Mini-program packaging method, device, electronic device, and medium

The automated merging of mini-program sub-packages into the main package using cloud-based systems addresses the inefficiency of manual code integration, improving development efficiency and reducing resource consumption.

CN112052011BActive Publication Date: 2025-01-03TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011076888.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-10
Publication Date
2025-01-03
Estimated Expiration
2040-10-10

AI Technical Summary

Technical Problem

The manual merging of sub-packages into main packages in mini-program development increases human resource consumption and reduces development efficiency due to the need for manual code modification.

Method used

A method and device for packaging mini-programs that automatically merge the business code of sub-packages into the main package by acquiring path address information, merging project files according to a common specification, and using a cloud-based system to streamline the process.

Benefits of technology

Reduces human resource consumption and enhances development efficiency by automating the merging of sub-package business code into the main package, leveraging cloud technology for resource management and integration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112052011B_ABST
    Figure CN112052011B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a method, device, electronic device and medium for merging packages of mini-programs, and relate to the field of computers. The method includes: obtaining the path address information of the main package to be merged and the path address information of at least one sub-package; obtaining the first project file of the main package based on the path address information of the main package, and obtaining the second project file of each sub-package based on the path address information of each sub-package, the first project file and each second project file are developed according to the same project file development specification, and for any one of the first project file and each second project file, the business code of the project file is included in the designated file; merging the content of the designated file of each second project file into the designated file of the first project file; based on the merged first project file, obtaining the target mini-program. The embodiments of the present application achieve the goal of reducing the consumption of human resources and improving the efficiency of program development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a method, device, electronic device and medium for packaging mini-programs. Background Art

[0002] With the continuous development of computer technology, the types of applications are gradually increasing, and the number of applications required by users is also gradually increasing. Mini programs are becoming more and more popular among users because they do not need to be downloaded and installed.

[0003] During the development of mini programs, the functions of mini programs will increase, and the size will also increase with the iteration of versions. Dividing the mini program into multiple packages and downloading them from the server can speed up the rendering speed and the loading speed. Each sub-packaged mini program contains a main package and at least one sub-package, and each sub-package and the main package can be developed independently. Usually, the code of each independently developed sub-package and main package needs to be manually modified to merge each sub-package into the main package. This process will increase additional human resources and reduce development efficiency. Summary of the invention

[0004] The present application provides a method, device, electronic device and medium for packaging small programs that can reduce human resources.

[0005] In a first aspect, a method for packaging a mini-program is provided, the method comprising:

[0006] Obtaining the path address information of the main package to be merged and the path address information of at least one sub-package;

[0007] Acquire a first project file of the main package based on the path address information of the main package, and acquire a second project file of each sub-package based on the path address information of each sub-package, wherein the first project file and each second project file are developed according to the same project file development specification, and for any one of the first project file and each second project file, the business code of the project file is included in the designated file;

[0008] Merging the contents of the designated files of each second project file into the designated files of the first project file;

[0009] Based on the merged first project file, a target applet is obtained.

[0010] In a second aspect, a device for packaging a mini-program is provided, the device comprising:

[0011] A path address acquisition module, used to acquire path address information of the main package to be merged and path address information of at least one sub-package;

[0012] A project file acquisition module is used to acquire a first project file of a main package based on the path address information of the main package, and to acquire a second project file of each sub-package based on the path address information of each sub-package. The first project file and each second project file are developed according to the same project file development specification. For any one of the first project file and each second project file, the business code of the project file is included in the designated file.

[0013] A designated file merging module, used for merging the contents of designated files of each second project file into the designated file of the first project file;

[0014] The mini-program module is obtained, and is used to obtain the target mini-program based on the merged first project file.

[0015] In a third aspect, an electronic device is provided, the electronic device comprising:

[0016] one or more processors;

[0017] Memory;

[0018] One or more applications, wherein the one or more applications are stored in a memory and configured to be executed by one or more processors, and the one or more programs are configured to: execute the method for packaging applet according to the first aspect.

[0019] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the method for packaging small programs shown in the first aspect is implemented.

[0020] The beneficial effects of the technical solution provided by this application are:

[0021] The present application provides a method, device, electronic device and medium for packaging a mini-program. Compared with the prior art, the present application obtains the first project file of the main package and the second project file of each sub-package. For any project file in the first project file and the second project file, the business code of the project file is included in a designated file. By merging the contents of the designated files of each second project file into the designated file of the first project file, the business code of each sub-package is automatically merged into the business code of the main package, which can reduce the consumption of human resources and improve program development efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in describing the embodiments of the present application are briefly introduced below.

[0023] Figure 1 A flowchart of a method for packaging a mini-program provided in an embodiment of the present application;

[0024] Figure 2 A schematic diagram of the structure of a small program packaging device provided in an embodiment of the present application;

[0025] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be interpreted as limiting the present application.

[0027] It will be understood by those skilled in the art that, unless expressly stated, the singular forms "one", "said", and "the" used herein may also include plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be an intermediate element. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein includes all or any unit and all combinations of one or more associated listed items.

[0028] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0029] The technical solution and how the technical solution of the present application solves the above technical problems are described in detail. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.

[0030] An embodiment of the present application provides a method for packaging a mini-program, which can be executed by any terminal device, such as a mobile phone, a laptop computer, a desktop computer, a tablet computer, etc., and can also be executed by a server or a server cluster. The server cluster includes at least two servers. For ease of description, the embodiment of the present application will be described in detail from the perspective of the terminal device.

[0031] In an embodiment of the present application, the terminal device can obtain the project files of the package (the first project file of the main package and / or the second project files of any one or several sub-packages) from the server, wherein the project files of the package can be stored in the cloud to the server or in a database based on cloud technology.

[0032] Cloud technology refers to a hosting technology that unifies hardware, software, network and other resources within a wide area network or local area network to achieve data computing, storage, processing and sharing.

[0033] Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The backend services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future, each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data of different levels will be processed separately. All kinds of industry data need strong system backing support, which can only be achieved through cloud computing.

[0034] Cloud computing is a computing model that distributes computing tasks on a resource pool composed of a large number of computers, allowing various application systems to obtain computing power, storage space and information services as needed. The network that provides resources is called a "cloud". From the user's perspective, the resources in the "cloud" are infinitely scalable and can be obtained at any time, used on demand, expanded at any time, and paid for by use.

[0035] As a provider of basic cloud computing capabilities, a cloud computing resource pool (referred to as a cloud platform, generally referred to as an IaaS (Infrastructure as a Service) platform) will be established, and various types of virtual resources will be deployed in the resource pool for external customers to choose to use. The cloud computing resource pool mainly includes: computing devices (virtualized machines, including operating systems), storage devices, and network devices.

[0036] According to the logical function division, the PaaS (Platform as a Service) layer can be deployed on the IaaS (Infrastructure as a Service) layer, and the SaaS (Software as a Service) layer can be deployed on the PaaS layer. SaaS can also be deployed directly on IaaS. PaaS is a platform for software operation, such as databases, web containers, etc. SaaS is a variety of business software, such as web portals, SMS mass senders, etc. Generally speaking, SaaS and PaaS are upper layers relative to IaaS.

[0037] Cloud computing refers to the delivery and use model of IT infrastructure, which means obtaining required resources through the network in an on-demand and easily scalable manner; in a broad sense, cloud computing refers to the delivery and use model of services, which means obtaining required services through the network in an on-demand and easily scalable manner. This service can be related to IT and software, the Internet, or other services. Cloud computing is the product of the development and integration of traditional computer and network technologies such as grid computing, distributed computing, parallel computing, utility computing, network storage technologies, virtualization, and load balancing.

[0038] With the development of the Internet, real-time data streams, and the diversification of connected devices, as well as the demand for search services, social networks, mobile commerce, and open collaboration, cloud computing has developed rapidly. Different from the previous parallel distributed computing, the emergence of cloud computing will promote revolutionary changes in the entire Internet model and enterprise management model from a conceptual perspective.

[0039] Cloud storage is a new concept that extends and develops from the concept of cloud computing. A distributed cloud storage system (hereinafter referred to as storage system) refers to a storage system that uses cluster applications, grid technology, and distributed storage file systems to bring together a large number of different types of storage devices (storage devices are also called storage nodes) in the network through application software or application interfaces to work together and provide external data storage and business access functions.

[0040] At present, the storage method of the storage system is: create a logical volume, and when creating a logical volume, allocate physical storage space for each logical volume. The physical storage space may be composed of disks of a storage device or several storage devices. The client stores data on a logical volume, that is, stores the data on the file system. The file system divides the data into many parts, each of which is an object. The object contains not only data but also additional information such as data identification (ID, ID entity). The file system writes each object into the physical storage space of the logical volume, and the file system records the storage location information of each object, so that when the client requests to access the data, the file system can allow the client to access the data according to the storage location information of each object.

[0041] The process of the storage system allocating physical storage space to a logical volume is as follows: based on the estimated capacity of the objects stored in the logical volume (this estimate often has a large margin relative to the actual capacity of the objects to be stored) and the grouping of independent redundant disk arrays (RAID, Redundant Array of Independent Disks), the physical storage space is pre-divided into stripes. A logical volume can be understood as a stripe, thereby allocating physical storage space to the logical volume.

[0042] In short, a database can be seen as an electronic filing cabinet - a place where electronic files are stored, and users can add, query, update, delete, and other operations on the data in the files. The so-called "database" is a collection of data that is stored together in a certain way, can be shared with multiple users, has as little redundancy as possible, and is independent of the application.

[0043] A database management system (DBMS) is a computer software system designed for managing databases. It generally has basic functions such as storage, retrieval, security, and backup. Database management systems can be classified according to the database model they support, such as relational, XML (Extensible Markup Language); or according to the type of computer they support, such as server clusters, mobile phones; or according to the query language used, such as SQL (Structured Query Language), XQuery; or according to performance focus, such as maximum scale, maximum operating speed; or other classification methods. Regardless of the classification method used, some DBMS can cross categories, for example, supporting multiple query languages ​​at the same time.

[0044] Figure 1A flowchart of a method for packaging a small program provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method may include steps S101 to S104. The execution subject of the embodiment of the present application may be any electronic device. In practical applications, the solution provided by the embodiment of the present application may be implemented as an application, or as a package combining tool for a small program (referred to as a small program package combining tool). Based on the application or the small program package combining tool, the main package and at least one sub-package may be automatically synthesized to obtain a small program.

[0045] Step S101, obtaining path address information of a main packet to be merged and path address information of at least one sub-packet.

[0046] Among them, the path address information of the package (main package or any sub-package) is the path address for storing the package. The package can be stored in the terminal device or in a device that is communicatively connected to the terminal device, such as a server.

[0047] In an embodiment of the present application, the path address information of the package may be a Hypertext Transfer Protocol (HTTP) address, a Distributed Version Control System (Git for short) address, or a directory list, etc., which is not limited here.

[0048] In the specific application process, the user (such as a technician) can configure the path address information of the main package and the path address information of each sub-package in a preset configuration file. The terminal device is installed with a small program package combining tool, which can obtain the preset configuration file and read the path address information of the main package and the path address information of each sub-package from the preset configuration file. Among them, the preset configuration file can be an mp2.config.json file.

[0049] In a possible implementation, the configuration file may include a mainPackage file and a subPackages file. The mainPackage file is used to configure the path address information of the main package, which may be a Git address, an HTTP address, or other address information. The subPackages file is used to configure the path address information of each subpackage, which may also be a Git address, an HTTP address, or other address information. The path address information of the main package and each subpackage may be in different or the same form. For example, the path address information of the main package may be a Git address, the path address information of one subpackage may be an HTTP address, and the path address information of another subpackage may be a Git address.

[0050] The user may also directly input the path address information of the main package and / or the path address information of each sub-package. For example, the user may input the path address information of the main package and / or the path address information of each sub-package through a command line.

[0051] In a possible implementation: when the command line is mp2 merge, it indicates that the current directory is the directory where the main package is located, and there is no need to re-download the main package; when the command line is mp2 merge main packageA packageB, it indicates that the user has specified the main package and each sub-package, wherein the first parameter is main, indicating the main package, the second parameter is packageA, indicating a sub-package, and the third parameter is packageB, indicating another sub-package, wherein the number of parameters in the command line is equal to the sum of the number of the main package and the sub-packages, that is, the parameters corresponding to the sub-package can be more than the two shown above, but can also be one, or at least three, and when each parameter is the directory where the package is located, the merge tool can directly use the directory to merge the packages, and there is no need to re-download the main package and each sub-package; when the command line is mp2merge--config. / mp2.config.json, it indicates that the user has specified the preset configuration file mp2.config.json file, and the merge tool can obtain the path address information of the main package and the path address information of each sub-package from the mp2.config.json file.

[0052] It should be noted that during the development of a mini-program project, the mini-program project can be split into a main package project and at least one sub-package project. The main package project and the sub-package projects can be developed simultaneously to speed up development. Generally, the main package project contains important codes for the mini-program, which is usually developed by the mini-program development team itself. The sub-package projects mainly contain the implementation code of one or several functions of the mini-program. Splitting the mini-program project into the main package project and at least one sub-package project can achieve the reuse of mini-program functions, that is, one mini-program can contain the functions of another mini-program, that is, the sub-package of one mini-program can be merged into another mini-program. In order to speed up development, the sub-package projects can be developed by partners of the mini-program development team.

[0053] Step S102: acquiring a first project file of the main package based on the path address information of the main package, and acquiring a second project file of each sub-package based on the path address information of each sub-package.

[0054] The first project file and each second project file are developed according to the same project file development specification. For any one of the first project file and each second project file, the business code of the project file is included in the designated file.

[0055] In the embodiment of the present application, the first project file and each second project file are developed according to the same project file development specification, which stipulates that the business code of the project file needs to be included in a specified file, so that when the developer develops the project, based on the project file development specification, the business code of the main package is included in the specified file of the first project file, and the business code of each sub-package is included in the specified file of each second project file. Furthermore, when the first project file and each second project file are combined, the content of the specified file of each second project file can be accurately merged into the specified file of the first project file, that is, the business code of the main package and the business code of each sub-package are accurately merged together.

[0056] The project file development specification can be a directory structure specification. Any directory in the directory structure specification specifies the content that can be added to the directory, so that the business code in the project file is not lost when the package merging tool is merging.

[0057] In a possible implementation, the project file development specification may be:

[0058]

[0059]

[0060] Among them, in the above-mentioned project file development specifications, the business code can be included in the entry file, namely the app.js file, the global configuration file, namely the app.json file, and the project name file, namely the project-name file, that is, the designated file includes the app.js file, the app.json file and the project-name file, wherein the project-name file is included in the package file, namely the packages file, therefore, the designated file may also include the app.js file, the app.json file and the packages file.

[0061] It should be noted that the above-mentioned project file development specifications are only exemplary. In the actual development process, the above-mentioned project file development specifications may be completely different, completely the same, or partially the same, and no limitation is made here.

[0062] In an embodiment of the present application, when the path address information of a package (a main package or any sub-package) is a Git address, the package-joining tool can obtain the project file of the package corresponding to the Git address from the Git repository through the git clone command. For example, by git cloning the git address, directly access the file corresponding to the git address in the Git repository, thereby obtaining the project file of the package corresponding to the git address; when the path address information of the package is an HTTP address, the package-joining tool can download the project file of the package from the web page corresponding to the HTTP address, wherein, when the project file of the package is a compressed package, for example, a Zip (a data compression file format) package, the compressed package needs to be decompressed.

[0063] Of course, in actual application, the path address information of the package is not limited to the Git address and HTTP address, but can also be other addresses. The package combining tool can obtain the project file of the package according to any form of the path address information of the package.

[0064] Step S103: merge the contents of the designated files of the second project files into the designated files of the first project files.

[0065] During the development of the mini program project, it is necessary to strictly abide by the project file development specifications for development. When merging, the merging tool needs to merge the contents of the specified files of each second project file into the specified files of the first project file, that is, in the developed project file, the business code is included in the specified file. When merging, the merging tool can accurately merge the contents of the specified files of each second project file into the specified files of the first project file, that is, accurately merge the business codes of each sub-package with the business code of the main package, which can avoid operation errors.

[0066] Step S104, obtaining a target applet based on the merged first project file.

[0067] In an embodiment of the present application, a target mini program can be obtained based on the merged first project file. For example, the merged first project file can be used as the project file of the target mini program, or the merged first project file can be processed to obtain the project file of the target mini program.

[0068] An embodiment of the present application provides a method for packaging a mini-program. Compared with the prior art, the embodiment of the present application can obtain the first project file of the main package and the second project file of each sub-package. For any project file in the first project file and the second project file, the business code of the project file is included in the designated file. By merging the contents of the designated files of each second project file into the designated file of the first project file, the business code of each sub-package is automatically merged into the business code of the main package, which can reduce the consumption of human resources and improve program development efficiency.

[0069] In another possible implementation of the embodiment of the present application, each second project file is developed based on a development template, and the development template is a project template of a basic code obtained based on the first project file with sensitive code portions in the source code deleted.

[0070] In the embodiment of the present application, since the first project file and each second project file are developed according to the same project file development specification, there is no need to provide the source code of the first project file to the subcontracted development team. Instead, the project file development specification is provided to the subcontracted development team.

[0071] Furthermore, the project file development specifications and development templates can be provided to the subcontracted development team. To prevent security issues such as sensitive code leakage, the sensitive code in the source code of the first project file can be deleted to obtain the first project file with the sensitive code portion deleted. Based on the first project file with the sensitive code portion deleted, a project template for the basic code can be obtained.

[0072] When developing each sub-project of the mini-program project, you can use the project template of the basic code to develop the second project file of each sub-project. Since the project template only contains the basic code corresponding to the main package and does not contain the sensitive code corresponding to the main package, it can prevent the leakage of sensitive code and loss of sensitive data, effectively ensuring the security of the code.

[0073] In another possible implementation of the embodiment of the present application, the specified file may also include an app.js file, an app.json file, and a packages file. Among them, the app.js file is the entry file, the app.json file is the global configuration file, and the packages file is the package file. The following will be explained one by one in the order of implementation mode A1-implementation mode A3, wherein the order of implementation mode A1-A3 is only the order of description, and the order does not have a substantial order of precedence.

[0074] Implementation A1: The designated file includes a package file, namely, a packages file.

[0075] In step S103, merging the content of the designated files of each second project file into the designated file of the first project file may specifically include: merging the content of the package files of each second project file into the package file of the first project file.

[0076] In the embodiment of the present application, the content in the packages file of the project file (the first project file or any second project file) is the main business code part of the project file, and the content in the packages file of each second project file can be merged into the packages file of the first project file.

[0077] Among them, it can be seen from the above project file development specifications that the content of the packages file includes the project-name file, and the project-name file includes component files, page files, image files, etc.

[0078] When merging the contents of the packages file of any second project file into the packages file of the first project file, the project-name file of the second project file and the component files, pages files, images files and other files contained in the project-name file of the second project file can be added below the project-name file of the first project file to obtain two parallel project-name files.

[0079] That is, essentially, the project-name file of each second project file is copied to the packages file, so that the packages file includes the project-name file of the first project file and the project-name files of each second project file.

[0080] Specifically, when the implementation A1 is actually executed, the first project file may be copied to a designated folder first, and then the contents of the packages files of the second project files may be merged into the packages file of the first project file.

[0081] Implementation method A2: The specified file includes the entry file, that is, the app.js file.

[0082] Wherein, in step S103, merging the contents of the designated files of each second project file into the designated file of the first project file may specifically include step S1031.

[0083] Step S1031, merging the global variable information in the entry files of each second project file into the global variable information in the entry file of the first project file.

[0084] In the embodiment of the present application, a global variable can be created by a certain object function or anywhere in the mini program. A global variable can be referenced by all objects or functions of the mini program.

[0085] Among them, the global variables of the mini program are defined in the global variable globalData object in the app.js file, and the global variable information includes the global variables contained in the globalData object. In the embodiment of the present application, the global variables in the globalData object in the app.js file of each second project file need to be merged into the globalData object in the app.js file of the first project file.

[0086] For any global variable in the globalData object, the global variable may be pre-configured in a preset configuration file, or may be a global variable directly input by a user through a command line.

[0087] In a possible implementation, when the command line is mp2 merge --global "{'version':'1.0.0'}", it indicates that the user has entered a global variable, wherein {'version':'1.0.0'} is the JSON format of the global variable.

[0088] Specifically, step S1031, merging the global variable information in the entry files of each second project file into the global variable information in the entry file of the first project file, may specifically include steps S10311 to S10315.

[0089] Step S10311, converting the text content in the entry file of the first project file into an abstract syntax tree, and converting the text content in the entry files of each second project file into an abstract syntax tree.

[0090] In the embodiment of the present application, the Abstract Syntax Tree (AST) is an abstract representation of the syntax structure of the source code. For the entry file of the first project file and the entry files of each second project, for any entry file, the text content of the entry file can be read first, and the text content of the entry file can be converted into AST using a preset conversion tool. Each node on the AST corresponds to each object in the text content, and any node on the AST includes the type of the node, the name of the node, and sub-node information.

[0091] The preset conversion tool may be any tool that can convert text content into AST, and the preset conversion tool is not limited in the embodiments of the present application. As a specific implementation, the preset conversion tool may be a tool provided by Babel, which is a compiler. The tool may be Babylon in Babel, and Babylon may convert the text content in the app.js file into AST according to the format of BabelAST.

[0092] Step S10312: merge the syntax tree parts corresponding to the global variable objects in each abstract syntax tree to obtain a merged syntax tree part.

[0093] In an embodiment of the present application, for the abstract syntax tree of the first project file and the abstract syntax trees of each second project file, the syntax tree part corresponding to the global variable object can be extracted from each abstract syntax tree, that is, the syntax tree part corresponding to the globalData object can be extracted, and the syntax tree parts corresponding to the extracted globalData objects can be merged to obtain a merged syntax tree part.

[0094] Step S10313: replace the syntax tree portion corresponding to the global variable object in the abstract syntax tree of the first project file with the merged syntax tree portion to obtain a processed abstract syntax tree of the first project file.

[0095] In an embodiment of the present application, when the merged syntax tree part is used to replace the syntax tree part corresponding to the globalData object in the abstract syntax tree of the first project file, the merged syntax tree part can be written into the abstract syntax tree of the first project file from which the syntax tree part corresponding to the global variable object has been extracted to obtain the processed abstract syntax tree of the first project file.

[0096] Step S10314: convert the processed abstract syntax tree of the first project file into text content.

[0097] Step S10315, replacing the text content in the entry file of the first project file with the converted text content.

[0098] In an embodiment of the present application, the abstract syntax tree of the processed first project file can be converted into text content, and the text content obtained by the conversion can be used to replace the text content in the entry file of the first project file, so that the text content in the entry file of the first project file after replacement includes the global variables in the globalData objects of each second project file.

[0099] It should be noted that when merging the global variable information in the entry files of each second project file into the global variable information in the entry file of the first project file, in addition to merging using the method in steps S10311-S10315, regular methods can also be used for merging.

[0100] Specifically, when merging using a regular expression, for the app.js file of the first project file and any of the app.js files of the second project files, the text content in the app.js file can be read first, and the text content is in the form of a string. A string that meets the preset regular expression can be matched from the text content. For example, the string that meets the preset regular expression can be a string of globalData:{...}, and then, the string that meets the preset regular expression is converted into a string in the form of a preset attribute, the preset attribute can be a value attribute, and the string in the form of the value attribute can be a string in the form of var globalData={...}, and then, through the eval function, the string in the form of the preset attribute is converted into a target object, and the target object can be a js object. After each app.js file is extracted to the target object, each target object is merged, and the merged target object is used to replace the target object in the app.js file of the first project file. Among them, the eval function can obtain the value of the input string.

[0101] Implementation method A3: The specified file includes the global configuration file, that is, the app.json file.

[0102] Wherein, step S103, merging the contents of the designated files of each second project file into the designated file of the first project file, may specifically include steps S1032 to S1034.

[0103] Step S1032: determining the path address information of the sub-package in the global configuration file of the first project file and the path address information of the sub-package in the global configuration files of each second project file.

[0104] In the embodiment of the present application, for the app.json file of the first project file and the app.json files of each second project file, any app.json file includes a subpackages field, and the subpackages field represents the path address information of the subpackage.

[0105] You can read the content in the app.json file, determine the subpackages field in the app.json file, and thus determine the path address information of the subpackage in the app.json file.

[0106] Specifically, the json parsing function of node.js (a JavaScript runtime environment) can be used to parse the content in the app.json file into a js object, and the value of the js object with the subpackages attribute can be extracted from the parsed js object.

[0107] Step S1033, merging the determined path address information of each sub-packet to obtain merged path address information.

[0108] In the embodiment of the present application, the subpackages field in the first project file may be merged with the subpackages field in the second project file to obtain merged path address information.

[0109] Specifically, the values ​​of the extracted js objects with the subpackages attribute may be merged to obtain the merged value of the js object with the subpackages attribute, that is, to obtain the merged path address information.

[0110] Step S1034: Use the merged path address information to replace the path address information of the sub-package in the global configuration file of the first project file.

[0111] In an embodiment of the present application, the value of the js object with the subpackages attribute in the app.json file of the first project file can be replaced by the value of the merged js object with the subpackages attribute, and the replaced js object can be converted into the content in the app.json file, so that the app.json file of the first project file includes the subpackages field in the app.json files of each second project file.

[0112] Another possible implementation of the embodiment of the present application, in step S104, obtaining the target applet based on the merged first project file may specifically include:

[0113] Obtain target program identification information; replace the program identification information in the merged first project file with the target program identification information; and obtain the target applet based on the replaced first project file.

[0114] In the embodiment of the present application, the target program identification information can be pre-configured in a preset configuration file, for example, appid is configured in the mp2.config.json file, and the appid is the target program identification information. The package combining tool can obtain the target program identification information from the preset configuration file.

[0115] The user can also directly enter the target program identification information through the command line. In one possible implementation: when the command line is mp2 merge --appid <appid>, it indicates that the user has entered the target applet ID.

[0116] During the actual execution process, the project configuration project.config.json file in the merged first project file can be determined, the content of the project.config.json file can be read, and the read content can be converted into a js object. The appid field in the js object can be replaced with the obtained target program identification information, and the replaced js object can be converted into the content in the project.config.json file to obtain the replaced project.config.json file, thereby obtaining the replaced first project file.

[0117] Furthermore, the replaced first project file may be used as the target applet, or the replaced first project file may be processed to obtain the target applet.

[0118] The purpose of replacing the program identification information in the merged first project file with the target program identification information is to facilitate access to the continuous integration (CI) process and realize the function of automatic deployment of the mini-program. Each program identification information corresponds to a different environment or mini-program body. In order to facilitate the unification between the program identification information and the environment, the target program environment information can be obtained while replacing the program identification information in the merged first project file with the target program identification information, and the program environment information in the merged first project file can be replaced with the target program environment information.

[0119] The target program environment information may be pre-configured in a preset configuration file. As a possible implementation method, the env field may be configured in the mp2.config.json file, that is, the target program environment information may be configured.

[0120] The user can also input the target program environment information through the command line. For example, when the command line is mp2 merge --env dev, it indicates that the user has input the target program environment information.

[0121] Of course, during actual execution, the command line includes not only the commands involved in the above-mentioned embodiments, but also other commands. For example, when the command line is mp2 merge--cdn, it indicates that the image resources can be uploaded to the content delivery network (Content Delivery Network, CDN), wherein the image resources are the images in the project file. Usually, the important images in the first project file need to be placed in the first project file, and the other images in the first project file except the important images, and all or part of the images in each second project file can be uploaded to CDN to reduce the size of the project file; when the command line is mp2 merge--preview, it indicates that the merged first project file can be previewed; when the command line is mp2 merge--open, it indicates that the merged first project file can be opened; when the command line is mp2 merge--upload, it indicates that the merged first project file can be uploaded to the server of the mini program.

[0122] The above embodiment introduces the method of combining packages of mini programs in detail from the perspective of method steps. The following will introduce the specific implementation of this application, which is as follows:

[0123] In the embodiment of the present application, the path address information of the main package, the path address information of each sub-package, the global variable information, the target program environment information and the target program identification information can be configured in advance in a preset configuration file, and the configuration file can be as follows:

[0124]

[0125] The path address information of the main package and the path address information of each sub-package can be extracted from the above configuration file, the first project file of the main package is obtained based on the path address information of the main package, and the second project file of each sub-package is obtained based on the path address information of each sub-package.

[0126] The first project file of the main package includes package files, entry files, global configuration files, project configuration files, etc. For example, the first project file of the main package is as follows:

[0127]

[0128] The sub-packaged second project file includes a package file, an entry file, a global configuration file, a project configuration file, etc. For example, the sub-packaged second project file is as follows (the sub-package packageA is shown below, and other sub-packages are similar to packageA and are not listed one by one here):

[0129]

[0130] In an embodiment of the present application, the contents of the packages file of each second project file can be first merged into the packages file of the first project file, and then the global variable information in the app.js file of each second project file can be merged into the global variable information in the app.js file of the first project file. Then, the path address information of the sub-package in the app.json file of each second project file can be merged into the app.json file of the first project file, and then the program identification information in the project.config.json of the first project file can be replaced with the target program identification information, and the target mini program can be obtained based on the first project file finally obtained.

[0131] Among them, the specific implementation methods of the merging part and the replacing part can be found in the relevant description of the above embodiment, which will not be repeated here.

[0132] The above specifically describes the method of packaging a mini program from the perspective of method steps. The following describes the packaging device of a mini program from the perspective of a virtual module, as shown below:

[0133] The present application embodiment provides a small program packaging device, such as Figure 2 As shown, the mini-program packaging device 20 may include: a path address acquisition module 201, a project file acquisition module 202, a specified file merging module 203, and a mini-program acquisition module 204, wherein:

[0134] The path address acquisition module 201 is used to acquire the path address information of the main packet to be merged and the path address information of at least one sub-packet.

[0135] The project file acquisition module 202 is used to acquire the first project file of the main package based on the path address information of the main package, and to acquire the second project file of each subpackage based on the path address information of each subpackage. The first project file and each second project file are developed according to the same project file development specification. For any one of the first project file and each second project file, the business code of the project file is included in the specified file.

[0136] The designated file merging module 203 is used to merge the contents of the designated files of each second project file into the designated file of the first project file.

[0137] The small program obtaining module 204 is used to obtain a target small program based on the merged first project file.

[0138] In another possible implementation of the embodiment of the present application, each second project file is developed based on a development template, and the development template is a project template of a basic code obtained based on the first project file with sensitive code portions in the source code deleted.

[0139] In another possible implementation of the embodiment of the present application, the designated file includes a package file;

[0140] The designated file merging module 203 is specifically used for:

[0141] The content in the package files of each second project file is merged into the package file of the first project file.

[0142] In another possible implementation of the embodiment of the present application, the designated file includes an entry file;

[0143] The designated file merging module 203 is specifically used for:

[0144] The global variable information in the entry file of each second project file is merged into the global variable information in the entry file of the first project file.

[0145] In another possible implementation of the embodiment of the present application, when the designated file merging module 203 merges the global variable information in the entry files of each second project file into the global variable information in the entry file of the first project file, it is specifically used to:

[0146] Converting text content in an entry file of the first project file into an abstract syntax tree, and converting text content in an entry file of each second project file into an abstract syntax tree;

[0147] Merge the syntax tree parts corresponding to the global variable objects in each abstract syntax tree to obtain a merged syntax tree part;

[0148] Replacing the syntax tree portion corresponding to the global variable object in the abstract syntax tree of the first project file with the merged syntax tree portion to obtain a processed abstract syntax tree of the first project file;

[0149] Converting the processed abstract syntax tree of the first project file into text content;

[0150] The converted text content replaces the text content in the entry file of the first project file.

[0151] In another possible implementation of the embodiment of the present application, the designated file includes a global configuration file;

[0152] The designated file merging module 203 is specifically used for:

[0153] Determine the path address information of the sub-package in the global configuration file of the first project file, and the path address information of the sub-package in the global configuration file of each second project file;

[0154] Merging the determined path address information of each sub-packet to obtain merged path address information;

[0155] The merged path address information is used to replace the path address information of the sub-package in the global configuration file of the first project file.

[0156] In another possible implementation of the embodiment of the present application, the mini-program module 204 is obtained to be specifically used for:

[0157] Obtain target program identification information;

[0158] Replacing the program identification information in the merged first project file with the target program identification information;

[0159] Based on the replaced first project file, a target applet is obtained.

[0160] The mini-program packaging device 20 of this embodiment can execute a mini-program packaging method provided in the method embodiment of the present application. The implementation principle is similar and will not be repeated here.

[0161] An embodiment of the present application provides a mini-program packaging device. Compared with the prior art, the embodiment of the present application obtains the first project file of the main package and the second project file of each sub-package. For any one of the first project file and the second project file, the business code of the project file is included in the designated file. By merging the contents of the designated files of each second project file into the designated file of the first project file, the business codes of each sub-package are automatically merged into the business code of the main package, which can reduce the consumption of human resources and improve program development efficiency.

[0162] The above introduces the packaging device of the mini-program of the present application from the perspective of a virtual module. The following introduces the electronic device of the present application from the perspective of a physical device.

[0163] The present application embodiment provides an electronic device, such as Figure 3 As shown, Figure 3 The electronic device 4000 shown includes: a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, such as through a bus 4002. Optionally, the electronic device 4000 may also include a transceiver 4004. It should be noted that in actual applications, the transceiver 4004 is not limited to one, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of the present application.

[0164] Processor 4001 may be a CPU, a general-purpose processor, a DSP, an ASIC, an FPGA or other programmable logic device, a transistor logic device, a hardware component or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. Processor 4001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0165] The bus 4002 may include a path to transmit information between the above components. The bus 4002 may be a PCI bus or an EISA bus, etc. The bus 4002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0166] Memory 4003 can be ROM or other types of static storage devices that can store static information and instructions, RAM or other types of dynamic storage devices that can store information and instructions, or it can be EEPROM, CD-ROM or other optical disk storage, optical disk storage (including compressed optical disk, laser disk, optical disk, digital versatile disk, Blu-ray disk, etc.), magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited to this.

[0167] The memory 4003 is used to store application code for executing the solution of the present application, and the execution is controlled by the processor 4001. The processor 4001 is used to execute the application code stored in the memory 4003 to implement the content shown in any of the above method embodiments.

[0168] An embodiment of the present application provides an electronic device, and the electronic device in the embodiment of the present application includes: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs are configured to: execute the mini-program packaging method shown in the method embodiment.

[0169] The electronic device of the present application is introduced above from the perspective of a physical device. The following introduces the computer-readable storage medium of the present application from the perspective of a storage medium.

[0170] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer-readable storage medium is run on a computer, the computer can execute the corresponding content in the aforementioned method embodiment.

[0171] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0172] The above description is only a partial implementation method of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.< / appid>

Claims

1. A method for packaging a small program, characterized in that: include: Obtaining the path address information of the main package to be merged and the path address information of at least one sub-package; Acquire a first project file of the main package based on the path address information of the main package, and acquire a second project file of each subpackage based on the path address information of each subpackage, wherein the first project file and each of the second project files are developed according to the same project file development specification, and for any one of the first project file and each of the second project files, the business code of the project file is included in a designated file; Merging the contents of each designated file of the second project file into the designated file of the first project file; the designated file includes an entry file; Based on the merged first project file, a target applet is obtained; The step of merging the contents of each designated file of the second project file into the designated file of the first project file includes: Converting the text content in the entry file of the first project file into an abstract syntax tree, and converting the text content in the entry file of each of the second project files into an abstract syntax tree; Merging syntax tree parts corresponding to the global variable objects in each of the abstract syntax trees to obtain a merged syntax tree part; Replacing the syntax tree portion corresponding to the global variable object in the abstract syntax tree of the first project file with the merged syntax tree portion to obtain a processed abstract syntax tree of the first project file; Converting the processed abstract syntax tree of the first project file into text content; The converted text content replaces the text content in the entry file of the first project file.

2. The method according to claim 1, characterized in that Each of the second project files is developed according to a development template, and the development template is a project template of a basic code obtained based on the first project file with sensitive code parts in the source code deleted.

3. The method according to claim 1, characterized in that The specified file includes a package file; The step of merging the contents of each designated file of the second project file into the designated file of the first project file includes: The contents of the package files of each of the second project files are merged into the package files of the first project files.

4. The method according to claim 1, characterized in that: The specified file includes a global configuration file; The step of merging the contents of each designated file of the second project file into the designated file of the first project file includes: Determine the path address information of the sub-package in the global configuration file of the first project file, and the path address information of the sub-package in the global configuration file of each of the second project files; Merging the determined path address information of each sub-packet to obtain merged path address information; The merged path address information is used to replace the path address information of the sub-package in the global configuration file of the first project file.

5. The method according to claim 1, characterized in that The step of obtaining the target applet based on the merged first project file includes: Obtain target program identification information; Replacing the program identification information in the merged first project file with the target program identification information; Based on the replaced first project file, a target applet is obtained.

6. A small program packaging device, characterized in that: include: A path address acquisition module, used to acquire path address information of the main package to be merged and path address information of at least one sub-package; a project file acquisition module, configured to acquire a first project file of the main package based on the path address information of the main package, and to acquire a second project file of each sub-package based on the path address information of each sub-package, wherein the first project file and each of the second project files are developed according to the same project file development specification, and for any one of the first project file and each of the second project files, the business code of the project file is included in a designated file; A designated file merging module, used for merging the contents of the designated files of each of the second project files into the designated files of the first project files; Obtaining a mini-program module, used to obtain a target mini-program based on the merged first project file; The module for merging designated files is further used to convert the text content in the entry file of the first project file into an abstract syntax tree, and to convert the text content in the entry files of each of the second project files into an abstract syntax tree; the designated file includes the entry file; and the syntax tree parts corresponding to the global variable objects in each of the abstract syntax trees are merged to obtain a merged syntax tree part; Replacing the syntax tree portion corresponding to the global variable object in the abstract syntax tree of the first project file with the merged syntax tree portion to obtain a processed abstract syntax tree of the first project file; The processed abstract syntax tree of the first project file is converted into text content; and the converted text content replaces the text content in the entry file of the first project file.

7. The device according to claim 6, characterized in that Each of the second project files is developed according to a development template, and the development template is a project template of a basic code obtained based on the first project file with sensitive code parts in the source code deleted.

8. The device according to claim 6, characterized in that The specified file includes a package file; The designated file merging module is further configured to merge the contents of the package files of each of the second project files into the package files of the first project files.

9. The device according to claim 6, characterized in that The specified file includes a global configuration file; The designated file merging module is further used to determine the path address information of the sub-package in the global configuration file of the first project file and the path address information of the sub-package in the global configuration file of each of the second project files; merge the determined path address information of each sub-package to obtain merged path address information; and use the merged path address information to replace the path address information of the sub-package in the global configuration file of the first project file.

10. The device according to claim 6, characterized in that The mini-program obtaining module is further used to obtain target program identification information; replace the program identification information in the merged first project file with the target program identification information; and obtain the target mini-program based on the replaced first project file.

11. An electronic device, characterized in that: It includes: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to: execute the mini-program packaging method according to any one of claims 1 to 5.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, it implements the method for packaging mini-programs as described in any one of claims 1 to 5.