A program package processing method, device, electronic device and storage medium

By automatically obtaining and copying matching package versions, the problem of user manual selection errors caused by incompatibility between Vue framework versions is solved, and the convenience and accuracy of package download and installation are achieved.

CN114661338BActive Publication Date: 2025-02-25BEIJING DAJIA INTERNET INFORMATION TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210354067.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-06
Publication Date
2025-02-25
Estimated Expiration
2042-04-06

AI Technical Summary

Technical Problem

In the case of incompatibility between Vue framework versions, users need to manually select and download and install the corresponding package, which is prone to errors and inconvenient.

Method used

Copy it into the program dependency directory of the program to be written by automatically obtaining the associated version of the package that the program is to be written and determining the matching package from the download directory of multiple versions, and copy it to the program's dependency directory for reference when writing the program.

Benefits of technology

It avoids the problem that users may make mistakes in manually selecting the version, and simplifies the download and installation process of the package, making it more smooth and convenient.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114661338B_ABST
    Figure CN114661338B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method, device, electronic device and storage medium for processing a program package. The method comprises: obtaining an associated version of a program package that a program to be written depends on; determining a download directory that matches the associated version from download directories of multiple versions of program packages; copying the program package under the matching download directory to the first dependent directory of the program, so as to reference the program package when writing the program. The embodiment of the present disclosure can avoid manually downloading the corresponding version of the program package according to the operating environment, avoids possible errors in manual selection, and makes the user download and installation process smoother and more convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device and storage medium for processing a program package. Background Art

[0002] With the development of computer technology, package technology has emerged. A package is a collection of multiple recurring functional codes (API, Application Programming Interface) by developers. For example, an API is implemented as a button with white text on a blue background that responds to click operations. Then the API can be added to the package. When users develop new programs, they can download the package and reference the API in the package at a specified location to implement the API functions without having to rewrite the API code program.

[0003] Vue is a front-end web framework. Developers can integrate some functional codes that rely on the Vue framework into a program package. This program package can be used in other web development using the Vue framework to save development time. However, Vue versions are incompatible. For example, a program package based on the Vue2.0 version cannot run normally on the Vue3.0 version, and vice versa. In the related art, corresponding program packages are generated for different versions of the Vue framework, and users manually choose which version of the program package to download and install according to the operating environment. For users, manually downloading and installing the program package version may be erroneous and inconvenient depending on the operating environment. Summary of the invention

[0004] The present disclosure provides a method, device, electronic device and storage medium for processing a program package. This is to at least solve the problem in the related art that manually downloading the installation package may cause errors and is inconvenient. The technical solution of the present disclosure is as follows:

[0005] According to a first aspect of an embodiment of the present disclosure, a method for processing a program package is provided, comprising:

[0006] Get the associated version of the package that the program to be written depends on;

[0007] Determine, from the download directories of the multiple version packages, a download directory that matches the associated version;

[0008] The program package under the matching download directory is copied to the first dependent directory of the program, so as to reference the program package when compiling the program.

[0009] In a possible implementation, the method of generating the multiple version packages includes:

[0010] The program package writing files are named with different version identifiers to obtain the program package writing files with different version identifiers;

[0011] Obtaining a compilation tool that matches the version identifier;

[0012] The corresponding program package writing files are compiled using the compilation tools to obtain multiple version program packages.

[0013] In a possible implementation, the method for generating the program package writing file includes:

[0014] Get multiple versions of grammar writing rules;

[0015] When a sub-rule in the grammar writing rule fails to be applicable to the multiple versions, a replacement rule of the sub-rule is used to write a program package writing file, wherein the replacement rule is applicable to the multiple versions.

[0016] In a possible implementation, the method for generating the program package writing file includes:

[0017] Get multiple versions of grammar writing rules;

[0018] When the sub-rules in the grammar writing rules fail to apply to the multiple versions, conditional statements are used to write program statements for each of the multiple versions respectively to obtain a program package writing file.

[0019] In a possible implementation, the using the compilation tool to compile the corresponding program package writing files to obtain multiple version program packages includes:

[0020] Rename the version identifier of the program package writing file to the default file identifier in the second dependent directory of the compilation tool;

[0021] Rename the name identifier of the compilation tool to a default tool identifier in the second dependency directory;

[0022] Paste the renamed package writing file and the renamed compilation tool into the corresponding second dependency directory respectively;

