CN111966358A - Code packaging method and device, electronic equipment and computer readable storage medium - Google Patents
Code packaging method and device, electronic equipment and computer readable storage medium Download PDFInfo
- Publication number
- CN111966358A CN111966358A CN202010747810.9A CN202010747810A CN111966358A CN 111966358 A CN111966358 A CN 111966358A CN 202010747810 A CN202010747810 A CN 202010747810A CN 111966358 A CN111966358 A CN 111966358A
- Authority
- CN
- China
- Prior art keywords
- code file
- code
- packaging
- generate
- fragments
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/447—Target code generation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/70—Software maintenance or management
- G06F8/71—Version control; Configuration management
Abstract
The disclosure provides a code packaging method and device and electronic equipment. The method comprises the following steps: in the process of editing codes by a user, acquiring an abstract syntax tree of the codes to be packaged from a code editor of a browser; analyzing the abstract syntax tree into different types of code file segments; and packaging the code file fragments with the same type to generate a corresponding executable code file packet. The packaging of code can be implemented without relying on the operating system environment and operating system software.
Description
Technical Field
The present disclosure relates to the field of code management technologies, and in particular, to a code packing method, a code packing apparatus, an electronic device, and a computer-readable storage medium.
Background
Currently, project codes are basically presented in a modularization mode, and modularization means dispersion and cannot be directly used for presentation, so that corresponding packing operation needs to be carried out on the modularization codes to form an integral code package. The core idea of the modular packaging is to find out the dependency relationship among the code modules and then pack the code modules into an integral code package.
A commonly used packing tool is that a JavaScript application gets a static module packer (module bundler) webpack, and when the webpack processes the JavaScript application, a dependency graph (dependency graph) is recursively constructed, where each code module required by the application is included, and then the code modules are packed into one or more code packages.
However, the existing packaging tool usually needs to depend on an operating system environment of a server or a client and needs to depend on a lot of operating system software, so that developers are required to build a complicated development environment, and the complexity of implementation and the consumed labor cost are high. Therefore, it is necessary to provide a new code packing method.
Disclosure of Invention
The embodiment of the disclosure provides a new code packing method, so as to realize the packing of codes without depending on an operating system environment and operating system software.
According to a first aspect of the embodiments of the present disclosure, there is provided a code packing method, the method including:
in the process of editing codes by a user, acquiring an abstract syntax tree of the codes to be packaged from a code editor of a browser;
analyzing the abstract syntax tree into different types of code file segments;
and packaging the code file fragments with the same type to generate a corresponding executable code file packet.
Optionally, the parsing the abstract syntax tree into different types of code file fragments includes:
and analyzing the abstract syntax tree by adopting a Babel browser analysis technology to obtain different types of code file fragments.
Optionally, wherein the types of the code file fragments include: a JS code file segment, a cascading style sheet CSS code file segment and an MD code file segment.
Optionally, the packaging the code file fragments of the same type to generate a corresponding executable code file package includes:
packaging the JS code file fragments to generate a JS executable code file package;
packaging the CSS code file fragments to generate a CSS executable code file package; and the number of the first and second groups,
and packaging the MD code file fragments to generate an MD executable code file package.
Optionally, after parsing the abstract syntax tree by using a Babel browser parsing technology to obtain different types of code file fragments, the method further includes:
and temporarily storing the different types of code file fragments in a cache of the browser.
Optionally, after the packaging the code file fragments of the same type to generate the corresponding executable code file package, the method further includes:
and when a code acquisition instruction is received, the executable code file packet is sent to an application system.
Optionally, after the packaging the code file fragments of the same type to generate the corresponding executable code file package, the method further includes:
and dynamically associating the executable code file package with the application system function through a pre-registered application system function.
According to a second aspect of the embodiments of the present disclosure, there is provided a code packing apparatus, the apparatus including:
the acquisition module is used for acquiring an abstract syntax tree of a code to be packaged from a code editor of the browser in the process of editing the code by a user;
the analysis module is used for analyzing the abstract syntax tree into different types of code file fragments;
and the packing module is used for packing the code file fragments with the same type to generate a corresponding executable code file package.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including:
a processor and a memory for storing instructions for controlling the processor to perform a method according to any one of the first aspects of embodiments of the present disclosure.
According to a fourth aspect of the embodiments of the present disclosure, there is provided a processor, which when executed, performs the method of any one of the first aspect of the embodiments of the present disclosure.
According to the method of the embodiment of the disclosure, in the process of editing the code by a user, an abstract syntax tree of the code to be packaged is obtained from a code editor of a browser; analyzing the abstract syntax tree into different types of code file segments; and packaging the code file fragments with the same type to generate a corresponding executable code file packet. The packaging of code can be implemented without relying on the operating system environment and operating system software.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a schematic flow chart diagram of a code packing method of an embodiment of the present disclosure;
FIG. 2 is a schematic flow chart of a code packaging method to which an embodiment of the present disclosure is applied;
FIG. 3 is a schematic block diagram of a code packaging apparatus of an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of an electronic device of an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The embodiment of the disclosure provides a code packaging method. Specifically, as shown in fig. 1, the method may include the following steps 1100 to 1300:
step 1100, in the process of editing the code by the user, obtaining the abstract syntax tree of the code to be packaged from the code editor of the browser.
Step 1200, parsing the abstract syntax tree into different types of code file segments.
Specifically, the abstract syntax tree may be parsed by using a Babel browser parsing technique to obtain different types of code file fragments. For example, the abstract syntax tree can be parsed by running the babel and the corresponding babel plugin in real-time during the course of the user editing the code. Wherein, the types of the code file fragments comprise: JS code file segment, Cascading Style Sheets (CSS) code file segment, and md (markdown) code file segment.
In practical application, after the abstract syntax tree is analyzed to obtain different types of code file fragments, the different types of code file fragments can be further temporarily stored in the cache of the browser.
Step 1300, packaging the code file fragments with the same type to generate a corresponding executable code file packet.
Specifically, the JS code file segment may be packaged to generate a JS executable code file package; packaging the CSS code file fragments to generate a CSS executable code file package; and packaging the MD code file fragments to generate an MD executable code file package.
In a feasible implementation manner, after the code file segments with the same type are packaged to generate a corresponding executable code file packet, the executable code file packet may be further issued to an application system according to a received code acquisition instruction from an application program.
In another possible implementation, after the code file fragments of the same type are packaged to generate a corresponding executable code file package, the executable code file package may be dynamically associated with the application system function through a pre-registered application system function.
The application system is composed of a computer hardware system, system software and application software. The computer hardware system consists of arithmetic unit, controller, memory, peripheral interface and peripheral equipment, the system software includes operation system, compiling program, database management system, high level languages, etc. and the application software consists of common support software and various application software packages.
In the application system, classification management can be established by using Java technology, so that the addition, deletion, modification and check are supported, and tree file data is constructed. The tree file data is stored in a database, and the tree file data can be displayed in a visual mode by using a react technology in the foreground. The user may manage the tree file data, for example, managing a multi-level code version folder, and managing a plurality of code files associated in each level of the code version folder.
Further, the application system also supports the storage of tree file data. Specifically, the tree file data may be stored in a database and a file server, respectively. In the process of loading codes, preferentially loading corresponding code files from the tree file data stored in the file server; and when the file server is abnormal, loading the corresponding code file from the tree file data stored in the database. And meanwhile, when the file server is abnormal, the tree file data in the database can be automatically synchronized to the file server.
As shown in fig. 2, in this embodiment, for the JS code file type, a pre-load/cancel pre-load action is defined for the JS code file type, when JS is set as pre-load, JS1, JS2, and JSn are automatically analyzed and merged into a unified JS executable code file package through Babel during construction, and the JS executable code file package is introduced before the application system is loaded, so that some application system function events can be registered before the application system is loaded, and the effect of service association is achieved. And a JS code editor is used in the foreground to be associated with the JS executable code file packet, the compiling of the JS file, the grammar highlighting, the format control and the code prompting are supported, in addition, a browser compiler is realized before the saving, the file is compiled in real time during the saving, the code before the compiling and the code after the compiling are saved to the background and are simultaneously stored, and the source code and the code after the compiling are distinguished by the storage.
For the CSS file type, when the CSS is set to be preloaded, the CSS1, the CSS2 and the CSSn are automatically merged into a unified CSS executable code file package during construction, the CSS executable code file package is introduced before the application system is loaded, and some global styles can be defined for the application system. In the foreground, a CSS code editor is used to associate with a CSS executable code file package and support CSS files.
Aiming at the MD file type, the MD editor is associated with the MD file in the foreground, the real-time editing and previewing functions are realized, and the method is used for writing the technical document of the specific small program in the application system
In the code packaging method of the embodiment, in the process of editing codes by a user, an abstract syntax tree of the codes to be packaged is obtained from a code editor of a browser; analyzing the abstract syntax tree into different types of code file segments; and packaging the code file fragments with the same type to generate a corresponding executable code file packet. The method has the advantages that developers do not need to build a complicated development environment and know various complex parameters constructed by packaging, and can develop and compile by opening a browser, so that a large amount of labor cost is reduced, and the codes can be packaged without depending on an operating system environment and operating system software. Meanwhile, the problems can be quickly released and repaired, the agility of the development process of the application system is improved, and the method is associated with the bottom layer function of the application system and is convenient to integrate to various services of the application system.
Fig. 3 is a schematic structural diagram of a code packaging apparatus according to an embodiment of the present disclosure. In this embodiment, there is further provided a code packaging apparatus, as shown in fig. 3, the code packaging apparatus 3000 of this embodiment may include: an acquisition module 3100, a parsing module 3200, and a packing module 3300.
The obtaining module 3100 is configured to obtain an abstract syntax tree of a code to be packaged from a code editor of a browser in a process of editing the code by a user.
An parsing module 3200 for parsing the abstract syntax tree into different types of code file segments.
A packing module 3300, configured to pack the code file fragments with the same type to generate a corresponding executable code file package.
Optionally, the parsing module 3200 may use a Babel browser parsing technique to parse the abstract syntax tree to obtain different types of code file segments.
Wherein, the types of the code file fragments comprise: a JS code file segment, a cascading style sheet CSS code file segment and an MD code file segment.
Optionally, the packaging module 3300 may specifically package the JS code file segment to generate a JS executable code file package; packaging the CSS code file fragments to generate a CSS executable code file package; and packaging the MD code file fragments to generate an MD executable code file package.
Further, the code packaging apparatus 3000 may further include a storage module, configured to temporarily store the different types of code file fragments in a cache of the browser.
Further, the code packaging apparatus 3000 may further include an issuing module, configured to issue the executable code file package to an application system when receiving the code obtaining instruction.
Further, the code packaging apparatus 3000 may further include an association module, configured to dynamically associate the executable code file package with the application system function through a pre-registered application system function.
The code packaging apparatus of this embodiment may be configured to execute the technical solution of the above method embodiment, and the implementation principle and the technical effect are similar, which are not described herein again.
In this embodiment, there is also provided an electronic device, which may include the code packaging apparatus 3000 described in the apparatus embodiment of the present disclosure; alternatively, the electronic device is the electronic device 4000 shown in fig. 4, and includes:
a processor and a memory for storing instructions for controlling the processor to perform a method described in any of the method embodiments of the present disclosure.
The implementation subject of the embodiment of the method executed in the electronic equipment can be a server or a terminal device.
The present embodiments provide a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, perform the method described in any of the method embodiments of the present disclosure.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims (10)
1. A method of code packaging, the method comprising:
in the process of editing codes by a user, acquiring an abstract syntax tree of the codes to be packaged from a code editor of a browser;
analyzing the abstract syntax tree into different types of code file segments;
and packaging the code file fragments with the same type to generate a corresponding executable code file packet.
2. The method of claim 1, wherein the parsing the abstract syntax tree into different types of code file fragments comprises:
and analyzing the abstract syntax tree by adopting a Babel browser analysis technology to obtain different types of code file fragments.
3. The method of claim 1, wherein the types of code file fragments comprise: a JS code file segment, a cascading style sheet CSS code file segment and an MD code file segment.
4. The method of claim 3, wherein said packaging said code file fragments of the same type to generate a corresponding executable code file package comprises:
packaging the JS code file fragments to generate a JS executable code file package;
packaging the CSS code file fragments to generate a CSS executable code file package; and the number of the first and second groups,
and packaging the MD code file fragments to generate an MD executable code file package.
5. The method of claim 2, wherein after parsing the abstract syntax tree using a Babel browser parsing technique to obtain different types of code file fragments, the method further comprises:
and temporarily storing the different types of code file fragments in a cache of the browser.
6. The method of claim 1, wherein after packaging the code file fragments of the same type to generate a corresponding executable code file package, the method further comprises:
and when a code acquisition instruction is received, the executable code file packet is sent to an application system.
7. The method of claim 1, wherein after packaging the code file fragments of the same type to generate a corresponding executable code file package, the method further comprises:
and dynamically associating the executable code file package with the application system function through a pre-registered application system function.
8. A code packaging apparatus, the apparatus comprising:
the acquisition module is used for acquiring an abstract syntax tree of a code to be packaged from a code editor of the browser in the process of editing the code by a user;
the analysis module is used for analyzing the abstract syntax tree into different types of code file fragments;
and the packing module is used for packing the code file fragments with the same type to generate a corresponding executable code file package.
9. An electronic device, comprising:
a processor and a memory for storing instructions for controlling the processor to perform the method of any of claims 1 to 7.
10. A computer readable storage medium storing executable instructions that, when executed by a processor, perform the method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010747810.9A CN111966358B (en) | 2020-07-30 | 2020-07-30 | Code packaging method and device, electronic equipment and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202010747810.9A CN111966358B (en) | 2020-07-30 | 2020-07-30 | Code packaging method and device, electronic equipment and computer readable storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN111966358A true CN111966358A (en) | 2020-11-20 |
CN111966358B CN111966358B (en) | 2022-06-07 |
Family
ID=73363614
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202010747810.9A Active CN111966358B (en) | 2020-07-30 | 2020-07-30 | Code packaging method and device, electronic equipment and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN111966358B (en) |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109298900A (en) * | 2018-10-23 | 2019-02-01 | 中国农业银行股份有限公司 | A kind of application fractionation and on-demand loading method, apparatus |
CN109614772A (en) * | 2018-11-20 | 2019-04-12 | 江苏通付盾信息安全技术有限公司 | Code conversion method and device based on application installation package file |
CN110058849A (en) * | 2019-03-13 | 2019-07-26 | 平安普惠企业管理有限公司 | Generation method, device, computer equipment and the storage medium of flow chart |
CN110134401A (en) * | 2019-04-12 | 2019-08-16 | 深圳壹账通智能科技有限公司 | Code snippet localization method, device, computer equipment and storage medium |
CN110442330A (en) * | 2019-07-05 | 2019-11-12 | 五八有限公司 | List element conversion method, device, electronic equipment and storage medium |
CN110471666A (en) * | 2019-07-18 | 2019-11-19 | 五八有限公司 | Code automatic switching method and device, code converter and medium |
CN111209004A (en) * | 2019-12-30 | 2020-05-29 | 北京健康之家科技有限公司 | Code conversion method and device |
CN111381817A (en) * | 2020-03-25 | 2020-07-07 | 北京字节跳动网络技术有限公司 | Method, device, medium and electronic equipment for realizing cross-platform multi-language development |
-
2020
- 2020-07-30 CN CN202010747810.9A patent/CN111966358B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109298900A (en) * | 2018-10-23 | 2019-02-01 | 中国农业银行股份有限公司 | A kind of application fractionation and on-demand loading method, apparatus |
CN109614772A (en) * | 2018-11-20 | 2019-04-12 | 江苏通付盾信息安全技术有限公司 | Code conversion method and device based on application installation package file |
CN110058849A (en) * | 2019-03-13 | 2019-07-26 | 平安普惠企业管理有限公司 | Generation method, device, computer equipment and the storage medium of flow chart |
CN110134401A (en) * | 2019-04-12 | 2019-08-16 | 深圳壹账通智能科技有限公司 | Code snippet localization method, device, computer equipment and storage medium |
CN110442330A (en) * | 2019-07-05 | 2019-11-12 | 五八有限公司 | List element conversion method, device, electronic equipment and storage medium |
CN110471666A (en) * | 2019-07-18 | 2019-11-19 | 五八有限公司 | Code automatic switching method and device, code converter and medium |
CN111209004A (en) * | 2019-12-30 | 2020-05-29 | 北京健康之家科技有限公司 | Code conversion method and device |
CN111381817A (en) * | 2020-03-25 | 2020-07-07 | 北京字节跳动网络技术有限公司 | Method, device, medium and electronic equipment for realizing cross-platform multi-language development |
Also Published As
Publication number | Publication date |
---|---|
CN111966358B (en) | 2022-06-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109032631B (en) | Application program patch package obtaining method and device, computer equipment and storage medium | |
US20130086424A1 (en) | Debugging analysis in running multi-user systems | |
CN112394942B (en) | Distributed software development compiling method and software development platform based on cloud computing | |
CN110377321A (en) | Method, apparatus, terminal and the storage medium of application program updating | |
CN111680253B (en) | Page application data packet generation method and device, computer equipment and storage medium | |
CN114253535A (en) | H5 page multi-language rendering method and device | |
CN112558980A (en) | Multi-software-package management method and device | |
CN110427258B (en) | Resource scheduling control method and device based on cloud platform | |
CN103744680A (en) | Method and device for business process processing | |
CN111740948B (en) | Data packet issuing method, dynamic updating method, device, equipment and medium | |
CN109388403A (en) | Rely on method for implanting, device, equipment and storage medium | |
US8171045B2 (en) | Record based code structure | |
CN106681773A (en) | Android system starting method and device, and Android mobile terminal | |
CN106775824A (en) | A kind of application file packaging system and method with channel information | |
CN110688147A (en) | Method for packing and analyzing metadata | |
US10656922B2 (en) | Systems and methods for providing an application transformation tool | |
CN111966358B (en) | Code packaging method and device, electronic equipment and computer readable storage medium | |
CN112631563A (en) | System development method and device based on framework, computer equipment and storage medium | |
EP1202171A2 (en) | Compile method and program recording medium | |
CN111506309A (en) | Task execution method and system, and computer-readable storage medium | |
CN116431155A (en) | Front-end application construction method, medium, device and computing equipment | |
CN110806891A (en) | Method and device for generating software version of embedded equipment | |
CN112596706A (en) | Patterned code generation method, device and computer readable storage medium | |
CN111880803A (en) | Software construction method and device applied to multiple platforms | |
CN112306501A (en) | Business data acquisition method and device, storage medium and computing equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
TR01 | Transfer of patent right |
Effective date of registration: 20221128 Address after: Room 301, R&D Building 1, No. 1588 Lianhang Road, Minhang District, Shanghai, 200000 (18/2 hills, 481 block, Pujiang Town) Patentee after: Shanghai Pan Micro Software Co.,Ltd. Address before: No. 3006, Huancheng West Road, Fengxian District, Shanghai Patentee before: SHANGHAI WEAVER NETWORK TECHNOLOGY CO.,LTD. |
|
TR01 | Transfer of patent right |