CN114661338A - Program package processing method and device, electronic equipment and storage medium - Google Patents

Program package processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114661338A
CN114661338A CN202210354067.XA CN202210354067A CN114661338A CN 114661338 A CN114661338 A CN 114661338A CN 202210354067 A CN202210354067 A CN 202210354067A CN 114661338 A CN114661338 A CN 114661338A
Authority
CN
China
Prior art keywords
program
package
version
compiling
program package
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210354067.XA
Other languages
Chinese (zh)
Inventor
胡富民
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202210354067.XA priority Critical patent/CN114661338A/en
Publication of CN114661338A publication Critical patent/CN114661338A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • G06F8/42Syntactic analysis

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The disclosure relates to a program package processing method and device, an electronic device and a storage medium. The method comprises the following steps: acquiring a relevant version of a program package on which a program to be written depends; determining a download directory matched with the associated version from download directories of a plurality of version program packages; and copying the program package under the matched download directory into a first dependent directory of the program so as to refer to the program package when the program is written. The method and the device for downloading the program package of the corresponding version can avoid manual downloading of the program package of the corresponding version according to the running environment, avoid possible errors in manual selection, and enable the downloading and installation process of a user to be smoother and more convenient.

Description

Program package processing method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a package, an electronic device, and a storage medium.
Background
With the development of computer technology, package (package) technology has emerged. The program package is formed by integrating multiple kinds of repeated function codes (API) by a developer. For example, some API is an implementation: blue background and white characters, and responding to the button of the clicking operation. The API may be added to the package. When a user develops a new program, the function of the API can be realized without repeatedly writing the code program of the API by downloading the program package and referencing the API in the program package at a specified position.
Vue is a front-end web page frame, a developer can integrate some function codes depending on Vue frame into a program package, and the program package can be used in other web page development using Vue frame to save development time. However, versions Vue are incompatible, for example: packages based on vue2.0 version do not run normally on vue3.0 version and vice versa. In the related art, corresponding packages are generated for Vue frameworks of different versions, and a user manually selects which version of package to download and install according to an operating environment. For the user, it may be inconvenient to make mistakes in manually downloading the installation package version according to the operating environment.
Disclosure of Invention
The disclosure provides a program package processing method and device, an electronic device and a storage medium. At least solving the problem that manual downloading of the installation program package in the related art is inconvenient to make mistakes. The technical scheme of the disclosure is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a method for processing a package, including:
acquiring a relevant version of a program package on which a program to be written depends;
determining a download directory matched with the associated version from download directories of a plurality of version program packages;
and copying the program package under the matched downloading catalogue to a first dependent catalogue of the program so as to refer to the program package when the program is written.
In a possible implementation manner, the generating manner of the multiple version packages includes:
naming the program package compiling file by using different version identifications to obtain the program package compiling file with different version identifications;
acquiring a compiling tool matched with the version identification;
and compiling the corresponding program package compiling files by using the compiling tool respectively to obtain a plurality of version program packages.
In a possible implementation manner, the generation manner of the package writing file includes:
obtaining grammar writing rules of a plurality of versions;
when a sub-rule in the grammar writing rule fails to apply to the plurality of versions, writing a package writing file with an alternative rule of the sub-rule, wherein the alternative rule applies to the plurality of versions.
In a possible implementation manner, the generation manner of the package writing file includes:
obtaining grammar writing rules of a plurality of versions;
and when the sub-rules in the grammar writing rule are not suitable for the plurality of versions, respectively writing the program statements of each version in the plurality of versions by using the conditional statements to obtain a program package writing file.
In a possible implementation manner, the compiling the corresponding program package compiling files by using the compiling tool respectively to obtain a plurality of version program packages includes:
renaming the version identification of the program package writing file as a default file identification in a second dependent directory of the compiling tool;
renaming the name identifier of the compiling tool as a default tool identifier in the second dependent directory;
pasting the renamed program package compiling file and the renamed compiling tool into corresponding second dependent directories respectively;
compiling the renamed program package compiling file by using the renamed compiling tool respectively to obtain program packages of multiple versions.
In a possible implementation manner, after compiling the renamed package writing file by using the renamed compiling tool respectively to obtain a plurality of version packages, the method further includes:
and respectively storing the plurality of version program packages into corresponding downloading catalogues.
In a possible implementation manner, before the obtaining an associated version of a package on which a program to be written depends, the method further includes:
installing a combined API interface program package which the program package depends on;
reading the associated version of the program package which is depended by the program to be written by utilizing the combined API program package;
and if the combined API program package is not matched with the associated version, downloading the API program package matched with the version.
According to a second aspect of the embodiments of the present disclosure, there is provided a processing apparatus of a package, including:
the obtaining module is used for obtaining the associated version of the program package on which the program to be written depends;
the determining module is used for determining a download directory matched with the associated version from the download directories of the program packages of the multiple versions;
and the copying module is used for copying the program package under the matched downloading catalogue to a first dependent catalogue of the program so as to refer to the program package when the program is written.
In one possible implementation, the determining module includes:
the naming submodule is used for naming the program package compiling file by using different version identifications to obtain the program package compiling file with different version identifications;
the obtaining sub-module is used for obtaining a compiling tool matched with the version identification;
and the compiling submodule is used for compiling the corresponding program package compiling files by using the compiling tool respectively to obtain a plurality of version program packages.
In one possible implementation, the naming sub-module includes:
a first obtaining unit configured to obtain a plurality of versions of a grammar authoring rule;
and the replacing unit is used for writing the program package writing file by using the replacing rule of the sub-rule when the sub-rule in the grammar writing rule is not suitable for the plurality of versions, wherein the replacing rule is suitable for the plurality of versions.
In one possible implementation, the naming sub-module includes:
a second obtaining unit configured to obtain a plurality of versions of the grammar authoring rule;
and the writing unit is used for writing the program statement of each version in the plurality of versions respectively by using the conditional statement to obtain the program package writing file when the sub-rule in the grammar writing rule is not suitable for the plurality of versions.
In one possible implementation, the compiling submodule includes:
the first renaming unit is used for renaming the version identifier of the program package writing file to be a default file identifier in a second dependent directory of the compiling tool;
a second renaming unit, configured to rename the name identifier of the compiling tool to a default tool identifier in the second dependent directory;
the pasting unit is used for pasting the renamed program package compiling file and the renamed compiling tool into the corresponding second dependent directories respectively;
and the copying unit is used for compiling the renamed program package compiling file by using the renamed compiling tool respectively to obtain program packages of multiple versions.
In one possible implementation manner, the method further includes:
and the storage submodule is used for respectively storing the plurality of version program packages into corresponding download directories.
In one possible implementation manner, the method further includes:
the installation module is used for installing the combined API program package depended by the program package;
the reading module is used for reading the associated version of the program package which is depended by the program to be written by utilizing the combined API program package;
and the downloading module is used for downloading the API program package matched with the version if the combined API program package is not matched with the associated version.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement the processing method of the program package according to any one of the embodiments of the present disclosure.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a computer-readable storage medium, wherein instructions of the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the processing method of the program package according to any one of the embodiments of the present disclosure.
According to a fifth aspect of the embodiments of the present disclosure, there is provided a computer program product, which includes instructions, and is characterized in that the instructions, when executed by a processor of an electronic device, enable the electronic device to execute the processing method of the program package according to any one of the embodiments of the present disclosure.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects: according to the program package loading method and device, the program package relevant version depended on by the program to be written is automatically obtained, the program package matched with the relevant version is determined from the downloading catalogues of the program packages with the multiple versions, and the program package is copied to the first dependent catalog of the program to be written for the program to refer. The user can avoid downloading the program package of the corresponding version manually according to the operating environment, thereby avoiding possible mistakes in manual selection and ensuring that the downloading and installation process of the user is smoother and more convenient.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
Fig. 1 is a flow chart illustrating a method of processing a package according to an exemplary embodiment.
FIG. 2 is an interface diagram illustrating a package write file according to an exemplary embodiment.
FIG. 3 is a flow diagram illustrating a method of processing a package in accordance with an exemplary embodiment.
Fig. 4 is a block diagram illustrating a processing device of a package according to an example embodiment.
FIG. 5 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood by those of ordinary skill in the art, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in sequences other than those illustrated or otherwise described herein. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
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 for presentation, analyzed data, etc.) referred to in the present disclosure are both information and data that are authorized by the user or sufficiently authorized by various parties.
Fig. 1 is a flowchart illustrating a processing method of a package according to an exemplary embodiment, which is used in a terminal, as shown in fig. 1, and includes the following steps.
Step S101, acquiring the associated version of the program package which the program to be written depends on.
In the embodiment of the present disclosure, the program to be written may include a program matched with a specific development project. The packages on which the program depends may include packages that are referenced when the program is written. For example: vue is a JavaScript framework that allows some of the Vue dependent framework function code to be integrated into a package during the development of a web page. The program package can be referred to in the development process of other web pages (programs to be written) using the Vue frame, so as to achieve the aim of saving development time. In one example, the associated version of the dependent package may be determined by reading a package json file in a code repository where the program to be written is located.
Step S103, determining a download directory matched with the associated version from the download directories of the program packages of the plurality of versions.
In the embodiment of the present disclosure, the versions of the packages may not be compatible with each other, for example, the web page based on the vue2.x framework cannot use the package developed based on the vue3.x framework. Therefore, the embodiment of the present disclosure may download a plurality of version programs to the respective download directories in advance. For example: and downloading the program package of the Vue2.x version to the lib/vue2 directory, and downloading the program package of the Vue3.x version to the lib/vue3 directory. When the associated version of the program package on which the written program depends is acquired as the vue2.x version, the download directory matched with the associated version is the lib/vue2 directory. It should be noted that the multi-version package configuration is not limited to the above examples, for example, multiple versions of the read. js framework and multiple versions of the angular. js framework, and other modifications are possible for those skilled in the art based on the teachings of the technical spirit of the present application, but all that can be achieved with the same or similar functions and effects as the present application are covered by the protection scope of the present application.
In the embodiment of the present disclosure, the multiple version program packages may include compiled files generated by the program package compiled files of the same version in the compiling tools of different versions, or may include compiled files generated by the program package compiled files of different versions in the compiling tools respectively corresponding to the program package compiled files. When a plurality of versions of program packages generate compiled files in compiling tools of different versions for compiling files by the same program package, developers of the program packages can only compile and maintain the compiled files of one version, and manpower and material resources are saved.
Step S105, copying the program package under the matched download directory to a first dependent directory of the program, so as to refer to the program package when the program is written.
In an embodiment of the present disclosure, the first dependent directory includes a reference directory of the package, for example: program statements: and import H from 'H' indicates that the front-end program module enters the directory H to read the program package H, and the read content is used for programming the program. In one example, a default first dependent directory of the main program in the package specification, such as an index under lib/directory, js file, may also be referenced as the first dependent directory of the program. When the program package is copied into the first dependency directory, the front-end program module enters the first dependency directory, and reads the program package under the first dependency directory, so that the content of the program package is referred.
In the embodiment of the present disclosure, the method in step S101 to step S103 is automatically executed, and may be written in a script file. When the program package is downloaded and installed from the program package management tool (such as npm or yarn), the script file is automatically executed, the version program package depended by the program to be written is matched into the corresponding download directory, and the program package is copied from the download directory into the first dependency directory. In one example, the script file, such as a poststatus, may utilize: and program statements of script/install.js and postscript/install.js indicate that the postscript file is automatically executed after the program package is installed.
According to the program package loading method and device, the program package relevant version depended on by the program to be written is automatically obtained, the program package matched with the relevant version is determined from the downloading catalogues of the program packages with the multiple versions, and the program package is copied to the first dependent catalog of the program to be written for the program to refer. The user can avoid downloading the program package of the corresponding version manually according to the operating environment, thereby avoiding possible mistakes in manual selection and ensuring that the downloading and installation process of the user is smoother and more convenient.
In a possible implementation manner, the generating manner of the multiple version packages includes:
naming the program package compiling file by using different version identifications to obtain the program package compiling file with different version identifications;
acquiring a compiling tool matched with the version identification;
and compiling the corresponding program package compiling files by using the compiling tool respectively to obtain a plurality of version program packages.
In the embodiment of the present disclosure, a package writing file may be newly created, and the package writing file is named with different version identifiers, such as vue2 and vue3. It is also possible to download an existing package authoring file from the package management tool and to author the package on the basis of the existing package authoring file, for example by executing in the command line: yann add vue2@ npm: vue @2.6.14, which effectively functions to create a directory vue2 under the root directory node _ modules of the code repository, download vue a compressed package of the package 2.6.14 version from the package management tool, and decompress the compressed package into the directory vue2.
Obtaining a compiling tool matched with the version identifier, for example, a compiling tool corresponding to the vue2 version is vue-loader15, a compiling tool corresponding to the vue3 version is vue-loader16, and compiling corresponding packages to write files by using the compiling tools, for example: the program written files are compiled by using vue-loader15 to compile vue2, and the program written files are compiled by using vue-loader16 to compile vue3, so that a plurality of version packages are obtained.
In the embodiment of the disclosure, the frame version on which the program to be written depends needs to be consistent with the frame version on which the program package depends, and one of the important factors influencing whether the version can be normally used is the compiling environment of the program package. According to the embodiment of the disclosure, multiple versions of the program packages can be obtained by writing the files by using the same program package and compiling by adopting different compiling tools. Due to the fact that the same program package compiling file is adopted, compared with the program package compiling files of multiple versions in the aspects of development and maintenance, the development efficiency of the program package is greatly improved, and the maintenance difficulty is reduced.
In a possible implementation manner, the generation manner of the package writing file includes:
obtaining grammar writing rules of a plurality of versions;
when a sub-rule in the grammar writing rule fails to apply to the plurality of versions, writing a package writing file with an alternative rule of the sub-rule, wherein the alternative rule applies to the plurality of versions.
In the embodiment of the present disclosure, the syntax writing rule may include syntax writing rules of a programming language, sub-rules of syntax writing rules of different versions may be different, for example, a function component v-model, in a 2.x version, using v-model is equivalent to binding value prop and triggering an input event, if it is desired to change prop or event name, a model option needs to be added in a child component; in version 3.x, the functional component v-model is equivalent to passing the model value prop and receiving the thrown update model value event. The sub-rules applicable to version 2.x do not apply to version 3.x, so alternative rules that apply to both version 2.x and version 3.x may be chosen, e.g. all applicable. sync parts in the codebase replace them with v-models, for all v-models without parameters, rep and event are renamed model value and update, respectively: model value. In the following examples: after registering a component 2.x, the component name is passed as a string to the first parameter of the rendering function, which can work properly. In 3.x, since the VNode is context-free, the registered component cannot be implicitly looked up with the string ID. An imported resolveComponent method needs to be used. The following alternative rules may be employed: the entire application is defaulted to vue3 behavior, turning on only certain compatibility features.
In the embodiment of the disclosure, by using the substitution rule instead of the sub-rule which cannot be applied to all versions, the program files applicable to all versions can be written in the codes of the program package writing files, and the program packages of different versions are obtained by compiling through different compiling tools.
In a possible implementation manner, the generation manner of the package writing file includes:
obtaining grammar writing rules of a plurality of versions;
and when the sub-rules in the grammar writing rule are not suitable for the plurality of versions, respectively writing the program statements of each version in the plurality of versions by using the condition statements to obtain a program package writing file.
In the embodiment of the present disclosure, when a sub rule in a grammar writing rule is not applicable to all versions, a program statement of each of multiple versions may be written separately, and a judgment is performed by using a conditional statement, for example, an if statement, a case statement, an isVue3 statement, and the like. For example, a module is written using a 2.x version of program code, a module is written using a 3.x version of program code, the version on which the currently developed project depends is determined using isVue3, and the corresponding execution module is selected. In one example, the above embodiments may also be used in combination, for example: when a sub-rule in the grammar writing rule fails to apply to the plurality of versions, a package writing file is first written using an alternative rule of the sub-rule. And under the condition that the sub-rules do not have the substitute rules, respectively writing the program statements of each version of the multiple versions by using the conditional statements to obtain a program package writing file.
Referring to table 1, the left column in table 1 lists syntax differences of different versions, and the right column in table 1 lists compatible schemes.
Figure BDA0003582075230000091
Figure BDA0003582075230000101
In the embodiment of the disclosure, the program statements of each of the multiple versions are written respectively by using the conditional statements to obtain the program package writing file, the program files suitable for all versions can be written in a set of codes of the program package writing file, and the program packages of different versions are obtained by compiling through different compiling tools.
FIG. 2 is an interface diagram illustrating a package write file according to an exemplary embodiment. Referring to fig. 2, the compiling the corresponding program package writing files by using the compiling tool respectively to obtain a plurality of version program packages includes:
renaming the version identification of the program package writing file as a default file identification in a second dependent directory of the compiling tool;
renaming the name identifier of the compiling tool as a default tool identifier in the second dependent directory;
pasting the renamed program package compiling file and the renamed compiling tool into corresponding second dependent directories respectively;
compiling the renamed program package compiling file by using the renamed compiling tool respectively to obtain program packages of multiple versions.
In an embodiment of the present disclosure, the second dependency directory may include a location of the package when the compiling tool performs compiling. For example, in the compilation tool vue-loader15, the dependency directory can be expressed as: import Vue from 'Vue'. In the compiler tool vue-loader16, the dependency directory can also be expressed as: import Vue from 'Vue'. Dependency directories are generally not modifiable in a compilation tool. Referring to FIG. 2, when compiling vue2 version, vue2 needs to be renamed vue, where vue is the second dependent directory default file identification for the compilation tool of vue2. At the same time, the compiler tool vue-loader15 needs to be named vue-loader. And respectively pasting the renamed package writing file and the renamed compiling tool to the corresponding second dependent directory, for example, compiling vue2 version package writing file, pasting vue2 (namely vue) after renaming from the original directory Lib/vue2 into Lib/vue, and pasting vue-loader15(vue-loader) after renaming from the original directory Lib/vue-loader15 into Lib/vue-loader. A compilation operation is performed. The same operations as for version vue2 may be repeated while compiling the other versions. Multiple versions of the package are obtained.
According to the embodiment of the disclosure, the compiling file of the program package and the corresponding compiling tool are renamed and pasted into the second dependent directory of the compiling tool, so that the program packages of different versions can be compiled respectively, and the program packages of multiple versions are generated.
In a possible implementation manner, after compiling the renamed package writing file by using the renamed compiling tool respectively to obtain a plurality of version packages, the method further includes:
and respectively storing the plurality of version program packages into corresponding downloading catalogues.
In the embodiment of the present disclosure, referring to fig. 2, multiple versions of packages may be generated in the second dependent directory vue, and in an example, after a package of one version is generated, the package is stored in a corresponding download directory, for example, a package compiling file of the version vue2 is compiled to generate an index. In another example, multiple versions of the package may be generated at vue at once and stored in the corresponding download directory.
According to the embodiment of the disclosure, the program packages of multiple versions are stored in the corresponding download directories, so that the program packages are guided to the version of the program package matched with the version of the program to be written in the installation process, and the installation and use of the program packages are ensured.
Before the obtaining of the associated version of the program package on which the program to be written depends, the method further includes:
installing a combined API interface program package which the program package depends on;
reading the associated version of the program package which is depended by the program to be written by utilizing the combined API program package;
and if the combined API program package is not matched with the associated version, downloading the API program package matched with the version.
In embodiments of the present disclosure, the modular API interface package may be included within the package with the associated function code being closely spaced in location. The combined API interface package is, for example: vue-demi. vue-dem is based on vue3.x version of the framework protocol and is therefore suitable for vue3.x version of the program to be developed. In the combined API interface package vue-demi, the associated version of the package on which the program to be written depends can be read using the command statement import { defineComponent } from 'vue-demi', and the API interface package matching the associated version can be determined. For example, the above statement is equivalent to import { defineComponent } from '@ vue/composition-api' in vue2.x environment; equivalent to import { defineComponent } from 'vue' in vue3.x environment. If the current runtime environment is read to be the vue3.x environment, then no further API interface packages need to be downloaded, since the combined API interface package vue-demi is itself applicable to the vue3.x environment. If the current runtime environment is read to be a vue2.x environment, then the API interface package matching the vue2.x environment needs to be downloaded.
According to the method and the device for installing the combined API program package, the combined API program package can be used as the dependent file of the program package of the associated version in the embodiment of the disclosure, so that the combined API program package is installed before the program package of the associated version is installed, development and writing of some API functions can be avoided, the size of the program package of the associated version is reduced, and the writing difficulty of the program package of the associated version is reduced.
FIG. 3 is a flow diagram illustrating a method of processing a package in accordance with an exemplary embodiment. Referring to fig. 3, the method includes:
in step S301, a combined API package to which the package depends is installed.
In the embodiment of the disclosure, the combined API interface package depended on by the associated version package is declared in the associated version package, so that the combined API interface package depended on by the associated version package is downloaded and installed first before the associated version package is downloaded.
Step S303, reading the associated version of the program package which is depended by the program to be written by utilizing the combined API program package.
According to the embodiment of the disclosure, the command statement import { defineComponent } from 'vue-demi' can be used to read the associated version of the program package depended by the program to be written, and determine the API interface program package matched with the associated version.
Step S305, if the combined API interface program package is not matched with the associated version, downloading the API interface program package matched with the version.
Step S101, acquiring the associated version of the program package which the program to be written depends on.
In the embodiment of the present disclosure, after the API interface package is installed, the obtaining of the associated version of the package on which the program to be written depends is performed automatically, for example, the associated version of the package on which the program to be written depends may be determined by reading a package.
Step S103, determining a download directory matched with the associated version from the download directories of the program packages of the plurality of versions.
The embodiment of the disclosure can download a plurality of version programs to the respective download directories in advance. And downloading the packages of the Vue2.x version to the lib/vue2 directory, downloading the packages of the Vue3.x version to the lib/vue3 directory and determining the packages of which the associated versions are matched from the corresponding download directories.
Step S105, copying the program package under the matched download directory to a first dependent directory of the program, so as to refer to the program package when the program is written.
In the embodiment of the present disclosure, the first dependent directory includes a reference directory of the package, for example, an index, a js file under a lib/directory as the first dependent directory of the program. When the program package is copied into the first dependency directory, the front-end program module enters the first dependency directory, and reads the program package under the first dependency directory, so that the content of the program package is referred.
It should be understood that, although the steps in the flowchart are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in the figures may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of execution of the steps or stages is not necessarily sequential, but may be performed alternately or in alternation with other steps or at least some of the other steps or stages.
It is understood that the same/similar parts between the embodiments of the method described above in this specification can be referred to each other, and each embodiment focuses on the differences from the other embodiments, and it is sufficient that the relevant points are referred to the descriptions of the other method embodiments.
Fig. 4 is a block diagram illustrating a processing device of a package according to an example embodiment. Referring to fig. 4, the apparatus includes:
an obtaining module 401, configured to obtain an associated version of a program package on which a program to be written depends;
a determining module 402, configured to determine, from the download directories of the multiple version packages, a download directory that matches the associated version;
a copying module 403, configured to copy the program package under the matched download directory into a first dependent directory of the program, so as to refer to the program package when writing the program.
In one possible implementation, the determining module includes:
the naming submodule is used for naming the program package compiling file by using different version identifications to obtain the program package compiling file with different version identifications;
the obtaining sub-module is used for obtaining a compiling tool matched with the version identification;
and the compiling submodule is used for compiling the corresponding program package compiling files by using the compiling tool respectively to obtain a plurality of version program packages.
In one possible implementation, the naming sub-module includes:
a first obtaining unit configured to obtain a plurality of versions of a grammar authoring rule;
and the replacing unit is used for writing the program package writing file by using the replacing rule of the sub-rule when the sub-rule in the grammar writing rule is not suitable for the plurality of versions, wherein the replacing rule is suitable for the plurality of versions.
In one possible implementation, the naming sub-module includes:
a second obtaining unit configured to obtain a plurality of versions of the grammar authoring rule;
and the writing unit is used for writing the program statement of each version in the plurality of versions respectively by using the conditional statement to obtain the program package writing file when the sub-rule in the grammar writing rule is not suitable for the plurality of versions.
In one possible implementation, the compiling submodule includes:
the first renaming unit is used for renaming the version identifier of the program package writing file to be a default file identifier in a second dependent directory of the compiling tool;
a second renaming unit, configured to rename the name identifier of the compiling tool to a default tool identifier in the second dependent directory;
the pasting unit is used for pasting the renamed program package compiling file and the renamed compiling tool into the corresponding second dependent directories respectively;
and the copying unit is used for compiling the renamed program package compiling file by using the renamed compiling tool respectively to obtain program packages of multiple versions.
In one possible implementation manner, the method further includes:
and the storage submodule is used for respectively storing the plurality of version program packages into corresponding download directories.
In one possible implementation manner, the method further includes:
the installation module is used for installing the combined API program package depended by the program package;
the reading module is used for reading the associated version of the program package which is depended by the program to be written by utilizing the combined API program package;
and the downloading module is used for downloading the API program package matched with the version if the combined API program package is not matched with the associated version.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 5 is a block diagram of an electronic device 500 illustrating a method for processing a package according to an example embodiment. For example, the electronic device 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a gaming console, a tablet device, a medical device, a fitness device, a personal digital assistant, and so forth.
Referring to fig. 5, electronic device 500 may include one or more of the following components: processing component 502, memory 504, power component 506, multimedia component 508, audio component 510, interface to input/output (I/O) 512, sensor component 514, and communication component 516.
The processing component 502 generally controls overall operation of the electronic device 500, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 502 may include one or more processors 520 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 502 can include one or more modules that facilitate interaction between the processing component 502 and other components. For example, the processing component 502 can include a multimedia module to facilitate interaction between the multimedia component 508 and the processing component 502.
The memory 504 is configured to store various types of data to support operations at the electronic device 500. Examples of such data include instructions for any application or method operating on the electronic device 500, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 504 may be implemented by any type or combination of volatile or non-volatile storage devices, 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.
The power supply component 506 provides power to the various components of the electronic device 500. The power components 506 may include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power for the electronic device 500.
The multimedia component 508 includes a screen providing an output interface between the electronic device 500 and a 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 an input signal from a 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 boundary of a 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 facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the electronic device 500 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 510 is configured to output and/or input audio signals. For example, the audio component 510 includes a Microphone (MIC) configured to receive external audio signals when the electronic device 500 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 504 or transmitted via the communication component 516. In some embodiments, audio component 510 also includes a speaker for outputting audio signals.
The I/O interface 512 provides an interface between the processing component 502 and peripheral interface modules, which may be 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.
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 may detect an open/closed state of the electronic device 500, the relative positioning of components, such as a display and keypad of the electronic device 500, the sensor assembly 514 may detect a change in the position of the electronic device 500 or components of the electronic device 500, the presence or absence of user contact with the electronic device 500, orientation or acceleration/deceleration of the device 500, and a change in the temperature of the electronic device 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of a nearby object 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.
The communication component 516 is configured to facilitate wired or wireless communication between the electronic device 500 and other devices. The electronic device 500 may 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 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
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, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a computer-readable storage medium comprising instructions, such as the memory 504 comprising instructions, executable by the processor 520 of the electronic device 500 to perform the above-described method is also provided. For example, the computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
In an exemplary embodiment, a computer program product is also provided, which includes instructions executable by the processor 520 of the electronic device 500 to perform the above-described method.
It should be noted that the descriptions of the above-mentioned apparatus, the electronic device, the computer-readable storage medium, the computer program product, and the like according to the method embodiments may also include other embodiments, and specific implementations may refer to the descriptions of the related method embodiments, which are not described in detail herein.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements 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 (10)