[0023] The renamed program package writing files are compiled using the renamed compilation tools to obtain multiple versions of program packages.

[0024] In a possible implementation, after respectively using the renamed compilation tool to compile the renamed program package writing files to obtain multiple version program packages, the following step further includes:

[0025] The multiple version program packages are stored in corresponding download directories respectively.

[0026] In a possible implementation, before obtaining the associated version of the program package that the program to be written depends on, the process further includes:

[0027] The combined API interface package that the installation package depends on;

[0028] Using the combined API interface program package, read the associated version of the program package that the program to be written depends on;

[0029] If the combined API interface program package does not match the associated version, an API interface program package matching the version is downloaded.

[0030] According to a second aspect of an embodiment of the present disclosure, there is provided a device for processing a program package, including:

[0031] An acquisition module is used to obtain the associated versions of the program packages that the program to be written depends on;

[0032] A determination module, used to determine a download directory matching the associated version from among the download directories of multiple version packages;

[0033] The copy module is used to copy the program package under the matching download directory to the first dependent directory of the program, so as to reference the program package when compiling the program.

[0034] In a possible implementation, the determining module includes:

[0035] A naming submodule is used to name the program package writing files with different version identifiers to obtain the program package writing files with different version identifiers;

[0036] An acquisition submodule is used to acquire a compilation tool that matches the version identifier;

[0037] The compiling submodule is used to compile the corresponding program package writing files using the compiling tool to obtain multiple version program packages.

[0038] In a possible implementation, the naming submodule includes:

[0039] A first acquisition unit is used to acquire multiple versions of grammar writing rules;

[0040] The replacement unit is used for, when a sub-rule in the grammar writing rule fails to be applicable to the multiple versions, to write a program package writing file using a replacement rule of the sub-rule, wherein the replacement rule is applicable to the multiple versions.

[0041] In a possible implementation, the naming submodule includes:

[0042] A second acquisition unit is used to acquire multiple versions of grammar writing rules;

[0043] The writing unit is used to use conditional statements to write program statements of each version in the multiple versions respectively when the sub-rules in the grammar writing rules are not applicable to the multiple versions, so as to obtain a program package writing file.

[0044] In a possible implementation, the compiling submodule includes:

[0045] A first renaming unit, used for renaming the version identifier of the program package writing file to a default file identifier in the second dependent directory of the compilation tool;

[0046] A second renaming unit, configured to rename the name identifier of the compilation tool to a default tool identifier in the second dependency directory;

[0047] A pasting unit, used to paste the renamed program package writing file and the renamed compilation tool into the corresponding second dependency directory respectively;

[0048] The copying unit is used to compile the renamed program package writing files using the renamed compilation tool to obtain multiple versions of the program package.

[0049] In a possible implementation, the method further includes:

[0050] The storage submodule is used to store the multiple version program packages in corresponding download directories respectively.

[0051] In a possible implementation, the method further includes:

[0052] Installation module, used to install the combined API interface package that the package depends on;

[0053] A reading module, used to use the combined API interface program package to read the associated version of the program package that the program to be written depends on;

[0054] The download module is used to download an API interface program package that matches the version if the combined API interface program package does not match the associated version.

[0055] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0056] processor;

[0057] a memory for storing instructions executable by the processor;

[0058] The processor is configured to execute the instructions to implement a method for processing a program package as described in any one of the embodiments of the present disclosure.

[0059] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided. When instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a method for processing a program package as described in any one of the embodiments of the present disclosure.

[0060] According to a fifth aspect of an embodiment of the present disclosure, a computer program product is provided, which includes instructions, and is characterized in that when the instructions are executed by a processor of an electronic device, the electronic device is enabled to execute a method for processing a program package as described in any one of the embodiments of the present disclosure.

[0061] The technical solution provided by the embodiment of the present disclosure brings at least the following beneficial effects: the embodiment of the present disclosure automatically obtains the associated version of the program package that the program to be written depends on, determines the program package that matches the associated version from the download directories of multiple version program packages, and copies it to the first dependent directory of the program to be written for reference by the program. The user is freed from manually downloading the corresponding version of the program package according to the operating environment, avoiding possible errors in manual selection, and making the user's download and installation process smoother and more convenient.

[0062] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0063] The drawings herein are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description are used to explain the principles of the present disclosure, and do not constitute improper limitations on the present disclosure.

