CN114003269A - Component processing method and device, electronic equipment and storage medium - Google Patents

Component processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN114003269A
CN114003269A CN202111231929.1A CN202111231929A CN114003269A CN 114003269 A CN114003269 A CN 114003269A CN 202111231929 A CN202111231929 A CN 202111231929A CN 114003269 A CN114003269 A CN 114003269A
Authority
CN
China
Prior art keywords
component
project
dependent
components
attribute information
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
CN202111231929.1A
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.)
Guahao Net Hangzhou Technology Co Ltd
Original Assignee
Guahao Net Hangzhou 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 Guahao Net Hangzhou Technology Co Ltd filed Critical Guahao Net Hangzhou Technology Co Ltd
Priority to CN202111231929.1A priority Critical patent/CN114003269A/en
Publication of CN114003269A publication Critical patent/CN114003269A/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

Landscapes

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

Abstract

The embodiment of the invention discloses a component processing method, a device, electronic equipment and a storage medium, wherein the method comprises the following steps: responding to a pre-written component processing instruction, and acquiring at least two project components of a target project; extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result; the member attribute information comprises an identifier of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process; and determining a component to be processed according to the identifier of the dependent component in the matching result, updating member attribute information corresponding to the component to be processed, and installing the dependent component based on the updated member attribute information. According to the technical scheme of the embodiment of the invention, the repeated detection is added in the process of calling and installing the component, the occupation of the project file on the storage space is reduced, and the performance of the project related application is improved.

Description