1. A method for processing a package, comprising:
acquiring a relevant version of a program package on which a program to be written depends;
determining a download directory matched with the associated version from download directories of a plurality of version program packages;
and copying the program package under the matched downloading catalogue to a first dependent catalogue of the program so as to refer to the program package when the program is written.
2. The method of claim 1, wherein the plurality of version packages are generated in a manner that comprises:
naming the program package compiling file by using different version identifications to obtain the program package compiling file with different version identifications;
acquiring a compiling tool matched with the version identification;
and compiling the corresponding program package compiling files by using the compiling tool respectively to obtain a plurality of version program packages.
3. The method of claim 2, wherein the generation of the package authoring file comprises:
obtaining grammar writing rules of a plurality of versions;
when a sub-rule in the grammar writing rule fails to apply to the plurality of versions, writing a package writing file using a substitute rule of the sub-rule, wherein the substitute rule applies to the plurality of versions.
4. The method of claim 2, wherein the generation of the package authoring file comprises:
obtaining grammar writing rules of a plurality of versions;
and when the sub-rules in the grammar writing rule are not suitable for the plurality of versions, respectively writing the program statements of each version in the plurality of versions by using the conditional statements to obtain a program package writing file.
5. The method according to claim 2, wherein the compiling the corresponding program package compiling file by using the compiling tool respectively to obtain a plurality of version program packages comprises:
renaming the version identification of the program package writing file as a default file identification in a second dependent directory of the compiling tool;
renaming the name identifier of the compiling tool as a default tool identifier in the second dependent directory;
pasting the renamed program package compiling file and the renamed compiling tool into corresponding second dependent directories respectively;
compiling the renamed program package compiling file by using the renamed compiling tool respectively to obtain program packages of multiple versions.
6. The method according to claim 5, wherein after compiling the renamed package authoring file using the renamed compilation tool to obtain a plurality of version packages, further comprising:
and respectively storing the plurality of version program packages into corresponding downloading catalogues.
7. A package processing apparatus, comprising:
the obtaining module is used for obtaining the associated version of the program package on which the program to be written depends;
the determining module is used for determining a download directory matched with the associated version from the download directories of the program packages of the multiple versions;
and the copying module is used for copying the program package under the matched downloading catalogue to a first dependent catalogue of the program so as to refer to the program package when the program is written.
8. An electronic device, comprising:
a processor;
a memory for storing the processor-executable instructions;
wherein the processor is configured to execute the instructions to implement a method of processing a program package as claimed in any one of claims 1 to 6.
9. A computer-readable storage medium, wherein instructions in the computer-readable storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the processing method of the package according to any one of claims 1 to 6.
10. A computer program product comprising instructions which, when executed by a processor of an electronic device, enable the electronic device to carry out the method of processing a package according to any one of claims 1 to 6.
CN202210354067.XA 2022-04-06 2022-04-06 Program package processing method and device, electronic equipment and storage medium Pending CN114661338A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210354067.XA CN114661338A (en) 2022-04-06 2022-04-06 Program package processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210354067.XA CN114661338A (en) 2022-04-06 2022-04-06 Program package processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114661338A true CN114661338A (en) 2022-06-24