[0064] Figure 1 The invention is a flowchart of a method for processing a program package according to an exemplary embodiment.

[0065] Figure 2 The present invention is an interface diagram of a program package editing file according to an exemplary embodiment.

[0066] Figure 3 The invention is a flowchart of a method for processing a program package according to an exemplary embodiment.

[0067] Figure 4 The invention is a block diagram of a device for processing a program package according to an exemplary embodiment.

[0068] Figure 5 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0069] In order to enable ordinary persons in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings.

[0070] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0071] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.

[0072] Figure 1 is a flowchart of a method for processing a program package according to an exemplary embodiment. Figure 1 As shown, the method is used in a terminal and includes the following steps.

[0073] Step S101, obtaining the associated version of the program package that the program to be written depends on.

[0074] In the disclosed embodiment, the program to be written may include a program that matches a specific development project. The program package that the program depends on may include the program package referenced when writing the program. For example: Vue is a JavaScript framework. During the development of a web page, some functional codes that depend on the Vue framework can be integrated into a program package. In the development process of other web pages (programs to be written) using the Vue framework, the above-mentioned program package can be referenced to save development time. In one example, the associated version of the dependent program package can be determined by reading the package.json file in the code repository where the program to be written is located.

[0075] Step S103: determining a download directory that matches the associated version from among the download directories of multiple version packages.

[0076] In the disclosed embodiment, the versions of the program package may be incompatible. For example, a web page based on the Vue2.x framework cannot use a program package developed based on the Vue3.x framework. Therefore, the disclosed embodiment can pre-download multiple versions of the program to their respective download directories. For example: download the Vue2.x version of the program package to the lib / vue2 directory, and download the Vue3.x version of the program package to the lib / vue3 directory. When the associated version of the program package that the program with the written program depends on is obtained as the Vue2.x version, the download directory that matches the associated version is the lib / vue2 directory. It should be noted that the multiple versions of the program package setting method are not limited to the above examples. For example, multiple versions of the React.js framework and multiple versions of the Angular.js framework. The technicians in the relevant field may make other changes under the inspiration of the technical essence of this application, but as long as the functions and effects achieved are the same or similar to those of this application, they should be covered within the scope of protection of this application.

[0077] In the disclosed embodiment, the multiple versions of the program packages may include compiled files generated by the same version of the program package writing files in different versions of the compilation tools, or may include compiled files generated by different version of the program package writing files in the compilation tools corresponding to them. Wherein, when the multiple versions of the program packages are compiled files generated by the same program package writing files in different versions of the compilation tools, the developer of the program package can only write and maintain the writing files of one version, saving manpower and material resources.

[0078] Step S105, copying the program package in the matching download directory to the first dependent directory of the program, so as to reference the program package when compiling the program.

[0079] In the disclosed embodiment, the first dependency directory includes a reference directory of the program package, for example: the program statement: import H from 'h', indicates that the front-end program module enters directory h to read the program package H, and uses the read content for program writing. In one example, the default first dependency directory of the main program in the program package specification can also be referenced, such as the index,js file in the lib / directory as the first dependency directory of the program. After the program package is copied to the first dependency directory, the front-end program module enters the first dependency directory, reads the program package under the first dependency directory, and thus references the content of the program package.

[0080] In the disclosed embodiment, the method in steps S101 to S103 is automatically executed content and can be written in a script file. After the program package is downloaded and installed from a package management tool (such as npm or yarn), the script file is automatically executed, and the version package that the program to be written depends on is matched to the corresponding download directory, and the program package is copied from the download directory to the first dependent directory. In one example, the script file, such as postinstall, can use the program statements of "install": "scripts / install.js", "postinstall": "scripts / install.js", which means that after the installation of the program package is completed, the postinstall script file is automatically executed.

[0081] The disclosed embodiment automatically obtains the associated version of the program package that the program to be written depends on, determines the program package that matches the associated version from the download directory of multiple versions of the program package, and copies it to the first dependent directory of the program to be written for reference by the program. The user is freed from manually downloading the corresponding version of the program package according to the operating environment, avoiding possible errors in manual selection, and making the user's download and installation process smoother and more convenient.

[0082] In a possible implementation, the method of generating the multiple version packages includes:

[0083] The program package writing files are named with different version identifiers to obtain the program package writing files with different version identifiers;