Component processing method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a component processing method and device, electronic equipment and a storage medium.
Background
At present, each part of a front-end project can be developed in a componentized form, and based on the development, the project can depend on a corresponding component to realize a specific function in the stages of development, operation and the like, it can be understood that the front-end project and the loaded component form a dependency relationship.
In the prior art, while a dependency relationship exists between a project and a loaded component, a dependency relationship may also exist between different loaded components, for example, a component loaded by a project needs to be supported by a specific third-party component to realize a specific function. However, when multiple components all depend on a specific third-party component and there are different requirements for the third-party component by the multiple components, the project installs the third-party component multiple times according to the requirements, so that the finally generated project file is large in volume.
Therefore, in the solutions provided by the related technologies, the front-end project often has an excessively large project file due to multiple installations of the same component, and meanwhile, the component is loaded multiple times during the running process of the project, which reduces the performance of the project-related application.
Disclosure of Invention
The invention provides a component processing method, a component processing device, electronic equipment and a storage medium, wherein the repeated detection is added in the component calling and installing process, the occupation of a project file on a storage space is reduced, and the performance of project related application is improved.
In a first aspect, an embodiment of the present invention provides a component processing method, where the method includes:
responding to a pre-written component processing instruction, and acquiring at least two project components of a target project;
extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result; the member attribute information comprises an identifier of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process;
and determining a component to be processed according to the identifier of the dependent component in the matching result, updating member attribute information corresponding to the component to be processed, and installing the dependent component based on the updated member attribute information.
In a second aspect, an embodiment of the present invention further provides a component processing apparatus, where the apparatus includes:
the project component acquisition module is used for responding to a pre-written component processing instruction and acquiring at least two project components of a target project;
the matching module is used for extracting the member attribute information corresponding to each project component and matching the member attribute information to obtain a matching result; the member attribute information comprises an identifier of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process;
and the processing module is used for determining the components to be processed according to the identifiers of the dependent components in the matching result, updating the member attribute information corresponding to the components to be processed, and installing the dependent components based on the updated member attribute information.
In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the component processing method according to any of the embodiments of the present invention.
In a fourth aspect, the present invention further provides a storage medium containing computer-executable instructions, which when executed by a computer processor, are used for executing the component processing method according to any one of the embodiments of the present invention.
According to the technical scheme of the embodiment of the invention, at least two project components of a target project are obtained in response to a component processing instruction which is compiled in advance; extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result, so as to determine a common dependent component of the project components; further, determining the components to be processed according to the identifiers of the dependent components in the matching result, updating member attribute information corresponding to the components to be processed, and installing the dependent components based on the updated member attribute information. The repeatability detection is added in the process of calling and installing the component, the problem that the same component is installed for multiple times in a project is solved, the occupation of a project file on a storage space is reduced, furthermore, the same component does not need to be loaded for multiple times by a system, and the performance of related application of the project is improved.
Drawings
In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, a brief description is given below of the drawings used in describing the embodiments. It should be clear that the described figures are only views of some of the embodiments of the invention to be described, not all, and that for a person skilled in the art, other figures can be derived from these figures without inventive effort.
Fig. 1 is a schematic flow chart illustrating a component processing method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a component processing method according to a second embodiment of the present invention;
fig. 3 is a flowchart of a component processing method according to a third embodiment of the present invention;
fig. 4 is a block diagram of a component processing apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the invention and are not limiting of the invention. It should be further noted that, for the convenience of description, only some of the structures related to the present invention are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a component processing method according to an embodiment of the present invention, where the embodiment is applicable to a situation where a component on which a project depends is repeatedly detected when a project file is built, and the method may be executed by a component processing apparatus, where the apparatus may be implemented in the form of software and/or hardware, and the hardware may be an electronic device, such as a mobile terminal, a PC terminal, or a server.
As shown in fig. 1, the method specifically includes the following steps:
and S110, responding to a pre-written component processing instruction, and acquiring at least two project components of the target project.
In a front-end related project, different portions of the project may be developed in a componentized form. Illustratively, for a front-end web page project, a component may be developed for a navigation bar, a component may be developed for a text editing area, and corresponding components may be developed for a header and footer area, respectively, it may be understood that each independent, visual/interactive area on a page has a specific component corresponding thereto, each component is a part of the web page project, and the project in the development or running stage can realize specific functions based on the components. Those skilled in the art should understand that each component has independent HTML, css and js codes, and meanwhile, the components can be combined according to the requirement of a project to generate a new component.
Therefore, the related and dependent components in the project development and operation process can be used as project components, correspondingly, the project needing to determine the project components is a target project, and the instruction for determining and acquiring the project components of the target project is a component processing instruction.
In the actual application process, a script containing a component processing instruction can be written based on a specific programming language, and when the script is detected to run, the instruction in the script can be executed, so that the project component of the target project is obtained; corresponding controls can be developed according to the component processing instructions, for example, after script processing instructions are written in advance, corresponding component acquisition controls are developed based on the instructions, and an acquisition task of a specific project associated component can be triggered by clicking the controls by workers. Those skilled in the art should understand that there are many ways to trigger and respond to the component processing instruction, and the specific triggering and responding ways should be selected according to the actual situation, and the embodiments of the present disclosure are not limited specifically herein.
It should be noted that there may be one or more project components associated with a project, and meanwhile, different project components may also depend on other third-party components, it may be understood that development or operation of a target project depends on the project components, and meanwhile, implementation of a specific function by the project components depends on the third-party components, and the third-party components may be components in an existing component library or components edited by a developer according to specific requirements. In order to realize the functional support of the item component, the third-party component may be installed in the file corresponding to the target item for multiple times and run simultaneously, and therefore, in this embodiment, in order to perform the repetitive detection on the third-party component on which the item component depends, at least two components are obtained in response to the component processing instruction.
And S120, extracting the member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result.
When at least two project components of the acquired target project are processed, member attribute information corresponding to each project component needs to be extracted first. Specifically, the project component may be stored in a specific server, and a specific file is generated to describe information related to each project component associated with the target project, for example, the generated file may record an identifier and a version number of each component associated with the target project and stored in the server, and further, for each project component, information about a dependency relationship between the component itself and another third-party component may also be recorded in the file, for example, a component identified as a may implement a specific function depending on a third-party component identified as B.
Based on this, in the present embodiment, the information describing the association relationship between the component itself and other third-party components is the member attribute information of the project component, and the third-party component on which the project component depends is the dependent component. It can be understood that the dependent component is a component called by the corresponding project component in the development and/or operation process, and at least the identifier of the dependent component is included in the member attribute information corresponding to each project component.
In this embodiment, after the member attribute identifiers corresponding to the item components are extracted, in order to determine whether different item components are associated with the same dependent component, matching may be performed on the member attribute information. It can be understood that, since the member attribute information includes the identification of the dependent component, in the matching result, the identification of the dependent component is also included, and the matched dependent component is the third-party component commonly associated with at least two item components.
It should be noted that although the dependent component commonly associated with at least two project components can be determined through the matching result, different requirements may exist for the dependent component by different project components. Illustratively, the component identified as a also requires support of a dependent component identified as B in version 1.0.0 in order to implement a particular function, and the component identified as C also requires support of a dependent component identified as B in version 2.0.0 in order to implement a corresponding function. Therefore, the matching result obtained based on the attribute information of each member may further include requirement information of the project component on the dependent component.
S130, determining the components to be processed according to the identification of the dependent components in the matching result, updating member attribute information corresponding to the components to be processed, and installing the dependent components based on the updated member attribute information.
In this embodiment, according to the identifier of the dependent component in the matching result, at least two item components associated with the dependent component may be determined, and in order to implement processing on the repeatable component, the determined at least two item components may be used as components to be processed. It is to be understood that the pending component is an item component that is associated with the same identification dependency component as other item components, where the other item components may be one or more.
In this embodiment, because the project needs to be installed according to the content recorded in the member attribute information when calling the dependent component required by the project component in the development or operation process, in order to avoid installing the dependent component with the same identifier in the project file for multiple times, after determining the component to be processed in at least two project components, the member attribute information of the component to be processed needs to be updated.
Specifically, a specific version may be screened from a plurality of different versions of the dependent component based on a preset screening rule, and the member attribute information corresponding to the item component other than the dependent component associated with the version may be replaced based on the screened version information. And automatically determining the dependent components compatible with the project components based on a preset determination rule, and replacing the member attribute information corresponding to all the project components based on the version information of the determined dependent components.
Furthermore, in the stage of project development or operation, the system can install a certain version of dependent component in the project file based on the updated member attribute information of each project file, so that the problem that the final generated project file is too large due to the fact that the dependent component with the same identifier is installed for multiple times is avoided.
According to the technical scheme of the embodiment, at least two project components of a target project are acquired in response to a component processing instruction which is written in advance; extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result, so as to determine a common dependent component of the project components; further, determining the components to be processed according to the identifiers of the dependent components in the matching result, updating member attribute information corresponding to the components to be processed, and installing the dependent components based on the updated member attribute information. The repeatability detection is added in the process of calling and installing the component, the problem that the same component is installed for multiple times in a project is solved, the occupation of a project file on a storage space is reduced, furthermore, the same component does not need to be loaded for multiple times by a system, and the performance of related application of the project is improved.
Example two
Fig. 2 is a flowchart illustrating a component processing method according to a second embodiment of the present invention, where on the basis of the foregoing embodiment, in response to a component processing instruction, a project dependent component set and/or a development dependent component set are determined by traversing a file directory corresponding to a target project, and then at least two project components are determined in the set; extracting and matching the dependent component identification and the version number in the member attribute information of each item component, thereby determining the repetitive dependent components associated with at least two item components; and finally, determining the repetitive dependency components of the specific version compatible with each project component based on the extracted version number, and replacing the version number in the corresponding member attribute information according to the version number of the repetitive dependency components of the version, so that the project file is prevented from being provided with the repetitive dependency components of multiple versions. The specific implementation manner can be referred to the technical scheme of the embodiment. The technical terms that are the same as or corresponding to the above embodiments are not repeated herein.
As shown in fig. 2, the method specifically includes the following steps:
s210, when the situation that the pre-written component processing script runs is detected, responding to a component processing instruction in the component processing script, and determining a file directory corresponding to the target project according to the component processing instruction.
In this embodiment, project components required for a project may be uploaded and stored in a server associated with a Node Package Manager (NPM). The NPM is a node.js package management and distribution tool, and has become an unofficial standard for publishing Node modules (packages).
Specifically, when the NPM server uploads a component corresponding to a storage-related function, a file directory corresponding to the item/component may be generated. For example, under a package directory corresponding to one component, all the individual components are stored in a folder form, and then a plurality of subfolders and files are created in each folder, for example, a src/directory storage component source code is created under a color-picker/directory, a reference to a component is provided outside a js file pair is created, and the like. And further, integrating and exporting all the components to obtain a complete component library, and finally modifying the configuration information related to the components and then publishing the modified configuration information to the NPM server. After the component is uploaded successfully, the front-end project can install the associated component through the npm install command.
In this embodiment, the file directory corresponding to the target item is determined according to the component processing instruction, and the instruction source may be a pre-written JavaScript-based script file. Those skilled in the art will appreciate that the language in which the script is written may be selected according to task requirements, and embodiments of the present disclosure are not specifically limited in this regard.
In this embodiment, for an NPM server storing a plurality of components, the file directory determined according to the component processing instruction is a directory of a node _ modules folder corresponding to the current item, and it should be understood by those skilled in the art that the node _ modules is a folder for storing the components after installing the node, and for example, tools such as webpack, gulp, grunt, and the like can be stored.
S220, traversing the file directory, determining a project dependent component set and/or a development dependent component set associated with the target project, and acquiring at least two project components according to the project dependent component set and/or the development dependent component set.
In this embodiment, after determining the file directory of the node _ modules corresponding to the item file according to the component processing instruction, in order to determine at least two item components corresponding to the target item, a file in which attribute information of member members of the item components is recorded is also determined, and therefore, the system needs to traverse the determined folder.
Specifically, for the NPM server, after the node _ modules folder path is introduced into the system, the folder path may be determined by an fs.existsync method in node.js, and when the determination result indicates that the folder path does not exist, traversal is terminated. And when the judgment result shows that the folder path exists, judging whether the file is a folder or a file by an fs. If the file is the folder, judging other files in the folder by repeating the method until the file recorded with the project component member attribute information is determined.
Optionally, traversing the file directory, and determining an item description file corresponding to the target item; and determining a project dependent component set and/or a development dependent component set in the project description file according to a component set confirmation instruction in the component processing script.
In this embodiment, for the NPM server, the file recorded with the item component member attribute information may be a packag. A package json file defines various components required for the project and configuration information of the project (such as a project name, a project version, a project license and other metadata), and there may be a package json file under a root directory of each project. JSON file can be considered a JSON object, each member of which is an item setting for the current item, as will be understood by those skilled in the art. In this embodiment, based on a package json file corresponding to a project, at least two project components on which the project depends and a dependent component associated with each project component can be determined.
The Json file also comprises a dependency field and a devdependences field, wherein the dependency field specifies a component on which the project runs, the devdependences field specifies a component on which the project develops, and it can be understood that a component set represented by the dependency field is a project dependent component set, and a component set represented by the devdependences field is a development dependent component set.
Illustratively, a "browse" may be included in the dependencies field: "-13.0.0" and "karma-browse": "5.0.1" indicating the latest version of 13.0.x (not less than 13.0.0 version) and the latest version of 5.0.x (not less than 5.0.1 version) of karma-browse component that need to be relied upon during the operation of the component. It will be appreciated that two of the components in the above example are dependent components of the project component corresponding to the package. Similarly, other dependent components can be determined in the devdependences field, and the embodiments of the present disclosure are not described herein again.
Therefore, in the process of traversing the file directory, keyword matching can be performed based on the file name "package.
When traversing the folder based on the method, if it is determined that the file is not a package json file, the determination may be continued for other files until a package json file including the item dependent component set and/or the development dependent component set is determined.
And S230, extracting the identification of the dependent component associated with each project component and the version number corresponding to the dependent component according to the information extraction instruction in the pre-written component processing script.
In this embodiment, the member attribute information may include an identifier of the dependent component, such as a name of the component, and the member attribute information may further include a version number corresponding to the dependent component. For example, version number 13.0.0 for the browse component and version number 5.0.1 for the karma-browse component in the above example. Therefore, based on the information extraction instruction in the pre-written component processing script, in addition to extracting the identification of the dependent component associated with the project component, the version number of each dependent component can be extracted. Specifically, the dependency field and the devdependency field may be parsed and extracted by using an fs.
S240, writing the extracted identifier of the dependent component and the version number corresponding to the dependent component into the target item description file, and determining the matching result of the member attribute information based on the target item description file.
In this embodiment, after parsing and extracting the identifier and version number of the dependent component associated with the project component, in order to determine the dependent component associated with the project components from the dependent components, the extracted information needs to be written into a new project description file. Specifically, when the component processing script runs and determines the target item, the system may automatically generate a repeat package json file corresponding to the target item, so as to write the extracted identifier and version number of the dependent component. It will be appreciated that the new project description file is the target project description file.
Furthermore, based on the target project description file, the identification of the dependent component associated with each project component is matched, the repetitive dependent component associated with at least two project components is determined, and the identification of the repetitive dependent component is used as the matching result.
In this embodiment, after the target item description file written with the dependent component identifier and the version number is obtained, the identifier of the dependent component may be matched based on the file, so as to determine the dependent component associated with the plurality of item components, and it can be understood that the determined dependent component is a repetitive dependent component to be installed by the system for multiple times.
Illustratively, for a project component browse, the component depends on a grunt component to realize the corresponding function, and for a project component karma-browse, the grunt component is also required to realize the corresponding function, so that the grunt component is a repetitive dependency component associated with two project components.
And S250, determining the item assembly associated with the repeated dependency assembly as the assembly to be processed according to the identification of the repeated dependency assembly in the matching result.
After the repeatability dependency components are determined, the components to be processed can be determined from the plurality of project components according to the corresponding relation between the repeatability dependency components and the project components. Continuing with the above example, when it is determined that the grunt component is a repetitive dependent component, the project components associated with the component browse and karma-browse are the pending components of the current project.
It can be understood that, if the to-be-processed components are not processed and the project file is directly constructed, the grunt components are installed according to the requirements of the two project components, that is, when the requirements of the two project components on the grunt components are inconsistent, the grunt components are installed in the project file for multiple times, so that the file volume of the finally generated project file is large.
And S260, carrying out consistency detection on the repeatability dependent components related to the components to be processed, updating member attribute information corresponding to the components to be processed according to the detection result, and installing the dependent components based on the updated member attribute information.
In this embodiment, after determining the repeatability dependent components of at least two components to be processed, consistency detection can be implemented by comparing the information of the requirement of each component to be processed on the repeatability dependent components, which is described in detail below.
Optionally, consistency detection is performed on the version numbers of the repetitive dependent components associated with the components to be processed, and when it is detected that the version numbers of the repetitive dependent components are not consistent, the version numbers of the repetitive dependent components associated with the components to be processed are updated based on compatibility between the repetitive dependent components and the components to be processed.
The version number of the repeatability dependent assemblies associated with each to-be-processed assembly represents the requirements of each to-be-processed assembly on the repeatability dependent assemblies, and through comparison of version number information, the repeatability dependent assemblies of which version or versions are required by each to-be-processed assembly can be determined to serve as supports for achieving specific functions, and differences among the version requirements can be determined, so that the repeatability dependent assemblies of specific versions which are all compatible with each to-be-processed assembly are screened or determined.
Continuing with the above example, when determining a grow component associated with both the project component browse and the project component karma-browse, it may also be determined that the minimum requirement for the grow component version by browse is version 0.4.1, and the minimum requirement for the grow component version by karma-browse is version 1.3.0. Based on a preset repeatability dependency component version screening rule, it can be determined that the 1.3.0 version of the grunt component is the repeatability dependency component which is fully compatible with each component to be processed, and further, the member attribute information of the browse component is modified, that is, the version number of the grunt component associated with the component is modified from 0.4.1 to 1.3.0. It is to be appreciated that only the 1.3.0 version of the grunt component need be installed in the project file, and that no other versions (e.g., 0.4.1 version) of the grunt component need be installed.
It should be noted that, in the actual application process, in addition to determining the final version number of the repetitive dependent component in an automatic manner, the final version number may be manually screened out from a plurality of version numbers of each member attribute information. It is understood that after determining the version requirement information of each to-be-processed component for the repetitive dependent component, each version number is displayed in a specific page, and a worker manually determines the repetitive dependent component of a specific version compatible with all the to-be-processed components. Further, according to the finally determined version number for the repetitive dependency component, in each member attribute information, member attribute information inconsistent with the finally determined version number is determined, and the version number in the inconsistent member attribute information is replaced based on the finally determined version number.
It should be further noted that, for the repeatedly dependent components, the finally determined version number compatible with each component to be processed may not belong to any current member attribute information. That is, after determining the version requirement information of each to-be-processed component for the repetitive dependent component, a version number that does not belong to any of the above version requirement information may be selected as the final version number in an automatic or manual manner, and the version number only needs to be compatible with each to-be-processed component without affecting normal development and operation of the project. Furthermore, the version number in the member attribute information of each component to be processed is replaced according to the final version number, namely, the version number of the repetitive dependent component associated with all the components to be processed is updated, and only the repetitive dependent component corresponding to the final version number is installed in the process of installing the component in the project file.
According to the technical scheme, in response to a component processing instruction, a project dependent component set and/or a development dependent component set are determined in a mode of traversing a file directory corresponding to a target project, and then at least two project components are determined in the set; extracting and matching the dependent component identification and the version number in the member attribute information of each item component, thereby determining the repetitive dependent components associated with at least two item components; and finally, determining the repetitive dependency components of the specific version compatible with each project component based on the extracted version number, and replacing the version number in the corresponding member attribute information according to the version number of the repetitive dependency components of the version, so that the project file is prevented from being provided with the repetitive dependency components of multiple versions.
EXAMPLE III
As an alternative embodiment of the foregoing embodiment, fig. 3 is a flowchart of a component processing method according to a third embodiment of the present invention. For clearly describing the technical solution of the present embodiment, the case that the application scenario is to perform repeatability detection on the component on which the project depends when the project file is built is taken as an example, but the application scenario is not limited to the above scenario and can be applied to various scenarios that require processing on the component required by the project.
Referring to fig. 3, when a pre-written component processing script runs, a target item and a file directory corresponding to the target item may be determined, and when it is determined that a path of the file directory exists by using the fs.existsync method in node.js, a node _ modules folder path may be introduced. Further, files in the node _ modules folder are traversed sequentially, the files in the folder are judged by an fs.statsync (dir). isdiretone () method in the node.js, if the files are judged to be the folder, the node _ modules folder is continuously traversed, and if the files are judged to be the folder, whether the file name is package.json is further confirmed. Json, when the file is determined to be the item description file package corresponding to the target item, the subsequent component processing procedure may be executed.
Continuing to refer to fig. 3, after the item description file is determined, extracting dependent component identifiers and version numbers represented by dependency fields and devDependencies fields in a package json file by an fs.readfilesync method in a node, writing the extracted information into an automatically generated repeat package.json file corresponding to the target item for consistency detection, specifically, determining repetitive dependent components associated with a plurality of item components by matching identifiers of dependent components associated with different item components, and taking the item components corresponding to the repetitive dependent components as components to be processed.
With continued reference to FIG. 3, after the repeatability dependent components are determined, version requirement information of different to-be-processed components for the repeatability dependent components can also be determined. When the version requirement information is different, a specific version number compatible with each component to be processed can be determined automatically or manually aiming at the repetitive dependent component, and further, the version number in the member attribute information of each component to be processed is replaced in a unified manner according to the determined specific version number. Based on the above, when the repeatability dependent component is installed in the project file, only the specific version of the component can be installed, and the repeatability dependent components of different versions are not required to be installed in the project file according to the original version requirement information of each component to be processed.
The beneficial effects of the above technical scheme are: the repeatability detection is added in the process of calling and installing the component, the problem that the same component is installed for multiple times in a project is solved, the occupation of a project file on a storage space is reduced, furthermore, the same component does not need to be loaded for multiple times by a system, and the performance of related application of the project is improved.
Example four
Fig. 4 is a block diagram of a component processing apparatus according to a fourth embodiment of the present invention, which is capable of executing a component processing method according to any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method. As shown in fig. 4, the apparatus specifically includes: an item component acquisition module 310, a matching module 320, and a processing module 330.
The item component acquiring module 310 is configured to acquire at least two item components of the target item in response to a pre-written component processing instruction.
The matching module 320 is configured to extract member attribute information corresponding to each item component, and match the member attribute information to obtain a matching result; the member attribute information comprises an identification of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process.
The processing module 330 is configured to determine a component to be processed according to the identifier of the dependent component in the matching result, and update the member attribute information corresponding to the component to be processed, so as to install the dependent component based on each updated member attribute information.
On the basis of the above technical solutions, the item component acquiring module 310 includes a file directory determining unit and an item component acquiring unit.
And the file directory determining unit is used for responding to the component processing instruction in the component processing script when the pre-written component processing script is detected to run, and determining the file directory corresponding to the target item according to the component processing instruction.
And the project component acquisition unit is used for traversing the file directory, determining a project dependent component set and/or a development dependent component set associated with the target project, and acquiring the at least two project components according to the project dependent component set and/or the development dependent component set.
Optionally, the item component obtaining unit is further configured to traverse the file directory, and determine an item description file corresponding to the target item; and determining the project dependent component set and/or the development dependent component set in the project description file according to a component set confirmation instruction in the component processing script.
On the basis of the above technical solutions, the member attribute information further includes a version number corresponding to the dependent component, and the matching module 320 includes a dependent component identifier extracting unit and a matching unit.
And the dependent component identification extracting unit is used for extracting the identification of the dependent component associated with each project component and the version number corresponding to the dependent component according to the information extracting instruction in the pre-written component processing script.
And the matching unit is used for writing the extracted identifier of the dependent component and the version number corresponding to the dependent component into a target item description file, and determining the matching result of the attribute information of each member based on the target item description file.
Optionally, the matching unit is further configured to match the identifier of the dependency component associated with each item component based on the target item description file, determine the repetitive dependency components associated with at least two item components, and use the identifier of the repetitive dependency component as the matching result.
On the basis of the above technical solutions, the processing module 330 includes a to-be-processed component determining unit and a consistency detecting unit.
And the to-be-processed component determining unit is used for determining the item component associated with the repeated dependency component as the to-be-processed component according to the identification of the repeated dependency component in the matching result.
And the consistency detection unit is used for carrying out consistency detection on the repeatability dependent assemblies associated with the assemblies to be processed and updating the member attribute information corresponding to the assemblies to be processed according to the detection result.
Optionally, the consistency detecting unit is further configured to perform consistency detection on the version numbers of the repetitive dependent components associated with the components to be processed, and when it is detected that the version numbers of the repetitive dependent components are not consistent, update the version numbers of the repetitive dependent components associated with the components to be processed based on compatibility between the repetitive dependent components and the components to be processed.
According to the technical scheme provided by the embodiment, at least two project components of a target project are acquired in response to a pre-written component processing instruction; extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result, so as to determine a common dependent component of the project components; further, determining the components to be processed according to the identifiers of the dependent components in the matching result, updating member attribute information corresponding to the components to be processed, and installing the dependent components based on the updated member attribute information. The repeatability detection is added in the process of calling and installing the component, the problem that the same component is installed for multiple times in a project is solved, the occupation of a project file on a storage space is reduced, furthermore, the same component does not need to be loaded for multiple times by a system, and the performance of related application of the project is improved.
The component processing device provided by the embodiment of the invention can execute the component processing method provided by any embodiment of the invention, and has corresponding functional modules and beneficial effects of the execution method.
It should be noted that, the units and modules included in the apparatus are merely divided according to functional logic, but are not limited to the above division as long as the corresponding functions can be implemented; in addition, specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the embodiment of the invention.
EXAMPLE five
Fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present invention. FIG. 5 illustrates a block diagram of an exemplary electronic device 40 suitable for use in implementing embodiments of the present invention. The electronic device 40 shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiment of the present invention.
As shown in fig. 5, electronic device 40 is embodied in the form of a general purpose computing device. The components of electronic device 40 may include, but are not limited to: one or more processors or processing units 401, a system memory 402, and a bus 403 that couples the various system components (including the system memory 402 and the processing unit 401).
Bus 403 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. By way of example, such architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, micro-channel architecture (MAC) bus, enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 40 typically includes a variety of computer system readable media. Such media may be any available media that is accessible by electronic device 40 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 402 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM)404 and/or cache memory 405. The electronic device 40 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 406 may be used to read from and write to non-removable, nonvolatile magnetic media (not shown in FIG. 5, commonly referred to as a "hard drive"). Although not shown in FIG. 5, a magnetic disk drive for reading from and writing to a removable, nonvolatile magnetic disk (e.g., a "floppy disk") and an optical disk drive for reading from or writing to a removable, nonvolatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 403 by one or more data media interfaces. Memory 402 may include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the invention.
A program/utility 408 having a set (at least one) of program modules 407 may be stored, for example, in memory 402, such program modules 407 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which examples or some combination thereof may comprise an implementation of a network environment. Program modules 407 generally perform the functions and/or methods of the described embodiments of the invention.
The electronic device 40 may also communicate with one or more external devices 409 (e.g., keyboard, pointing device, display 410, etc.), with one or more devices that enable a user to interact with the electronic device 40, and/or with any devices (e.g., network card, modem, etc.) that enable the electronic device 40 to communicate with one or more other computing devices. Such communication may be through input/output (I/O) interface 411. Also, the electronic device 40 may communicate with one or more networks (e.g., a Local Area Network (LAN), a Wide Area Network (WAN), and/or a public network, such as the internet) via the network adapter 412. As shown, the network adapter 412 communicates with the other modules of the electronic device 40 over the bus 403. It should be appreciated that although not shown in FIG. 5, other hardware and/or software modules may be used in conjunction with electronic device 40, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems, among others.
The processing unit 401 executes various functional applications and data processing, for example, implementing a component processing method provided by an embodiment of the present invention, by executing a program stored in the system memory 402.
EXAMPLE six
An embodiment of the present invention also provides a storage medium containing computer-executable instructions for performing a component processing method when executed by a computer processor.
The method comprises the following steps:
responding to a pre-written component processing instruction, and acquiring at least two project components of a target project;
extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result; the member attribute information comprises an identifier of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process;
and determining a component to be processed according to the identifier of the dependent component in the matching result, updating member attribute information corresponding to the component to be processed, and installing the dependent component based on the updated member attribute information.
Computer storage media for embodiments of the invention may employ any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
A computer readable signal medium may include a propagated data signal with computer readable item code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
The item code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer project code for carrying out operations for embodiments of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + + or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The project code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present invention and the technical principles employed. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, although the present invention has been described in greater detail by the above embodiments, the present invention is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims (10)

