@@ -39,91 +39,6 @@ export default async args => {
3939
4040 const copyAsync = promisify ( copy ) ;
4141
42- // Inline plugin to prepare JS actions for Studio Pro format
43- const studioProFormatPlugin = {
44- name : "studio-pro-format" ,
45- generateBundle ( options , bundle ) {
46- for ( const [ fileName , chunk ] of Object . entries ( bundle ) ) {
47- if ( chunk . type !== "chunk" || ! fileName . endsWith ( ".js" ) ) continue ;
48-
49- let code = chunk . code ;
50-
51- // 1. Check if header exists and remove it (we'll add it back at line 1)
52- const hasHeader = code . includes ( "// This file was generated by Mendix Studio Pro." ) ;
53- if ( hasHeader ) {
54- // Remove existing header (7 lines)
55- code = code . replace (
56- / ^ \/ \/ T h i s f i l e w a s g e n e r a t e d b y M e n d i x S t u d i o P r o \. \r ? \n \/ \/ \r ? \n \/ \/ W A R N I N G : O n l y t h e f o l l o w i n g c o d e w i l l b e r e t a i n e d w h e n a c t i o n s a r e r e g e n e r a t e d : \r ? \n \/ \/ - t h e i m p o r t l i s t \r ? \n \/ \/ - t h e c o d e b e t w e e n B E G I N U S E R C O D E a n d E N D U S E R C O D E \r ? \n \/ \/ - t h e c o d e b e t w e e n B E G I N E X T R A C O D E a n d E N D E X T R A C O D E \r ? \n \/ \/ O t h e r c o d e y o u w r i t e w i l l b e l o s t t h e n e x t t i m e y o u d e p l o y t h e p r o j e c t \. \r ? \n / m,
57- ""
58- ) ;
59- }
60-
61- // 2. Remove Big import (will add back at line 8 with header)
62- const hasBigImport = code . match ( / ^ i m p o r t \s * \{ \s * B i g \s * \} \s * f r o m \s * [ " ' ] b i g \. j s [ " ' ] ; ? \s * $ / m) ;
63- if ( hasBigImport ) {
64- code = code . replace ( / ^ i m p o r t \s * \{ \s * B i g \s * \} \s * f r o m \s * [ " ' ] b i g \. j s [ " ' ] ; ? \s * \r ? \n / m, "" ) ;
65- }
66-
67- // 3. Add header at line 1 + Big import at line 8
68- const header = [
69- "// This file was generated by Mendix Studio Pro." ,
70- "//" ,
71- "// WARNING: Only the following code will be retained when actions are regenerated:" ,
72- "// - the import list" ,
73- "// - the code between BEGIN USER CODE and END USER CODE" ,
74- "// - the code between BEGIN EXTRA CODE and END EXTRA CODE" ,
75- "// Other code you write will be lost the next time you deploy the project." ,
76- 'import { Big } from "big.js";'
77- ] . join ( "\r\n" ) + "\r\n" ;
78-
79- code = header + code ;
80-
81- // 4. Add missing // BEGIN EXTRA CODE if // END EXTRA CODE exists without a BEGIN
82- if ( code . includes ( '// END EXTRA CODE' ) && ! code . includes ( '// BEGIN EXTRA CODE' ) ) {
83- // Find last import line, add BEGIN EXTRA CODE after it
84- code = code . replace ( / ( ^ i m p o r t .+ $ ) / m, '$1\n\n// BEGIN EXTRA CODE' ) ;
85- }
86-
87- // 5. If no EXTRA CODE markers at all, add empty block after imports
88- if ( ! code . includes ( '// BEGIN EXTRA CODE' ) && ! code . includes ( '// END EXTRA CODE' ) ) {
89- code = code . replace ( / ( ^ i m p o r t .+ $ ) ( \r ? \n ) + (? = \/ ? \* \* | e x p o r t ) / m, '$1\n\n// BEGIN EXTRA CODE\n// END EXTRA CODE\n\n' ) ;
90- }
91-
92- // 6. Fix export pattern: async function Name { } export { Name };
93- // → export async function Name { }
94- const exportMatch = code . match ( / e x p o r t \s * \{ \s * ( \w + ) \s * \} ; ? \s * $ / m) ;
95- if ( exportMatch ) {
96- const functionName = exportMatch [ 1 ] ;
97- const funcPattern = new RegExp ( `^(async\\s+function\\s+${ functionName } \\s*\\()` , "m" ) ;
98- code = code . replace ( funcPattern , "export $1" ) ;
99- code = code . replace ( / \n e x p o r t \s * \{ \s * \w + \s * \} ; ? \s * $ / m, "" ) ;
100- }
101-
102- // 7. Fix USER CODE marker indentation: Studio Pro uses tabs inside functions
103- // Match any whitespace before the markers and replace with single tab
104- code = code . replace ( / ^ [ \t ] + ( \/ \/ B E G I N U S E R C O D E ) / gm, "\t$1" ) ;
105- code = code . replace ( / ^ [ \t ] + ( \/ \/ E N D U S E R C O D E ) / gm, "\t$1" ) ;
106-
107- // 8. Ensure blank line before // BEGIN EXTRA CODE
108- code = code . replace ( / ( [ ^ \r \n ] ) \r ? \n ( \/ \/ B E G I N E X T R A C O D E ) / g, "$1\r\n\r\n$2" ) ;
109-
110- // 9. Ensure blank line after // END EXTRA CODE
111- code = code . replace ( / ( \/ \/ E N D E X T R A C O D E ) \r ? \n ( [ ^ \r \n ] ) / g, "$1\r\n\r\n$2" ) ;
112-
113- // 10. Normalize JSDoc formatting to match Studio Pro
114- // - Empty JSDoc lines: ` *` (one space before asterisk, nothing after)
115- // - Lines with text: ` * text` (one space before, one space after asterisk)
116- code = code . replace ( / ^ [ \t ] + \* [ \t ] + $ / gm, " *" ) ; // Empty JSDoc lines: remove trailing whitespace
117- code = code . replace ( / ^ [ \t ] + \* [ \t ] + ( .+ ) $ / gm, " * $1" ) ; // JSDoc with text: normalize to 1 space before and after asterisk
118-
119- // 11. Normalize all line endings to CRLF (Studio Pro expects \r\n everywhere)
120- code = code . replace ( / \r ? \n / g, "\r\n" ) ;
121-
122- chunk . code = code ;
123- }
124- }
125- } ;
126-
12742 files . forEach ( ( file , i ) => {
12843 const fileInput = relative ( cwd , file ) ;
12944 const fileOutput = basename ( file , ".ts" ) ;
@@ -159,7 +74,6 @@ export default async args => {
15974 } ) ,
16075 nodeResolvePlugin ,
16176 typescriptPlugin ,
162- studioProFormatPlugin ,
16377 i === files . length - 1
16478 ? command ( [
16579 async ( ) => copyLicenseFile ( cwd , outDir ) ,
0 commit comments