[0084] Obtaining a compilation tool that matches the version identifier;

[0085] The corresponding program package writing files are compiled using the compilation tools to obtain multiple version program packages.

[0086] In the disclosed embodiment, a new package writing file can be created, and the package writing file can be named with different version identifiers, such as vue2 and vue3. It is also possible to download an existing package writing file from a package management tool, and write based on the existing package writing file, for example, execute in the command line: yarn add vue2@npm:vue@2.6.14, the actual effect of this command is to create a new directory vue2 under the root directory node_modules of the code repository, download the compressed package of the vue package version 2.6.14 from the package management tool, and decompress the compressed package into the vue2 directory.

[0087] Obtain a compilation tool that matches the version identifier, for example, the compilation tool corresponding to the vue2 version is vue-loader 15, and the compilation tool corresponding to the vue3 version is vue-loader 16. Use the compilation tools to compile the corresponding program package writing files, for example: use vue-loader 15 to compile the program writing files of vue2, and use vue-loader16 to compile the program writing files of vue3 to obtain multiple version packages.

[0088] In the disclosed embodiment, the framework version that the program to be written depends on and the framework version that the program package depends on need to be consistent. One of the important factors that affect whether the version can be used normally is the compilation environment of the program package. In the disclosed embodiment, multiple versions of program packages can be obtained by using the same program package writing file and compiling with different compilation tools. Since the same program package writing file is used, the disclosed embodiment greatly improves the development efficiency of the program package and reduces the maintenance difficulty in terms of development and maintenance compared to developing and maintaining multiple versions of program package writing files.

[0089] In a possible implementation, the method for generating the program package writing file includes:

[0090] Get multiple versions of grammar writing rules;

[0091] When a sub-rule in the grammar writing rule fails to be applicable to the multiple versions, a replacement rule of the sub-rule is used to write a program package writing file, wherein the replacement rule is applicable to the multiple versions.

[0092] The grammar writing rules described in the embodiments of the present disclosure may include grammar writing rules for programming languages. The sub-rules of different versions of grammar writing rules may be different. For example, in the functional component v-model, in version 2.x, using v-model is equivalent to binding the value prop and triggering the input event. If you want to change the prop or event name, you need to add the model option in the ChildComponent component; in version 3.x, the functional component v-model is equivalent to passing the modelValue prop and receiving the thrown update:modelValue event. The sub-rules applicable to version 2.x are not applicable to version 3.x. Therefore, you can choose to use alternative rules that are applicable to both version 2.x and version 3.x. For example, replace all applicable .sync parts in the code base with v-model, and for all v-models without parameters, rename prop and event to modelvalue and update:modelValue respectively. For example: After registering a component in 2.x, pass the component name as a string to the first parameter of the rendering function, and it can work normally. In 3.x, since VNode is context-independent, you can no longer implicitly find registered components using string IDs. An imported resolveComponent method is required. An alternative rule can be adopted as follows: the entire application defaults to the behavior of vue3 and only enables certain compatibility features.

[0093] In the disclosed embodiment, by using substitution rules to replace sub-rules that are not applicable to all versions, program files applicable to all versions can be written in the code of a set of program package writing files, and compiled through different compilation tools to obtain different versions of program packages.

[0094] In a possible implementation, the method for generating the program package writing file includes:

[0095] Get multiple versions of grammar writing rules;

[0096] When the sub-rules in the grammar writing rules fail to apply to the multiple versions, conditional statements are used to write program statements for each of the multiple versions respectively to obtain a program package writing file.

[0097] In the disclosed embodiments, when the sub-rules in the grammar writing rules cannot be applied to all versions, the program statements of each version in the multiple versions can be written separately, and conditional statements can be used for judgment, such as if statements, case statements, isVue3 statements, etc. During the execution of the program package, the execution code that matches the version condition is selected through the specific version condition. For example, a module is written using the 2.x version program code, and a module is written using the 3.x version program code. IsVue3 is used to determine the version that the currently developed project depends on, and the corresponding execution module is selected. In one example, the above embodiments can also be used in combination, for example: when the sub-rules in the grammar writing rules fail to apply to the multiple versions, the program package writing file is first written using the replacement rules of the sub-rules. In the case that the sub-rules do not have replacement rules, conditional statements are used to write the program statements of each version in the multiple versions to obtain the program package writing file.