Family

ID=82035798

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210354067.XA Pending CN114661338A (en) 2022-04-06 2022-04-06 Program package processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114661338A (en)

Similar Documents

Publication Publication Date Title
CN109032606B (en) Native application compiling method and device and terminal
CN110308908B (en) Method and device for generating configuration file of application and displaying application page and storage medium
CN111736916A (en) Dynamic expansion method and device based on Java language, electronic equipment and storage medium
CN108170430B (en) Interface display method and system
CN111538502A (en) Installation package processing method and device, electronic equipment and storage medium
CN111913756B (en) Application program optimizing method, device and system, electronic equipment and storage medium
CN111221613B (en) Program calling method and device and storage medium
CN110851370B (en) Program testing method and device and storage medium
CN113010157A (en) Code generation method and device
CN112114814A (en) Compiled file determining method and device and application program generating method and device
CN114661338A (en) Program package processing method and device, electronic equipment and storage medium
CN114546436A (en) Micro front-end service updating method and device, electronic equipment and storage medium
CN112445484B (en) Register processing method and device, electronic equipment and storage medium
CN113590091A (en) Data processing method and device, electronic equipment and storage medium
CN109933357B (en) Application program upgrading method and device
CN107193622B (en) Code compiling processing method and device and terminal
CN109240646B (en) Method, device, equipment and storage medium for constructing application program development tool
CN113778440B (en) Data processing method and device, electronic equipment and storage medium
CN111273910B (en) Method, device and storage medium for acquiring resource number identifier
CN115098200B (en) Language switching method and device, electronic equipment and storage medium
CN111596949B (en) Method and device for developing application program
CN110795444B (en) DOM data updating method, page updating method and device
CN113885938A (en) Code modification method and device, electronic equipment and storage medium
CN113342355B (en) Code compiling method and device, electronic equipment and storage medium
CN112711420B (en) Code conversion method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination