didierphmartin / MagicCode

release 0.10.5
MIT License
10 stars 2 forks source link

Only 'server' folder is created when executing Magic Code Generator #1

Open orheault opened 2 years ago

orheault commented 2 years ago

When executing Magic Code Generator, I get this error. This is the last few line from the output tab.

I got the mdl file from https://www.magiccodegenerator.com/copy-of-documentation in the model section. I changed the mongodb connection string and output folder.

The server folder is created but not the client folder.


@Service({
    runonce: [
        {echo: '**************************************************'},
        {echo: '****** INSTALLING THE ANGULAR ENVIRONMENT ********'},
        {echo: '*                                                *'},
        {echo: '***  Please wait, this will take some time... ****'},
        {echo: '*                                                *'},
        {echo: '**************************************************'},
        {echo: ' '},
        {exec: 'ng version' },
        {exec: 'ng new client --defaults --skip-tests --verbose --force --skip-install'},
        { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/forms/form.component.css', destination:'client/src/app/views/forms/testClass/testClass.component.css'}},
        { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/lists/list.component.css', destination:'client/src/app/views/lists/testClass/testClass.component.css'}},
    ],
    executePre: [ 
    ],
    files: [ 
            { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/forms/form.component.css', destination:'client/src/app/views/forms/testClass/form.component.css'}},
            { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/lists/list.component.css', destination:'client/src/app/views/lists/testClass/list.component.css'}},
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/services/rest.service.hbs', destination:'client/src/app/services/rest.service.ts'}},
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/services/process.service.hbs', destination:'client/src/app/services/process.service.ts'}},
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/app.module.ts', destination:'client/src/app/app.module.ts'} },
        {handlebars: {template:'applicationTemplates/angular_bootstrap/README.md', destination:'client/README.md'}},
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/app.component.ts', destination:'client/src/app/app.component.ts'} },
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/app.component.css', destination:'client/src/app/app.component.css'} },
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/app.component.html' , destination:'client/src/app/app.component.html'}},    
        {handlebars: {template:'applicationTemplates/angular_bootstrap/index.html' , destination:'client/src/index.html'}},
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/views/home.component.ts', destination:'client/src/app/home.component.ts'}},   
        {handlebars: {template:'applicationTemplates/angular_bootstrap/app/views/pageNotFound.component.ts', destination:'client/src/app/pageNotFound.component.ts'}},
        { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/forms/form.component.hbs', destination:'client/src/app/views/forms/testClass/form.component.ts'}},
        { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/forms/form.component.html', destination:'client/src/app/views/forms/testClass/form.component.html'}},
        { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/lists/list.component.hbs', destination:'client/src/app/views/lists/testClass/list.component.ts'}},
        { handlebars: {name: 'testClass', template:'applicationTemplates/angular_bootstrap/app/views/lists/list.component.html', destination:'client/src/app/views/lists/testClass/list.component.html'}},
        {copy: {source: "c:/Users/orhea/.vscode/extensions/netfolder.magic-1.2.2/applicationTemplates/angular_bootstrap/package.json", destination: "client/package.json"} }
    ],
    executePost: [
        //{ECMAScript: {script:'c:/Users/orhea/.vscode/extensions/netfolder.magic-1.2.2/applicationTemplates/angular_bootstrap/app/views/addon.js', data: 'c:/dev/test-mcg/client/angular.json'}},
        {exec: "cd client"},
        //{exec: "npm install"},
        {exec: "code c:/dev/test-mcg/client"}
    ]
})
export class angular_bootstrap {};
OK

                COMPILE ERROR - Possible cause: 
                -> class and model definition Differences - Watch for uppercase lowercase in both.
                Example: export class nativeScript (see over) and type: "nativescript" (in .mdl file)
                TypeError: Cannot read properties of undefined (reading 'ORM')
closing code: 1

Here is the mdl source file:

import {Model, Start} from 'magicCode.js';

@Model([

{

        // Server specifications

        server: {

             name: 'Magic Code Server',

             description: 'Project to test the MongoDB back-end',

             documentation: 'openAPI 3.0',

             contact: 'alberteinstein@magiccodegenerator.com',

             version: '1.0',

             path: '/',                                           // Main server entry point

             type: 'NodeJS',                                // server type: nodeJS, Apache

             host: 'localhost',                               // host name

             port: '3000',                                      // server port

             url: 'http://localhost',                         // main server endpoint

             cors: {

                  origin:'*',

                   methods: "['GET','POST','DELETE','UPDATE','PUT']" 

                }, authentication: {

                type: 'JWTToken',

                key: 'ibLX-mf#R0ujo'Pg/[HG^5(bJ]&fWg',

                algorithm: 'HS256',

                 expiresIn: '2h',

                 redirect: 'http://localhost:8084'

                },

                interface: {

                 rest: true,

                 graphql: {

                          graphql: true

                  }

              }

           },

       },

       {

           // service specifications

            service: {

            path: '/user',                  // Service endpoint

            name: 'myClass',          // WARNING this property name should

                                                // be identical to the class name at

                                                // the end of this document and in

                                                // 'Start'.

            description:'Service used to test authenticated MongoDB-mongoose',

            paginate: true,

            storage: {

                    type: 'noSQL',

                    database: 'mongoDB',

                    ORM: 'mongoose',

                    connector:

     'mongodb://localhost:27017/blog?retryWrites=true&w=majority',

              }

         }

     },

     {

           application: {
                        name: "angular_bootstrap",
                      type: 'angular_bootstrap',
          }

      },

      {

           collections: [
             {

                   // Collection specifications

                  // you can define more than one collection per model

                 // each collection is defined as an object in the Array of objects

                  endpoint: 'testclass',

                  name: 'testClass',

                  model: {

                           id: { type: String, label:'id', required: true},

                           name: {type:String, label: 'Name', index: true, required: true}

                  },

                  methods: {

                          get: true,

                          put: true,

                          post: true,

                          delete: true

                  },

                   views: {

                             form: true,

                             list: true

                        }

                   }

               ]

           }

         ])
     class myClass{}
     Start(myClass,'c:/dev/test-mcg')
didierphmartin commented 2 years ago

The mdl file as posted here has some problems like missing commas. I will try the corrected one on my machine to replicate the problem or identify what is missing in the mdl or what should be removed.

didierphmartin commented 2 years ago

In the recent 1.2.2 release, a new error was introduced. To prevent this error, the mdl model definition is modified (a small modification). the next release (very soon) will include the modification in the engine and scenario-templates files. I will do a video about how to use the new update and will make available a sample mdl file.