[0098] Refer to Table 1. The left column in Table 1 lists the syntax differences between different versions, and the right column in Table 1 lists the compatible solutions.

[0099]

[0100]

[0101] In the disclosed embodiment, by utilizing conditional statements, program statements for each of the multiple versions are written separately to obtain a program package writing file. Program files applicable to all versions can be written in a set of program package writing file codes, and compiled using different compilation tools to obtain program packages of different versions.

[0102] Figure 2 FIG. 1 is an interface diagram of a program package editing file according to an exemplary embodiment. Figure 2 As shown, the corresponding program package writing files are compiled using the compilation tool to obtain multiple version packages, including:

[0103] Rename the version identifier of the program package writing file to the default file identifier in the second dependent directory of the compilation tool;

[0104] Rename the name identifier of the compilation tool to a default tool identifier in the second dependency directory;

[0105] Paste the renamed package writing file and the renamed compilation tool into the corresponding second dependency directory respectively;

[0106] The renamed program package writing files are compiled using the renamed compilation tools to obtain multiple versions of program packages.

[0107] In the embodiment of the present disclosure, the second dependent directory may include the location of the program package when the compilation tool is compiling. For example, in the compilation tool vue-loader15, the dependent directory can be expressed as: import Vue from'vue'. In the compilation tool vue-loader16, the dependent directory can also be expressed as: import Vue from'vue'. The dependent directory in the compilation tool is generally not modifiable. Reference Figure 2 As shown, when compiling the vue2 version, vue2 needs to be renamed to vue, where vue is the default file identifier of the second dependency directory of the vue2 compilation tool. At the same time, the compilation tool vue-loader15 needs to be renamed to vue-loader. Paste the renamed package writing files and the renamed compilation tools into the corresponding second dependency directory respectively. For example, to compile the vue2 version package writing files, paste the renamed vue2 (i.e. vue) from the original directory Lib / vue2 to Lib / vue, and paste the renamed vue-loader15 (vue-loader) from the original directory Lib / vue-loader15 to Lib / vue-loader. Execute the compilation operation. When compiling other versions, you can repeat the same operation as the vue2 version. Get multiple versions of the package.

[0108] In the disclosed embodiment, by renaming the program package writing file and the corresponding compilation tool and pasting them into the second dependency directory of the compilation tool, different versions of program packages can be compiled separately to generate multiple versions of program packages.

[0109] In a possible implementation, after respectively using the renamed compilation tool to compile the renamed program package writing files to obtain multiple version program packages, the following step further includes:

[0110] The multiple version program packages are stored in corresponding download directories respectively.

[0111] In the embodiments of the present disclosure, reference Figure 2 As shown, multiple versions of program packages may be generated in the second dependent directory vue. In one example, after a version of the program package is generated, the program package is stored in the corresponding download directory. For example, the vue2 version of the program package is compiled to generate an index.js file, and the index.js file is stored in the download directory Lib / vue2. After another version of the program package is generated, the storage process is performed again. In another example, multiple versions of program packages can be generated in vue at one time and stored in the corresponding download directories respectively.

[0112] The disclosed embodiment stores multiple versions of program packages in corresponding download directories, thereby ensuring that during the installation process, the program package is directed to a version of the program package that matches the version of the program to be written, thereby ensuring the installation and use of the program package.

[0113] Before obtaining the associated version of the program package that the program to be written depends on, the following step is also included:

[0114] The combined API interface package that the installation package depends on;

[0115] Using the combined API interface program package, read the associated version of the program package that the program to be written depends on;

[0116] If the combined API interface program package does not match the associated version, an API interface program package matching the version is downloaded.

[0117] In the disclosed embodiment, the combined API interface program package may be included in the program package, and the associated function codes are closely arranged in position. The combined API interface program package is, for example: vue-demi. vue-dem is based on the framework protocol of the vue3.x version, and is therefore applicable to the program to be developed of the vue3.x version. In the combined API interface program package vue-demi, the command statement import{defineComponent}from'vue-demi' can be used to read the associated version of the program package on which the program to be written depends, and determine the API interface program package that matches the associated version. For example, the above statement is equivalent to import{defineComponent}from'@vue / composition-api' in the vue2.x environment; and is equivalent to import{defineComponent}from'vue' in the vue3.x environment. If it is read that the current operating environment is the vue3.x environment, there is no need to download the API interface program package, because the combined API interface program package vue-demi itself is applicable to the vue3.x environment. If the current running environment is read as vue2.x environment, you need to download the API interface package that matches the vue2.x environment.

