A front-end project construction method, device, equipment and medium
By parsing client commands to generate package description files and distributed version control system templates, the problem of low development efficiency in front-end projects in existing technologies is solved, and code management and debugging efficiency is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG HAOHAN ENERGY TECH CO LTD
- Filing Date
- 2022-08-31
- Publication Date
- 2026-04-21
AI Technical Summary
Existing technologies are inefficient when creating new project frameworks, mainly because the structure of the original project framework cannot be changed, resulting in low efficiency in front-end project development.
By parsing the client's project search instructions, package description files and distributed version control system templates are generated. Combined with the project templates, the project is packaged to generate a front-end project.
It improves the development efficiency of front-end projects, enables unified management of business module code, simplifies the debugging process, and supports unified upgrades and updates in the future.
Smart Images

Figure CN115454399B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer application technology, and in particular to a method, apparatus, device and medium for constructing front-end projects. Background Technology
[0002] Project teams can use project frameworks to build the necessary front-end projects. Most existing new project frameworks are developed based on existing ones, and their technology is relatively outdated. When creating a new project framework, the process involves first copying and pasting the directory structure of the original framework, then modifying the files within it. After modification, the new project is debugged, and front-end development begins only after confirming everything is working correctly. Because the main structure of the original project framework cannot be changed, this process is inefficient. Summary of the Invention
[0003] In view of the shortcomings of the prior art described above, the purpose of this invention is to provide a method, apparatus, device and medium for building front-end projects, which can improve the development efficiency of front-end projects.
[0004] To achieve the above and other related objectives, the present invention provides a method for building a front-end project, comprising:
[0005] In response to the client's project search command, the server parses the option information within the project search command;
[0006] Based on the options provided, obtain the project information;
[0007] The project information is packaged to generate a package description file;
[0008] Based on the project information, obtain the corresponding distributed version control system template;
[0009] The project information is processed to generate a project template;
[0010] The package description file, generator, distributed version control system template, and project template are packaged to generate a front-end project.
[0011] In one embodiment of the present invention, the step of parsing the option information in the project search instruction in response to the client includes:
[0012] In response to the client's project search command, the server determines whether there is a historical directory within it that corresponds to the project directory in the project search command;
[0013] If the historical directory corresponding to the project directory does not exist, the project directory is saved in the server and the option information is parsed.
[0014] If a historical directory corresponding to the project directory exists, the option information is parsed.
[0015] In one embodiment of the present invention, the step of parsing the option information if a historical directory corresponding to the project directory exists includes:
[0016] If a historical directory corresponding to the project directory exists, determine whether the historical directory needs to be overwritten;
[0017] If it is necessary to overwrite the historical directory, the historical directory is deleted, the project directory is saved in the server, and the option information is parsed.
[0018] If it is not necessary to overwrite the historical directory, the project directory and the historical directory are merged to form a new project directory. The new project directory is saved in the server, and the option information is parsed.
[0019] In one embodiment of the present invention, the project information includes platform information and project template information.
[0020] In one embodiment of the present invention, the step of obtaining the corresponding distributed version control system template based on the project information includes:
[0021] Perform initialization processing on the distributed version control system to generate a distributed version control system template repository;
[0022] Based on the project template information in the project information, obtain the corresponding distributed version control system template and save it to the root directory of the server.
[0023] In one embodiment of the present invention, the distributed version control system template repository includes a plurality of distributed version control system templates.
[0024] In one embodiment of the present invention, the step of packaging the package description file, the generator, the distributed version control system template, and the project template to generate a front-end project includes:
[0025] Create a generator;
[0026] The package description file, the generator, the distributed version control system template, and the project template are processed to install dependencies and generate a front-end project.
[0027] The present invention also provides a front-end project building apparatus, comprising:
[0028] The option information acquisition module is used to respond to the client's project search command, and the server parses the option information in the project search command;
[0029] The project information acquisition module is used to obtain project information based on the option information;
[0030] The package description file generation module is used to package the project information and generate a package description file;
[0031] The system template generation module is used to obtain the corresponding distributed version control system template based on the project information.
[0032] A project template generation module is used to process the project information and generate a project template; and
[0033] The front-end project generation module is used to package the package description file, generator, distributed version control system template, and project template to generate a front-end project.
[0034] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the front-end project construction method.
[0035] The present invention also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the front-end project construction method.
[0036] As described above, the present invention provides a method, apparatus, device and medium for building a front-end project. In the process of building a front-end project, it can achieve unified management of the project code of each business module, including code file structure, code style and code core architecture. At the same time, it can improve the development efficiency of the front-end project and facilitate the debugging of the front-end project. Attached Figure Description
[0037] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0038] Figure 1 The diagram shows an application environment of a front-end project construction method according to an embodiment of the present invention.
[0039] Figure 2 The diagram shown is a flowchart illustrating a method for building a front-end project according to an embodiment of the present invention.
[0040] Figure 3 yes Figure 2 A schematic diagram of a specific implementation method for step S10.
[0041] Figure 4 yes Figure 2 A flowchart illustrating a specific implementation of step S40.
[0042] Figure 5 yes Figure 2 A flowchart illustrating a specific implementation of step S60.
[0043] Figure 6 The diagram shown is a structural schematic of a front-end project building apparatus according to an embodiment of the present invention.
[0044] Figure 7 This is a schematic diagram of the structure of a computer device according to an embodiment of the present invention;
[0045] Figure 8 This is another structural schematic diagram of a computer device according to one embodiment of the present invention.
[0046] Component designation explanation:
[0047] 10. Option Information Acquisition Module;
[0048] 20. Project Information Acquisition Module;
[0049] 30. Package description file generation module;
[0050] 40. System template generation module;
[0051] 50. Project template generation module;
[0052] 60. Front-end project generation module. Detailed Implementation
[0053] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0054] The present invention provides a method for building a front-end project, which can be applied to, for example... Figure 1In this application environment, the client can communicate with the server via a network. The server can accept the client's project search command, parse it, and obtain the project information required by the user. Then, it can process the project information accordingly, generating corresponding package description files, distributed version control system templates, and project templates. Finally, it performs dependency installation on the generator, package description files, distributed version control system templates, and project templates to obtain the front-end project required by the user. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. The server can be implemented using a standalone server or a server cluster consisting of multiple servers. The invention will be described in detail below through specific embodiments.
[0055] Please see Figure 2 As shown, Figure 2 A flowchart illustrating a front-end project construction method provided by an embodiment of the present invention, the construction method may include the following steps:
[0056] S10. In response to the client's project search command, the server parses the option information, which includes the project directory and option information.
[0057] Please see Figure 3 As shown, in one embodiment of the present invention, when step S10 is executed, i.e., in response to the client's project search instruction, the server parses the option information, wherein the project search instruction includes the project directory and option information. Specifically, the sub-steps of step S10 may include:
[0058] S11. In response to the client's project search command, the server determines whether there is a historical directory corresponding to the project directory within its internal system. The project search command includes the project directory and option information.
[0059] In one embodiment of the present invention, when a user needs to create a new front-end project, the user can input the corresponding project information through the client, for example, by entering the command `hh create<project name>` to create a project. After the user enters the command on the client, the client can generate a project search instruction and send the project search instruction to the server. The project search instruction may include a project directory and option information. The project directory may be the directory of the front-end project that the user needs to create, and the option information may be the corresponding functions and information of the front-end project that the user needs to create. After receiving the project search instruction, the server will parse the project search instruction and, based on the project directory in the project search instruction, determine whether the server has pre-stored a historical directory corresponding to the project directory. The historical directory may be a directory that has been reserved for front-end projects previously created by the user.
[0060] S12. If the historical directory does not exist, save the project directory on the server and parse the option information.
[0061] S13. If a historical directory exists, determine whether the historical directory needs to be overwritten.
[0062] S14. If it is necessary to overwrite the historical directory, the historical directory is overwritten through the project directory, the historical directory is deleted, the project directory is saved in the server, and the option information is parsed.
[0063] S15. If it is not necessary to overwrite the historical directory, merge the project directory with the historical directory to form a new project directory, save the project directory on the server, and parse the option information.
[0064] In one embodiment of the present invention, the server determines whether a historical directory corresponding to the project directory in the project search instruction exists within its internal system. If no historical directory exists, the option information in the project search instruction needs to be parsed, and the project directory is saved on the server so that it can be treated as a historical directory when a new front-end project is built next time. If a historical directory exists, it needs to determine whether the historical directory needs to be overwritten using the project directory in the project search instruction. If overwriting is required, the historical directory is overwritten using the project directory in the project search instruction, the historical directory is deleted, the project directory is saved on the server, and the option information is parsed. If overwriting is not required, the project directory in the project search instruction and the historical directory are merged to form a new historical directory, which is saved on the server, and the option information is parsed.
[0065] S20. Parse the option information to obtain the user's project information, which includes platform information and project template information.
[0066] In one embodiment of this invention, after the server parses the option information within the project search command, it can obtain the user's project information, which includes platform information and project template information. The platform information can be the platform selected by the user; for example, the platform can be Hypertext Markup Language (H5, 5th generation HTML), a mini-program platform, or a personal computer (PC). The project template information can be different project templates corresponding to different platforms. Different project templates can be preset within each platform, and the user can choose the project template they need.
[0067] S30. Package the project information and generate a package description file.
[0068] In one embodiment of the present invention, after obtaining the user's project information, the server can package the user's project information to generate a package description file. The package description file is used to express non-code-related information. It is a JSON format file—package.json—located in the root directory of the package and is an important component of the package. All behaviors of the package management tool are closely related to the fields of the package description file.
[0069] S40. Based on the user's project information, obtain the corresponding distributed version control system template and save it to the root directory of the server.
[0070] Please see Figure 4 As shown, in one embodiment of the present invention, when step S40 is executed, that is, based on the user's project information, the corresponding distributed version control system template is obtained and saved to the root directory of the server. Specifically, the sub-steps of step S40 may include:
[0071] S41. Initialize the distributed version control system and generate a distributed version control system template repository, which includes multiple distributed version control system templates.
[0072] In one embodiment of this invention, Git is an open-source distributed version control system that can effectively and quickly handle version management for projects ranging from very small to very large. The biggest difference between distributed and centralized systems is that developers can commit locally; each developer clones (git clone) a complete Git repository on their local machine. Therefore, the distributed version control system Git can be initialized via a server, generating multiple distributed version control system templates. These templates are then aggregated to form a distributed version control system template repository, which is stored on the server.
[0073] S42. Based on the project template information in the user's project information, obtain the corresponding distributed version control system template and save it to the root directory of the server.
[0074] In one embodiment of the present invention, after obtaining the distributed version control system template repository, the corresponding distributed version control system template in the repository can be retrieved based on the project template information within the user's project information. The distributed version control system template corresponding to the project template information can then be saved to the root directory of the server. Since the root directories of different systems on the server are different (e.g., the root directories of Windows and Mac systems are different), the distributed version control system templates can be saved to different root directories on the server depending on the system.
[0075] S50. Process the user's project information, generate a project template, and save it to the client's directory.
[0076] In one embodiment of the present invention, after obtaining the user's project information, the user's project information can be used to render a template using a view template engine. The view template ejs can be a JavaScript template library used to generate HTML strings from JSON data. The ejs syntax template mainly extracts the dynamic differences of the project template, and then passes the collected user's project information as input parameters to the ejs template to finally obtain a complete project template, which is then saved to the client's directory.
[0077] S60 packages the package description file, generator, distributed version control system template, and project template to generate a front-end project.
[0078] Please see Figure 5 As shown, in one embodiment of the present invention, when step S60 is executed, the package description file, generator, distributed version control system template, and project template are packaged to generate a front-end project. Specifically, the sub-steps of step S60 may include:
[0079] S61. Create a generator to generate subsequent code.
[0080] In one embodiment of the present invention, after the project template is generated, the server can create a corresponding generator to generate subsequent code based on the package description file, the distributed version control system template, and the project template.
[0081] S62. Perform dependency processing on package description files, generators, distributed version control system templates, and project templates to generate a front-end project.
[0082] In one embodiment of the present invention, after obtaining the package description file, generator, distributed version control system template, and project template, dependency installation can be performed to install project dependencies. In project management, project dependencies define the relationship between the execution order of activities, indicating that a change in one activity will affect the other. During the installation of project dependencies, the server executes the corresponding npm i commands, such as npm init (initializing the current directory), npm i (installing all dependencies), and npm i express (installing modules to default dependencies). After executing the corresponding npm i commands, a front-end project meeting the user's requirements can be generated.
[0083] As can be seen, the above solution achieves unified management of the code across various business modules during the front-end project construction process, including code file structure, coding style, and core code architecture. It also improves front-end project development efficiency and facilitates debugging. Furthermore, it allows for unified upgrades and updates during later maintenance of the front-end project.
[0084] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0085] Please see Figure 6 As shown, the present invention also provides a front-end project building apparatus, which corresponds one-to-one with the building methods in the above embodiments. The building apparatus may include: an option information acquisition module 10, a project information acquisition module 20, a package description file generation module 30, a system template generation module 40, a project template generation module 50, and a front-end project generation module 60. Detailed descriptions of each functional module are as follows:
[0086] The option information acquisition module 10 is used to respond to the client's project search command. The server parses the option information, whereby the project search command includes the project directory and option information.
[0087] The project information acquisition module 20 is used to parse the option information to obtain the user's project information, which includes platform information and project template information.
[0088] Package description file generation module 30 is used to package project information and generate package description files.
[0089] The system template generation module 40 is used to obtain the corresponding distributed version control system template based on the user's project information and save it to the root directory of the server.
[0090] The project template generation module 50 is used to process the user's project information, generate project templates, and save them to the client's directory.
[0091] The front-end project generation module 60 is used to package the package description file, generator, distributed version control system template, and project template to generate a front-end project.
[0092] In one embodiment of the present invention, the option information acquisition module 10 is specifically used to respond to a project search command from a client. The server determines whether a historical directory corresponding to the project directory exists within its internal system. The project search command includes the project directory and option information. If no historical directory exists, the project directory is saved on the server, and the option information is parsed. If a historical directory exists, it is determined whether the historical directory needs to be overwritten. If the historical directory needs to be overwritten, it is overwritten using the project directory, the historical directory is deleted, the project directory is saved on the server, and the option information is parsed. If the historical directory does not need to be overwritten, the project directory and the historical directory are merged to form a new project directory, which is saved on the server, and the option information is parsed.
[0093] In one embodiment of the present invention, the system template generation module 40 is specifically used to initialize the distributed version control system and generate a distributed version control system template repository, wherein the distributed version control system template repository includes multiple distributed version control system templates. Based on the project template information within the user's project information, the corresponding distributed version control system template is obtained and saved to the root directory of the server.
[0094] In one embodiment of the present invention, the front-end project generation module 60 is specifically used to create a generator to generate subsequent code. It performs dependency processing on the package description file, generator, distributed version control system template, and project template to generate the front-end project.
[0095] This invention provides a front-end project building apparatus that enables unified management of the project code across various business modules during the front-end project building process. This includes code file structure, coding style, and core code architecture. It also improves front-end project development efficiency and facilitates debugging. Furthermore, it allows for unified upgrades and updates during later maintenance of the front-end project.
[0096] Specific limitations regarding the construction device can be found in the limitations of the construction method described above, and will not be repeated here. Each module in the aforementioned construction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0097] Please see Figure 7 As shown, the present invention also provides a computer device, which can be a server. The computer device includes a processor, memory, a network interface, and a database connected via a system bus. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage media stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used to communicate with external clients via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a front-end project construction method.
[0098] Please see Figure 8 As shown, the present invention also provides another computer device, which can be a client. This computer device includes a processor, memory, network interface, display screen, and input device connected via a system bus. The processor of this computer device provides computing and control capabilities. The memory of this computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface of this computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a front-end project construction method.
[0099] In one embodiment of the present invention, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it performs the following steps:
[0100] In response to the client's project search command, the server parses the option information, which includes the project directory and option information.
[0101] The option information is parsed to obtain the user's project information, which includes platform information and project template information.
[0102] Package the project information to generate a package description file.
[0103] Based on the user's project information, obtain the corresponding distributed version control system template and save it to the root directory of the server.
[0104] The system processes the user's project information, generates a project template, and saves it to the client's directory.
[0105] Package the package description file, generator, distributed version control system template, and project template to generate a front-end project.
[0106] In one embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, wherein the computer program, when executed by a processor, performs the following steps:
[0107] In response to the client's project search command, the server parses the option information, which includes the project directory and option information.
[0108] The option information is parsed to obtain the user's project information, which includes platform information and project template information.
[0109] Package the project information to generate a package description file.
[0110] Based on the user's project information, obtain the corresponding distributed version control system template and save it to the root directory of the server.
[0111] The system processes the user's project information, generates a project template, and saves it to the client's directory.
[0112] Package the package description file, generator, distributed version control system template, and project template to generate a front-end project.
[0113] It should be noted that the functions or steps that can be implemented by the computer-readable storage medium or computer device described above can be referred to in the foregoing method embodiments. To avoid repetition, they will not be described one by one here.
[0114] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), Rambus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0115] In the description of this specification, the references to terms such as "this embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0116] The embodiments of the present invention disclosed above are merely illustrative of the invention. The embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the content of this specification. This specification selects and specifically describes these embodiments to better explain the principles and practical applications of the invention, thereby enabling those skilled in the art to better understand and utilize the invention. The invention is limited only by the claims and their full scope and equivalents.
Claims
1. A method for building a front-end project, characterized in that, include: In response to the client's project search command, the server determines whether there is a historical directory within it that corresponds to the project directory in the project search command; If the historical directory corresponding to the project directory does not exist, the project directory is saved in the server, and the option information in the project search instruction is parsed. If a historical directory corresponding to the project directory exists, determine whether the historical directory needs to be overwritten: if the historical directory needs to be overwritten, delete the historical directory, save the project directory in the server, and parse the option information; If it is not necessary to overwrite the historical directory, the project directory and the historical directory are merged to form a new project directory. The new project directory is saved in the server, and the option information is parsed. Based on the options provided, obtain the project information; The project information is packaged to generate a package description file; Based on the project information, obtain the corresponding distributed version control system template; The project information is processed to generate a project template; Create a generator; The package description file, the generator, the distributed version control system template, and the project template are processed to install dependencies and generate a front-end project.
2. The method for building a front-end project according to claim 1, characterized in that, The project information includes platform information and project template information.
3. The method for building a front-end project according to claim 1, characterized in that, The step of obtaining the corresponding distributed version control system template based on the project information includes: Perform initialization processing on the distributed version control system to generate a distributed version control system template repository; Based on the project template information in the project information, obtain the corresponding distributed version control system template and save it to the root directory of the server.
4. The method for building a front-end project according to claim 3, characterized in that, The distributed version control system template repository includes multiple distributed version control system templates.
5. A front-end project building apparatus, characterized in that, The method for building a front-end project as described in any one of claims 1 to 4, wherein the building apparatus comprises: The option information acquisition module is used to respond to the client's project search command, and the server parses the option information in the project search command; The project information acquisition module is used to obtain project information based on the option information; The package description file generation module is used to package the project information and generate a package description file; The system template generation module is used to obtain the corresponding distributed version control system template based on the project information. A project template generation module is used to process the project information and generate a project template; and The front-end project generation module is used to package the package description file, generator, distributed version control system template, and project template to generate a front-end project.
6. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method for building a front-end project as described in any one of claims 1 to 4.
7. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method for building a front-end project as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Project construction method and device, computer equipment and storage medium
CN112416327A
Front-end project code generation method and device, computer equipment and storage medium
CN114371841A