File type determination method and device, equipment, medium and program product
In front-end project development, using file identification information to match configuration and module file information databases, combined with the display of generated record information, the problem of inefficient detection of useless files is solved, and fast and accurate file type judgment and management is achieved, improving Project cleanliness and maintainability.
Patent Information
- Application Number
- CN202411506761.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-02-18
AI Technical Summary
During the development of front-end project, the accumulation of useless files leads to an increase in storage space, increasing project management difficulty, and traditional manual cleaning methods are inefficient, making it impossible to detect useless files quickly and accurately.
By obtaining the file identification information of each file in the target project directory and matching it with the preset configuration file information library and module file information library, obtaining the file identification information that failed to match and its generated record information, displaying it on the page. Allows the user to confirm the file type, thereby determining useless files.
It realizes the rapid and accurate identification and deletion of useless files, improves the cleanliness and maintainability of the project, avoids the misdeletion of important files, and improves the convenience and accuracy of file management.
Smart Images

Figure CN119473377A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of big data technology, and in particular, relates to a method, device, equipment, medium and program product for determining a file type. Background Art
[0002] During the front-end project development process, the accumulation of useless files not only takes up storage space, but also increases the difficulty of project management and reduces the neatness and maintainability of the project.
[0003] The traditional cleaning method relies on developers to manually locate and check useless files, which is not only cumbersome but also inefficient. Developers need to spend a lot of time and energy to check the files in the project one by one to determine whether they are still useful. However, with the expansion of project scale and the acceleration of iteration speed, the manual cleaning method of useless files can no longer meet the needs of efficient management. This not only wastes the valuable time of developers, but also may cause important files to be accidentally deleted due to human negligence, bringing unnecessary risks to the project.
[0004] Therefore, the prior art has the problem of being unable to quickly and accurately detect useless files. Summary of the invention
[0005] The embodiments of the present application provide a method, apparatus, device, medium and program product for determining a file type, which can quickly and accurately detect useless files and improve the neatness and maintainability of a project.
[0006] In a first aspect, an embodiment of the present application provides a method for determining a file type, comprising:
[0007] Get the file identification information of each file in the target project directory;
[0008] Matching each file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library to obtain a matching result;
[0009] In the database, generation record information corresponding to the target file identification information is obtained, wherein the matching result corresponding to the target file identification information is that the matching with the configuration file identification information and the module file identification information fails;
[0010] On the first page, the target file identification information and its corresponding generation record information are displayed;
[0011] In response to a first input to a first control in a first page, it is determined that a file corresponding to the first control in a target project directory is a useless type file, wherein the first control corresponds one-to-one to target file identification information in the first page.
[0012] In a possible embodiment of the first aspect, before matching each file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library to obtain a matching result, the method further includes:
[0013] In response to a project compilation completion instruction, obtaining file identification information of the compiled project file and file identification information of a static file referenced by a page entry file;
[0014] The file identification information of the compiled project file and the file identification information of the static file are both used as module file identification information and stored in the module file information library.
[0015] In a possible embodiment of the first aspect, before obtaining, in a database, generation record information corresponding to the target file identification information, the method further includes:
[0016] During the life cycle of the project, obtain the generation record information of each file in the target project directory;
[0017] The generated record information and its corresponding file identification information are stored in the database.
[0018] In a possible embodiment of the first aspect, generating the record information includes creation information; the creation information includes a creator, a creation time, and creation remarks information.
[0019] In a possible embodiment of the first aspect, the generated record information includes content update information; the content update information includes updater, update time and update remarks information.
[0020] In a possible embodiment of the first aspect, the generated record information includes reference change information; the reference change information includes an operator, an operation time, an operation remark information, and a file identification information of the referenced file.
[0021] In a possible embodiment of the first aspect, the reference file includes a first type reference file and a second type reference file, wherein the first type reference file is a file having a reference record, and the second type reference file is a file having a dereference record.
[0022] In a possible embodiment of the first aspect, the method further includes:
[0023] In the target project directory, delete the file information of useless type files.
[0024] Based on the same inventive concept, in a second aspect, an embodiment of the present application further provides a device for determining a file type, including:
[0025] An acquisition module is used to obtain the file identification information of each file in the target project directory;
[0026] A matching module, used to match each file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library, to obtain a matching result;
[0027] The acquisition module is further used to acquire generation record information corresponding to the target file identification information in the database, wherein the matching result corresponding to the target file identification information is that the matching with both the configuration file identification information and the module file identification information fails;
[0028] A display module, used to display the target file identification information and its corresponding generation record information on the first page;
[0029] The determination module is used to determine, in response to a first input to a first control in a first page, that a file corresponding to the first control in a target project directory is a useless type file, wherein the first control corresponds one-to-one to the target file identification information in the first page.
[0030] Based on the same inventive concept, in the third aspect, an embodiment of the present application also provides a device for determining a file type, the device comprising a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the method for determining the file type in the first aspect or any embodiment of the first aspect is implemented.
[0031] Based on the same inventive concept, in a fourth aspect, an embodiment of the present application further provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the first aspect or the method for determining the file type in any embodiment of the first aspect is implemented.
[0032] Based on the same inventive concept, in the fifth aspect, an embodiment of the present application also provides a computer program product. When the instructions in the computer program product are executed by the processor of the device, the device can execute the first aspect, or the method for determining the file type in any embodiment of the first aspect.
[0033] The method, device, equipment, medium and program product for determining the file type of the embodiment of the present application collects the file identification information of all files in the target project directory, and then uses the file identification information to match the configuration file identification information in the preset configuration file information library and the module file identification information in the module file information library, so as to quickly identify the target file that is neither a configuration file nor a module file. Then, the target file is taken as the focus object, and the generation record information of the target file is further retrieved from the database and displayed intuitively on the first page, for example, the generation record information such as the creation information, content update information and reference change information of the target file can be displayed, providing developers with detailed judgment basis for the file type, so as to more accurately determine whether the file is a useful file or a useless file, effectively preventing important files from being accidentally deleted, and the user only needs to perform a simple operation on the corresponding first control on the first page to easily confirm and mark these useless files, which greatly improves the convenience and accuracy of project file management and improves the neatness and maintainability of the project. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Other features, objects and advantages of the present application will become more apparent by reading the following detailed description of non-limiting embodiments with reference to the accompanying drawings, in which the same or similar reference numerals represent the same or similar features and the accompanying drawings are not drawn to scale.
[0035] Figure 1 This is a flowchart of a method for determining a file type provided in an embodiment of the present application;
[0036] Figure 2 This is another flowchart of the method for determining the file type provided in the embodiment of the present application;
[0037] Figure 3 This is another flowchart of the method for determining the file type provided in the embodiment of the present application;
[0038] Figure 4 is another flowchart of a method for determining a file type provided in an embodiment of the present application;
[0039] Figure 5 is a structural schematic diagram of a device for determining a file type provided in an embodiment of the present application;
[0040] Figure 6 It is a structural schematic diagram of a file type determination device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application and are not configured to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0042] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0043] It should be understood that the term "and / or" used in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.
[0044] It is obvious to those skilled in the art that various modifications and changes can be made in the present application without departing from the spirit or scope of the present application. Therefore, the present application is intended to cover modifications and changes of the present application that fall within the scope of the corresponding claims (technical solutions for protection) and their equivalents. It should be noted that the implementation methods provided in the embodiments of the present application can be combined with each other without contradiction.
[0045] It should be noted that the acquisition, storage, use and processing of data in the embodiments of the present application are in compliance with the relevant provisions of national laws and regulations.
[0046] It should also be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, and they should be regarded as exemplary. Their purpose is only to illustrate the feasibility of implementing the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0047] Before describing the technical solutions provided by the embodiments of the present application, in order to facilitate the understanding of the embodiments of the present application, the present application first specifically describes the problems existing in the related art:
[0048] During the front-end project development process, the accumulation of useless files not only takes up storage space, but also increases the difficulty of project management and reduces the neatness and maintainability of the project.
[0049] The traditional cleaning method relies on developers to manually locate and troubleshoot useless files, which is not only cumbersome but also inefficient. Developers need to spend a lot of time and energy to check the files in the project one by one to determine whether they are still useful. However, with the expansion of project scale and the acceleration of iteration speed, the manual cleaning of useless files can no longer meet the needs of efficient management. This not only wastes the valuable time of developers, but also may cause important files to be accidentally deleted due to human negligence, bringing unnecessary risks to the project. Therefore, the relevant technology has the problem of being unable to quickly and accurately detect useless files.
[0050] Based on this, the embodiments of the present application provide a method, apparatus, device, medium and program product for determining the file type, which can quickly and accurately determine whether a file is a useful file or a useless file, effectively prevent important files from being accidentally deleted, and improve the neatness and maintainability of the project.
[0051] The following is a detailed description of the method for determining the file type provided in the embodiment of the present application in conjunction with the accompanying drawings.
[0052] Figure 1 is a flowchart of a method for determining a file type provided in an embodiment of the present application, such as Figure 1 As shown, the method may include steps S110 to S150.
[0053] S110, obtaining file identification information of each file in the target project directory.
[0054] The target project directory is a specific folder or path containing multiple files and subdirectories, and the target project directory includes a series of files of the entire project.
[0055] The file identification information is used to uniquely identify the file. For example, the file identification information may include the file name and path information.
[0056] Specifically, obtaining the file identification information of each file in the target project directory refers to retrieving and collecting the unique identification information of each file from the specified project folder, for example, obtaining the file name and file path of each file in the target project directory.
[0057] S120, matching each file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library to obtain a matching result.
[0058] The configuration file information base may be a storage structure such as a database or a database table. The configuration file information base pre-establishes and stores identification information for uniquely identifying the configuration file. The identification information for uniquely identifying the configuration file may be referred to as configuration file identification information.
[0059] The configuration file can include the setting parameter information for the project operation. For example, you can add some configuration files of the front-end project, such as .gitignore, .eslintignore, package.json, vue.config.js, dist, node_modules, and other files and directories to the configuration file information library, and ignore these files and directories during scanning. The configuration file information library can be flexibly configured to determine which files or directories do not need to be scanned, which has flexible configuration functions.
[0060] The module file information base is similar to the configuration file information base, and is a storage structure such as a database or database table that is pre-established and stores identification information for uniquely identifying module files. The identification information for uniquely identifying module files may be referred to as module file identification information.
[0061] Module files are files used when compiling a project, such as project compilation files, static files referenced by page entry files, etc.
[0062] Specifically, the file identification information of each file in the target project directory may be compared with the configuration file identification information pre-stored in the configuration file information library and the module file identification information pre-stored in the module file information library one by one to obtain a matching result.
[0063] S130, obtaining generation record information corresponding to the target file identification information in the database, wherein the matching result corresponding to the target file identification information is that the matching with both the configuration file identification information and the module file identification information fails.
[0064] The matching result is file identification information that fails to match both the configuration file identification information and the module file identification information, which can be referred to as target file identification information. The file corresponding to the target file identification information can be referred to as the target file.
[0065] The generation record information corresponding to the target file identification information includes record information of the target file during the generation process, such as creation or modification records of the target file.
[0066] Specifically, when there is target file identification information in the file identification information of each file in the target project directory that fails to match both the configuration file identification information and the module file identification information, the generation record information corresponding to the target file identification information can be obtained in the database, that is, the generation record information of the target file can be obtained, so as to further determine whether the target file corresponding to the target file identification information is a useless file.
[0067] S140, displaying the target file identification information and its corresponding generation record information on the first page.
[0068] Specifically, the target file identification information and the generation record information associated therewith may be displayed in the first page.
[0069] S150, in response to a first input to a first control in a first page, determining that a file corresponding to the first control in a target project directory is a useless type file, wherein the first control corresponds one-to-one to target file identification information in the first page.
[0070] There is a one-to-one correspondence between the first control in the first page, the target file identification information, and the target file.
[0071] Specifically, when the user reads the target file identification information and its corresponding generation record information, and performs an operation (i.e., the first input) on the first control associated with the specific target file identification information on the first page, it can be determined that the target file corresponding to the first control in the target project directory is a useless file.
[0072] According to the method for determining the file type provided by the embodiment of the present application, by collecting the file identification information of all files in the target project directory, and then using the file identification information to match the configuration file identification information in the preset configuration file information library and the module file identification information in the module file information library, the target file that is neither a configuration file nor a module file can be quickly identified. Then the target file is taken as the focus of attention, and the generation record information of the target file is further retrieved from the database and displayed intuitively on the first page, for example, the generation record information such as the creation information, content update information and reference change information of the target file can be displayed, providing developers with detailed judgment basis for the file type, so that it can be more accurately determined whether the file is a useful file or a useless file, effectively preventing important files from being accidentally deleted, and the user only needs to perform a simple operation on the corresponding first control on the first page to easily confirm and mark these useless files, which greatly improves the convenience and accuracy of project file management and improves the neatness and maintainability of the project.
[0073] It should be noted that after finding the target file, the embodiment of the present application does not directly treat it as a useless type file, but further obtains and displays the generation record information of the target file. After further confirmation by the user, the file is determined to be a useless type file. The file type can be accurately and effectively determined, which effectively prevents important files from being accidentally deleted and improves the neatness of the project.
[0074] Figure 2 This is another flowchart of the method for determining the file type provided in the embodiment of the present application.
[0075] In some embodiments, Figure 2 As shown, in step S120, each file identification information is matched with the configuration file identification information in the preset configuration file information library and the module file identification information in the preset module file information library. Before obtaining the matching result, the method for determining the file type may also include steps S161 and S162.
[0076] S161, in response to a project compilation completion instruction, obtaining file identification information of the compiled project file and file identification information of the static file referenced by the page entry file.
[0077] The project compilation completion instruction is a signal instruction indicating that the compilation process of the project has been completed.
[0078] Compilation project files refer to project files that participate in the compilation process.
[0079] The page entry file is the starting point file of the project. When the user starts the project, the page entry file will be loaded and executed first. As the entry point of the project, the page entry file can reference static files and provide the user with an initial page view.
[0080] Specifically, when the project is compiled, the file identification information of the compiled project file and the file identification information of the file of the project entry page can be obtained, and this information is used for subsequent file processing or type determination operations.
[0081] S162: The file identification information of the compiled project file and the file identification information of the static file are both used as module file identification information, and stored in a module file information library.
[0082] Specifically, the file identification information of the compiled project file and the static file are both regarded as module file identification information, and the information is saved in the module file information library.
[0083] The embodiment of the present application can automatically collect the file identification information of the compiled project files and static files after the project compilation is completed, and store this information as module file identification information in the module file information library. After the project is compiled, the identification information of the compiled project files and static files can be automatically and comprehensively recorded in the module file information library, thereby ensuring that key files such as the compiled project files and static files can be effectively recorded, providing a solid foundation for the subsequent identification of useless files.
[0084] Figure 3 This is another flowchart of the method for determining the file type provided in the embodiment of the present application.
[0085] In some embodiments, Figure 3 As shown, before obtaining the generation record information corresponding to the target file identification information in the database in step S130, the method for determining the file type may further include steps S171 and S172.
[0086] S171, during the life cycle of the project, obtaining generation record information of each file in the target project directory.
[0087] The life cycle of a project refers to the various stages that a project goes through from the start of compilation to the completion of compilation. During the life cycle of a project, a large number of files will be generated and modified, so collecting the generation record information of these files is very important for project management and file type determination.
[0088] Specifically, during the entire life cycle of the project, generation record information of each file is collected from the target project directory to prepare for searching the corresponding generation record information in the database according to the target file identification information in the subsequent steps.
[0089] S172, storing the generated record information and its corresponding file identification information in a database.
[0090] Specifically, after the generation record information of each file in the project directory is obtained, the generation record information and its corresponding file identification information may be stored together in a database so that the information can be quickly retrieved and used later.
[0091] The embodiment of the present application comprehensively collects the generation record information of the files in the target project directory during the project life cycle, and stores the generation record information and its corresponding file identification information in the database, which facilitates the subsequent rapid retrieval and use of this information, thereby effectively supporting the accurate determination of file types.
[0092] In some embodiments, generating record information includes creation information; the creation information includes creator, creation time and creation remarks information.
[0093] The creation notes provide a clear record of additional information about the file, helping not only the creator but also non-creators to quickly and accurately understand the purpose, importance, and other relevant considerations of the file. This information helps developers better judge the role and function of the file in the project, and also helps developers quickly and accurately determine the type of the target file based on this additional information.
[0094] The generation record information of the embodiment of the present application includes detailed creation information, such as the creator, creation time, and creation notes, which are helpful to track the source of the file. For example, the creation information of the target file can be displayed on the first page, including the creator, creation time, and creation notes, and then the creator of the target file can confirm whether the type of the target file is currently a useful type or a useless type.
[0095] In some embodiments, the generated record information includes content update information; the content update information includes updater, update time and update remarks information.
[0096] The update note information is an additional description or annotation of the modification or update of the file content, which may include detailed information such as the reason for the modification, the specific content of the modification, the impact on the file, etc. It is an additional explanation of the file modification provided by the project members.
[0097] The embodiment of the present application includes content update information in the generated record information, such as details such as the updater, update time, and update notes, which helps to comprehensively track the content modification history of the file, ensure that project members can clearly understand the latest status of the file and the reason for the change, and also helps developers to quickly and accurately determine the type of the target file based on this information.
[0098] In some embodiments, the generated record information includes reference change information; the reference change information includes the operator, operation time, operation note information and file identification information of the referenced file.
[0099] Reference files are files that reference other files in a project. The existence of reference files indicates that there is a certain dependency relationship between them and other files. For example, if file A references file B, then file A can be called a reference file and file B can be called a referenced file.
[0100] In an embodiment of the present application, the generated record information includes reference change information, which records in detail the operator, operation time, operation notes and the identification of the referenced file. This comprehensive record helps project members track changes in file reference relationships, understand the dependencies and mutual influences between files, and helps developers quickly and accurately determine whether the type of the target file is a useful type or a useless type based on this information.
[0101] In some embodiments, the reference file includes a first type reference file and a second type reference file, wherein the first type reference file is a file with a reference record, and the second type reference file is a file with a dereference record.
[0102] The first type of reference file is a file with a reference record. The first type of reference file references other files, and this reference relationship is clearly recorded. This record may include information such as the time of the reference, the location of the reference, and the purpose of the reference.
[0103] The second type of reference file is a file with a dereference record. The second type of reference file once referenced other files, but later due to some reason (such as outdated file content, file deletion or replacement, etc.), this reference relationship was removed. The dereference record can also include information such as the time and reason for the dereference.
[0104] In an embodiment of the present application, by distinguishing between reference files of the first type (having reference records) and the second type (having dereference records), the reference status of files can be managed more accurately, helping project members to clearly understand which files reference a file and which files reference a file and then dereference it, thereby quickly and accurately clarifying the file dependencies of the project and better determining the type of the target file.
[0105] Figure 4 This is another flowchart of the method for determining the file type provided in the embodiment of the present application.
[0106] In some embodiments, Figure 4 As shown, the method for determining the file type may further include step S180.
[0107] S180, deleting file information of useless type files in the target project directory.
[0108] Specifically, a deletion operation is performed in the target project directory to remove relevant information of files that are identified as useless types.
[0109] The embodiment of the present application helps to clean up the project directory, reduce unnecessary file information, and improve the neatness and maintainability of the project by deleting file information of useless types of files in the target project directory.
[0110] In one example, when Webpack compiles the front-end code, it will parse the files referenced in the project into modules. When Webpack completes the compilation, this system obtains the information of all the modules in the project and stores it in the module list (module file information library). Then it scans each file in the project directory. Those files that are not in the module list or in the configuration file information library are files that are not used in the project and are the target files of focus. Then, the Git command is used to find out the generation record information of the target file, such as creation information, latest content change information, and reference relationship change information.
[0111] The embodiment of the present application compiles the front-end code and parses the module information through Webpack, which can automatically identify and locate unused target files in the project, and then use Git commands to analyze the generation records of these files, such as creation, content changes, and reference relationship changes, etc., thereby helping developers to efficiently manage and clean up useless files, optimize project structure, reduce unnecessary resource usage, and improve code quality and maintenance efficiency.
[0112] In one embodiment, the file type determination system may include an initialization module, a parsing module, a detection module, and a directory scanning module. The entire system is integrated into the Webpack platform in the form of a Webpack plug-in. When compiling the front-end code, it can automatically execute the useless files used in the detection project without having to start a third-party software to scan separately. The functions of each module of the system are as follows:
[0113] Initialization module: responsible for connecting to the Webpack platform, reading information such as the configuration file information library and project directory address; listening to the compilation completion instruction, and when the Webpack compilation is completed, obtaining the identification information of all module files in the project directory, and then storing the identification information of all modules in the module list (module file information library).
[0114] Webpack is a static module packaging tool for JavaScript applications. It can compile the modules generated by the Vue.js front-end framework into HTML, javascript and css files that can be recognized by the browser. At the same time, it provides a rich external interface, allowing users to access the platform in the form of plug-ins to expand its functionality.
[0115] For example, the steps for the initialization module to implement the initialization function are as follows:
[0116] 1) Read configuration information such as configuration file information library and project address.
[0117] 2) Listen to the compilation completion event of the Webpack platform. This event will be triggered when Webpack completes compiling the front-end code.
[0118] 3) Determine whether Webpack triggers a compilation completion event. If yes, go to step 4; if no, go to step 2.
[0119] 4) Get all modules compiled by Webpack and store all modules in the module list (module file information library).
[0120] Parsing module: Some files are directly referenced in the Index.html file (page entry file). Webpack will not process these files during compilation, so they cannot be found in the module list (module file information library). The parsing module is mainly responsible for parsing the Index.html file, obtaining the referenced files (static files) therein, and adding the static files to the module list (module file information library). In this way, when detecting useless files, the static files directly referenced in the Index.html file (page entry file) will also be included in the detection scope.
[0121] For example, the steps for the parsing module to implement the function of parsing the entry file are as follows:
[0122] 1) Get the Webpack compiler object.
[0123] 2) Use the method provided by the webpack compiler object to get the Index.html path.
[0124] 3) Read the contents of the Index.html file and convert it into a string format.
[0125] 4) Use regular expressions to match tag strings that reference static files (script tags and link tags, which are mainly used in the Index.html file to reference static files), and store them in the static file tag list.
[0126] 5) Determine whether there is a value in the static file tag list. If yes, execute step 6. If not, end the process.
[0127] 6) Traverse the static file tag list and obtain the string content of each tag.
[0128] 7) Determine whether a static file is referenced in the tag. If yes, go to step 8; if no, go to step 12.
[0129] 8) Parse the static file name from the tag string.
[0130] 9) Assemble the path information of the static file according to the application path of the static file.
[0131] 10) Assemble information such as static file name and static file path into a module object.
[0132] 11) Store the module object in the module list (module file information library).
[0133] 12) Determine whether the static file tag list has been traversed. If yes, end the process. If not, execute step 6.
[0134] Directory scanning module: It mainly starts from the project root directory and uses a depth-first algorithm to scan and obtain all files under each directory.
[0135] For example, the directory scanning module can use the DFS algorithm to recursively scan from the root directory of the project, and compare each file with the module file information library and the configuration file information library. The steps for the directory scanning module to implement the function of traversing project files are as follows:
[0136] 1) Read the project address information.
[0137] 2) Set the root directory as the current directory.
[0138] 3) Traverse all files and directories in the current directory and get each object (there are two main types of objects: file objects and folder objects).
[0139] 4) Determine whether the object is in the configuration file information library. If so, there is no need to detect the object and execute step 8. If not, execute step 5.
[0140] 5) Determine whether the object is a file object. If so, execute step 6. If not, it means that the object is a folder object, and execute step 7.
[0141] 6) Detect whether the file object is the target file (the specific function is reflected in the detection module's detection of whether the file is used), and then execute step 8.
[0142] 7) Set the directory where the folder object is located as the current directory and execute step 3.
[0143] 8) Determine whether the objects in the current directory have been traversed. If yes, execute step 9; if not, execute step 3.
[0144] 9) Determine whether the current directory is the root directory. If so, execute step 11; if not, execute step 10.
[0145] 10) Set the parent directory (parent directory) of the current directory as the current directory, and then execute step 7.
[0146] 11) Traverse the files in the project target and output the detection results of each file.
[0147] Detection module: responsible for comparing files with the module list (module file information library) and the configuration file information library, detecting unused target files, and querying the target file's creation information (creator, creation time, creation notes), recent update information (updator, update time, update notes) and file reference change information (which files have referenced it, and which files have deleted the reference), etc.
[0148] The detection module has the function of detecting whether a file is in use. This function is mainly responsible for comparing and detecting the file object with the module objects in the configuration file information library and the module file information library. If the file object is not matched in the module list (module file information library) and the configuration file information library, it means that the file is not in use and belongs to the target file.
[0149] For example, the process steps for detecting whether a module detects whether a file is in the module list (module file information library) are as follows:
[0150] 1) Create an array to store the target file information and generate a target file list.
[0151] 2) Get the file path information of the file object currently being detected.
[0152] 3) Traverse the module list (module file information library) and obtain each module object.
[0153] 4) Get the file path information of the module object.
[0154] 5) Compare the file path information of the file object currently being detected with the file path information of the module object in the module list (module file information library) to determine whether they are the same. If so, it means that the file currently being detected is used by other files, and the process ends. If not, execute step 6.
[0155] 6) Determine whether the module list is traversed. If so, it means that the module identical to the file object is not found in the module list. Go to step 7. If not, go to step 3.
[0156] 7) Obtain the creation information, latest update information and reference change information of the file, and store this information and file information into the target file list (the specific function is reflected in the "Obtain File Log Function").
[0157] For another example, the detection module also has the function of obtaining file logs. It can query the Git change record information of the file according to the file path, and parse the file's creation time, creator, creation note information, latest change time, latest change person, latest change note information, and file reference change information from the Git change record information. The process of obtaining the file log function is as follows:
[0158] 1) Get the path information of the target file.
[0159] 2) According to the path information, use the Git command to obtain all Git change record information of the target file.
[0160] Git is an open source distributed version control system that can efficiently and quickly handle version management of small to very large projects.
[0161] 3) Convert all Git change record information of the file into an array. The first set of information in the array is the latest change information of the file, and the last set of information in the array is the creation information of the file.
[0162] 4) Get the first set of elements in the array. The first set of elements is the Git record of the latest file changes.
[0163] 5) Use regular expressions to match the latest change person, latest change date, and latest change notes of the file from the first group of elements.
[0164] 6) Get the last set of elements from the array. The last set of elements is the Git record of file creation.
[0165] 7) Use regular expressions to match the file creator, creation date, and creation notes from the last set of elements.
[0166] 8) Get the reference change information of the file (the specific function is reflected in the "Get file reference change information function").
[0167] 9) Store the file path information, file creation information, latest change information and file reference change information into a useless file list.
[0168] Among them, the function of obtaining file reference change information is mainly responsible for obtaining all Git log information from the creation date of the target file to the present according to the creation date of the target file, traversing these log information, checking the change content of the file in each log, and filtering out the file reference change record information from the Git log information. The reference change record information of the target file mainly includes two kinds of information: when the target file was referenced by whom in what file and when the target file was removed by whom in what file.
[0169] Git log information mainly includes two types of information: those that do not involve file changes and those that involve file changes. Git log information that involves file changes includes changed files. This function is responsible for traversing these changed files to check whether the change information of these files involves reference changes to the target file. If the content of the file change adds a reference to the target file, it means that the target file is used in the file. If the content of the file change deletes the reference to the target file, it means that the use of the target file is abandoned in the file.
[0170] The process of obtaining file reference change information is as follows:
[0171] 1) Create a reference change information array specifically used to store the reference change information of the target file.
[0172] 2) Get the creation time and path information of the target file.
[0173] 3) Execute the Git command to obtain all Git log string information from the creation time of the target file to the present.
[0174] 4) Split the Git log string information into a log string array according to each Git commit.
[0175] 5) Traverse the log string array and obtain each Git commit log string information.
[0176] 6) Determine whether the Git commit involves file changes. If yes, go to step 7; if no, go to step 14.
[0177] 7) Get the changed file information in the Git commit log string information and assemble it into an array (changed file array).
[0178] 8) Traverse the changed file array and obtain the information of each changed file.
[0179] 9) Obtain the Git commit ID from the Git commit log string information, and use the Git commit ID and file information to query the changes (file changes) of the file submitted this time;
[0180] 10) Determine whether the file change content involves a reference to the target file (add a reference to the target file, obtain and delete a reference to the target file). If so, execute step 11; if not, execute step 13.
[0181] 11) Get Git committer information, Git commit date information, and Git commit comment information from the Git commit log string information.
[0182] 12) Assemble the Git committer information, Git commit date information, Git commit comment information, changed file path, and change type (adding references or removing references) into a reference change information object of the target file and add it to the reference change information array.
[0183] 13) Determine whether the traversal of the changed file array is complete, if yes, execute step 14, if not, execute step 8;
[0184] 14) Determine whether the log string array is traversed, if yes, execute step 15, if not, execute step 5.
[0185] 15) Returns the reference change information of the target file.
[0186] The embodiment of the present application integrates Webpack compilation and Git command analysis, and combines initialization, parsing, directory scanning and detection modules. The system can automatically identify, locate and manage unused target files in the project, while providing and displaying detailed file generation, change and reference relationship information. Only after further confirmation by the user can the file be determined to be a useless type file. The file type can be determined accurately and effectively, effectively preventing important files from being accidentally deleted while improving the cleanliness of the project.
[0187] In one embodiment, the process of determining the file type by the file type determination system is as follows:
[0188] 1) Read configuration information such as configuration file information library and project address.
[0189] 2) Listen to the compilation completion event of the Webpack platform. This event will be triggered when Webpack completes compiling the front-end code.
[0190] 3) Determine whether Webpack triggers a compilation completion event. If yes, go to step 4; if no, go to step 2.
[0191] 4) Use the compilation object to get all the modules compiled by Webpack, and store all the modules in the module list (configuration file information library).
[0192] 5) Get the path information of Index.html (page entry file).
[0193] 6) Read and parse the contents of the Index.html file, and obtain the referenced static files from it (for specific functions, see the above-mentioned parsing entry file function).
[0194] 7) Add static file information to the module list.
[0195] 8) Traverse all files under the front-end project directory starting from the front-end project root directory and obtain each file (for specific functions, see the above-mentioned traversal project file function).
[0196] 9) Compare the file with the module list and blacklist to filter out useless files (for specific functions, see the above-mentioned detection module to detect whether the file is used).
[0197] 10) Based on the target file information, query the creation information and recent change information of the target file (for specific functions, see the above-mentioned Get File Log function).
[0198] 11) According to the useless file information and creation information, query the reference change information of the useless file (for specific functions, see the function of obtaining file reference change information) and display it on the first page.
[0199] 12) In response to a first input to a first control in a first page, output a type detection result of a target file.
[0200] The embodiment of the present application effectively screens out the target file by monitoring Webpack compilation events, parsing HTML files, traversing project files and comparing them with the module list (module file information library) and the configuration file information library, and combines file creation, change and reference information for users to further confirm whether the target file is a useless file, which can prevent the accidental deletion of important files and improve the efficiency of project management and file cleanup.
[0201] Based on the same inventive concept, the embodiment of the present application also provides a device for determining the file type, such as Figure 5 As shown, the device 500 may include an acquisition module 510 , a matching module 520 , a display module 530 and a determination module 540 .
[0202] An acquisition module 510 is used to acquire file identification information of each file in the target project directory;
[0203] A matching module 520, used to match each file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library, to obtain a matching result;
[0204] The acquisition module 510 is further used to acquire generation record information corresponding to the target file identification information in the database, wherein the matching result corresponding to the target file identification information is that the matching with both the configuration file identification information and the module file identification information fails;
[0205] Display module 530, used to display target file identification information and its corresponding generation record information on the first page;
[0206] The determination module 540 is used to determine, in response to a first input to a first control in a first page, that a file corresponding to the first control in a target project directory is a useless type file, wherein the first control corresponds one-to-one to the target file identification information in the first page.
[0207] The file type determination device provided in the embodiment of the present application collects the file identification information of all files in the target project directory, and then uses the file identification information to match the configuration file identification information in the preset configuration file information library and the module file identification information in the module file information library, so as to quickly identify the target file that is neither a configuration file nor a module file. Then, the target file is taken as the focus object, and the generation record information of the target file is further retrieved from the database and displayed intuitively on the first page, for example, the generation record information such as the creation information, content update information and reference change information of the target file can be displayed, providing developers with detailed judgment basis for the file type, so that it can more accurately determine whether the file is a useful file or a useless file, effectively preventing important files from being accidentally deleted, and the user only needs to perform a simple operation on the corresponding first control on the first page to easily confirm and mark these useless files, which greatly improves the convenience and accuracy of project file management and improves the neatness and maintainability of the project.
[0208] In some embodiments, before the matching module is used to match each file identification information with the configuration file identification information in the preset configuration file information library and the module file identification information in the preset module file information library to obtain the matching result, the device further includes a storage module:
[0209] The acquisition module is further used to obtain the file identification information of the compiled project file and the file identification information of the static file referenced by the page entry file in response to the project compilation completion instruction;
[0210] The storage module is used to use the file identification information of the compiled project file and the file identification information of the static file as module file identification information, and store them in the module file information library.
[0211] In some embodiments, before the acquisition module is used to acquire the generation record information corresponding to the target file identification information in the database, the device further includes:
[0212] The acquisition module is also used to obtain the generation record information of each file in the target project directory during the life cycle of the project;
[0213] The storage module is also used to store the generated record information and its corresponding file identification information in the database.
[0214] In some embodiments, generating record information includes creation information; the creation information includes creator, creation time and creation remarks information.
[0215] In some embodiments, the generated record information includes content update information; the content update information includes updater, update time and update remarks information.
[0216] In some embodiments, the generated record information includes reference change information; the reference change information includes the operator, operation time, operation note information and file identification information of the referenced file.
[0217] In some embodiments, the reference file includes a first type reference file and a second type reference file, wherein the first type reference file is a file with a reference record, and the second type reference file is a file with a dereference record.
[0218] In some embodiments, the device further comprises a deletion module:
[0219] The deletion module is used to delete the file information of useless files in the target project directory.
[0220] Each module in the file type determination device provided in the embodiment of the present application can realize Figures 1 to 4 The functions of each step of the provided method for determining the file type and its ability to achieve the corresponding technical effects are not described in detail here for the sake of brevity.
[0221] Figure 6 A schematic diagram of the hardware structure of a device for determining a file type provided in an embodiment of the present application is shown.
[0222] The file type determination device may include a processor 601 and a memory 602 storing computer program instructions.
[0223] Specifically, the processor 601 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0224] The memory 602 may include a large capacity memory for data or instructions. For example, but not limitation, the memory 602 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, the memory 602 may include a removable or non-removable (or fixed) medium. In appropriate cases, the memory 602 may be inside or outside a device for determining the file type. In a particular embodiment, the memory 602 is a non-volatile solid-state memory.
[0225] The memory may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, generally, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., memory devices) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to one aspect of the present disclosure.
[0226] The processor 601 implements any one of the file type determination methods in the above embodiments by reading and executing computer program instructions stored in the memory 602 .
[0227] In one example, the file type determination device may further include a communication interface 603 and a bus 604. Figure 6 As shown, the processor 601, the memory 602, and the communication interface 603 are connected via a bus 604 and communicate with each other.
[0228] The communication interface 603 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.
[0229] The bus 604 includes hardware, software or both, and couples the components of the file type determination device to each other. For example, but not limitation, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Extended Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), a Hyper Transport (HT) interconnection, an Industry Standard Architecture (ISA) bus, an InfiniBand interconnection, a Linear Predictive Coding (LPC) bus, a memory bus, a MicroChannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (Peripheral Component Interconnect-X, PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VESA Local Bus, VLB) bus or other suitable buses or a combination of two or more of these. Where appropriate, the bus 604 may include one or more buses. Although embodiments of the present application describe and illustrate a particular bus, the present application contemplates any suitable bus or interconnect.
[0230] The device can execute the method for determining the file type in the embodiment of the present application based on each unit / component in the file type determination device, thereby realizing the combination Figures 1 to 6 Describes how the file type is determined.
[0231] In addition, in combination with the method for determining the file type in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by the processor, any one of the methods for determining the file type in the above embodiment is implemented.
[0232] The present application also provides a computer program product. When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes each process of implementing any one of the above-mentioned file type determination method embodiments.
[0233] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0234] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), appropriate firmware, plug-in, function card, etc. When implemented in software, the elements of the present application are programs or code segments used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or communication link by a data signal carried in a carrier. "Machine-readable medium" may include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, read-only memory (Read-Only Memory, ROM), flash memory, erasable read-only memory (Erasable Read Only Memory, EROM), floppy disks, compact disc read-only memory (Compact Disc Read-Only Memory, CD-ROM), optical discs, hard disks, optical fiber media, radio frequency (Radio Frequency, RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.
[0235] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.
[0236] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.
[0237] The above are only specific implementation methods of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. A method for determining a file type, characterized in that: include: Get the file identification information of each file in the target project directory; Matching each of the file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library to obtain a matching result; In the database, generation record information corresponding to the target file identification information is obtained, wherein the matching result corresponding to the target file identification information is a failure to match both the configuration file identification information and the module file identification information; In the first page, the target file identification information and the corresponding generation record information are displayed; In response to a first input to a first control in the first page, it is determined that a file corresponding to the first control in the target project directory is a useless type file, wherein the first control corresponds one-to-one to the target file identification information in the first page.
2. The method according to claim 1, characterized in that Before matching each of the file identification information with the configuration file identification information in the preset configuration file information library and the module file identification information in the preset module file information library to obtain a matching result, the method further includes: In response to a project compilation completion instruction, obtaining file identification information of the compiled project file and file identification information of a static file referenced by a page entry file; The file identification information of the compiled project file and the file identification information of the static file are both used as the module file identification information and stored in the module file information library.
3. The method according to claim 1, characterized in that Before obtaining the generation record information corresponding to the target file identification information in the database, the method further includes: During the life cycle of the project, obtaining generation record information of each file in the target project directory; The generation record information and its corresponding file identification information are stored in the database.
4. The method according to claim 3, characterized in that: The generation record information includes creation information; the creation information includes creator, creation time and creation remarks information.
5. The method according to claim 3, characterized in that: The generation record information includes content update information; the content update information includes updater, update time and update remarks information.
6. The method according to claim 3, characterized in that The generation record information includes reference change information; the reference change information includes the operator, operation time, operation remark information and file identification information of the referenced file.
7. The method according to claim 6, characterized in that The reference file includes a first type reference file and a second type reference file, wherein the first type reference file is a file with a reference record, and the second type reference file is a file with a dereference record.
8. The method according to any one of claims 1 to 7, characterized in that: Also includes: In the target project directory, the file information of the useless type file is deleted.
9. A device for determining a file type, characterized in that: include: An acquisition module is used to obtain the file identification information of each file in the target project directory; A matching module, used to match each of the file identification information with the configuration file identification information in a preset configuration file information library and the module file identification information in a preset module file information library, respectively, to obtain a matching result; The acquisition module is further used to acquire, in a database, generation record information corresponding to the target file identification information, wherein the matching result corresponding to the target file identification information is a failure to match both the configuration file identification information and the module file identification information; A display module, used for displaying the target file identification information and the corresponding generation record information on a first page; A determination module is used to determine, in response to a first input to a first control in the first page, that a file corresponding to the first control in the target project directory is a useless type file, wherein the first control corresponds one-to-one to the target file identification information in the first page.
10. A device for determining a file type, characterized in that: The device comprises: a processor and a memory storing computer program instructions; when the processor executes the computer program instructions, the method for determining the file type according to any one of claims 1 to 8 is implemented.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method for determining the file type according to any one of claims 1 to 8 is implemented.
12. A computer program product, characterized in that When the instructions in the computer program product are executed by a processor of a device, the device is enabled to execute the method for determining the file type according to any one of claims 1 to 8.