[0118] In the embodiment of the present disclosure, the combined API interface program package can be used as a dependent file of the associated version program package in the embodiment of the present disclosure, so that before installing the associated version program package, the combined API interface program package is installed first, which can avoid the development and writing of some API functions, reduce the size of the associated version program package, and thus reduce the difficulty of writing the associated version program package.

[0119] Figure 3 FIG. 1 is a flowchart of a method for processing a program package according to an exemplary embodiment. Figure 3 As shown, the method includes:

[0120] Step S301, installing the combined API interface program package that the program package depends on.

[0121] In the disclosed embodiment, by declaring the combined API interface program package that the associated version depends on in the program package, the combined API interface program package that the associated program package depends on is first downloaded and installed before the associated version program package is downloaded.

[0122] Step S303: using the combined API interface program package, read the associated version of the program package that the program to be written depends on.

[0123] In the disclosed embodiment, the command statement import{defineComponent}from'vue-demi' may be used to read the associated version of the program package that the program to be written depends on, and determine the API interface program package that matches the associated version.

[0124] Step S305: If the combined API interface program package does not match the associated version, then download an API interface program package that matches the version.

[0125] Step S101, obtaining the associated version of the program package that the program to be written depends on.

[0126] In the disclosed embodiment, after the API interface package is installed, the associated version of the package on which the program to be written depends is automatically obtained. For example, the associated version of the dependent package can be determined by reading the package.json file in the code repository where the program to be written is located.

[0127] Step S103: determining a download directory that matches the associated version from among the download directories of multiple version packages.

[0128] The disclosed embodiment can pre-download multiple versions of programs to their respective download directories. From the download directories of multiple versions of program packages, download the Vue2.x version of the program package to the lib / vue2 directory, download the Vue3.x version of the program package to the lib / vue3 directory, and determine the program package with the matching associated version from the corresponding download directory.

[0129] Step S105, copying the program package in the matching download directory to the first dependent directory of the program, so as to reference the program package when compiling the program.

[0130] In the disclosed embodiment, the first dependency directory includes a reference directory of the program package, such as the index and js files in the lib / directory as the first dependency directory of the program. After the program package is copied to the first dependency directory, the front-end program module enters the first dependency directory, reads the program package in the first dependency directory, and references the content of the program package.

[0131] It should be understood that, although the various steps in the flow chart are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear description in this article, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the figure may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0132] It can be understood that the same / similar parts between the various embodiments of the above method in this specification can refer to each other, and each embodiment focuses on the differences from other embodiments. For related points, please refer to the description of other method embodiments.

[0133] Figure 4 is a block diagram of a processing device for a program package according to an exemplary embodiment. Figure 4 , the device comprises:

[0134] The acquisition module 401 is used to acquire the associated version of the program package that the program to be written depends on;

[0135] A determination module 402 is used to determine a download directory that matches the associated version from among the download directories of multiple version packages;

[0136] The copy module 403 is used to copy the program package in the matching download directory to the first dependent directory of the program, so as to reference the program package when compiling the program.

[0137] In a possible implementation, the determining module includes:

[0138] A naming submodule is used to name the program package writing files with different version identifiers to obtain the program package writing files with different version identifiers;

[0139] An acquisition submodule is used to acquire a compilation tool that matches the version identifier;

[0140] The compiling submodule is used to compile the corresponding program package writing files using the compiling tool to obtain multiple version program packages.

[0141] In a possible implementation, the naming submodule includes:

[0142] A first acquisition unit is used to acquire multiple versions of grammar writing rules;

[0143] The replacement unit is used for, when a sub-rule in the grammar writing rule fails to be applicable to the multiple versions, to write a program package writing file using a replacement rule of the sub-rule, wherein the replacement rule is applicable to the multiple versions.

[0144] In a possible implementation, the naming submodule includes:

[0145] A second acquisition unit is used to acquire multiple versions of grammar writing rules;

[0146] The writing unit is used to use conditional statements to write program statements of each version in the multiple versions respectively when the sub-rules in the grammar writing rules are not applicable to the multiple versions, so as to obtain a program package writing file.

[0147] In a possible implementation, the compiling submodule includes:

