VS Code-based project starting method and apparatus, and electronic device
Through the project startup plug-in developed in VS Code, software development projects are automatically identified and started, which solves the problems of cumbersome operation and high programming capabilities in the existing technology, and improves the efficiency of software development.
Patent Information
- Application Number
- CN202510345109.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2045-03-24
AI Technical Summary
In existing software development technology, creating and starting different types of software development projects requires manual identification of project types and execution of corresponding startup commands. The operation is cumbersome and the programming ability requirements are high, resulting in low software development efficiency.
Provide a project startup method based on VS Code. Through the project startup plug-in developed in VS Code, it obtains the project directory of the user's workspace, traverses the directory to determine whether there is a project type identification file, records the target project type, obtains the startup file and executes the target startup command to start the project.
It realizes automatic identification of project types and launching corresponding types of projects, reducing manual operations, reducing programming capabilities requirements, and improving software development efficiency.
Smart Images

Figure CN119861910A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a project startup method, device and electronic device based on VS Code. Background Art
[0002] With the continuous development of Internet technology, it is generally necessary to create different types of software development projects to meet diverse software development needs. Existing software development technology usually adopts the method of manually creating the required type of project for development. After creating multiple different types of projects in this way, if the relevant personnel want to start a specified type of project, they need to manually identify the type of each project and find the specified type of project and then execute the corresponding start command to start the project. The operation is cumbersome and requires high programming ability of the relevant personnel. It is difficult to start multiple different types of projects, and the software development efficiency is low. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a project startup method, device and electronic device based on VS Code to alleviate the above-mentioned problems existing in the existing software development technology.
[0004] In a first aspect, an embodiment of the present invention provides a project startup method based on VS Code, the method being applied to a project startup plug-in developed in VS Code, the method comprising: obtaining a project directory of a workspace corresponding to a user; wherein the workspace contains at least one project, and the project directory includes a file directory of each project represented in a tree structure; traversing the project directory to determine whether there is a project type identification file in the project directory; if there is a project type identification file in the project directory, recording a target project type identification file in the project directory, and determining a target project type of the workspace based on the target project type identification file; obtaining a startup file from the project directory based on preset rules; wherein the startup file includes a startup command for starting the corresponding project; obtaining a target startup command for starting the target project from the obtained startup file based on the target project type, and executing the target startup command to start the target project.
[0005] In a second aspect, an embodiment of the present invention further provides a project startup device based on VS Code, the device being applied to a project startup plug-in developed in VS Code, the device comprising: a first acquisition module, for acquiring a project directory of a workspace corresponding to a user; wherein the workspace contains at least one project, and the project directory comprises a file directory of each project represented in a tree structure; a judgment module, for traversing the project directory to determine whether there is a project type identification file in the project directory; a record determination module, for recording a target project type identification file in the project directory if there is a project type identification file in the project directory, and determining a target project type of the workspace based on the target project type identification file; a second acquisition module, for acquiring a startup file from the project directory based on a preset rule; wherein the startup file comprises a startup command for starting the corresponding project; a startup module, for acquiring a target startup command for starting the target project from the obtained startup file based on the target project type, and executing the target startup command to start the target project.
[0006] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer-executable instructions that can be executed by the processor, and the processor executes the computer-executable instructions to implement the project startup method based on VS Code described in the first aspect above.
[0007] The embodiment of the present invention provides a project startup method, device and electronic device based on VS Code, which obtains the project directory of the workspace corresponding to the user; traverses the project directory to determine whether there is a project type identification file in the project directory; if there is a project type identification file in the project directory, then the target project type identification file in the project directory is recorded, and the target project type of the workspace is determined based on the target project type identification file; based on preset rules, a startup file is obtained from the project directory; based on the target project type, a target startup command for starting the target project is obtained from the obtained startup file, and the target startup command is executed to start the target project. By adopting the above technology, the project startup plug-in developed in VS Code can be used to automatically identify the type of project and start the corresponding type of project, which reduces the manual operations required to start the specified type of project, has low programming ability requirements for relevant personnel, and is conducive to improving software development efficiency.
[0008] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0009] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0011] Figure 1 This is a flowchart of a project startup method based on VS Code in an embodiment of the present invention; Figure 2 This is an example diagram of using a project startup plug-in to start a project in an embodiment of the present invention; Figure 3 This is a schematic diagram of the structure of a project startup device based on VS Code in an embodiment of the present invention; Figure 4 The figure is a schematic diagram of the structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0012] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0013] At present, existing software development technologies usually adopt a method of manually creating projects of the required types for development. After creating multiple projects of different types in this way, if relevant personnel want to start a specified type of project, they need to manually identify the type of each project and find the specified type of project and then execute the corresponding start command to start the project. The operation is cumbersome and requires high programming ability of the relevant personnel. It is difficult to start multiple projects of different types, and the software development efficiency is low.
[0014] Based on this, the present invention provides a project startup method, device and electronic device based on VS Code, which can alleviate the above-mentioned problems existing in existing software development technology.
[0015] To facilitate understanding of this embodiment, a project startup method based on VS Code disclosed in an embodiment of the present invention is first described in detail. This method can be applied to a project startup plug-in developed in VS Code. Figure 1 As shown, the method may include the following steps: Step S102, obtaining the project directory of the workspace corresponding to the user.
[0016] The workspace may include at least one project, and the project directory may include a file directory of each project represented in a tree structure.
[0017] The types of projects can be divided according to programming languages. For example, the types of projects can include Vue, Node.js, Python, Java, etc. The specific division method of project types is not limited here.
[0018] Step S104, traverse the project directory to determine whether there is a project type identification file in the project directory.
[0019] In actual application, the project type identification file may refer to a file that is representative of the project type, such as the package.json file in a Node.js project, the pom.xml file in a Java project, etc. The definition method of the project type identification file is not limited here.
[0020] Step S106: If there is a project type identification file in the project directory, the target project type identification file in the project directory is recorded, and the target project type of the workspace is determined based on the target project type identification file.
[0021] For example, if there is a package.json file in the project directory, it can be determined that the workspace contains a Node.js project (that is, the target project type of the workspace is of the Node.js type); if there is a pom.xml file in the project directory, it can be determined that the workspace contains a Java project (that is, the target project type of the workspace is of the Java type).
[0022] Step S108, obtaining a startup file from the project directory based on a preset rule.
[0023] The startup file includes a startup command for starting a corresponding project.
[0024] The preset rules can be defined in terms of file name, data structure in the file, data content in the file, project metadata, file directory hierarchy, etc. The definition method of the preset rules is not limited here.
[0025] Step S110 , obtaining a target startup command for starting the target project from the obtained startup file based on the target project type, and executing the target startup command to start the target project.
[0026] An embodiment of the present invention provides a project startup method based on VS Code, which obtains the project directory of the workspace corresponding to the user; traverses the project directory to determine whether there is a project type identification file in the project directory; if there is a project type identification file in the project directory, then the target project type identification file in the project directory is recorded, and the target project type of the workspace is determined based on the target project type identification file; based on preset rules, a startup file is obtained from the project directory; based on the target project type, a target startup command for starting the target project is obtained from the obtained startup file, and the target startup command is executed to start the target project. By adopting the above technology, the project startup plug-in developed in VS Code can be used to automatically identify the type of project and start the corresponding type of project, which reduces the manual operations required to start the specified type of project, has low programming ability requirements for relevant personnel, and is conducive to improving software development efficiency.
[0027] As a possible implementation, the preset rules may include a first rule for determining whether the main file name of the file contains the first keyword, a second rule for determining whether the extension of the file is the target extension, a third rule for determining whether the data structure of the file is the target data structure, and a fourth rule for determining whether the data in the file contains the second keyword. Based on this, the above step S108 (i.e., obtaining the startup file from the project directory based on the preset rules) may include: Step 1, traverse the project directory to get the file name of each file in the project directory.
[0028] The file name may include the main file name and extension of the corresponding file.
[0029] Step 2: Obtain an initial candidate file from the project directory based on the first rule, the second rule and the obtained file name.
[0030] The candidate files may include a first initial candidate file whose main file name contains the first keyword and / or a second initial candidate file whose extension is the target extension.
[0031] Exemplarily, when traversing to a file in the project directory, the file name (including the main file name and the extension) of the file can be obtained, and based on the first rule, it can be determined whether the main file name of the file contains the first keyword. If the main file name of the file contains the first keyword (such as "config", "setup", etc.), the file can be determined as the first initial candidate file; after obtaining the extension of the file, it can also be determined based on the second rule whether the extension of the file is the target extension (such as ".json", ".xml", ".yaml", ".sh", etc.). If the extension of the file is the target extension, the file can be determined as the second initial candidate file; if the file is determined to be the first initial candidate file and / or the second initial candidate file, it means that the possibility that the file is a startup file is relatively high, and it can be further determined whether the file is a startup file.
[0032] Step 3, perform data analysis on the obtained initial candidate file, and based on the third rule, the fourth rule and the data analysis result, obtain a candidate file whose data structure is the target data structure and whose data contains the second keyword from the obtained initial candidate file, and then obtain the startup file from the obtained candidate file.
[0033] For example, after traversing to a file in the project directory and determining that the file is the first initial candidate file and / or the second initial candidate file, the file may be further parsed to obtain the data structure and data content of the file, and based on the third rule, it may be determined whether the data structure of the file is the target data structure (e.g., having a "scripts" field, a <build>Tags, etc.), if the data structure of the file is the target data structure, then it is further determined based on the fourth rule whether the data content of the file contains a second keyword (such as "start", "run", "main", etc.); if the data content of the file contains the second keyword, the file can be determined as a candidate file; if the file is determined as a candidate file, it means that the possibility that the file is a startup file is very high, and the file can be directly determined as a startup file or further determined whether the file is a startup file.
[0034] In actual application, the above preset rules may also include project metadata (such as .gitignore files, README.md files, etc.) and / or a fifth rule for determining whether the file directory level is the target level. Based on this, there are two main operation methods for obtaining the startup file from the candidate files obtained in step 3 above: Operation mode 1, extracting the obtained candidate file as the startup file.
[0035] Continuing with the previous example, for a certain candidate file, the candidate file can be directly determined as a startup file and the candidate file can be obtained.
[0036] Operation method 2, determines the file directory level of the candidate file obtained, and obtains the target file from the candidate file based on the project metadata and / or the fifth rule, and then extracts the obtained target file as the startup file; wherein, the target file includes the project metadata and / or the file directory level of the target file as the target level.
[0037] Continuing with the previous example, for a candidate file, the file directory level of the candidate file can be determined, and based on the fifth rule, it can be determined whether the file directory level of the candidate file is the target level. If the file directory level of the candidate file is the target level, the candidate file can be determined as the target file, and the candidate file can be extracted as the startup file; it can also be determined whether the candidate file includes project metadata. If the candidate file includes project metadata, the candidate file can be determined as the target file, and the candidate file can be obtained as the startup file.
[0038] As a possible implementation, the above-mentioned project startup method based on VS Code may also include: if there is a project type identification file in the project directory, then recording the target file directory of the target project type identification file, and caching the recorded target file directory, so as to directly determine the target project type identification file based on the cached target file directory when traversing to the target project directory. By adopting the above-mentioned operation method of caching the results generated during the traversal process, the cached results can be directly used when the cached results appear during the traversal process, which can reduce repeated calculations during the traversal process, thereby facilitating improving the efficiency of traversing the project directory to find the project type identification file.
[0039] As a possible implementation, determining the target project type of the workspace based on the target project type identification file in step S106 may include: obtaining a file name of the project type identification file; and determining the target project type of the workspace based on the obtained file name.
[0040] For example, if it is detected that the file name of a certain file is "package.json", then the target project type that can be determined is the Node.js type; if it is detected that the file name of a certain file is "pom.xml", then the target project type that can be determined is the Java type.
[0041] As a possible implementation, the above-mentioned VS Code-based project startup method may also include: providing a graphical user interface to display the project directory through the graphical user interface after obtaining the project directory of the workspace corresponding to the user.
[0042] As a possible implementation, after displaying the project directory through a graphical user interface, the above-mentioned VSCode-based project startup method may also include: in response to a file selection operation or a folder selection operation on the project directory displayed by the graphical user interface, generating a startup menu and displaying it through the graphical user interface, so as to traverse the project directory after responding to the project startup trigger operation on the startup menu to determine whether there is a project type identification file in the project directory.
[0043] Exemplarily, after the project directory is displayed on the graphical user interface, the user can select any file or folder in the project directory on the graphical user interface (such as right-clicking or double-clicking the mouse) to trigger the project startup plug-in developed in VS Code to generate a startup menu and display the startup menu through the graphical user interface. The startup menu may include startup options, and the user can select the startup option on the startup menu, thereby triggering the project startup plug-in to traverse the project directory through the selection operation to determine whether there is a project type identification file in the project directory.
[0044] As a possible implementation, the startup file may correspond to the target project type one by one. Based on this, if there is only one target project type, then in step S110, obtaining a target startup command for starting the target project from the obtained startup file based on the target project type may include: obtaining the target startup command from the startup file.
[0045] Accordingly, if there are multiple target project types, then in the above step S110, obtaining a target startup command for starting the target project from the obtained startup file based on the target project type may include: Step A1: Generate a startup project selection menu based on the target project type and the startup file and display it through a graphical user interface.
[0046] The startup project selection menu may include options corresponding to each target project type, and each option is generated based on the corresponding target project type and its corresponding startup file.
[0047] Step A2, in response to a selection operation of a target option in a startup item selection menu displayed on a graphical user interface, a target startup file corresponding to the target option is determined from the startup file, and a target startup command is obtained from the target startup file.
[0048] For ease of understanding, the implementation of the above-mentioned project startup method based on VS Code is described as follows by taking a specific application as an example.
[0049] You can develop a project startup plug-in that is integrated into the VS Code environment in advance so that you can use the project startup plug-in to start the project. Figure 2 As shown, the process of starting a project using the project startup plug-in is as follows: Step S1, identifying the project type.
[0050] Among them, project types can include Vue, Node.js, Python, Java and other types.
[0051] The operation method of the above step S1 may include: Step S11, check the project root directory.
[0052] For example, a user opens a large workspace containing one or more projects in VS Code. The project startup plug-in can obtain the project directory tree of the current workspace, and start from the current workspace directory of VS Code, and check whether there is a project type identification file (such as package.json file, pom.xml file, requirements.txt file, etc.) directory by directory.
[0053] Step S12, recording the inspection path.
[0054] The project startup plug-in can record the checked paths during the inspection process to avoid repeated inspections.
[0055] Step S13, determine the project type.
[0056] Once the project type identification file is found, the project startup plug-in can record the path of the project type identification file in the project directory tree and determine the project type based on the file type of the project type identification file. For example, if there is a Node.js project and a Java project in the workspace, the project startup plug-in will detect the package.json file and identify that there is a Node.js project in the workspace, and the project startup plug-in will detect the pom.xml file and identify that there is a Java project in the workspace.
[0057] Step S2, determine the startup file location.
[0058] Possible startup file identifiers can be defined in advance for each project type (for example, the startup file identifier of a Node.js project can be the start script, the "scripts" field in the package.json file, etc.), so that the project startup plug-in can use a depth-first search algorithm to search the project directory to determine the startup file location.
[0059] The search process of the depth-first search algorithm can mainly include: starting from the project root directory, performing a depth-first search on each directory; for each directory, checking whether there is a startup file identifier; if the startup file identifier is found, recording the path of the directory where the startup file identifier exists; if the project type has a known common directory structure, the common directory structure can be checked first; for a specific type of project, you can first check whether there is a startup file identifier in the root directory instead of checking whether there is a startup file identifier in the subdirectory (for example, for a Node.js project, you can first check the package.json file in the root directory instead of deeply checking the subdirectory).
[0060] Starting from the project root directory, the operation mode of depth-first search for each directory can be: the project startup plug-in starts from the project root directory and gives priority to checking common startup files in the root directory (such as package.json files are usually located in the root directory). If the startup file is not found in the root directory, the project startup plug-in will record the root directory and recursively check the subdirectories; in each subdirectory, the project startup plug-in again gives priority to checking the startup file instead of going deep into deeper subdirectories to check the startup file; once the startup file is found in a directory, the project startup plug-in will stop further searching in that branch and return the search results to the user, that is, the project startup plug-in will give priority to the main project types marked by the user instead of searching deeply in each subdirectory.
[0061] When using the depth-first search algorithm to search the project directory to determine the location of the startup file, you can use the cache mechanism to cache the results of previous searches. When the same search conditions appear, you can directly use the cached results to reduce repeated calculations. You can also formulate a series of rules based on experience in advance so that when analyzing file contents (such as analyzing file names, parsing file data, etc.), you can use the formulated rules to filter out startup files. For example, files with file names containing "config", "setup", etc. may be startup files, and files with shallower path depth may be startup files. Project metadata (such as .gitignore, README.md, etc.) is used to infer possible startup file locations. Possible startup files are filtered out based on common startup file types (such as .json, .xml, .yaml, .sh, etc.). Files with specific data structures (such as those with the "scripts" field, files with <build>tags, etc.) and whose data content contains specific keywords (such as "start", "run", "main", etc.) may be startup files, and those with specific file names (such as "package.json", etc.) may be startup files.
[0062] Step S3, executing a start command according to the project type.
[0063] The operation method of the above step S3 may include: Step S31, read the start command.
[0064] The corresponding startup command in the corresponding startup file can be read according to the project type and the determined startup file location.
[0065] For example, the project startup plug-in finds the "scripts" field in the package.json file (this is a common startup file identifier). If the "start": "node app.js" command is defined in the "scripts" field, the project startup plug-in can extract the command as the startup command.
[0066] Step S32, execute the start command.
[0067] For example, for a Node.js project, the child_process module of Node.js can be used to execute the startup command of the read Node.js project.
[0068] In the above step S3, the project corresponds to the startup file whose location is determined (that is, each project has a unique startup file for starting the project and the directory location is known), and each startup file contains a startup command for starting the corresponding project. After determining the project type and obtaining the startup command, the project startup plug-in can adopt the following two different operation modes according to whether there is one or more project types: (1) if there is only a single type of project, the startup command is directly executed; (2) if there are multiple types of projects, the options corresponding to each option are generated based on each project type and its corresponding startup file, and then a startup project selection menu containing multiple options is generated and displayed through the provided user interface, so that the user can trigger the project startup plug-in to execute the startup file corresponding to the specified option by selecting the specified option in the startup project selection menu.
[0069] In actual application, each option in the startup project selection menu can be named with the folder name where the startup file is located + the project type name, so that users can intuitively know the project to be started through the startup project selection menu and select the corresponding option to trigger the startup of the corresponding project.
[0070] Step S4, displaying the execution result of the startup command.
[0071] The project startup plug-in can capture the startup command execution result obtained after the above step S3 and display it in the terminal of VS Code.
[0072] Continuing with the previous example, after obtaining the execution result of the startup command, the project startup plug-in can display the execution result of the startup command through the user interface.
[0073] The advantages of the above VS Code-based project startup method compared to existing technologies are mainly reflected in the following aspects: 1) Improve development efficiency: By automatically identifying project types and startup files, developers can reduce manual operations during project configuration and startup, significantly improving development efficiency.
[0074] 2) Reduce operational error rates: Automated processing reduces human intervention, thereby reducing errors caused by manual operations.
[0075] 3) Enhanced user experience: Allow users to select a project to start through the user interface, so that programming beginners can easily manage and start projects.
[0076] 4) Flexibility and scalability: It supports multiple programming languages, is suitable for a variety of project types, and has good flexibility and scalability.
[0077] Based on the above-mentioned project startup method based on VS Code, an embodiment of the present invention further provides a project startup device based on VS Code, which can be applied to a project startup plug-in developed in VS Code, see Figure 3 As shown, the device may include the following modules: The first acquisition module 302 is used to acquire a project directory of a workspace corresponding to the user; wherein the workspace includes at least one project, and the project directory includes a file directory of each project represented in a tree structure.
[0078] The determination module 304 is used to traverse the project directory to determine whether there is a project type identification file in the project directory.
[0079] The recording and determining module 306 is configured to record a target project type identification file in the project directory if a project type identification file exists in the project directory, and determine the target project type of the workspace based on the target project type identification file.
[0080] The second acquisition module 308 is used to acquire a startup file from the project directory based on a preset rule; wherein the startup file includes a startup command for starting a corresponding project.
[0081] The startup module 310 is used to obtain a target startup command for starting the target project from the obtained startup file based on the target project type, and execute the target startup command to start the target project.
[0082] By adopting the above-mentioned project startup device based on VS Code, the project startup plug-in developed in VS Code can be used to automatically identify the type of project and start the corresponding type of project, reducing the manual operations required to start the specified type of project, and having low programming ability requirements for relevant personnel, which is conducive to improving software development efficiency.
[0083] The above-mentioned preset rules may include a first rule for determining whether the main file name of a file contains a first keyword, a second rule for determining whether the extension of a file is a target extension, a third rule for determining whether the data structure of a file is a target data structure, and a fourth rule for determining whether the data in the file contains a second keyword; based on this, the above-mentioned second acquisition module 308 may also be used to: traverse the project directory to obtain the file name of each file in the project directory; wherein the file name includes the main file name and extension of the corresponding file; obtain initial candidate files from the project directory based on the first rule, the second rule and the obtained file name; wherein the candidate files include a first initial candidate file whose main file name contains the first keyword and / or a second initial candidate file whose extension is the target extension; perform data parsing on the obtained initial candidate files, and obtain a candidate file whose data structure is the target data structure and whose data in the file contains the second keyword from the obtained initial candidate files based on the third rule, the fourth rule and the data parsing result, and then obtain the startup file from the obtained candidate files.
[0084] The above-mentioned preset rules may also include project metadata and / or a fifth rule for determining whether the file directory level is the target level; based on this, the above-mentioned second acquisition module 308 may also be used to extract the obtained candidate file as a startup file; or, determine the file directory level of the obtained candidate file, and obtain the target file from the candidate file based on the project metadata and / or the fifth rule, and then extract the obtained target file as the startup file; wherein, the target file includes the project metadata and / or the file directory level of the target file is the target level.
[0085] The above-mentioned record determination module 306 can also be used for: if there is a project type identification file in the project directory, then the target file directory of the target project type identification file is recorded, and the recorded target file directory is cached, so that when traversing to the target project directory, the target project type identification file is directly determined based on the cached target file directory.
[0086] The record determination module 306 may also be used to: obtain the file name of the project type identification file; and determine the target project type of the workspace based on the obtained file name.
[0087] The first acquisition module 302 may also be used to provide a graphical user interface, so as to display the project directory through the graphical user interface after acquiring the project directory of the workspace corresponding to the user.
[0088] The above-mentioned first acquisition module 302 can also be used for: after displaying the project directory through the graphical user interface, in response to a file selection operation or a folder selection operation for the project directory displayed by the graphical user interface, generating a startup menu and displaying it through the graphical user interface, so as to traverse the project directory after responding to the project start trigger operation for the startup menu to determine whether there is a project type identification file in the project directory.
[0089] The startup file may correspond to the target project type one by one. Based on this, if there is only one target project type, the startup module 310 may also be used to obtain the target startup command from the startup file.
[0090] If there are multiple target project types, the above-mentioned startup module 310 can also be used to: generate a startup project selection menu based on the target project type and the startup file and display it through the graphical user interface; wherein the startup project selection menu includes options corresponding to each target project type, and each option is generated based on the corresponding target project type and its corresponding startup file; in response to a selection operation of a target option in the startup project selection menu displayed by the graphical user interface, determine the target startup file corresponding to the target option from the startup file, and obtain the target startup command from the target startup file.
[0091] The implementation principle and technical effects of the project startup device based on VS Code provided in the embodiment of the present invention are the same as those of the aforementioned project startup method based on VS Code. For the sake of brief description, for matters not mentioned in the embodiment of the project startup device based on VS Code, reference may be made to the corresponding contents in the aforementioned project startup method based on VS Code.
[0092] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 41 and a memory 40, the memory 40 stores computer executable instructions that can be executed by the processor 41, and the processor 41 executes the computer executable instructions to implement the above-mentioned VS Code-based project startup method.
[0093] exist Figure 4 In the illustrated embodiment, the electronic device further includes a bus 42 and a communication interface 43 , wherein the processor 41 , the communication interface 43 and the memory 40 are connected via the bus 42 .
[0094] Among them, the memory 40 may include a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 43 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used. The bus 42 can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The bus 42 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0095] The processor 41 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit in the processor 41 or the instruction in the form of software. The above processor 41 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiment of the present invention can be directly embodied as a hardware decoding processor to execute, or it can be executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 41 reads the information in the memory and completes the steps of the project startup method based on VS Code in the aforementioned embodiment in combination with its hardware.
[0096] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0097] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that can be executed by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., various media that can store program codes.
[0098] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are only used for descriptive purposes and cannot be understood as indicating or implying relative importance.
[0099] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.< / build> < / build>
Claims
1. A project startup method based on VS Code, characterized in that: The method is applied to a project startup plug-in developed in VS Code, and the method includes: Obtaining a project directory of a workspace corresponding to the user; wherein the workspace includes at least one project, and the project directory includes a file directory of each project represented in a tree structure; Traversing the project directory to determine whether there is a project type identification file in the project directory; If there is a project type identification file in the project directory, recording the target project type identification file in the project directory, and determining the target project type of the workspace based on the target project type identification file; Obtaining a startup file from the project directory based on a preset rule; wherein the startup file includes a startup command for starting a corresponding project; A target startup command for starting the target project is acquired from the obtained startup file based on the target project type, and the target startup command is executed to start the target project.
2. The method according to claim 1, characterized in that The preset rules include a first rule for determining whether the main file name of a file contains a first keyword, a second rule for determining whether the extension of a file is a target extension, a third rule for determining whether the data structure of a file is a target data structure, and a fourth rule for determining whether the data in the file contains a second keyword; Obtaining a startup file from the project directory based on preset rules, including: Traversing the project directory to obtain the file name of each file in the project directory; wherein the file name includes the main file name and extension of the corresponding file; Acquire initial candidate files from the project directory based on the first rule, the second rule and the obtained file name; wherein the candidate files include a first initial candidate file whose main file name contains the first keyword and / or a second initial candidate file whose extension name is the target extension name; The obtained initial candidate file is subjected to data parsing, and based on the third rule, the fourth rule and the data parsing result, a candidate file whose data structure is the target data structure and whose data contains the second keyword is obtained from the obtained initial candidate file, and then the startup file is obtained from the obtained candidate file.
3. The method according to claim 2, characterized in that The preset rule also includes project metadata and / or a fifth rule for determining whether the file directory level is a target level; obtaining the startup file from the obtained candidate files includes: Extract the obtained candidate file as the startup file; or, determine the file directory level of the obtained candidate file, and obtain the target file from the candidate file based on the project metadata and / or the fifth rule, and then extract the obtained target file as the startup file; wherein the target file includes the project metadata and / or the file directory level of the target file as the target level.
4. The method according to claim 1, characterized in that: The method further comprises: If there is a project type identification file in the project directory, the target file directory of the target project type identification file is recorded, and the recorded target file directory is cached so that when traversing to the target project directory, the target project type identification file is directly determined based on the cached target file directory.
5. The method according to claim 2, characterized in that: Determining the target project type of the workspace based on the target project type identification file includes: Get the file name of the project type identification file; A target project type of the workspace is determined based on the obtained file name.
6. The method according to claim 2, characterized in that The method further comprises: A graphical user interface is provided to display the project directory through the graphical user interface after obtaining the project directory of the workspace corresponding to the user.
7. The method according to claim 6, characterized in that After displaying the project catalog via the graphical user interface, the method further includes: In response to a file selection operation or a folder selection operation on a project directory displayed by the graphical user interface, a startup menu is generated and displayed through the graphical user interface, so as to traverse the project directory in response to a project startup trigger operation on the startup menu to determine whether there is a project type identification file in the project directory.
8. The method according to claim 6, characterized in that The startup file corresponds to the target project type one by one; if there is only one target project type, obtaining a target startup command for starting the target project from the obtained startup file based on the target project type includes: Obtain the target startup command from the startup file; If there are multiple target project types, obtaining a target startup command for starting the target project from the obtained startup file based on the target project type includes: Generate a startup project selection menu based on the target project type and the startup file and display it through the graphical user interface; wherein the startup project selection menu includes options corresponding to each target project type, and each option is generated based on the corresponding target project type and its corresponding startup file; In response to a selection operation of a target option in a startup item selection menu displayed on the graphical user interface, a target startup file corresponding to the target option is determined from the startup file, and the target startup command is obtained from the target startup file.
9. A project startup device based on VS Code, characterized in that: The device is applied to a project startup plug-in developed in VS Code, and the device includes: A first acquisition module is used to acquire a project directory of a workspace corresponding to a user; wherein the workspace includes at least one project, and the project directory includes a file directory of each project represented in a tree structure; A determination module, used for traversing the project directory to determine whether there is a project type identification file in the project directory; a recording and determining module, configured to record a target project type identification file existing in the project directory if a project type identification file exists in the project directory, and determine a target project type of the workspace based on the target project type identification file; A second acquisition module is used to acquire a startup file from the project directory based on a preset rule; wherein the startup file includes a startup command for starting a corresponding project; The startup module is used to obtain a target startup command for starting the target project from the obtained startup file based on the target project type, and execute the target startup command to start the target project.
10. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Software project development method and device, computer storage medium and computer equipment
CN113448572A
Automatic container starting method based on various types of projects
CN113485795A
Software project dependency analysis method and device, computer equipment and storage medium
CN115202709A
Front-end project deployment method and device based on VS Code
CN116820445A