From 230e89517242de5615feeb3a88edf7155ec7b800 Mon Sep 17 00:00:00 2001 From: Niels Steenbeek Date: Mon, 15 Feb 2021 11:35:36 +0100 Subject: [PATCH] Set version 4.0.3 --- bin/main.js | 2 +- bin/root/tools/setFormCustomizable.js | 2 +- package.json | 2 +- src/main.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/main.js b/bin/main.js index df0dce1..41dd3d9 100644 --- a/bin/main.js +++ b/bin/main.js @@ -1 +1 @@ -/*! HSO D365 CLI 4.0.2 | (c) HSO Innovation */(()=>{"use strict";var e={216:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]","ig"),e.publisher,t),a.sed("-i",new RegExp("<%= solution %>","ig"),e.solution,t),a.sed("-i",new RegExp("<%= environment %>","ig"),e.environment,t),a.sed("-i",new RegExp("<%= namespace %>","ig"),e.namespace,t)},e.initPackageJson=function(e,t){var n=a.ls("Webresources/package.json")[0];a.sed("-i","<%= projectname %>",e.toLowerCase(),n),a.sed("-i",new RegExp("<%= description %>","ig"),t.solution,n),a.sed("-i",new RegExp("<%= publisher %>","ig"),t.publisher,n)},e.initWebpackConfig=function(e){var t=a.ls("Webresources/webpack.config.js")[0];a.sed("-i",new RegExp("<%= publisher %>","ig"),e.publisher,t),a.sed("-i",new RegExp("<%= namespace %>","ig"),e.namespace,t),a.sed("-i",new RegExp("<%= description %>","ig"),e.namespace,t)},e.inquirer=function(){return s.prompt([{type:"input",name:"environment",message:"D365 environment url (eg. https://yourproject.crm4.dynamics.com):"},{type:"input",name:"solution",message:"D365 Solution name:"},{type:"input",name:"publisher",message:"D365 Publisher Prefix (3 chars a-z):"},{type:"input",name:"namespace",message:"Namespace (eg. Customer or Product name):"}])},e}();t.Create=c},681:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]","ig"),n,"src/"+e+"/"+c),a.sed("-i",new RegExp("<%= namespace %>","ig"),r,"src/"+e+"/"+c),a.exec("git add src/"+e+"/"+c)})),console.log("Adding D365 Entity files done"),[2]}}))}))},e}();t.Entity=l},128:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.Generator=void 0;var r=n(563),i=n(524),o=n(429),a=n(286),s=n(655),c=n(560),u=function(){function e(){}return e.generate=function(e,t){if(i.test("-e","src"))if(e)if(["entity","webresource","model","licensevalidator"].includes(e.toLowerCase())){if("entity"===e.toLowerCase())return o.Entity.generateEntity(t);if("webresource"===e.toLowerCase())return a.Webresource.generateWebresource(t);if("model"===e.toLocaleLowerCase())return console.log(r.red("Deprecated: please use Entity instead")),c.Model.generateModel(t);if("licensevalidator"===e.toLowerCase())return s.LicenseValidator.generateLicenseValidator(t)}else console.log(r.red("Schematic "+e+" not supported!"));else console.log(r.red("No schematic specified!"));else console.log(r.red("You are not inside the project Webresources folder!"))},e.showGenerateHelp=function(){console.log("Arguments:"),console.log(" "+r.blue("schematic")),console.log(" The schematic or collection:schematic to generate."),console.log(" Example: Entity, Webresource or LicenseValidator.")},e}();t.Generator=u},655:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]","ig"),e,"src/License/"+o),a.sed("-i",new RegExp("<%= publisher %>","ig"),n,"src/License/"+o),a.sed("-i",new RegExp("<%= namespace %>","ig"),r,"src/License/"+o)})),o=a.ls("webpack.config.js")[0],a.sed("-i","entry: {",'entry: {\n LicenseValidator: [\n path.resolve(__dirname, "src/License/Validator.ts")\n ],',o),a.exec("git add webpack.config.js"),console.log("Adding D365 License Validator done"),[2]}}))}))},e}();t.LicenseValidator=c},560:function(e,t,n){var r,i=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]Using entityLogicalName '"+this.entityLogicalName+"'
"),[4,this.writeModelFile()];case 1:return e.sent(),[4,this.writeEnumFile()];case 2:return e.sent(),[4,this.writeFormContextFile()];case 3:return e.sent(),this.log("Generating files finished"),[2]}}))}))},t.prototype.writeModelFile=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,o,s,c,d,p,f;return a(this,(function(a){switch(a.label){case 0:return this.log("Generating "+this.entityname+".model.ts
"),e="src/"+this.entityname+"/"+this.entityname+".model.ts",u.cp("-r",__dirname+"/Entity/Entity.model.ts","src/"+this.entityname),u.cp("-r","src/"+this.entityname+"/Entity.model.ts",e),u.rm("-rf","src/"+this.entityname+"/Entity.model.ts"),u.sed("-i",new RegExp("Entity","g"),this.entityname,e),u.exec("git add "+e),t=String(l.readFileSync(e)),[4,this.getAttributeInterfaceTypes()];case 1:return n=a.sent(),[4,this.getRelationshipInterfaceTypes()];case 2:return r=a.sent(),[4,this.getImportStrings(r)];case 3:return i=a.sent(),[4,this.getTypeStrings()];case 4:return o=a.sent(),[4,this.getAttributesString(n,r)];case 5:return s=a.sent(),c=s,[4,this.getRelationshipsString(r,n)];case 6:return s=c+a.sent(),d=s,[4,this.getCombinedAttributeRelationshipString(n,r)];case 7:return s=d+a.sent(),p=this.entityname+"Model extends Model {",t=t.replace(p,""+p+s),f="interface",t=t.replace(f,""+i+o+f),u.ShellString(t).to(e),this.log("Generated "+this.entityname+".model.ts
"),[2]}}))}))},t.prototype.getImportStrings=function(e){return o(this,void 0,void 0,(function(){var n,r,i,o,s,c,l;return a(this,(function(a){switch(a.label){case 0:n="",r=0,i=Object.keys(e),a.label=1;case 1:return rNavigationProperty \''+o+"' generated
\n Referenced model '"+c+"Model' not found.
\n Add referenced entity '"+c+'\' by following cli command:
\n hso-d365 generate Entity '+c+'
\n And regenerate \''+this.entityname+'\' by following cli command:
\n hso-d365 generate Entity '+this.entityname+"
\n "),a.label=3;case 3:return r++,[3,1];case 4:return[2,n]}}))}))},t.prototype.getCombinedAttributeRelationshipString=function(e,n){return o(this,void 0,void 0,(function(){var r,i,o,s,c,l,d,p,f,h;return a(this,(function(a){switch(a.label){case 0:r="",i=Object.keys(e),o=0,s=Object.keys(n),a.label=1;case 1:return o"),a.label=4;case 4:return n++,[3,2];case 5:return[2,t]}}))}))},t.prototype.getInterfaceType=function(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return t=e.AttributeType,n=e.SchemaName,["String","Memo","DateTime","Lookup","Customer","Owner","Uniqueidentifier"].includes(t)?[2,"string"]:[3,1];case 1:return["Boolean"].includes(t)?[2,"boolean"]:[3,2];case 2:return["Picklist"].includes(t)?[2,n+"Values"]:[3,3];case 3:return["Integer","Double","BigInt","Decimal","Double","Money"].includes(t)?[2,"number"]:[3,4];case 4:return["Status"].includes(t)?[4,d.NodeApi.getStatusOptionSet(this.entityLogicalName,this.bearer)]:[3,6];case 5:return[2,r.sent().map((function(e){return e.value})).join(" | ")];case 6:return["State"].includes(t)?[4,d.NodeApi.getStateOptionSet(this.entityLogicalName,this.bearer)]:[3,8];case 7:return[2,r.sent().map((function(e){return e.value})).join(" | ")];case 8:return[2]}}))}))},t.prototype.getTypeStrings=function(){return o(this,void 0,void 0,(function(){var e,t,n,r,i,o,s,c,u,l;return a(this,(function(a){switch(a.label){case 0:return e="",[4,d.NodeApi.getAttributesMetadata(this.entityLogicalName,this.bearer)];case 1:t=a.sent(),n=0,r=t,a.label=2;case 2:return n"),[4,this.getFormContextAttributesString()];case 1:return e=o.sent(),t="src/"+this.entityname+"/"+this.entityname+".formContext.ts",u.cp("-r",__dirname+"/Entity/Entity.formContext.ts","src/"+this.entityname),u.cp("-r","src/"+this.entityname+"/Entity.formContext.ts",t),u.rm("-rf","src/"+this.entityname+"/Entity.formContext.ts"),u.sed("-i",new RegExp("Entity","g"),this.entityname,t),u.exec("git add "+t),n=String(l.readFileSync(t)),r=this.entityname+"FormContext {",i=n.replace(r,r+"\n"+e),u.ShellString(i).to(t),this.log("Generated "+this.entityname+".formContext.ts
"),[2]}}))}))},t.prototype.getFormContextAttributesString=function(){return o(this,void 0,void 0,(function(){var e,n,r,i,o,s,c,u,l,p,f;return a(this,(function(a){switch(a.label){case 0:return e="",[4,d.NodeApi.getAttributesMetadata(this.entityLogicalName,this.bearer)];case 1:for(n=a.sent(),r=0,i=n;r'+this.entityLogicalName+" attribute "+e+" falls back to Xrm.Attributes.Attribute.
"),"Xrm.Attributes.Attribute")},t.prototype.writeEnumFile=function(){return o(this,void 0,void 0,(function(){var e,t,n,r;return a(this,(function(i){switch(i.label){case 0:return this.log("Generating "+this.entityname+".enum.ts
"),[4,this.getAttributeNamesEnumString()];case 1:return e=i.sent(),[4,this.getEnumStrings()];case 2:return t=i.sent(),n="src/"+this.entityname+"/"+this.entityname+".enum.ts",u.cp("-r",__dirname+"/Entity/Entity.enum.ts","src/"+this.entityname),u.cp("-r","src/"+this.entityname+"/Entity.enum.ts",n),u.rm("-rf","src/"+this.entityname+"/Entity.enum.ts"),u.exec("git add "+n),r=String(l.readFileSync(n)),this.log("Generated "+this.entityname+".enum.ts
"),u.ShellString(r+e+t).to(n),[2]}}))}))},t.prototype.getAttributeNamesEnumString=function(){return o(this,void 0,void 0,(function(){var e,n,r,i,o,s,c;return a(this,(function(a){switch(a.label){case 0:return e="",[4,d.NodeApi.getAttributesMetadata(this.entityLogicalName,this.bearer)];case 1:for(n=a.sent(),e+="export enum "+this.entityname+"AttributeNames {\n",r=0,i=n;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]","ig"),o,"src/"+e+"/"+i),a.sed("-i",new RegExp("<%= namespace %>","ig"),u,"src/"+e+"/"+i),a.exec("git add src/"+e+"/"+i)})),d=a.ls("webpack.config.js")[0],p="React"===n?"tsx":"ts",a.sed("-i","entry: {","entry: {\n "+e+': [\n path.resolve(__dirname, "src/'+e+"/"+e+"."+p+'")\n ],',d),a.exec("git add webpack.config.js"),console.log("Adding D365 Webresource done"),[2]}}))}))},e}();t.Webresource=u},368:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1] [options]"),a.command("new ").alias("n").description("Creates a new workspace and an initial Webresource setup").action((function(e){s.Create.createProject(e)})).on("--help",(function(){s.Create.showCreateHelp()})),a.command("generate [name]").alias("g").description("Generates and/or modifies files bases on a schematic.").action((function(e,t){u.Generator.generate(e,t)})).on("--help",(function(){u.Generator.showGenerateHelp()})),a.command("extractTranslations").alias("extract").description("Extracts translation to resx files").action((function(){p.Resx.extract()})).on("--help",(function(){console.log("In translation folder a folder 'locales' will be generated having translation files."),console.log("It will generate one locales.resx file."),console.log("You have to add for each required language a copy yourself like locales.1033.resx."),console.log("Once done, the tooling will keep up-to-date for you.")})),a.command("lint").alias("l").description("Runs linting tools on project code").action((function(){o.exec("npm run lint")})).on("--help",(function(){console.log("Runs linting tools on project code using the configuration as specified in your projects '.eslintrc.json' file")})),a.command("build").alias("b").description("Compiles project into an output directory named dist").action((function(){o.exec("npm run build:prod")})).on("--help",(function(){console.log("The command can be used to build the project to be distributed to the D365 environment using the 'deploy' command")})),a.command("deploy").option("-f, --force","Force unmodified files as well").description("Invokes the deploy builder").action((function(e){var t=e.force;d.Deploy.deployProject(t)})).on("--help",(function(){console.log("Distributes the project to the D365 environment. You need to run the 'build' command first")})),a.command("update").alias("u").description("Updates existing workspace and Webresource setup").action((function(){c.Update.updateProject()})).on("--help",(function(){c.Update.showUpdateHelp()})),a.command("setFormCustomizable ").alias("f").description("Sets the Solution forms iscustomizable/canbedeleted true/false").action((function(e){o.exec("npm run setFormCustomizable:"+(e?"true":"false"))})).on("--help",(function(){console.log("Sets the Solution forms iscustomizable/canbedeleted true/false")})),a.command("showFiddlerRule").alias("fiddler").description("Show the Fiddler AutoResponder Rule Editor lines").action((function(){return r(void 0,void 0,void 0,(function(){var e,t,n,r,o,a;return i(this,(function(i){switch(i.label){case 0:return[4,l.Variables.get()];case 1:return e=i.sent(),t=e.publisher,n=e.namespace,r="REGEX:(?insx).+\\/"+t+"_\\/"+n+"\\/(?'foldername'[^?]*)\\/(?'fname'[^?]*.js)",o=process.cwd(),a=o+"\\dist\\"+t+"_\\"+n+"\\${foldername}\\${fname}",console.log("Please add to first Rule Editor line (including REGEX:): \n"+r),console.log("Please add to second Rule Editor line: \n"+a),[2]}}))}))})),a.arguments("").action((function(){a.outputHelp(),console.log(""),console.log("echo Unknown command!")})),a.parse(process.argv)},334:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]\n Login\n \n \n