[0148] A first renaming unit, used for renaming the version identifier of the program package writing file to a default file identifier in the second dependent directory of the compilation tool;

[0149] A second renaming unit, configured to rename the name identifier of the compilation tool to a default tool identifier in the second dependency directory;

[0150] A pasting unit, used to paste the renamed program package writing file and the renamed compilation tool into the corresponding second dependency directory respectively;

[0151] The copying unit is used to compile the renamed program package writing files using the renamed compilation tool to obtain multiple versions of the program package.

[0152] In a possible implementation, the method further includes:

[0153] The storage submodule is used to store the multiple version program packages in corresponding download directories respectively.

[0154] In a possible implementation, the method further includes:

[0155] Installation module, used to install the combined API interface package that the package depends on;

[0156] A reading module, used to use the combined API interface program package to read the associated version of the program package that the program to be written depends on;

[0157] The download module is used to download an API interface program package that matches the version if the combined API interface program package does not match the associated version.

[0158] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0159] Figure 5 1 is a block diagram of an electronic device 500 for a method for processing a program package according to an exemplary embodiment. For example, the electronic device 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0160] Reference Figure 5 , the electronic device 500 may include one or more of the following components: a processing component 502 , a memory 504 , a power component 506 , a multimedia component 508 , an audio component 510 , an input / output (I / O) interface 512 , a sensor component 514 , and a communication component 516 .

[0161] The processing component 502 generally controls the overall operation of the electronic device 500, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 502 may include one or more modules to facilitate the interaction between the processing component 502 and other components. For example, the processing component 502 may include a multimedia module to facilitate the interaction between the multimedia component 508 and the processing component 502.

[0162] The memory 504 is configured to store various types of data to support operations on the electronic device 500. Examples of such data include instructions for any application or method operating on the electronic device 500, contact data, phone book data, messages, pictures, videos, etc. The memory 504 may be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, optical disk, or graphene memory.

[0163] The power supply component 506 provides power to the various components of the electronic device 500. The power supply component 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 500.

[0164] The multimedia component 508 includes a screen that provides an output interface between the electronic device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front camera and / or a rear camera. When the electronic device 500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0165] The audio component 510 is configured to output and / or input audio signals. For example, the audio component 510 includes a microphone (MIC), and when the electronic device 500 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 504 or sent via the communication component 516. In some embodiments, the audio component 510 also includes a speaker for outputting an audio signal.

[0166] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0167] The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the electronic device 500. For example, the sensor assembly 514 can detect the open / closed state of the electronic device 500, the relative positioning of the components, such as the display and keypad of the electronic device 500, and the sensor assembly 514 can also detect the position change of the electronic device 500 or the components of the electronic device 500, the presence or absence of contact between the user and the electronic device 500, the orientation or acceleration / deceleration of the device 500, and the temperature change of the electronic device 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor assembly 514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0168] The communication component 516 is configured to facilitate wired or wireless communication between the electronic device 500 and other devices. The electronic device 500 can access a wireless network based on a communication standard, such as WiFi, a carrier network (such as 2G, 3G, 4G or 5G), or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0169] In an exemplary embodiment, the electronic device 500 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0170] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory 504 including instructions, and the above instructions can be executed by the processor 520 of the electronic device 500 to perform the above method. For example, the computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0171] In an exemplary embodiment, a computer program product is further provided. The computer program product includes instructions. The instructions can be executed by the processor 520 of the electronic device 500 to complete the above method.

[0172] It should be noted that the above-mentioned devices, electronic devices, computer-readable storage media, computer program products, etc. may also include other implementation methods according to the description of the method embodiments. The specific implementation methods can refer to the description of the relevant method embodiments, which will not be described one by one here.

[0173] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered exemplary only, and the true scope and spirit of the present disclosure are indicated by the claims.

[0174] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. A method for processing a program package, characterized in that: include: Get the associated version of the package that the program to be written depends on; Determine a download directory matching the associated version from download directories of multiple version packages; wherein the multiple version packages are files for program package writing, which are compiled and generated using compilation tools of different versions, and the program package writing file is generated in a manner including: obtaining grammar writing rules of multiple versions; when a sub-rule in the grammar writing rule fails to apply to the multiple versions, using a replacement rule of the sub-rule to write a program package writing file, wherein the replacement rule applies to the multiple versions; The program package under the matching download directory is copied to the first dependent directory of the program, so as to reference the program package when compiling the program.