1. A component handling method, comprising:
responding to a pre-written component processing instruction, and acquiring at least two project components of a target project;
extracting member attribute information corresponding to each project component, and matching the member attribute information to obtain a matching result; the member attribute information comprises an identifier of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process;
and determining a component to be processed according to the identifier of the dependent component in the matching result, updating member attribute information corresponding to the component to be processed, and installing the dependent component based on the updated member attribute information.
2. The method of claim 1, wherein said retrieving at least two item components of a target item in response to a pre-written component processing instruction comprises:
when the running of a pre-written component processing script is detected, responding to a component processing instruction in the component processing script, and determining a file directory corresponding to the target project according to the component processing instruction;
and traversing the file directory, determining a project dependent component set and/or a development dependent component set associated with the target project, and acquiring the at least two project components according to the project dependent component set and/or the development dependent component set.
3. The method of claim 2, wherein traversing the file directory, determining a set of project dependent components and/or a set of development dependent components associated with the target item, comprises:
traversing the file directory, and determining an item description file corresponding to the target item;
and determining the project dependent component set and/or the development dependent component set in the project description file according to a component set confirmation instruction in the component processing script.
4. The method according to claim 1, wherein the member attribute information further includes a version number corresponding to the dependent component, and the extracting member attribute information corresponding to each item component and matching each member attribute information to obtain a matching result includes:
extracting the identification of a dependent component associated with each project component and the version number corresponding to the dependent component according to an information extraction instruction in a pre-written component processing script;
and writing the extracted identifier of the dependent component and the version number corresponding to the dependent component into a target item description file, and determining a matching result of each member attribute information based on the target item description file.
5. The method of claim 4, wherein determining a matching result of each member attribute information based on the target item description file comprises:
and matching the identifiers of the dependent components associated with the project components based on the target project description file, determining the repetitive dependent components associated with at least two project components, and taking the identifiers of the repetitive dependent components as the matching result.
6. The method according to claim 5, wherein the determining a component to be processed according to the identifier of the dependent component in the matching result and updating the member attribute information corresponding to the component to be processed comprises:
determining an item assembly associated with the repeated dependency assembly as an assembly to be processed according to the identification of the repeated dependency assembly in the matching result;
and carrying out consistency detection on the repeatability dependent assemblies associated with the assemblies to be processed, and updating member attribute information corresponding to the assemblies to be processed according to the detection result.
7. The method according to claim 6, wherein the performing consistency detection on the repeatability dependent components associated with each component to be processed and updating the member attribute information corresponding to each component to be processed according to the detection result comprises:
and when the version numbers of the repeated dependent components are not consistent, updating the version numbers of the repeated dependent components associated with the components to be processed based on the compatibility of the repeated dependent components and the components to be processed.
8. A component handling apparatus, comprising:
the project component acquisition module is used for responding to a pre-written component processing instruction and acquiring at least two project components of a target project;
the matching module is used for extracting the member attribute information corresponding to each project component and matching the member attribute information to obtain a matching result; the member attribute information comprises an identifier of a dependent component, and the dependent component comprises a component called by a corresponding project component in the development and/or operation process;
and the processing module is used for determining the components to be processed according to the identifiers of the dependent components in the matching result, updating the member attribute information corresponding to the components to be processed, and installing the dependent components based on the updated member attribute information.
9. An electronic device, characterized in that the electronic device comprises:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the component processing method of any one of claims 1-7.
10. A storage medium containing computer-executable instructions for performing the component processing method of any one of claims 1-7 when executed by a computer processor.
CN202111231929.1A 2021-10-22 2021-10-22 Component processing method and device, electronic equipment and storage medium Pending CN114003269A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111231929.1A CN114003269A (en) 2021-10-22 2021-10-22 Component processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111231929.1A CN114003269A (en) 2021-10-22 2021-10-22 Component processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114003269A true CN114003269A (en) 2022-02-01

Family

ID=79923683

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111231929.1A Pending CN114003269A (en) 2021-10-22 2021-10-22 Component processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114003269A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816393A (en) * 2022-05-18 2022-07-29 北京百度网讯科技有限公司 Information generation method, device, equipment and storage medium
CN115145631A (en) * 2022-08-31 2022-10-04 云账户技术(天津)有限公司 Ghost dependence processing method and device, electronic equipment and readable storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114816393A (en) * 2022-05-18 2022-07-29 北京百度网讯科技有限公司 Information generation method, device, equipment and storage medium
CN114816393B (en) * 2022-05-18 2023-12-19 北京百度网讯科技有限公司 Information generation method, device, equipment and storage medium
CN115145631A (en) * 2022-08-31 2022-10-04 云账户技术(天津)有限公司 Ghost dependence processing method and device, electronic equipment and readable storage medium

Similar Documents

Publication Publication Date Title
US20240045850A1 (en) Systems and methods for database orientation transformation
CN111061489B (en) Multi-platform compiling detection method, device, equipment and medium
CN107783766B (en) Method and device for cleaning files of application program
CN114003269A (en) Component processing method and device, electronic equipment and storage medium
CN113051514B (en) Element positioning method and device, electronic equipment and storage medium
CN110659210A (en) Information acquisition method and device, electronic equipment and storage medium
CN113127050B (en) Application resource packaging process monitoring method, device, equipment and medium
CN113971037A (en) Application processing method and device, electronic equipment and storage medium
CN113050984A (en) Resource calling method and device, electronic equipment and storage medium
CN113760306A (en) Method and device for installing software, electronic equipment and storage medium
CN111274130A (en) Automatic testing method, device, equipment and storage medium
CN110716804A (en) Method and device for automatically deleting useless resources, storage medium and electronic equipment
CN110704025A (en) Method and device for generating coding specification tool, storage medium and electronic equipment
CN113377342B (en) Project construction method and device, electronic equipment and storage medium
CN110888641A (en) Automatic script generation method and device, server and storage medium
CN113190235B (en) Code analysis method and device, electronic terminal and storage medium
CN112748930B (en) Compilation detection method, device, equipment and storage medium
CN109948251B (en) CAD-based data processing method, device, equipment and storage medium
US8843896B2 (en) Metamodeling contextual navigation of computer software applications
CN111124423A (en) Multi-platform-based compiling detection method, device, server and medium
CN112114811A (en) Compiling method, device and equipment
CN113590225B (en) Mapping detection method and device, electronic equipment and storage medium
CN113535147A (en) Method and device for generating calling code, electronic terminal and storage medium
CN111273956B (en) Program module loading method, device, equipment and storage medium
CN115421785B (en) Method, device and medium for transplanting application program

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