2. The method according to claim 1, characterized in that The method of generating the multiple version packages includes: The program package writing files are named with different version identifiers to obtain the program package writing files with different version identifiers; Obtaining a compilation tool that matches the version identifier; The corresponding program package writing files are compiled using the compilation tools to obtain multiple version program packages.

3. The method according to claim 2, characterized in that The method for generating the program package writing file includes: Get multiple versions of grammar writing rules; When the sub-rules in the grammar writing rules fail to apply to the multiple versions, conditional statements are used to write program statements for each of the multiple versions respectively to obtain a program package writing file.

4. The method according to claim 2, characterized in that: The corresponding program package writing files are compiled by using the compilation tool to obtain multiple version packages, including: Rename the version identifier of the program package writing file to the default file identifier in the second dependent directory of the compilation tool; Rename the name identifier of the compilation tool to a default tool identifier in the second dependency directory; Paste the renamed package writing file and the renamed compilation tool into the corresponding second dependency directory respectively; The renamed program package writing files are compiled using the renamed compilation tools to obtain multiple versions of program packages.

5. The method according to claim 4, characterized in that After the renamed program package writing files are compiled by using the renamed compilation tool to obtain multiple version program packages, the method further includes: The multiple version program packages are stored in corresponding download directories respectively.

6. The method according to any one of claims 1 to 5, characterized in that Before obtaining the associated version of the program package that the program to be written depends on, the following step is also included: The combined API interface package that the installation package depends on; Using the combined API interface program package, read the associated version of the program package that the program to be written depends on; If the combined API interface program package does not match the associated version, an API interface program package matching the version is downloaded.

7. A program package processing device, characterized in that: include: An acquisition module is used to obtain the associated versions of the program packages that the program to be written depends on; A determination module is used to determine a download directory that matches the associated version from the download directories of multiple version packages; wherein the multiple version packages are files for program package writing, which are compiled and generated using compilation tools of different versions, and the determination module includes a naming submodule, which includes: a first acquisition unit, which is used to acquire grammar writing rules of multiple versions; a substitution unit, which is used to write a program package writing file using a substitution rule of the subrule when a subrule in the grammar writing rule fails to apply to the multiple versions, wherein the substitution rule is applicable to the multiple versions; The copy module is used to copy the program package under the matching download directory to the first dependent directory of the program, so as to reference the program package when compiling the program.

8. The device according to claim 7, characterized in that The determination module comprises: A naming submodule is used to name the program package writing files with different version identifiers to obtain the program package writing files with different version identifiers; An acquisition submodule is used to acquire a compilation tool that matches the version identifier; The compiling submodule is used to compile the corresponding program package writing files using the compiling tool to obtain multiple version program packages.

9. The device according to claim 8, characterized in that The naming submodule includes: A second acquisition unit is used to acquire multiple versions of grammar writing rules; The writing unit is used to use conditional statements to write program statements of each version in the multiple versions respectively when the sub-rules in the grammar writing rules are not applicable to the multiple versions, so as to obtain a program package writing file.

10. The device according to claim 8, characterized in that The compilation submodule includes: A first renaming unit, used for renaming the version identifier of the program package writing file to a default file identifier in the second dependent directory of the compilation tool; A second renaming unit, configured to rename the name identifier of the compilation tool to a default tool identifier in the second dependency directory; A pasting unit, used to paste the renamed program package writing file and the renamed compilation tool into the corresponding second dependency directory respectively; The copying unit is used to compile the renamed program package writing files using the renamed compilation tool to obtain multiple versions of the program package.

11. The device according to claim 10, characterized in that Also includes: The storage submodule is used to store the multiple version program packages in corresponding download directories respectively.

12. The device according to any one of claims 7 to 11, characterized in that Also includes: Installation module, used to install the combined API interface package that the package depends on; A reading module, used to use the combined API interface program package to read the associated version of the program package that the program to be written depends on; The download module is used to download an API interface program package that matches the version if the combined API interface program package does not match the associated version.

13. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method for processing the program package according to any one of claims 1 to 6.

14. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method for processing the program package as claimed in any one of claims 1 to 6.

15. A computer program product, comprising instructions, characterized in that: When the instructions are executed by a processor of an electronic device, the electronic device is enabled to execute the method for processing a program package as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Dependent package version management method and device, equipment and storage medium

    CN111522577A