@ind-rcg/modeler-sfdx-cli-plugin 246.1049.0 → 248.1029.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +25 -0
  2. package/lib/commands/modeler/workspace/utils/importContracts.js +1 -0
  3. package/lib/constants.js +1 -1
  4. package/lib/model/workspace.js +1 -1
  5. package/lib/types/messages.js +1 -1
  6. package/lib/utils/fsHelper.js +1 -1
  7. package/lib/utils/importContractsHelper.js +1 -0
  8. package/lib/utils/packageHelper.js +1 -1
  9. package/lib/utils/serverHelper.js +1 -1
  10. package/lib/utils/templateEngine.js +1 -1
  11. package/lib/utils/templateHelper.js +1 -1
  12. package/lib/utils/xmlHelper.js +1 -1
  13. package/messages/modeler-workspace-utils-importContracts.md +50 -0
  14. package/oclif.manifest.json +44 -1
  15. package/package.json +13 -12
  16. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/CreateAsync/Bo${NAME}.AfterCreateAsync.bl.js +3 -1
  17. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/CreateAsync/Bo${NAME}.BeforeCreateAsync.bl.js +3 -1
  18. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/DoValidateAsync/Bo${NAME}.AfterDoValidateAsync.bl.js +3 -1
  19. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/DoValidateAsync/Bo${NAME}.BeforeDoValidateAsync.bl.js +3 -1
  20. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/Initialize/Bo${NAME}.AfterInitialize.bl.js +3 -1
  21. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/Initialize/Bo${NAME}.BeforeInitialize.bl.js +3 -1
  22. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/LoadAsync/Bo${NAME}.AfterLoadAsync.bl.js +3 -1
  23. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/LoadAsync/Bo${NAME}.BeforeLoadAsync.bl.js +3 -1
  24. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/SaveAsync/Bo${NAME}.AfterSaveAsync.bl.js +3 -1
  25. package/templates/contractTemplates/YourModule Section/BO/BO_BusinessObject/businessobject/Bo${NAME}/Mv2/SaveAsync/Bo${NAME}.BeforeSaveAsync.bl.js +3 -1
  26. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/Lo${NAME}/Mv2/DoValidateAsync/Lo${NAME}.AfterDoValidateAsync.bl.js +3 -1
  27. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/Lo${NAME}/Mv2/DoValidateAsync/Lo${NAME}.BeforeDoValidateAsync.bl.js +3 -1
  28. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/Lo${NAME}/Mv2/LoadAsync/Lo${NAME}.AfterLoadAsync.bl.js +3 -1
  29. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/Lo${NAME}/Mv2/LoadAsync/Lo${NAME}.BeforeLoadAsync.bl.js +3 -1
  30. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/Lo${NAME}/Mv2/SaveAsync/Lo${NAME}.AfterSaveAsync.bl.js +3 -1
  31. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/Lo${NAME}/Mv2/SaveAsync/Lo${NAME}.BeforeSaveAsync.bl.js +3 -1
  32. package/templates/contractTemplates/YourModule Section/BO/LO_ListObject/_snippets/ListItemSimplePropertiesSimplepropertySnipp.xml +4 -0
  33. package/templates/contractTemplates/YourModule Section/BO/LU_LookupObject/Lu${NAME}/Mv2/LoadAsync/Lu${NAME}.AfterLoadAsync.bl.js +3 -1
  34. package/templates/contractTemplates/YourModule Section/BO/LU_LookupObject/Lu${NAME}/Mv2/LoadAsync/Lu${NAME}.BeforeLoadAsync.bl.js +3 -1
  35. package/templates/contractTemplates/YourModule Section/BO/Methods_or_BusinessLogic/${REFERENCE_OBJECT}.${NAME}.bl.js +3 -1
  36. package/templates/contractTemplates/YourModule Section/BO/Methods_or_BusinessLogic/${REFERENCE_OBJECT}.${NAME}Async.bl.js +3 -1
  37. package/templates/contractTemplates/YourModule Section/PR/PR_Process_&_UI/{#ModuleName#_#Name#/#ModuleName#_#Name#Process.processflow.xml → ${MODULE}_${NAME}/${MODULE}_${NAME}Process.processflow.xml } +1 -1
  38. package/templates/contractTemplates/YourModule Section/PR/PR_Process_&_UI/${MODULE}_${NAME}/${MODULE}_${NAME}UI.userinterface.xml +4 -0
  39. package/templates/contractTemplates/YourModule Section/PR/PR_Process_&_UI/UserInterface.md +907 -32
  40. package/templates/templateDefinitions.json +137 -5
  41. package/templates/contractTemplates/BL_BusinessLogic/${REFERENCE_OBJECT}.${NAME}.bl.js +0 -53
  42. package/templates/contractTemplates/BL_BusinessLogic/${REFERENCE_OBJECT}.${NAME}Async.bl.js +0 -52
  43. package/templates/contractTemplates/BL_BusinessLogic/BusinessLogic.md +0 -4
  44. package/templates/contractTemplates/YourModule Section/PR/PR_Process_&_UI/#ModuleName#_#Name#/#ModuleName#_#Name#.userinterface.xml +0 -4
package/README.md CHANGED
@@ -47,6 +47,7 @@ In this section we will provide a quick overview about the existing commands
47
47
  * [`sf modeler:workspace:server:start`](#sf-modelerworkspaceserverstart)
48
48
  * [`sf modeler:workspace:upgrade`](#sf-modelerworkspaceupgrade)
49
49
  * [`sf modeler:workspace:utils:base64encode`](#sf-modelerworkspaceutilsbase64encode)
50
+ * [`sf modeler:workspace:utils:importContracts`](#sf-modelerworkspaceutilsimportcontracts)
50
51
  * [`sf modeler:workspace:utils:migrateContracts`](#sf-modelerworkspaceutilsmigratecontracts)
51
52
  * [`sf modeler:workspace:validate`](#sf-modelerworkspacevalidate)
52
53
 
@@ -709,6 +710,30 @@ EXAMPLES
709
710
  $ sf modeler:workspace:utils:base64encode --input ./c3js.zip
710
711
  ```
711
712
 
713
+ ## `sf modeler:workspace:utils:importContracts`
714
+
715
+ Imports design contracts to the specified workspace.
716
+
717
+ ```
718
+ USAGE
719
+ $ sf modeler:workspace:utils:importContracts -i <value> [--json] [-p <value>] [-c]
720
+
721
+ FLAGS
722
+ -c, --core Use the flag to import only the core contracts (.core.xml) from a custom Modeler Content Package
723
+ (MCP) zip. Custom
724
+ contracts are skipped during import. If this flag is not set, only the custom contracts (*.xml)
725
+ are imported from the
726
+ custom MCP.zip.
727
+ -i, --input=<value> (required) Path to the Modeler Content Package (MCP) zip.
728
+ -p, --path=<value> path to the Modeler workspace
729
+
730
+ GLOBAL FLAGS
731
+ --json Format output as json.
732
+
733
+ DESCRIPTION
734
+ Imports design contracts to the specified workspace.
735
+ ```
736
+
712
737
  ## `sf modeler:workspace:utils:migrateContracts`
713
738
 
714
739
  Migrate existing contracts in your Modeler workspace to support the latest version of Modeler.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ImportContractsCommand=void 0;const core_1=require("@salesforce/core"),constants_1=require("../../../../constants"),messages_1=require("../../../../types/messages"),workspaceCommand_1=require("../../../../model/workspaceCommand"),sf_plugins_core_1=require("@salesforce/sf-plugins-core"),fsHelper_1=require("../../../../utils/fsHelper"),decompress=require("decompress"),importContractsHelper_1=require("../../../../utils/importContractsHelper"),path=require("path"),migrateContracts_1=require("./migrateContracts"),generateManifest_1=require("./generateManifest");core_1.Messages.importMessagesDirectory(__dirname);const importContractsMessages=core_1.Messages.loadMessages(constants_1.PACKAGE_NAME,messages_1.MessagesBundle.Workspace_Utils_ImportContracts),workspaceMessages=core_1.Messages.loadMessages(constants_1.PACKAGE_NAME,messages_1.MessagesBundle.Workspace);class ImportContractsCommand extends workspaceCommand_1.WorkspaceCommand{async run(){const{flags:s}=await this.parse(ImportContractsCommand);let e,t;this.workspace=await this.assignWorkspace(s.path);let a=path.resolve(s.input);(0,fsHelper_1.existsFile)(a)||(t=importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.InvalidFilePath,[a]),this.error(t)),this.workspace.exists()||(t=importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.InvalidWorkSpace,[this.workspace.getBasePath()]),this.error(t));let r=this.workspace.getTempFolderPath();try{this.spinner.start(importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.ExtractingInputMessage),workspaceMessages.getMessage(messages_1.MessagesBundle_Workspace.InProgress)),(0,fsHelper_1.createFolder)(r),await decompress(a,r),this.spinner.stop(workspaceMessages.getMessage(messages_1.MessagesBundle_Workspace.Done));let o=(0,importContractsHelper_1.getContractsType)(r),n=null,p=!1,c=!1;switch(o){case importContractsHelper_1.ContractsType.NEW_MODELER:n=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.WORKSPACE_SOURCE_FOLDER),p=!1,c=!1;break;case importContractsHelper_1.ContractsType.CORE:n=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.WORKSPACE_CONTRACTS_FOLDER),p=!0,c=!0;break;case importContractsHelper_1.ContractsType.CUST:n=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.WORKSPACE_CONTRACTS_FOLDER),p=!0,c=s?.core,(0,importContractsHelper_1.prepareForCustContractsImport)(r,s?.core);break;default:e=!1,t=importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.InvalidContractsType),this.error(t)}this.spinner.start(importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.ImportContractsMessage),workspaceMessages.getMessage(messages_1.MessagesBundle_Workspace.InProgress)),(0,fsHelper_1.cpdir)(n,this.workspace.getSourcePath()),this.spinner.stop(workspaceMessages.getMessage(messages_1.MessagesBundle_Workspace.Done));let g=[];s.path&&g.push("--path",this.workspace.getBasePath()),s.json&&g.push("--json"),p&&await migrateContracts_1.MigrateContracts.run(g),c&&await generateManifest_1.GenerateManifestCommand.run(g),t=importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.importContractsSuccess),e=!0,this.log(t)}catch(s){t=importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.UnexpectedError),this.error(`${t}\n ${s}`)}finally{this.spinner.start(importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.CleanupMessage),workspaceMessages.getMessage(messages_1.MessagesBundle_Workspace.InProgress)),(0,fsHelper_1.deleteFolder)(r),this.spinner.stop(workspaceMessages.getMessage(messages_1.MessagesBundle_Workspace.Done))}return{success:e,message:t}}}exports.ImportContractsCommand=ImportContractsCommand,ImportContractsCommand.description=importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.CommandDescription),ImportContractsCommand.flags={...workspaceCommand_1.WorkspaceCommand.flags,input:sf_plugins_core_1.Flags.string({summary:importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.InputFlagDescription),char:"i",required:!0,multiple:!1}),core:sf_plugins_core_1.Flags.boolean({summary:importContractsMessages.getMessage(messages_1.MessagesBundle_Workspace_Utils_ImportContracts.CoreFlagDescription),char:"c",required:!1})};
package/lib/constants.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WorkspaceConstants=exports.PACKAGE_NAME=void 0,exports.PACKAGE_NAME="@ind-rcg/modeler-sfdx-cli-plugin";class WorkspaceConstants{}exports.WorkspaceConstants=WorkspaceConstants,WorkspaceConstants.WORKSPACE_APPLICATION_FOLDER="appl",WorkspaceConstants.WORKSPACE_APPLICATION_BUILD_FOLDER="build",WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FOLDER="config",WorkspaceConstants.WORKSPACE_APPLICATION_DATA_FOLDER="data",WorkspaceConstants.WORKSPACE_APPLICATION_LOCALE_SNIPPETS_FOLDER="localeSnippets",WorkspaceConstants.WORKSPACE_SNIPPETS_FOLDER="contractSnippets",WorkspaceConstants.WORKSPACE_SOURCE_FOLDER="src",WorkspaceConstants.WORKSPACE_TEST_FOLDER="test",WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FOLDER=".vscode",WorkspaceConstants.WORKSPACE_IDENTIFIER_FILE=".modeler-workspace",WorkspaceConstants.WORKSPACE_GITIGNORE_FILE=".gitignore",WorkspaceConstants.WORKSPACE_README_FILE="README.md",WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FILE="config.json",WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FILE="settings.json",WorkspaceConstants.XML_XSD_MAPPING_FILE="xmlXsdMapping.json",WorkspaceConstants.WORKSPACE_APPLICATION_BUILD_STATUS_FILE="status.json",WorkspaceConstants.WORKSPACE_APPLICATION_VALIDATION_RESULT_FILE="generatorValidationResult.json",WorkspaceConstants.WORKSPACE_APPLICATION_GENERATOR_HANDOVER_FILE="generatorHandoverFile.json",WorkspaceConstants.MANIFEST_FILE="manifest.json",WorkspaceConstants.APP_DB="app.db3",WorkspaceConstants.APP_CONFIG="appConfig.json",WorkspaceConstants.BACKEND_SERVER_CONFIG="serverConfig.json",WorkspaceConstants.BACKEND_LOGGING_CONFIG="serverLogConfig.json",WorkspaceConstants.WORKSPACE_APPLICATION_TMP_FOLDER="tmp";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.WorkspaceConstants=exports.PACKAGE_NAME=void 0,exports.PACKAGE_NAME="@ind-rcg/modeler-sfdx-cli-plugin";class WorkspaceConstants{}exports.WorkspaceConstants=WorkspaceConstants,WorkspaceConstants.WORKSPACE_APPLICATION_FOLDER="appl",WorkspaceConstants.WORKSPACE_APPLICATION_BUILD_FOLDER="build",WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FOLDER="config",WorkspaceConstants.WORKSPACE_APPLICATION_DATA_FOLDER="data",WorkspaceConstants.WORKSPACE_APPLICATION_LOCALE_SNIPPETS_FOLDER="localeSnippets",WorkspaceConstants.WORKSPACE_SNIPPETS_FOLDER="contractSnippets",WorkspaceConstants.WORKSPACE_TEMP_FOLDER="temp",WorkspaceConstants.WORKSPACE_CONTRACTS_FOLDER="contracts",WorkspaceConstants.WORKSPACE_SOURCE_FOLDER="src",WorkspaceConstants.WORKSPACE_TEST_FOLDER="test",WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FOLDER=".vscode",WorkspaceConstants.WORKSPACE_IDENTIFIER_FILE=".modeler-workspace",WorkspaceConstants.WORKSPACE_GITIGNORE_FILE=".gitignore",WorkspaceConstants.WORKSPACE_README_FILE="README.md",WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FILE="config.json",WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FILE="settings.json",WorkspaceConstants.XML_XSD_MAPPING_FILE="xmlXsdMapping.json",WorkspaceConstants.WORKSPACE_APPLICATION_BUILD_STATUS_FILE="status.json",WorkspaceConstants.WORKSPACE_APPLICATION_VALIDATION_RESULT_FILE="generatorValidationResult.json",WorkspaceConstants.WORKSPACE_APPLICATION_GENERATOR_HANDOVER_FILE="generatorHandoverFile.json",WorkspaceConstants.MANIFEST_FILE="manifest.json",WorkspaceConstants.VERSION_FILE="version.xml",WorkspaceConstants.APP_DB="app.db3",WorkspaceConstants.APP_CONFIG="appConfig.json",WorkspaceConstants.BACKEND_SERVER_CONFIG="serverConfig.json",WorkspaceConstants.BACKEND_LOGGING_CONFIG="serverLogConfig.json",WorkspaceConstants.WORKSPACE_APPLICATION_TMP_FOLDER="tmp",WorkspaceConstants.PROCESS_FLOW_FILE_ENDING=".processflow.xml";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Workspace=void 0;const constants_1=require("../constants"),buildStatus_1=require("./buildStatus"),fsHelper=require("../utils/fsHelper"),templateHelper=require("../utils/templateHelper"),validationHelper=require("../utils/validationHelper"),path=require("path"),messageHelper=require("../utils/messageHelper"),messages_1=require("../types/messages"),errors_1=require("../types/errors"),componentHelper_1=require("../utils/componentHelper"),crypto_1=require("crypto");class Workspace{constructor(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("basePath");path.isAbsolute(e)||(e=path.resolve(e)),this.basePath=e}getBasePath(){return this.basePath}getApplicationPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_FOLDER)}getApplicationBuildPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_BUILD_FOLDER)}getApplicationConfigPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FOLDER)}getApplicationDataPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_DATA_FOLDER)}getSourcePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_SOURCE_FOLDER)}getTestPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_TEST_FOLDER)}getSnippetsPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_SNIPPETS_FOLDER)}getIDESettingsPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FOLDER)}getApplicationConfigFilePath(){return fsHelper.joinPaths(this.getApplicationConfigPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FILE)}getIdentifierFilePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_IDENTIFIER_FILE)}getGitIgnoreFilePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_GITIGNORE_FILE)}getReadmeFilePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_README_FILE)}getIDESettingsFilePath(){return fsHelper.joinPaths(this.getIDESettingsPath(),constants_1.WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FILE)}getManifestFilePath(){return fsHelper.joinPaths(this.getSourcePath(),constants_1.WorkspaceConstants.MANIFEST_FILE)}isProjectWorkspace(){return fsHelper.existsFile(this.getManifestFilePath())}isCoreWorkspace(){return!this.isProjectWorkspace()}exists(){return fsHelper.existsFile(this.getIdentifierFilePath())}checkForUpgrade(){let e=!1,t=this.getWorkspaceVersion(),s=this.getPluginVersion();return t!==s&&(e=!0),{upgradeAvailable:e,current:t,latest:s}}getWorkspaceVersion(){let e="246.1000.0";if(this.exists()){let t=fsHelper.readTextFile(this.getIdentifierFilePath());""!==t&&(e=t)}return e}getPluginVersion(){return(new componentHelper_1.ModelerComponentHelper).getComponentInfo().version}create(){if(this.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Create,messages_1.MessagesBundle_Workspace_Create.WorkspaceAlreadyExists,[this.getBasePath()]));[this.getApplicationPath(),this.getApplicationBuildPath(),this.getApplicationConfigPath(),this.getApplicationDataPath(),this.getSourcePath(),this.getTestPath(),this.getIDESettingsPath(),this.getSnippetsPath()].forEach((e=>{fsHelper.ensureFolderExists(e)})),[{path:this.getApplicationConfigFilePath(),data:JSON.stringify(templateHelper.getTemplateApplicationConfig(),null,4)},{path:this.getReadmeFilePath(),data:templateHelper.getTemplateReadmeFileData()},{path:this.getGitIgnoreFilePath(),data:templateHelper.getTemplateGitIgnoreFileData()},{path:this.getIdentifierFilePath(),data:this.getPluginVersion()},{path:this.getIDESettingsFilePath(),data:this.getIDESettings()}].forEach((e=>{fsHelper.ensureFileExists(e.path,e.data)})),fsHelper.cpdir(templateHelper.getContractTemplatesPath(),this.getSnippetsPath());const e=this.getApplicationConfig();e.application.uniqueID=(0,crypto_1.randomUUID)(),fsHelper.writeFile(this.getApplicationConfigFilePath(),JSON.stringify(e,null,4)||"")}upgrade(){fsHelper.deleteFolder(this.getSnippetsPath()),fsHelper.cpdir(templateHelper.getContractTemplatesPath(),this.getSnippetsPath()),fsHelper.writeFile(this.getIdentifierFilePath(),this.getPluginVersion()),fsHelper.ensureFileExists(this.getGitIgnoreFilePath(),templateHelper.getTemplateGitIgnoreFileData()),fsHelper.mergeFiles(templateHelper.getTemplateFilePath(templateHelper.TemplateFile.GIT_IGNORE),this.getGitIgnoreFilePath()),this.updateSettings()}updateSettings(){if(fsHelper.existsFolder(this.getIDESettingsPath())||fsHelper.ensureFolderExists(this.getIDESettingsPath()),!fsHelper.existsFile(this.getIDESettingsFilePath()))return void fsHelper.ensureFileExists(this.getIDESettingsFilePath(),this.getIDESettings());const e=fsHelper.readJsonFile(this.getIDESettingsFilePath());e["xml.fileAssociations"]=this.getFileAssociationsData();const t=JSON.stringify(e,null,4);fsHelper.writeFile(this.getIDESettingsFilePath(),t)}cleanup(){if(!this.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace,messages_1.MessagesBundle_Workspace.WorkspaceNotFound,[this.getBasePath()]));[this.getApplicationBuildPath(),this.getApplicationDataPath()].forEach((e=>{fsHelper.emptyFolder(e)}))}getApplicationConfig(){return this.exists()&&fsHelper.existsFile(this.getApplicationConfigFilePath())?fsHelper.readJsonFile(this.getApplicationConfigFilePath()):null}getLastBuildStatus(){return buildStatus_1.BuildStatus.fromWorkspace(this)}cleanupBuild(e=!1){if(!this.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace,messages_1.MessagesBundle_Workspace.WorkspaceNotFound,[this.getBasePath()]));let t=this.getApplicationBuildPath(),s=fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_TMP_FOLDER);e&&(fsHelper.createFolder(buildStatus_1.ValidatorStatus.getApplicationClockworkPath(s)),fsHelper.move(buildStatus_1.BuildStatus.getGenerationStatusFilePath(t),buildStatus_1.BuildStatus.getGenerationStatusFilePath(s)),fsHelper.move(buildStatus_1.ValidatorStatus.getValidationStatusFilePath(t),buildStatus_1.ValidatorStatus.getValidationStatusFilePath(s)),fsHelper.move(buildStatus_1.ValidatorStatus.getGeneratorHandoverFilePath(t),buildStatus_1.ValidatorStatus.getGeneratorHandoverFilePath(s))),fsHelper.emptyFolder(this.getApplicationBuildPath()),e&&fsHelper.move(s,t)}getIDESettings(){let e=this.getFileAssociationsData();return JSON.stringify({"xml.fileAssociations":e},null,4)}getFileAssociationsData(){let e=[],t=new componentHelper_1.GeneratorComponentHelper,s=fsHelper.readJsonFile(t.getXmlXsdMappingFilePath());for(let a in s){let i=fsHelper.joinPaths(t.getXmlSchemaPath(),s[a]);fsHelper.existsFile(i)&&e.push({pattern:a,systemId:i})}return e}}exports.Workspace=Workspace;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Workspace=void 0;const constants_1=require("../constants"),buildStatus_1=require("./buildStatus"),fsHelper=require("../utils/fsHelper"),templateHelper=require("../utils/templateHelper"),validationHelper=require("../utils/validationHelper"),path=require("path"),_=require("lodash"),messageHelper=require("../utils/messageHelper"),messages_1=require("../types/messages"),errors_1=require("../types/errors"),componentHelper_1=require("../utils/componentHelper"),crypto_1=require("crypto");class Workspace{constructor(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("basePath");path.isAbsolute(e)||(e=path.resolve(e)),this.basePath=e}getBasePath(){return this.basePath}getApplicationPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_FOLDER)}getTempFolderPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_TEMP_FOLDER)}getApplicationBuildPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_BUILD_FOLDER)}getApplicationConfigPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FOLDER)}getApplicationDataPath(){return fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_DATA_FOLDER)}getSourcePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_SOURCE_FOLDER)}getTestPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_TEST_FOLDER)}getSnippetsPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_SNIPPETS_FOLDER)}getIDESettingsPath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FOLDER)}getApplicationConfigFilePath(){return fsHelper.joinPaths(this.getApplicationConfigPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_CONFIG_FILE)}getIdentifierFilePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_IDENTIFIER_FILE)}getGitIgnoreFilePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_GITIGNORE_FILE)}getReadmeFilePath(){return fsHelper.joinPaths(this.basePath,constants_1.WorkspaceConstants.WORKSPACE_README_FILE)}getIDESettingsFilePath(){return fsHelper.joinPaths(this.getIDESettingsPath(),constants_1.WorkspaceConstants.WORKSPACE_IDE_SETTINGS_FILE)}getManifestFilePath(){return fsHelper.joinPaths(this.getSourcePath(),constants_1.WorkspaceConstants.MANIFEST_FILE)}isProjectWorkspace(){return fsHelper.existsFile(this.getManifestFilePath())}isCoreWorkspace(){return!this.isProjectWorkspace()}exists(){return fsHelper.existsFile(this.getIdentifierFilePath())}checkForUpgrade(){let e=!1,t=this.getWorkspaceVersion(),s=this.getPluginVersion();return t!==s&&(e=!0),{upgradeAvailable:e,current:t,latest:s}}getWorkspaceVersion(){let e="246.1000.0";if(this.exists()){let t=fsHelper.readTextFile(this.getIdentifierFilePath());""!==t&&(e=t)}return e}getPluginVersion(){return(new componentHelper_1.ModelerComponentHelper).getComponentInfo().version}create(){if(this.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Create,messages_1.MessagesBundle_Workspace_Create.WorkspaceAlreadyExists,[this.getBasePath()]));[this.getApplicationPath(),this.getApplicationBuildPath(),this.getApplicationConfigPath(),this.getApplicationDataPath(),this.getSourcePath(),this.getTestPath(),this.getIDESettingsPath(),this.getSnippetsPath()].forEach((e=>{fsHelper.ensureFolderExists(e)}));[{path:this.getApplicationConfigFilePath(),data:JSON.stringify((()=>{let e=templateHelper.getTemplateApplicationConfig();return e.application.uniqueID=(0,crypto_1.randomUUID)(),e})(),null,4)},{path:this.getReadmeFilePath(),data:templateHelper.getTemplateReadmeFileData()},{path:this.getGitIgnoreFilePath(),data:templateHelper.getTemplateGitIgnoreFileData()},{path:this.getIdentifierFilePath(),data:this.getPluginVersion()},{path:this.getIDESettingsFilePath(),data:this.getIDESettings()}].forEach((e=>{fsHelper.ensureFileExists(e.path,e.data)})),fsHelper.cpdir(templateHelper.getContractTemplatesPath(),this.getSnippetsPath())}upgrade(){fsHelper.deleteFolder(this.getSnippetsPath()),fsHelper.cpdir(templateHelper.getContractTemplatesPath(),this.getSnippetsPath()),fsHelper.writeFile(this.getIdentifierFilePath(),this.getPluginVersion()),fsHelper.ensureFileExists(this.getGitIgnoreFilePath(),templateHelper.getTemplateGitIgnoreFileData()),fsHelper.mergeFiles(templateHelper.getTemplateFilePath(templateHelper.TemplateFile.GIT_IGNORE),this.getGitIgnoreFilePath());let e=this.getApplicationConfig(),t=this.mergeConfig(this.getApplicationConfig(),templateHelper.getTemplateApplicationConfig());_.isEqual(e,t)||fsHelper.writeFile(this.getApplicationConfigFilePath(),JSON.stringify(t,null,4)),this.updateSettings()}mergeConfig(e,t){return _.merge(t,e)}updateSettings(){if(fsHelper.existsFolder(this.getIDESettingsPath())||fsHelper.ensureFolderExists(this.getIDESettingsPath()),!fsHelper.existsFile(this.getIDESettingsFilePath()))return void fsHelper.ensureFileExists(this.getIDESettingsFilePath(),this.getIDESettings());const e=fsHelper.readJsonFile(this.getIDESettingsFilePath());e["xml.fileAssociations"]=this.getFileAssociationsData();const t=JSON.stringify(e,null,4);fsHelper.writeFile(this.getIDESettingsFilePath(),t)}cleanup(){if(!this.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace,messages_1.MessagesBundle_Workspace.WorkspaceNotFound,[this.getBasePath()]));[this.getApplicationBuildPath(),this.getApplicationDataPath()].forEach((e=>{fsHelper.emptyFolder(e)}))}getApplicationConfig(){return this.exists()&&fsHelper.existsFile(this.getApplicationConfigFilePath())?fsHelper.readJsonFile(this.getApplicationConfigFilePath()):null}getLastBuildStatus(){return buildStatus_1.BuildStatus.fromWorkspace(this)}cleanupBuild(e=!1){if(!this.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace,messages_1.MessagesBundle_Workspace.WorkspaceNotFound,[this.getBasePath()]));let t=this.getApplicationBuildPath(),s=fsHelper.joinPaths(this.getApplicationPath(),constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_TMP_FOLDER);e&&(fsHelper.createFolder(buildStatus_1.ValidatorStatus.getApplicationClockworkPath(s)),fsHelper.move(buildStatus_1.BuildStatus.getGenerationStatusFilePath(t),buildStatus_1.BuildStatus.getGenerationStatusFilePath(s)),fsHelper.move(buildStatus_1.ValidatorStatus.getValidationStatusFilePath(t),buildStatus_1.ValidatorStatus.getValidationStatusFilePath(s)),fsHelper.move(buildStatus_1.ValidatorStatus.getGeneratorHandoverFilePath(t),buildStatus_1.ValidatorStatus.getGeneratorHandoverFilePath(s))),fsHelper.emptyFolder(this.getApplicationBuildPath()),e&&fsHelper.move(s,t)}getIDESettings(){let e=this.getFileAssociationsData();return JSON.stringify({"xml.fileAssociations":e},null,4)}getFileAssociationsData(){let e=[],t=new componentHelper_1.GeneratorComponentHelper,s=fsHelper.readJsonFile(t.getXmlXsdMappingFilePath());for(let a in s){let i=fsHelper.joinPaths(t.getXmlSchemaPath(),s[a]);fsHelper.existsFile(i)&&e.push({pattern:a,systemId:i})}return e}}exports.Workspace=Workspace;
@@ -1 +1 @@
1
- "use strict";var MessagesBundle,MessagesBundle_World,MessagesBundle_Workspace,MessagesBundle_Workspace_Create,MessagesBundle_Workspace_Upgrade,MessagesBundle_Workspace_Cleanup,MessagesBundle_Workspace_Build,MessagesBundle_Workspace_Package,MessagesBundle_Workspace_Validate,MessagesBundle_Workspace_Server_Start,MessagesBundle_Workspace_Utils_Base64Encode,MessagesBundle_Workspace_RefreshLocale,MessagesBundle_Workspace_Utils_MigrateContracts,MessagesBundle_Workspace_Utils_GenerateManifest,MessagesBundle_Workspace_Add;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MessagesBundle_Workspace_Add=exports.MessagesBundle_Workspace_Utils_GenerateManifest=exports.MessagesBundle_Workspace_Utils_MigrateContracts=exports.MessagesBundle_Workspace_RefreshLocale=exports.MessagesBundle_Workspace_Utils_Base64Encode=exports.MessagesBundle_Workspace_Server_Start=exports.MessagesBundle_Workspace_Validate=exports.MessagesBundle_Workspace_Package=exports.MessagesBundle_Workspace_Build=exports.MessagesBundle_Workspace_Cleanup=exports.MessagesBundle_Workspace_Upgrade=exports.MessagesBundle_Workspace_Create=exports.MessagesBundle_Workspace=exports.MessagesBundle_World=exports.MessagesBundle=exports.UpdateNotificationMessage=void 0,exports.UpdateNotificationMessage="A new update of <%= name %> is available.\nTo update your Modeler CLI plugin from <%= chalk.green(current) %> to <%= chalk.green(latest) %>, run: <%= chalk.blue(config.bin, 'plugins update') %>",function(e){e.World="world",e.Workspace="modeler-workspace",e.Workspace_Create="modeler-workspace-create",e.Workspace_Cleanup="modeler-workspace-cleanup",e.Workspace_Build="modeler-workspace-build",e.Workspace_Package="modeler-workspace-package",e.Workspace_Validate="modeler-workspace-validate",e.Workspace_Server_Start="modeler-workspace-server-start",e.Workspace_Utils_Base64Encode="modeler-workspace-utils-base64encode",e.Workspace_RefreshLocale="modeler-workspace-refresh-locale",e.Workspace_Upgrade="modeler-workspace-upgrade",e.Workspace_Utils_MigrateContracts="modeler-workspace-utils-migrateContracts",e.Workspace_Utils_GenerateManifest="modeler-workspace-utils-generateManifest",e.Workspace_Add="modeler-workspace-add"}(MessagesBundle=exports.MessagesBundle||(exports.MessagesBundle={})),function(e){e.CommandDescription="commandDescription",e.NameFlagDescription="nameFlagDescription",e.Examples="examples"}(MessagesBundle_World=exports.MessagesBundle_World||(exports.MessagesBundle_World={})),function(e){e.PathFlagDescription="pathFlagDescription",e.WorkspaceNotFound="workspaceNotFound",e.InProgress="inProgress",e.Done="done",e.Failed="failed"}(MessagesBundle_Workspace=exports.MessagesBundle_Workspace||(exports.MessagesBundle_Workspace={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspaceAlreadyExists="workspaceAlreadyExists",e.WorkspaceCreationSuccessful="workspaceCreationSuccessful",e.WorkspaceCreationFailed="workspaceCreationFailed"}(MessagesBundle_Workspace_Create=exports.MessagesBundle_Workspace_Create||(exports.MessagesBundle_Workspace_Create={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspaceDoesNotExist="workspaceDoesNotExist",e.WorkspaceUpgradationSuccessful="workspaceUpgradationSuccessful",e.WorkspaceUpgradationFailed="workspaceUpgradationFailed"}(MessagesBundle_Workspace_Upgrade=exports.MessagesBundle_Workspace_Upgrade||(exports.MessagesBundle_Workspace_Upgrade={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspaceCleanupSuccessful="workspaceCleanupSuccessful",e.WorkspaceCleanupFailed="workspaceCleanupFailed"}(MessagesBundle_Workspace_Cleanup=exports.MessagesBundle_Workspace_Cleanup||(exports.MessagesBundle_Workspace_Cleanup={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.ValidationErrors="ValidationErrors",e.GenerationSuccessful="GenerationSuccessful",e.GenerationFailed="GenerationFailed",e.NoOutput="NoOutput",e.BuildProgress="BuildProgress"}(MessagesBundle_Workspace_Build=exports.MessagesBundle_Workspace_Build||(exports.MessagesBundle_Workspace_Build={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspacePackageProgress="workspacePackageProgress",e.WorkspacePackageSuccessful="workspacePackageSuccessful",e.WorkspacePackageFailed="workspacePackageFailed"}(MessagesBundle_Workspace_Package=exports.MessagesBundle_Workspace_Package||(exports.MessagesBundle_Workspace_Package={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.ValidationErrors="ValidationErrors",e.ValidationSuccessful="ValidationSuccessful",e.ValidationFailed="ValidationFailed",e.NoOutput="NoOutput",e.ValidationProgress="ValidationProgress"}(MessagesBundle_Workspace_Validate=exports.MessagesBundle_Workspace_Validate||(exports.MessagesBundle_Workspace_Validate={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.SFConsumerKeyNotDefined="SFConsumerKeyNotDefined",e.PortNotDefined="PortNotDefined",e.SimulatorConfigNotFound="SimulatorConfigNotFound",e.ApplicationConfigNotFound="ApplicationConfigNotFound",e.ServerStartFailed="ServerStartFailed",e.ServerStopRequest="ServerStopRequest",e.EncryptionWarning="EncryptionWarning"}(MessagesBundle_Workspace_Server_Start=exports.MessagesBundle_Workspace_Server_Start||(exports.MessagesBundle_Workspace_Server_Start={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.InputFlagDescription="inputFlagDescription",e.InputFileNotFound="inputFileNotFound",e.InputFileSizeLimit="inputFileSizeLimit",e.Base64EncodeError="base64EncodeError"}(MessagesBundle_Workspace_Utils_Base64Encode=exports.MessagesBundle_Workspace_Utils_Base64Encode||(exports.MessagesBundle_Workspace_Utils_Base64Encode={})),function(e){e.commandDescription="commandDescription",e.ValidationErrors="ValidationErrors",e.RefreshInProgress="RefreshInProgress",e.RefreshSuccessful="RefreshSuccessful",e.RefreshFailed="RefreshFailed",e.MissingLocaleSnippets="MissingLocaleSnippets",e.BuildNotFound="BuildNotFound"}(MessagesBundle_Workspace_RefreshLocale=exports.MessagesBundle_Workspace_RefreshLocale||(exports.MessagesBundle_Workspace_RefreshLocale={})),function(e){e.CommandDescription="CommandDescription",e.MigrationInProgress="MigrationInProgress",e.MissingSrcDirectory="MissingSrcDirectory",e.WorkspaceNotFound="WorkspaceNotFound",e.MigrationFailed="MigrationFailed",e.MigrationComplete="MigrationComplete"}(MessagesBundle_Workspace_Utils_MigrateContracts=exports.MessagesBundle_Workspace_Utils_MigrateContracts||(exports.MessagesBundle_Workspace_Utils_MigrateContracts={})),function(e){e.commandDescription="commandDescription",e.inProgress="inProgress",e.failed="failed",e.successful="successful"}(MessagesBundle_Workspace_Utils_GenerateManifest=exports.MessagesBundle_Workspace_Utils_GenerateManifest||(exports.MessagesBundle_Workspace_Utils_GenerateManifest={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.TypeFlagDescription="typeFlagDescription",e.ModuleFlagDescription="moduleFlagDescription",e.NameFlagDescription="nameFlagDescription",e.WorkspaceAddSuccessful="workspaceAddSuccessful",e.WorkspaceAddAborted="workspaceAddAborted",e.WorkspaceAddFailed="workspaceAddFailed",e.WorkspaceAddError="workspaceAddError",e.WorkspaceUpgradeAvailable="workspaceUpgradeAvailable"}(MessagesBundle_Workspace_Add=exports.MessagesBundle_Workspace_Add||(exports.MessagesBundle_Workspace_Add={}));
1
+ "use strict";var MessagesBundle,MessagesBundle_World,MessagesBundle_Workspace,MessagesBundle_Workspace_Create,MessagesBundle_Workspace_Upgrade,MessagesBundle_Workspace_Cleanup,MessagesBundle_Workspace_Build,MessagesBundle_Workspace_Package,MessagesBundle_Workspace_Validate,MessagesBundle_Workspace_Server_Start,MessagesBundle_Workspace_Utils_Base64Encode,MessagesBundle_Workspace_RefreshLocale,MessagesBundle_Workspace_Utils_MigrateContracts,MessagesBundle_Workspace_Utils_GenerateManifest,MessagesBundle_Workspace_Utils_ImportContracts,MessagesBundle_Workspace_Add;Object.defineProperty(exports,"__esModule",{value:!0}),exports.MessagesBundle_Workspace_Add=exports.MessagesBundle_Workspace_Utils_ImportContracts=exports.MessagesBundle_Workspace_Utils_GenerateManifest=exports.MessagesBundle_Workspace_Utils_MigrateContracts=exports.MessagesBundle_Workspace_RefreshLocale=exports.MessagesBundle_Workspace_Utils_Base64Encode=exports.MessagesBundle_Workspace_Server_Start=exports.MessagesBundle_Workspace_Validate=exports.MessagesBundle_Workspace_Package=exports.MessagesBundle_Workspace_Build=exports.MessagesBundle_Workspace_Cleanup=exports.MessagesBundle_Workspace_Upgrade=exports.MessagesBundle_Workspace_Create=exports.MessagesBundle_Workspace=exports.MessagesBundle_World=exports.MessagesBundle=exports.UpdateNotificationMessage=void 0,exports.UpdateNotificationMessage="A new update of <%= name %> is available.\nTo update your Modeler CLI plugin from <%= chalk.green(current) %> to <%= chalk.green(latest) %>, run: <%= chalk.blue(config.bin, 'plugins update') %>",function(e){e.World="world",e.Workspace="modeler-workspace",e.Workspace_Create="modeler-workspace-create",e.Workspace_Cleanup="modeler-workspace-cleanup",e.Workspace_Build="modeler-workspace-build",e.Workspace_Package="modeler-workspace-package",e.Workspace_Validate="modeler-workspace-validate",e.Workspace_Server_Start="modeler-workspace-server-start",e.Workspace_Utils_Base64Encode="modeler-workspace-utils-base64encode",e.Workspace_RefreshLocale="modeler-workspace-refresh-locale",e.Workspace_Upgrade="modeler-workspace-upgrade",e.Workspace_Utils_MigrateContracts="modeler-workspace-utils-migrateContracts",e.Workspace_Utils_GenerateManifest="modeler-workspace-utils-generateManifest",e.Workspace_Utils_ImportContracts="modeler-workspace-utils-importContracts",e.Workspace_Add="modeler-workspace-add"}(MessagesBundle=exports.MessagesBundle||(exports.MessagesBundle={})),function(e){e.CommandDescription="commandDescription",e.NameFlagDescription="nameFlagDescription",e.Examples="examples"}(MessagesBundle_World=exports.MessagesBundle_World||(exports.MessagesBundle_World={})),function(e){e.PathFlagDescription="pathFlagDescription",e.WorkspaceNotFound="workspaceNotFound",e.InProgress="inProgress",e.Done="done",e.Failed="failed"}(MessagesBundle_Workspace=exports.MessagesBundle_Workspace||(exports.MessagesBundle_Workspace={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspaceAlreadyExists="workspaceAlreadyExists",e.WorkspaceCreationSuccessful="workspaceCreationSuccessful",e.WorkspaceCreationFailed="workspaceCreationFailed"}(MessagesBundle_Workspace_Create=exports.MessagesBundle_Workspace_Create||(exports.MessagesBundle_Workspace_Create={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspaceDoesNotExist="workspaceDoesNotExist",e.WorkspaceUpgradationSuccessful="workspaceUpgradationSuccessful",e.WorkspaceUpgradationFailed="workspaceUpgradationFailed"}(MessagesBundle_Workspace_Upgrade=exports.MessagesBundle_Workspace_Upgrade||(exports.MessagesBundle_Workspace_Upgrade={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspaceCleanupSuccessful="workspaceCleanupSuccessful",e.WorkspaceCleanupFailed="workspaceCleanupFailed"}(MessagesBundle_Workspace_Cleanup=exports.MessagesBundle_Workspace_Cleanup||(exports.MessagesBundle_Workspace_Cleanup={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.ValidationErrors="ValidationErrors",e.GenerationSuccessful="GenerationSuccessful",e.GenerationFailed="GenerationFailed",e.NoOutput="NoOutput",e.BuildProgress="BuildProgress"}(MessagesBundle_Workspace_Build=exports.MessagesBundle_Workspace_Build||(exports.MessagesBundle_Workspace_Build={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.WorkspacePackageProgress="workspacePackageProgress",e.WorkspacePackageSuccessful="workspacePackageSuccessful",e.WorkspacePackageFailed="workspacePackageFailed"}(MessagesBundle_Workspace_Package=exports.MessagesBundle_Workspace_Package||(exports.MessagesBundle_Workspace_Package={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.ValidationErrors="ValidationErrors",e.ValidationSuccessful="ValidationSuccessful",e.ValidationFailed="ValidationFailed",e.NoOutput="NoOutput",e.ValidationProgress="ValidationProgress"}(MessagesBundle_Workspace_Validate=exports.MessagesBundle_Workspace_Validate||(exports.MessagesBundle_Workspace_Validate={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.SFConsumerKeyNotDefined="SFConsumerKeyNotDefined",e.PortNotDefined="PortNotDefined",e.SimulatorConfigNotFound="SimulatorConfigNotFound",e.ApplicationConfigNotFound="ApplicationConfigNotFound",e.ServerStartFailed="ServerStartFailed",e.ServerStopRequest="ServerStopRequest",e.EncryptionWarning="EncryptionWarning"}(MessagesBundle_Workspace_Server_Start=exports.MessagesBundle_Workspace_Server_Start||(exports.MessagesBundle_Workspace_Server_Start={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.InputFlagDescription="inputFlagDescription",e.InputFileNotFound="inputFileNotFound",e.InputFileSizeLimit="inputFileSizeLimit",e.Base64EncodeError="base64EncodeError"}(MessagesBundle_Workspace_Utils_Base64Encode=exports.MessagesBundle_Workspace_Utils_Base64Encode||(exports.MessagesBundle_Workspace_Utils_Base64Encode={})),function(e){e.commandDescription="commandDescription",e.ValidationErrors="ValidationErrors",e.RefreshInProgress="RefreshInProgress",e.RefreshSuccessful="RefreshSuccessful",e.RefreshFailed="RefreshFailed",e.MissingLocaleSnippets="MissingLocaleSnippets",e.BuildNotFound="BuildNotFound"}(MessagesBundle_Workspace_RefreshLocale=exports.MessagesBundle_Workspace_RefreshLocale||(exports.MessagesBundle_Workspace_RefreshLocale={})),function(e){e.CommandDescription="CommandDescription",e.MigrationInProgress="MigrationInProgress",e.MissingSrcDirectory="MissingSrcDirectory",e.WorkspaceNotFound="WorkspaceNotFound",e.MigrationFailed="MigrationFailed",e.MigrationComplete="MigrationComplete"}(MessagesBundle_Workspace_Utils_MigrateContracts=exports.MessagesBundle_Workspace_Utils_MigrateContracts||(exports.MessagesBundle_Workspace_Utils_MigrateContracts={})),function(e){e.commandDescription="commandDescription",e.inProgress="inProgress",e.failed="failed",e.successful="successful"}(MessagesBundle_Workspace_Utils_GenerateManifest=exports.MessagesBundle_Workspace_Utils_GenerateManifest||(exports.MessagesBundle_Workspace_Utils_GenerateManifest={})),function(e){e.CommandDescription="commandDescription",e.InputFlagDescription="inputFlagDescription",e.CoreFlagDescription="coreFlagDescription",e.InvalidFilePath="invalidFilePath",e.InvalidWorkSpace="invalidWorkSpace",e.InvalidContractsType="invalidContractsType",e.importContractsSuccess="importContractsSuccess",e.UnexpectedError="unexpectedError",e.ExtractingInputMessage="extractingInputMessage",e.ImportContractsMessage="importContractsMessage",e.CleanupMessage="cleanupMessage"}(MessagesBundle_Workspace_Utils_ImportContracts=exports.MessagesBundle_Workspace_Utils_ImportContracts||(exports.MessagesBundle_Workspace_Utils_ImportContracts={})),function(e){e.CommandDescription="commandDescription",e.Examples="examples",e.TypeFlagDescription="typeFlagDescription",e.ModuleFlagDescription="moduleFlagDescription",e.NameFlagDescription="nameFlagDescription",e.WorkspaceAddSuccessful="workspaceAddSuccessful",e.WorkspaceAddAborted="workspaceAddAborted",e.WorkspaceAddFailed="workspaceAddFailed",e.WorkspaceAddError="workspaceAddError",e.WorkspaceUpgradeAvailable="workspaceUpgradeAvailable"}(MessagesBundle_Workspace_Add=exports.MessagesBundle_Workspace_Add||(exports.MessagesBundle_Workspace_Add={}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.cpdir=exports.getFileDate=exports.getFileSize=exports.base64EncodeFile=exports.move=exports.listDirs=exports.listFiles=exports.listContents=exports.readFile=exports.readTextFile=exports.readJsonFile=exports.emptyFolder=exports.createFolder=exports.createFile=exports.baseName=exports.parentPath=exports.relativePath=exports.joinPaths=exports.ensureFileExists=exports.writeFile=exports.deleteFolder=exports.mergeFiles=exports.ensureFolderExists=exports.existsFolder=exports.existsFile=void 0;const path=require("path"),fs=require("fs-extra"),_=require("lodash"),validationHelper=require("../utils/validationHelper"),errors_1=require("../types/errors");function existsFile(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("filePath");return fs.existsSync(e)&&fs.statSync(e).isFile()}function existsFolder(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("folderPath");return fs.existsSync(e)&&fs.statSync(e).isDirectory()}function ensureFolderExists(e){existsFolder(e)||createFolder(e)}function mergeFiles(e,t){const r=fs.readFileSync(e,"utf8"),s=fs.readFileSync(t,"utf8"),i=r.split("\n"),o=s.split("\n"),l=_.union(i,o);fs.writeFileSync(t,[...l].join("\n"))}function deleteFolder(e){existsFolder(e)&&fs.rmSync(e,{recursive:!0})}function ensureFileExists(e,t){existsFile(e)||createFile(e,t)}function joinPaths(...e){if(!validationHelper.isDefined(e)||!_.isArrayLike(e)||_.isEmpty(e))throw new errors_1.ArgumentError("paths");return path.join(...e)}function createFile(e,t){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("filePath");existsFile(e)||fs.writeFileSync(e,t||"")}function createFolder(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("folderPath");existsFolder(e)||fs.mkdirSync(e,{recursive:!0})}function emptyFolder(e){existsFolder(e)&&fs.emptyDirSync(e)}function readJsonFile(e){return existsFile(e)?fs.readJsonSync(e):null}function readTextFile(e){return existsFile(e)?fs.readFileSync(e,"utf8"):null}function readFile(e){return existsFile(e)?fs.readFileSync(e):null}function listContents(e){return fs.readdirSync(e).map((t=>path.join(e,t)))}function listFiles(e){return listContents(e).filter((e=>fs.statSync(e).isFile()))}function listDirs(e){return listContents(e).filter((e=>fs.statSync(e).isDirectory()))}function move(e,t){(existsFile(e)||existsFolder(e))&&fs.moveSync(e,t,{overwrite:!0})}function base64EncodeFile(e){return existsFile(e)?readFile(e).toString("base64"):null}function getFileSize(e){return existsFile(e)?fs.statSync(e).size:-1}function getFileDate(e){return existsFile(e)?fs.statSync(e).mtimeMs:-1}function cpdir(e,t){if(existsFolder(e)){ensureFolderExists(t),listFiles(e).forEach((e=>{createFile(joinPaths(t,path.basename(e)),readTextFile(e))})),listDirs(e).forEach((e=>{cpdir(e,joinPaths(t,path.basename(e)))}))}}exports.existsFile=existsFile,exports.existsFolder=existsFolder,exports.ensureFolderExists=ensureFolderExists,exports.mergeFiles=mergeFiles,exports.deleteFolder=deleteFolder,exports.writeFile=fs.writeFileSync,exports.ensureFileExists=ensureFileExists,exports.joinPaths=joinPaths,exports.relativePath=path.relative,exports.parentPath=path.dirname,exports.baseName=path.basename,exports.createFile=createFile,exports.createFolder=createFolder,exports.emptyFolder=emptyFolder,exports.readJsonFile=readJsonFile,exports.readTextFile=readTextFile,exports.readFile=readFile,exports.listContents=listContents,exports.listFiles=listFiles,exports.listDirs=listDirs,exports.move=move,exports.base64EncodeFile=base64EncodeFile,exports.getFileSize=getFileSize,exports.getFileDate=getFileDate,exports.cpdir=cpdir;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.listFilesRecursively=exports.cpdir=exports.getFileDate=exports.getFileSize=exports.base64EncodeFile=exports.move=exports.listDirs=exports.listFiles=exports.listContents=exports.readFile=exports.readTextFile=exports.readJsonFile=exports.emptyFolder=exports.createFolder=exports.createFile=exports.baseName=exports.parentPath=exports.relativePath=exports.joinPaths=exports.ensureFileExists=exports.writeFile=exports.deleteFile=exports.deleteFolder=exports.mergeFiles=exports.ensureFolderExists=exports.existsFolder=exports.existsFile=void 0;const path=require("path"),fs=require("fs-extra"),_=require("lodash"),validationHelper=require("../utils/validationHelper"),errors_1=require("../types/errors");function existsFile(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("filePath");return fs.existsSync(e)&&fs.statSync(e).isFile()}function existsFolder(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("folderPath");return fs.existsSync(e)&&fs.statSync(e).isDirectory()}function ensureFolderExists(e){existsFolder(e)||createFolder(e)}function mergeFiles(e,t){const r=fs.readFileSync(e,"utf8"),s=fs.readFileSync(t,"utf8"),i=r.split("\n"),l=s.split("\n"),o=_.union(i,l);fs.writeFileSync(t,[...o].join("\n"))}function deleteFolder(e){existsFolder(e)&&fs.rmSync(e,{recursive:!0})}function deleteFile(e){existsFile(e)&&fs.rmSync(e)}function ensureFileExists(e,t){existsFile(e)||createFile(e,t)}function joinPaths(...e){if(!validationHelper.isDefined(e)||!_.isArrayLike(e)||_.isEmpty(e))throw new errors_1.ArgumentError("paths");return path.join(...e)}function createFile(e,t){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("filePath");existsFile(e)||fs.writeFileSync(e,t||"")}function createFolder(e){if(validationHelper.isNullOrEmpty(e))throw new errors_1.ArgumentError("folderPath");existsFolder(e)||fs.mkdirSync(e,{recursive:!0})}function emptyFolder(e){existsFolder(e)&&fs.emptyDirSync(e)}function readJsonFile(e){return existsFile(e)?fs.readJsonSync(e):null}function readTextFile(e){return existsFile(e)?fs.readFileSync(e,"utf8"):null}function readFile(e){return existsFile(e)?fs.readFileSync(e):null}function listContents(e){return fs.readdirSync(e).map((t=>path.join(e,t)))}function listFiles(e){return listContents(e).filter((e=>fs.statSync(e).isFile()))}function listDirs(e){return listContents(e).filter((e=>fs.statSync(e).isDirectory()))}function move(e,t){(existsFile(e)||existsFolder(e))&&fs.moveSync(e,t,{overwrite:!0})}function base64EncodeFile(e){return existsFile(e)?readFile(e).toString("base64"):null}function getFileSize(e){return existsFile(e)?fs.statSync(e).size:-1}function getFileDate(e){return existsFile(e)?fs.statSync(e).mtimeMs:-1}function cpdir(e,t,r=null){if(r||(r=()=>!0),existsFolder(e)){ensureFolderExists(t),listFiles(e).forEach((e=>{if(r(e)){let r=joinPaths(t,path.basename(e));(0,exports.writeFile)(r,readTextFile(e))}})),listDirs(e).forEach((e=>{cpdir(e,joinPaths(t,path.basename(e)),r)}))}}function listFilesRecursively(e){let t=[];return existsFolder(e)?(t.push(...listFiles(e)),listDirs(e).forEach((e=>{t.push(...listFilesRecursively(e))})),t):t}exports.existsFile=existsFile,exports.existsFolder=existsFolder,exports.ensureFolderExists=ensureFolderExists,exports.mergeFiles=mergeFiles,exports.deleteFolder=deleteFolder,exports.deleteFile=deleteFile,exports.writeFile=fs.writeFileSync,exports.ensureFileExists=ensureFileExists,exports.joinPaths=joinPaths,exports.relativePath=path.relative,exports.parentPath=path.dirname,exports.baseName=path.basename,exports.createFile=createFile,exports.createFolder=createFolder,exports.emptyFolder=emptyFolder,exports.readJsonFile=readJsonFile,exports.readTextFile=readTextFile,exports.readFile=readFile,exports.listContents=listContents,exports.listFiles=listFiles,exports.listDirs=listDirs,exports.move=move,exports.base64EncodeFile=base64EncodeFile,exports.getFileSize=getFileSize,exports.getFileDate=getFileDate,exports.cpdir=cpdir,exports.listFilesRecursively=listFilesRecursively;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.prepareForCustContractsImport=exports.isCoreFile=exports.getContractsType=exports.ContractsType=void 0;const fsHelper=require("./fsHelper"),fsHelper_1=require("./fsHelper"),constants_1=require("../constants");let libxmljs;var ContractsType;function getContractsType(e){let t=fsHelper.joinPaths(e,constants_1.WorkspaceConstants.WORKSPACE_SOURCE_FOLDER,constants_1.WorkspaceConstants.MANIFEST_FILE);if(fsHelper.existsFile(t))return ContractsType.NEW_MODELER;let r=fsHelper.joinPaths(e,constants_1.WorkspaceConstants.VERSION_FILE);if(!fsHelper.existsFile(r))return ContractsType.INVALID_CONTRACTS_TYPE;libxmljs||(libxmljs=require("libxmljs"));let s=libxmljs.parseXmlString(fsHelper.readTextFile(r)).root(),o=s.attr("Mode")?.value(),l=s.attr("Type")?.value(),p=s.attr("ModelerMode")?.value();return"Complete"!=o||"Salesforce"!=p||l!=ContractsType.CORE&&l!=ContractsType.CUST?ContractsType.INVALID_CONTRACTS_TYPE:l}function isCoreFile(e){return e.endsWith(".core.xml")}function prepareForCustContractsImport(e,t=!1){let r=(0,fsHelper_1.listFilesRecursively)(e),s=r.filter(isCoreFile),o=r.filter((e=>!isCoreFile(e)));t?(o.forEach((e=>(0,fsHelper_1.deleteFile)(e))),s.forEach((e=>(0,fsHelper_1.move)(e,e.replace(/.core.xml$/,".xml"))))):s.forEach((e=>(0,fsHelper_1.deleteFile)(e)))}!function(e){e.NEW_MODELER="New_Modeler",e.CORE="Core",e.CUST="Cust",e.INVALID_CONTRACTS_TYPE="Invalid_ContractsType"}(ContractsType=exports.ContractsType||(exports.ContractsType={})),exports.getContractsType=getContractsType,exports.isCoreFile=isCoreFile,exports.prepareForCustContractsImport=prepareForCustContractsImport;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createDeploymentPackage=exports.normalizeFilePath=exports.PackageConstants=void 0;const JSZip=require("jszip"),walkSync=require("klaw-sync"),fs=require("fs-extra"),path=require("path"),_=require("lodash"),fsHelper=require("./fsHelper"),validationHelper=require("./validationHelper"),messageHelper=require("./messageHelper"),errors_1=require("../types/errors"),messages_1=require("../types/messages");class PackageConstants{static getSupportedAppFolders(){return[fsHelper.joinPaths(this.PACKAGE_APP_FOLDER_NAME,this.PACKAGE_APP_CLOCKWORK_FOLDER_NAME),fsHelper.joinPaths(this.PACKAGE_APP_FOLDER_NAME,this.PACKAGE_APP_EXTERNAL_FILES_FOLDER_NAME),fsHelper.joinPaths(this.PACKAGE_APP_FOLDER_NAME,this.PACKAGE_APP_REPLICATION_FILES_FOLDER_NAME)]}static getUnsupportedFiles(){return[this.PACKAGE_GENERATOR_HANDOVER_FILE,this.PACKAGE_GENERATOR_VALIDATION_RESULT_FILE,this.PACKAGE_DS_STORE_FILE]}static formatVersion(e){return`${e.getUTCFullYear()}${e.getUTCMonth().toString().padStart(2,"0")}${e.getUTCDate().toString().padStart(2,"0")}${e.getUTCHours().toString().padStart(2,"0")}${e.getUTCMinutes().toString().padStart(2,"0")}${e.getUTCSeconds().toString().padStart(2,"0")}${e.getUTCMilliseconds().toString().padStart(3,"0")}`}}function normalizeFilePath(e,t){const s=new RegExp("\\"+t,"g");return e.replace(s,path.posix.sep)}function __normalizeFilePath(e){return normalizeFilePath(e,path.sep)}async function createDeploymentPackage(e,t,s){if(!validationHelper.isDefined(e))throw new errors_1.ArgumentError("workspace");if(!validationHelper.isDefined(t)||!_.isDate(t))throw new errors_1.ArgumentError("versionDate");if(!validationHelper.isDefined(s)||!_.isArray(s))throw new errors_1.ArgumentError("components");if(!e.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace,messages_1.MessagesBundle_Workspace.WorkspaceNotFound,[e.getBasePath()]));e.getLastBuildStatus().ensureSuccess();let a=new JSZip,r=t,n=PackageConstants.formatVersion(t);const o=PackageConstants.getSupportedAppFolders(),i=PackageConstants.getUnsupportedFiles();let A=e.getApplicationBuildPath(),E=path.resolve(A),l=fsHelper.joinPaths(A,PackageConstants.PACKAGE_APP_FOLDER_NAME),P=[];walkSync(l,{nodir:!0,filter:e=>{let t=e.path.substring(E.length+1),s=_.toLower(t);if(_.some(o,(e=>_.startsWith(s,e)))){return!_.some(i,(e=>_.endsWith(s,e)))}return!1}}).forEach((e=>{let t=__normalizeFilePath(e.path.substring(E.length+1));a.file(t,fs.readFileSync(e.path)),P.push({path:t})}));let p={deploymentVersion:n,files:P},g={deploymentVersion:n,creationDate:r.toUTCString(),components:s,automatedTest:!1,inputValidationActive:!1};a.file(PackageConstants.PACKAGE_MANIFEST_FILE_NAME,JSON.stringify(p)),a.file(PackageConstants.PACKAGE_INFO_FILE_NAME,JSON.stringify(g));let c=fsHelper.joinPaths(e.getApplicationBuildPath(),PackageConstants.PACKAGE_FILE_NAME);await a.generateAsync({type:"nodebuffer",compression:"DEFLATE"}).then((e=>{fs.writeFileSync(c,e)}))}exports.PackageConstants=PackageConstants,PackageConstants.PACKAGE_INFO_FILE_NAME="info.json",PackageConstants.PACKAGE_MANIFEST_FILE_NAME="manifest.json",PackageConstants.PACKAGE_FILE_NAME="deployment.zip",PackageConstants.PACKAGE_APP_FOLDER_NAME="app",PackageConstants.PACKAGE_APP_CLOCKWORK_FOLDER_NAME="clockwork",PackageConstants.PACKAGE_APP_EXTERNAL_FILES_FOLDER_NAME="externalfiles",PackageConstants.PACKAGE_APP_REPLICATION_FILES_FOLDER_NAME="replicationfiles",PackageConstants.PACKAGE_GENERATOR_HANDOVER_FILE="generatorhandoverfile.json",PackageConstants.PACKAGE_GENERATOR_VALIDATION_RESULT_FILE="generatorvalidationresult.json",PackageConstants.PACKAGE_DS_STORE_FILE=".ds_store",exports.normalizeFilePath=normalizeFilePath,exports.createDeploymentPackage=createDeploymentPackage;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createDeploymentPackage=exports.normalizeFilePath=exports.PackageConstants=void 0;const JSZip=require("jszip"),walkSync=require("klaw-sync"),fs=require("fs-extra"),path=require("path"),_=require("lodash"),fsHelper=require("./fsHelper"),validationHelper=require("./validationHelper"),messageHelper=require("./messageHelper"),errors_1=require("../types/errors"),messages_1=require("../types/messages"),constants_1=require("../constants");class PackageConstants{static getSupportedAppFolders(){return[fsHelper.joinPaths(this.PACKAGE_APP_FOLDER_NAME,this.PACKAGE_APP_CLOCKWORK_FOLDER_NAME),fsHelper.joinPaths(this.PACKAGE_APP_FOLDER_NAME,this.PACKAGE_APP_EXTERNAL_FILES_FOLDER_NAME),fsHelper.joinPaths(this.PACKAGE_APP_FOLDER_NAME,this.PACKAGE_APP_REPLICATION_FILES_FOLDER_NAME)]}static getUnsupportedFiles(){return[constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_GENERATOR_HANDOVER_FILE,constants_1.WorkspaceConstants.WORKSPACE_APPLICATION_VALIDATION_RESULT_FILE,this.PACKAGE_DS_STORE_FILE]}static formatVersion(e){return`${e.getUTCFullYear()}${e.getUTCMonth().toString().padStart(2,"0")}${e.getUTCDate().toString().padStart(2,"0")}${e.getUTCHours().toString().padStart(2,"0")}${e.getUTCMinutes().toString().padStart(2,"0")}${e.getUTCSeconds().toString().padStart(2,"0")}${e.getUTCMilliseconds().toString().padStart(3,"0")}`}}function normalizeFilePath(e,t){const s=new RegExp("\\"+t,"g");return e.replace(s,path.posix.sep)}function __normalizeFilePath(e){return normalizeFilePath(e,path.sep)}async function createDeploymentPackage(e,t,s){if(!validationHelper.isDefined(e))throw new errors_1.ArgumentError("workspace");if(!validationHelper.isDefined(t)||!_.isDate(t))throw new errors_1.ArgumentError("versionDate");if(!validationHelper.isDefined(s)||!_.isArray(s))throw new errors_1.ArgumentError("components");if(!e.exists())throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace,messages_1.MessagesBundle_Workspace.WorkspaceNotFound,[e.getBasePath()]));e.getLastBuildStatus().ensureSuccess();let a=new JSZip,r=t,n=PackageConstants.formatVersion(t);const o=PackageConstants.getSupportedAppFolders(),i=PackageConstants.getUnsupportedFiles();let A=e.getApplicationBuildPath(),P=path.resolve(A),p=fsHelper.joinPaths(A,PackageConstants.PACKAGE_APP_FOLDER_NAME),l=[];walkSync(p,{nodir:!0,filter:e=>{let t=e.path.substring(P.length+1),s=_.toLower(t);if(_.some(o,(e=>_.startsWith(s,e)))){return!_.some(i,(e=>_.endsWith(s,e)))}return!1}}).forEach((e=>{let t=__normalizeFilePath(e.path.substring(P.length+1));a.file(t,fs.readFileSync(e.path)),l.push({path:t})}));let E={deploymentVersion:n,files:l},c={deploymentVersion:n,creationDate:r.toUTCString(),components:s,automatedTest:!1,inputValidationActive:!1};a.file(PackageConstants.PACKAGE_MANIFEST_FILE_NAME,JSON.stringify(E)),a.file(PackageConstants.PACKAGE_INFO_FILE_NAME,JSON.stringify(c));let g=fsHelper.joinPaths(e.getApplicationBuildPath(),PackageConstants.PACKAGE_FILE_NAME);await a.generateAsync({type:"nodebuffer",compression:"DEFLATE"}).then((e=>{fs.writeFileSync(g,e)}))}exports.PackageConstants=PackageConstants,PackageConstants.PACKAGE_INFO_FILE_NAME="info.json",PackageConstants.PACKAGE_MANIFEST_FILE_NAME="manifest.json",PackageConstants.PACKAGE_FILE_NAME="deployment.zip",PackageConstants.PACKAGE_APP_FOLDER_NAME="app",PackageConstants.PACKAGE_APP_CLOCKWORK_FOLDER_NAME="clockwork",PackageConstants.PACKAGE_APP_EXTERNAL_FILES_FOLDER_NAME="externalfiles",PackageConstants.PACKAGE_APP_REPLICATION_FILES_FOLDER_NAME="replicationfiles",PackageConstants.PACKAGE_DS_STORE_FILE=".ds_store",exports.normalizeFilePath=normalizeFilePath,exports.createDeploymentPackage=createDeploymentPackage;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createAppConfiguration=exports.createBackendConfiguration=exports.validateConfiguration=void 0;const componentHelper_1=require("./componentHelper"),fsHelper_1=require("./fsHelper"),validationHelper_1=require("./validationHelper"),messages_1=require("../types/messages"),fs=require("fs-extra"),constants_1=require("../constants"),path=require("path"),config_1=require("../types/config"),messageHelper=require("./messageHelper"),_=require("lodash");function getImageConfigs(e,t){return(0,validationHelper_1.isNullOrEmpty)(e)?{referenceImage:"",referenceImagePath:""}:(path.isAbsolute(e)||(e=path.resolve(path.join(t,e))),{referenceImage:path.basename(e),referenceImagePath:path.dirname(e)})}function validateConfiguration(e){const t=e.getApplicationConfig();if(!(0,validationHelper_1.isDefined)(t.server))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.SimulatorConfigNotFound,[e.getApplicationConfigFilePath()]));if(!(0,validationHelper_1.isDefined)(t.server.port)||!_.isNumber(t.server.port))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.PortNotDefined,[e.getApplicationConfigFilePath()]));if(!(0,validationHelper_1.isDefined)(t.application))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.ApplicationConfigNotFound,[e.getApplicationConfigFilePath()]));if((0,validationHelper_1.isNullOrEmpty)(t.application.sfConsumerKey))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.SFConsumerKeyNotDefined,[e.getApplicationConfigFilePath()]))}function createBackendConfiguration(e){const t=e.getApplicationConfig(),r=e.getApplicationDataPath(),a=new componentHelper_1.ServerComponentHelper,n=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.BACKEND_SERVER_CONFIG);let s=(0,fsHelper_1.readJsonFile)(a.getConfigurationTemplatePath());s.port=t.server.port,s.database=constants_1.WorkspaceConstants.APP_DB;const o=getImageConfigs(t.server.referenceImagePath,e.getApplicationConfigPath());s.referenceImage=o.referenceImage,s.referenceImagePath=o.referenceImagePath,s.mountpoints.forEach((e=>{(0,validationHelper_1.isDefined)(e.path)&&"/framework"==e.path&&(e.location=(new componentHelper_1.FrameworkComponentHelper).getPath())})),s.mountpoints.push({path:"/framework/app",location:(0,fsHelper_1.joinPaths)(e.getApplicationBuildPath(),"app")}),s.mountpoints.push({path:"/framework/configuration.json",location:(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.APP_CONFIG)}),fs.writeFileSync(n,JSON.stringify(s,null,4)||"");const i=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.APP_DB);(0,fsHelper_1.existsFile)(i)||fs.writeFileSync(i,"");const p=a.getLoggingConfigurationPath(),l=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.BACKEND_LOGGING_CONFIG);let c=t.server.logLevel;c in config_1.LogLevel||(c=config_1.LogLevel.ERROR);let g=(0,fsHelper_1.readJsonFile)(p);g.appenders.console={type:"logLevelFilter",level:c,appender:"consoleAppender"},g.appenders.consoleAppender={type:"console"},fs.writeFileSync(l,JSON.stringify(g,null,4)||"")}function createAppConfiguration(e){const t=e.getApplicationConfig(),r=e.getApplicationDataPath(),a=(new componentHelper_1.FrameworkComponentHelper).getConfigurationTemplatePath(),n=(0,fsHelper_1.joinPaths)(r,constants_1.WorkspaceConstants.APP_CONFIG);let s=(0,fsHelper_1.readJsonFile)(a);s.sfConsumerKey=t.application.sfConsumerKey,s.uniqueWorkspaceID=t.application.uniqueID,s.backend=`http://localhost:${t.server.port}/`,s.sfCallbackURL=`http://localhost:${t.server.port}/fake/services/oauth/success`,s.verbose=!0,fs.writeFileSync(n,JSON.stringify(s,null,4)||"")}exports.validateConfiguration=validateConfiguration,exports.createBackendConfiguration=createBackendConfiguration,exports.createAppConfiguration=createAppConfiguration;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createAppConfiguration=exports.createBackendConfiguration=exports.validateConfiguration=void 0;const componentHelper_1=require("./componentHelper"),fsHelper_1=require("./fsHelper"),validationHelper_1=require("./validationHelper"),messages_1=require("../types/messages"),fs=require("fs-extra"),constants_1=require("../constants"),path=require("path"),config_1=require("../types/config"),messageHelper=require("./messageHelper"),_=require("lodash");function getImageConfigs(e,t){return(0,validationHelper_1.isNullOrEmpty)(e)?{referenceImage:"",referenceImagePath:""}:(path.isAbsolute(e)||(e=path.resolve(path.join(t,e))),{referenceImage:path.basename(e),referenceImagePath:path.dirname(e)})}function validateConfiguration(e){const t=e.getApplicationConfig();if(!(0,validationHelper_1.isDefined)(t.server))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.SimulatorConfigNotFound,[e.getApplicationConfigFilePath()]));if(!(0,validationHelper_1.isDefined)(t.server.port)||!_.isNumber(t.server.port))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.PortNotDefined,[e.getApplicationConfigFilePath()]));if(!(0,validationHelper_1.isDefined)(t.application))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.ApplicationConfigNotFound,[e.getApplicationConfigFilePath()]));if((0,validationHelper_1.isNullOrEmpty)(t.application.sfConsumerKey))throw new Error(messageHelper.getMessage(messages_1.MessagesBundle.Workspace_Server_Start,messages_1.MessagesBundle_Workspace_Server_Start.SFConsumerKeyNotDefined,[e.getApplicationConfigFilePath()]))}function createBackendConfiguration(e){const t=e.getApplicationConfig(),a=e.getApplicationDataPath(),r=new componentHelper_1.ServerComponentHelper,n=(0,fsHelper_1.joinPaths)(a,constants_1.WorkspaceConstants.BACKEND_SERVER_CONFIG);let s=(0,fsHelper_1.readJsonFile)(r.getConfigurationTemplatePath());s.port=t.server.port,s.database=constants_1.WorkspaceConstants.APP_DB;const o=getImageConfigs(t.server.referenceImagePath,e.getApplicationConfigPath());s.referenceImage=o.referenceImage,s.referenceImagePath=o.referenceImagePath,s.mountpoints.forEach((e=>{(0,validationHelper_1.isDefined)(e.path)&&"/framework"==e.path&&(e.location=(new componentHelper_1.FrameworkComponentHelper).getPath())})),s.mountpoints.push({path:"/framework/app",location:(0,fsHelper_1.joinPaths)(e.getApplicationBuildPath(),"app")}),s.mountpoints.push({path:"/framework/configuration.json",location:(0,fsHelper_1.joinPaths)(a,constants_1.WorkspaceConstants.APP_CONFIG)}),fs.writeFileSync(n,JSON.stringify(s,null,4)||"");const i=(0,fsHelper_1.joinPaths)(a,constants_1.WorkspaceConstants.APP_DB);(0,fsHelper_1.existsFile)(i)||fs.writeFileSync(i,"");const p=r.getLoggingConfigurationPath(),l=(0,fsHelper_1.joinPaths)(a,constants_1.WorkspaceConstants.BACKEND_LOGGING_CONFIG);let c=t.server.logLevel;c in config_1.LogLevel||(c=config_1.LogLevel.ERROR);let g=(0,fsHelper_1.readJsonFile)(p);g.appenders.console={type:"logLevelFilter",level:c,appender:"consoleAppender"},g.appenders.consoleAppender={type:"console"},fs.writeFileSync(l,JSON.stringify(g,null,4)||"")}function createAppConfiguration(e){const t=e.getApplicationConfig(),a=e.getApplicationDataPath(),r=(new componentHelper_1.FrameworkComponentHelper).getConfigurationTemplatePath(),n=(0,fsHelper_1.joinPaths)(a,constants_1.WorkspaceConstants.APP_CONFIG);let s=(0,fsHelper_1.readJsonFile)(r);s.sfConsumerKey=t.application.sfConsumerKey,s.uniqueWorkspaceID=t.application.uniqueID,s.backend=`http://localhost:${t.server.port}/`,s.sfCallbackURL=`http://localhost:${t.server.port}/fake/services/oauth/success`,s.verbose=!0,t.application.sfSubDomainURL&&(s.sfSubDomainURL=t.application.sfSubDomainURL),fs.writeFileSync(n,JSON.stringify(s,null,4)||"")}exports.validateConfiguration=validateConfiguration,exports.createBackendConfiguration=createBackendConfiguration,exports.createAppConfiguration=createAppConfiguration;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TemplateEngine=exports.Utils=exports.TemplateEngineContext=exports.ValidationSet=exports.NON_MODULES=exports.TemplateEngineState=exports.ResourceType=exports.ResourceAction=exports.ContractType=exports.QuestionType=exports.Namespace=exports.NameIdentifier=void 0;const _=require("lodash"),inquirer=require("inquirer"),path=require("path"),walkSync=require("klaw-sync"),fsHelper_1=require("./fsHelper"),templateHelper_1=require("./templateHelper"),xmlHelper_1=require("./xmlHelper");var NameIdentifier,Namespace,QuestionType,ContractType;!function(e){e.Core="",e.Custom="My"}(NameIdentifier=exports.NameIdentifier||(exports.NameIdentifier={})),function(e){e.Core="CORE",e.Custom="CUSTOM"}(Namespace=exports.Namespace||(exports.Namespace={})),function(e){e.Type="TYPE",e.Name="NAME",e.Module="MODULE",e.FullName="FULL_NAME",e.Option="OPTION",e.Confirmation="CONFIRMATION"}(QuestionType=exports.QuestionType||(exports.QuestionType={})),function(e){e.Module="module",e.BusinessObject="businessobject",e.ListObject="listobject",e.LookupObject="lookupobject",e.DataSource="datasource",e.BusinessLogic="businesslogic"}(ContractType=exports.ContractType||(exports.ContractType={}));const ContractTypes=[ContractType.Module,ContractType.BusinessObject,ContractType.ListObject,ContractType.LookupObject,ContractType.DataSource,ContractType.BusinessLogic];var ResourceAction,ResourceType,TemplateEngineState;!function(e){e.Add="add",e.Update="update"}(ResourceAction=exports.ResourceAction||(exports.ResourceAction={})),function(e){e.File="file",e.Folder="folder",e.Tree="tree"}(ResourceType=exports.ResourceType||(exports.ResourceType={})),function(e){e[e.NEW=0]="NEW",e[e.DONE=1]="DONE",e[e.FAILED=2]="FAILED",e[e.ABORTED=3]="ABORTED"}(TemplateEngineState=exports.TemplateEngineState||(exports.TemplateEngineState={})),exports.NON_MODULES=["Application","BusinessObjectHelpers","ExternalFiles","Images","Locale","Plugins","SharedWebData","UI Plugins"];class ValidationSet{constructor(e){this.validations=e}validate(e){let t=!0;return _.forEach(this.validations,(r=>{let s=r(e);_.isBoolean(s)||!s||(t=s)})),t}}exports.ValidationSet=ValidationSet;class TemplateEngineContext{constructor(e){this.resourceTemplateDefinition=this.__loadResourceTemplateDefinition(),this.resourceOptions=this.__createResourceOptionsMap(),this.workspace=e}__loadResourceTemplateDefinition(){return(0,fsHelper_1.readJsonFile)((0,templateHelper_1.getTemplateDefinitionsFilePath)())}__createResourceOptionsMap(){let e=new Map;return _.forIn(this.resourceTemplateDefinition,(t=>{let r=t;_.forEach(r.options,(t=>{let r=t;e.set(r.name,r)}))})),e}getResourceTemplateTypes(){return ContractTypes}getResourceTemplateTypeData(e){return this.resourceTemplateDefinition[e]}getResourceTemplateOption(e){return this.resourceOptions.get(e)}getWorkspace(){return this.workspace}getModules(){let e=this.workspace.getSourcePath(),t=walkSync(e,{depthLimit:0,nofile:!0}),r=_.map(t,(t=>path.relative(e,t.path)));return _.without(r,...exports.NON_MODULES)}getReferenceObjects(e){let t=this.workspace.getSourcePath(),r=(0,fsHelper_1.joinPaths)(t,e,"BO"),s=[];return(0,fsHelper_1.existsFolder)(r)&&(s=walkSync(r,{depthLimit:0,nofile:!0})),_.map(s,(e=>path.relative(r,e.path)))}getWorkspaceParameters(){return{CUSTOM:this.workspace.isProjectWorkspace()?NameIdentifier.Custom:NameIdentifier.Core,NAMESPACE:this.workspace.isProjectWorkspace()?Namespace.Custom:Namespace.Core}}getResourceName(e,t,r){let s;switch(e){case ContractType.BusinessObject:case ContractType.ListObject:case ContractType.LookupObject:case ContractType.BusinessLogic:s=`${r}${t}`;break;case ContractType.DataSource:s=r===NameIdentifier.Custom&&t.indexOf(r)>=0?t:`${r}${t}`;break;default:s=`${t}`}return s}getMethodName(e){return _.lowerFirst(e)}getMethodFileName(e){return _.upperFirst(e)}getReferenceObjectMethodFolder(e,t){let r,s=this.workspace.getSourcePath(),a=(0,fsHelper_1.joinPaths)(s,e,"BO",t);return r=(0,fsHelper_1.existsFolder)((0,fsHelper_1.joinPaths)(a,"Mv1"))?"Mv1":"Mv2",r}getReferenceObjectBaseType(e){let t;return t=e.startsWith("Lo")?ContractType.ListObject:e.startsWith("Lu")?ContractType.LookupObject:ContractType.BusinessObject,t}}exports.TemplateEngineContext=TemplateEngineContext;class Utils{static parseStringEnumValue(e,t){let r=Object.keys(t).find((r=>t[r]===e));return t[r]}}exports.Utils=Utils;class TemplateEngine{constructor(e){this.context=new TemplateEngineContext(e)}getResourceTypeOptions(e){return _.map(e,(e=>e.name))}convertAnswersToParameters(e){let t={};return _.forIn(e,((e,r)=>{t[r.toUpperCase()]=e})),t}evaluateFunctionSpec(e,t){let r=e.fn,s=e.args;s=_.map(s,(e=>this.replaceTemplateParameters(e,t)));let a=this.context[r].apply(this.context,s);return e.allowNone&&_.isArrayLike(a)&&a.push({name:"(none)",value:""}),a}resolveParameter(e,t){let r;return r="string"==typeof e?this.replaceTemplateParameters(e,t):this.evaluateFunctionSpec(e,t),r}resolveOptionParameters(e,t){_.isNil(e)||_.forIn(e,((e,r)=>{let s=this.resolveParameter(e,t);t[r]=s}))}resolveReturnParameters(e,t){if(!_.isNil(e)){let r=this.setupParameters(e,t);_.merge(e,r)}}setupParameters(e,t){let r={};return _.isNil(e)||_.forIn(e,((e,s)=>{let a=this.resolveParameter(e,t);r[s]=a})),r}replaceTemplateParameters(e,t){let r=e;return _.forIn(t,((e,t)=>{if("string"==typeof e){let s=new RegExp(_.join(["\\${",t,"}"],""),"gm"),a=e;r=_.replace(r,s,a)}})),r}expandResources(e){let t=[];return _.forEach(e,(e=>{switch(e.type){case ResourceType.File:this.expandFileResource(e,t);break;case ResourceType.Folder:this.expandFolderResource(e,t);break;case ResourceType.Tree:this.expandTreeResource(e,t)}})),t}resolveResources(e,t){let r=[];return _.forEach(e,(e=>{let s=_.clone(e);s.target=this.replaceTemplateParameters(s.target,t),s.type===ResourceType.File&&this.prepareResourceFileData(s,t),r.push(s)})),r}getResourceSourcePath(e){return e&&e.source?(0,fsHelper_1.joinPaths)((0,templateHelper_1.getContractTemplatesPath)(),e.source):null}getResourceTargetPath(e){return(0,fsHelper_1.joinPaths)(this.context.getWorkspace().getSourcePath(),e.target)}prepareResourceFileData(e,t){if(e.type===ResourceType.File){let r;if(e.action===ResourceAction.Add)r=(0,fsHelper_1.readTextFile)(e.source);else if(e.action===ResourceAction.Update){let s=path.basename(e.target);if(r=(0,fsHelper_1.readTextFile)(e.target),!r)return e.state.error=!0,void(e.state.message=`Error loading '${s}' contract for XML templating.`);let a=e.tpl;if(a){a.data=this.replaceTemplateParameters(a.data,t);try{r=(0,xmlHelper_1.applyXmlTemplating)(a,r)}catch(t){let r="";t&&(r=t.message),e.state.error=!0,e.state.message=`Error during XML templating of '${s}' contract${_.isEmpty(r)?"":" -> "}${r}`}}}r=this.replaceTemplateParameters(r,t),e.data=r}}createResource(e,t,r,s){return{type:e,action:t,state:{error:!1,message:""},source:r,target:s}}expandFileResource(e,t){let r=Object.assign({},e,{action:e.action||ResourceAction.Add,state:{error:!1,message:""},source:this.getResourceSourcePath(e),target:this.getResourceTargetPath(e)});t.push(r)}expandFolderResource(e,t){let r=this.createResource(ResourceType.Folder,ResourceAction.Add,this.getResourceSourcePath(e),this.getResourceTargetPath(e));t.push(r)}expandTreeResource(e,t){let r=this.getResourceSourcePath(e),s=this.getResourceTargetPath(e);this.expandFolderResource(e,t);let a=walkSync(r,{filter:e=>!e.stats.isFile()||!e.path.endsWith(".md")});_.forEach(a,(e=>{let a;e.stats.isFile()?a=ResourceType.File:e.stats.isDirectory()&&(a=ResourceType.Folder);let o=e.path,i=(0,fsHelper_1.joinPaths)(s,path.relative(r,e.path)),n=this.createResource(a,ResourceAction.Add,o,i);t.push(n)}))}createResources(e){_.forEach(e,(e=>{switch(e.action||ResourceAction.Add){case ResourceAction.Add:e.type===ResourceType.File?(0,fsHelper_1.ensureFileExists)(e.target,e.data):(0,fsHelper_1.ensureFolderExists)(e.target);break;case ResourceAction.Update:e.type===ResourceType.File&&(0,fsHelper_1.writeFile)(e.target,e.data)}}))}canCreateResources(e,t,r){let s=!0,a=null,o=_.filter(e,(e=>e?.state.error));if(_.isEmpty(o)){let o=_.filter(e,(e=>e.type===ResourceType.File&&e.action===ResourceAction.Add)),i=null;_.forEach(o,(e=>{if(s&&(0,fsHelper_1.existsFile)(e.target)){s=!1,i=_.first(o).target;let e=(0,fsHelper_1.parentPath)(this.context.getWorkspace().getBasePath());switch(t){case ContractType.BusinessObject:case ContractType.ListObject:case ContractType.LookupObject:i=(0,fsHelper_1.parentPath)(i);case ContractType.DataSource:case ContractType.BusinessLogic:}i=(0,fsHelper_1.relativePath)(e,i)}})),s||(a=`The ${t} '${r}' already exists at ${i}. To create a new ${t}, re-run the command and specify a unique name.`)}else s=!1,a=_.join(_.map(o,(e=>e?.state.message)),"\n");return{success:s,message:a}}async processResourceOption(e,t,r,s){let a=!1;_.isNil(r)&&(a=!0,r=[]);let o={option:e,main:a,parameters:null,resources:null},i=_.clone(t);_.isNil(s)||(i=_.merge(i,s)),e?.questions&&(i=await this.askAdditionalQuestions(e.questions,i));let n=this.convertAnswersToParameters(i);n=_.merge(n,this.context.getWorkspaceParameters()),this.resolveOptionParameters(e.parameters,n),this.resolveReturnParameters(e.returnParameters,n);let p=this.expandResources(e.resources);if(o.parameters=n,o.resources=p,r.push(o),e?.includes)for(let t=0;t<e.includes.length;t++){const s=e.includes[t];let a=s.name,p=this.context.getResourceTemplateOption(a),c=this.setupParameters(s?.parameters,n);await this.processResourceOption(p,i,r,c),p?.returnParameters&&(o.parameters=_.merge(o.parameters,p.returnParameters))}if(o.main){let e=[];_.forEach(r,(t=>{const r=this.resolveResources(t.resources,t.parameters);e=e.concat(r)})),p=e}return{resources:p,parameters:n}}validateName(e){let t=[];t.push((e=>!(e.length<3||e.length>26)||"Use a minimum of 3 and a maximum of 26 characters containing alphanumeric and the underscore symbol.")),t.push((e=>!!new RegExp("^[a-zA-Z0-9_]+$","g").test(e)||"Use alphanumeric characters and the underscore symbol.")),t.push((e=>!new RegExp(NameIdentifier.Custom,"gi").test(e)||`Avoid using '${NameIdentifier.Custom}' in name value.`));let r=new ValidationSet(t);return r.validate.bind(r)}async askForResourceType(e,t){return inquirer.prompt([{name:QuestionType.Type,message:"Select the resource you want to add.",type:"list",choices:e}],t)}async askForResourceName(e){let t=_.get(e,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Name,message:`Specify a name for the ${t}:`,type:"input",validate:this.validateName(t)}],e)}async askForModule(e,t){let r=_.get(t,QuestionType.Name),s=_.get(t,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Module,message:`Select the module to which ${s} '${r}' should be added.`,type:"list",choices:e}],t)}async askForOption(e,t){let r=_.get(t,QuestionType.Name),s=_.get(t,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Option,message:`Select a suitable option for ${s} '${r}'.`,type:"list",choices:e}],t)}buildOptionQuestions(e,t){let r=_.cloneDeep(e),s=this.convertAnswersToParameters(t);return _.forEach(r,(e=>{e.choices=this.evaluateFunctionSpec(e.choices,s)})),r}async askAdditionalQuestions(e,t){let r=this.buildOptionQuestions(e,t);return inquirer.prompt(r,t)}async askForConfirmation(e){let t=_.get(e,QuestionType.Name),r=_.get(e,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Confirmation,message:`Do you really want to create the ${r} '${t}'?`,type:"confirm"}],e)}async processRequest(e){let t={State:TemplateEngineState.NEW,Message:"",Type:"",Name:"",Files:[]};try{let r=await this.askForResourceType(this.context.getResourceTemplateTypes(),e);r=await this.askForResourceName(r);let s=_.get(r,QuestionType.Type),a=Utils.parseStringEnumValue(s,ContractType),o=this.context.getResourceTemplateTypeData(a);if(o){!0===o.moduleRequired&&(r=await this.askForModule(this.context.getModules(),r));let e,s=o.options;if(1===s.length){let e={};e[QuestionType.Option]=s[0].name,r=_.merge(r,e)}r=await this.askForOption(this.getResourceTypeOptions(s),r);let a=_.get(r,QuestionType.Option);e=this.context.getResourceTemplateOption(a);let i=await this.processResourceOption(e,r),n=_.get(i.parameters,QuestionType.FullName,"");_.isEmpty(n)&&(n=_.get(i.parameters,QuestionType.Name));let p=_.get(i.parameters,QuestionType.Type);t.Name=n,t.Type=p;let c=this.canCreateResources(i.resources,p,n);if(c.success){r=await this.askForConfirmation(r),!0===_.get(r,QuestionType.Confirmation)?(this.createResources(i.resources),t.State=TemplateEngineState.DONE,t.Files=_.compact(_.map(i.resources,(e=>{if(e.type===ResourceType.File)return e.target})))):t.State=TemplateEngineState.ABORTED}else t.State=TemplateEngineState.FAILED,t.Message=c.message}}catch(e){t.State=TemplateEngineState.FAILED,t.Message=e.toString()}return t}}exports.TemplateEngine=TemplateEngine;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TemplateEngine=exports.Utils=exports.TemplateEngineContext=exports.ValidationSet=exports.NON_MODULES=exports.TemplateEngineState=exports.ResourceType=exports.ResourceAction=exports.ContractTypes=exports.ContractType=exports.QuestionType=exports.Namespace=exports.NameIdentifier=void 0;const _=require("lodash"),inquirer=require("inquirer"),path=require("path"),walkSync=require("klaw-sync"),fsHelper_1=require("./fsHelper"),templateHelper_1=require("./templateHelper"),xmlHelper_1=require("./xmlHelper"),constants_1=require("../constants");var NameIdentifier,Namespace,QuestionType,ContractType,ResourceAction,ResourceType,TemplateEngineState;!function(e){e.Core="",e.Custom="My"}(NameIdentifier=exports.NameIdentifier||(exports.NameIdentifier={})),function(e){e.Core="CORE",e.Custom="CUSTOM"}(Namespace=exports.Namespace||(exports.Namespace={})),function(e){e.Type="TYPE",e.Name="NAME",e.Module="MODULE",e.FullName="FULL_NAME",e.Option="OPTION",e.Confirmation="CONFIRMATION"}(QuestionType=exports.QuestionType||(exports.QuestionType={})),function(e){e.Module="module",e.BusinessObject="businessobject",e.ListObject="listobject",e.LookupObject="lookupobject",e.DataSource="datasource",e.BusinessLogic="businesslogic",e.UserInterface="userinterface",e.Process="process"}(ContractType=exports.ContractType||(exports.ContractType={})),exports.ContractTypes=Object.values(ContractType),function(e){e.Add="add",e.Update="update"}(ResourceAction=exports.ResourceAction||(exports.ResourceAction={})),function(e){e.File="file",e.Folder="folder",e.Tree="tree"}(ResourceType=exports.ResourceType||(exports.ResourceType={})),function(e){e[e.NEW=0]="NEW",e[e.DONE=1]="DONE",e[e.FAILED=2]="FAILED",e[e.ABORTED=3]="ABORTED"}(TemplateEngineState=exports.TemplateEngineState||(exports.TemplateEngineState={})),exports.NON_MODULES=["Application","BusinessObjectHelpers","ExternalFiles","Images","Locale","Plugins","SharedWebData","UI Plugins"];class ValidationSet{constructor(e){this.validations=e}validate(e){let t=!0;return _.forEach(this.validations,(r=>{let s=r(e);_.isBoolean(s)||!s||(t=s)})),t}}exports.ValidationSet=ValidationSet;class TemplateEngineContext{constructor(e){this.resourceTemplateDefinition=this.__loadResourceTemplateDefinition(),this.resourceOptions=this.__createResourceOptionsMap(),this.workspace=e}__loadResourceTemplateDefinition(){return(0,fsHelper_1.readJsonFile)((0,templateHelper_1.getTemplateDefinitionsFilePath)())}__createResourceOptionsMap(){let e=new Map;return _.forIn(this.resourceTemplateDefinition,(t=>{_.forEach(t.options,(t=>{let r=t;e.set(r.name,r)}))})),e}getResourceTemplateTypes(){return exports.ContractTypes}getResourceTemplateTypeData(e){return this.resourceTemplateDefinition[e]}getResourceTemplateOption(e){return this.resourceOptions.get(e)}getWorkspace(){return this.workspace}getModules(){let e=this.workspace.getSourcePath(),t=walkSync(e,{depthLimit:0,nofile:!0}),r=_.map(t,(t=>path.relative(e,t.path)));return _.without(r,...exports.NON_MODULES)}getReferenceObjects(e){let t=this.workspace.getSourcePath(),r=(0,fsHelper_1.joinPaths)(t,e,"BO"),s=[];return(0,fsHelper_1.existsFolder)(r)&&(s=walkSync(r,{depthLimit:0,nofile:!0})),_.map(s,(e=>path.relative(r,e.path)))}getReferenceProcessFlows(e,t=ContractType.UserInterface){if(t===ContractType.Process){return[{name:`${e}::FakeProcess`,value:(0,fsHelper_1.joinPaths)(e,"PR",`${e}_Fake`,`${e}_FakeProcess${constants_1.WorkspaceConstants.PROCESS_FLOW_FILE_ENDING}`)}]}const r=this.workspace.getSourcePath(),s=(0,fsHelper_1.joinPaths)(r,e,"PR");let a=[];if((0,fsHelper_1.existsFolder)(s)&&(a=walkSync(s,{traverseAll:!0,nodir:!0,filter:e=>e.path.endsWith(constants_1.WorkspaceConstants.PROCESS_FLOW_FILE_ENDING)})),_.isEmpty(a))throw"Make sure at least one process contract exists in the module to add a userinterface contract. To create a process contract for a module, run the 'sf modeler workspace add' command and select the process resource. Alternatively, retry the command with userinterface resource and select a module which has a process contract.";return _.map(a,(e=>({name:(0,xmlHelper_1.getRootName)((0,fsHelper_1.readTextFile)(e.path)),value:path.relative(r,e.path)})))}getWorkspaceParameters(){return{CUSTOM:this.workspace.isProjectWorkspace()?NameIdentifier.Custom:NameIdentifier.Core,NAMESPACE:this.workspace.isProjectWorkspace()?Namespace.Custom:Namespace.Core}}getResourceName(e,t,r){let s;switch(e){case ContractType.BusinessObject:case ContractType.ListObject:case ContractType.LookupObject:case ContractType.BusinessLogic:case ContractType.UserInterface:case ContractType.Process:s=this.addPrefix(t,r);break;case ContractType.DataSource:s=r===NameIdentifier.Custom&&t.indexOf(r)>=0?t:`${r}${t}`;break;default:s=`${t}`}return s}addSuffix(e,t){return e?.endsWith(t)||(e+=t),e}addPrefix(e,t){return e?.startsWith(t)||(e=`${t}${e}`),e}getParentPath(e){return(0,fsHelper_1.parentPath)(e)}getMethodName(e){return _.lowerFirst(e)}getMethodFileName(e){return _.upperFirst(e)}getReferenceObjectMethodFolder(e,t){let r,s=this.workspace.getSourcePath(),a=(0,fsHelper_1.joinPaths)(s,e,"BO",t);return r=(0,fsHelper_1.existsFolder)((0,fsHelper_1.joinPaths)(a,"Mv1"))?"Mv1":"Mv2",r}getReferenceObjectBaseType(e){let t;return t=e.startsWith("Lo")?ContractType.ListObject:e.startsWith("Lu")?ContractType.LookupObject:ContractType.BusinessObject,t}}exports.TemplateEngineContext=TemplateEngineContext;class Utils{static parseStringEnumValue(e,t){let r=Object.keys(t).find((r=>t[r]===e));return t[r]}}exports.Utils=Utils;class TemplateEngine{constructor(e){this.requestFileResources=[],this.context=new TemplateEngineContext(e)}getResourceTypeOptions(e){return _.map(e,(e=>e.name))}convertAnswersToParameters(e){let t={};return _.forIn(e,((e,r)=>{t[r.toUpperCase()]=e})),t}evaluateFunctionSpec(e,t){let r=e.fn,s=e.args;s=_.map(s,(e=>this.replaceTemplateParameters(e,t)));let a=this.context[r].apply(this.context,s);return e.allowNone&&_.isArrayLike(a)&&a.push({name:"(none)",value:""}),a}resolveParameter(e,t){let r;return r="string"==typeof e?this.replaceTemplateParameters(e,t):this.evaluateFunctionSpec(e,t),r}resolveOptionParameters(e,t){_.isNil(e)||_.forIn(e,((e,r)=>{t[r]=this.resolveParameter(e,t)}))}resolveReturnParameters(e,t){if(!_.isNil(e)){let r=this.setupParameters(e,t);_.merge(e,r)}}setupParameters(e,t){let r={};return _.isNil(e)||_.forIn(e,((e,s)=>{r[s]=this.resolveParameter(e,t)})),r}replaceTemplateParameters(e,t){let r=e;return _.forIn(t,((e,t)=>{if("string"==typeof e){let s=new RegExp(_.join(["\\${",t,"}"],""),"gm");r=_.replace(r,s,e)}})),r}expandResources(e){let t=[];return _.forEach(e,(e=>{switch(e.type){case ResourceType.File:this.expandFileResource(e,t);break;case ResourceType.Folder:this.expandFolderResource(e,t);break;case ResourceType.Tree:this.expandTreeResource(e,t)}})),t}resolveResources(e,t){let r=[];return _.forEach(e,(e=>{let s=_.clone(e);s.target=this.replaceTemplateParameters(s.target,t),s.type===ResourceType.File&&(this.prepareResourceFileData(s,t),this.requestFileResources.push(s)),r.push(s)})),r}getResourceSourcePath(e){return e&&e.source?(0,fsHelper_1.joinPaths)((0,templateHelper_1.getContractTemplatesPath)(),e.source):null}getResourceTargetPath(e){return(0,fsHelper_1.joinPaths)(this.context.getWorkspace().getSourcePath(),e.target)}prepareResourceFileData(e,t){if(e.type===ResourceType.File){let r;if(e.action===ResourceAction.Add)r=(0,fsHelper_1.readTextFile)(e.source);else if(e.action===ResourceAction.Update){let s=path.basename(e.target);if(r=(0,fsHelper_1.readTextFile)(e.target),!r){const a=this.requestFileResources.find((r=>e.target===this.replaceTemplateParameters(r.target,t)));if(!a||!a.data)return e.state.error=!0,void(e.state.message=`Error loading '${s}' contract for XML templating.`);r=a.data}let a=e.tpl;if(a){a.data=this.replaceTemplateParameters(a.data,t);try{r=(0,xmlHelper_1.applyXmlTemplating)(a,r)}catch(t){let r="";t&&(r=t.message),e.state.error=!0,e.state.message=`Error during XML templating of '${s}' contract${_.isEmpty(r)?"":" -> "}${r}`}}}r=this.replaceTemplateParameters(r,t),e.data=r}}createResource(e,t,r,s){return{type:e,action:t,state:{error:!1,message:""},source:r,target:s}}expandFileResource(e,t){let r=Object.assign({},e,{action:e.action||ResourceAction.Add,state:{error:!1,message:""},source:this.getResourceSourcePath(e),target:this.getResourceTargetPath(e)});t.push(r)}expandFolderResource(e,t){let r=this.createResource(ResourceType.Folder,ResourceAction.Add,this.getResourceSourcePath(e),this.getResourceTargetPath(e));t.push(r)}expandTreeResource(e,t){let r=this.getResourceSourcePath(e),s=this.getResourceTargetPath(e);this.expandFolderResource(e,t);let a=walkSync(r,{filter:e=>!e.stats.isFile()||!e.path.endsWith(".md")});_.forEach(a,(e=>{let a;e.stats.isFile()?a=ResourceType.File:e.stats.isDirectory()&&(a=ResourceType.Folder);let o=e.path,i=(0,fsHelper_1.joinPaths)(s,path.relative(r,e.path)),n=this.createResource(a,ResourceAction.Add,o,i);t.push(n)}))}createResources(e){_.forEach(e,(e=>{switch(e.action||ResourceAction.Add){case ResourceAction.Add:e.type===ResourceType.File?(0,fsHelper_1.ensureFileExists)(e.target,e.data):(0,fsHelper_1.ensureFolderExists)(e.target);break;case ResourceAction.Update:e.type===ResourceType.File&&(0,fsHelper_1.writeFile)(e.target,e.data)}}))}canCreateResources(e,t,r){let s=!0,a=null,o=_.filter(e,(e=>e?.state.error));if(_.isEmpty(o)){let o=_.filter(e,(e=>e.type===ResourceType.File&&e.action===ResourceAction.Add)),i=null;_.forEach(o,(e=>{if(s&&(0,fsHelper_1.existsFile)(e.target)){s=!1,i=_.first(o).target;let e=(0,fsHelper_1.parentPath)(this.context.getWorkspace().getBasePath());switch(t){case ContractType.BusinessObject:case ContractType.ListObject:case ContractType.LookupObject:i=(0,fsHelper_1.parentPath)(i)}i=(0,fsHelper_1.relativePath)(e,i)}})),s||(a=`The ${t} '${r}' already exists at ${i}. To create a new ${t}, re-run the command and specify a unique name.`)}else s=!1,a=_.join(_.map(o,(e=>e?.state.message)),"\n");return{success:s,message:a}}async processResourceOption(e,t,r,s){let a=!1;_.isNil(r)&&(a=!0,r=[]);let o={option:e,main:a,parameters:null,resources:null},i=_.clone(t);_.isNil(s)||(i=_.merge(i,s)),e?.questions&&(i=await this.askAdditionalQuestions(e.questions,i));let n=this.convertAnswersToParameters(i);n=_.merge(n,this.context.getWorkspaceParameters()),this.resolveOptionParameters(e.parameters,n),this.resolveReturnParameters(e.returnParameters,n);let c=this.expandResources(e.resources);if(o.parameters=n,o.resources=c,r.push(o),e?.includes)for(let t=0;t<e.includes.length;t++){const s=e.includes[t];let a=s.name,c=this.context.getResourceTemplateOption(a),p=this.setupParameters(s?.parameters,n);await this.processResourceOption(c,i,r,p),c?.returnParameters&&(o.parameters=_.merge(o.parameters,c.returnParameters))}if(o.main){let e=[];_.forEach(r,(t=>{const r=this.resolveResources(t.resources,t.parameters);e=e.concat(r)})),c=e}return{resources:c,parameters:n}}validateName(e){let t=[];t.push((e=>!(e.length<3||e.length>26)||"Use a minimum of 3 and a maximum of 26 characters containing alphanumeric and the underscore symbol.")),t.push((e=>!!new RegExp("^[a-zA-Z0-9_]+$","g").test(e)||"Use alphanumeric characters and the underscore symbol.")),t.push((e=>!new RegExp(NameIdentifier.Custom,"gi").test(e)||`Avoid using '${NameIdentifier.Custom}' in name value.`));let r=new ValidationSet(t);return r.validate.bind(r)}async askForResourceType(e,t){return inquirer.prompt([{name:QuestionType.Type,message:"Select the resource you want to add.",type:"list",choices:e}],t)}async askForResourceName(e){let t=_.get(e,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Name,message:`Specify a name for the ${t}:`,type:"input",validate:this.validateName(t)}],e)}async askForModule(e,t){let r=_.get(t,QuestionType.Name),s=_.get(t,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Module,message:`Select the module to which ${s} '${r}' should be added.`,type:"list",choices:e}],t)}async askForOption(e,t){let r=_.get(t,QuestionType.Name),s=_.get(t,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Option,message:`Select a suitable option for ${s} '${r}'.`,type:"list",choices:e}],t)}buildOptionQuestions(e,t){let r=_.cloneDeep(e),s=this.convertAnswersToParameters(t);return _.forEach(r,(e=>{e.choices=this.evaluateFunctionSpec(e.choices,s)})),r}async askAdditionalQuestions(e,t){let r=this.buildOptionQuestions(e,t);return inquirer.prompt(r,t)}async askForConfirmation(e){let t=_.get(e,QuestionType.Name),r=_.get(e,QuestionType.Type);return inquirer.prompt([{name:QuestionType.Confirmation,message:`Do you really want to create the ${r} '${t}'?`,type:"confirm"}],e)}async processRequest(e){let t,r={State:TemplateEngineState.NEW,Message:"",Type:"",Name:"",Files:[]};try{t=await this.askForResourceType(this.context.getResourceTemplateTypes(),e),t=await this.askForResourceName(t);let s=_.get(t,QuestionType.Type),a=Utils.parseStringEnumValue(s,ContractType),o=this.context.getResourceTemplateTypeData(a);if(o){!0===o.moduleRequired&&(t=await this.askForModule(this.context.getModules(),t));let e,s=o.options;if(1===s.length){let e={};e[QuestionType.Option]=s[0].name,t=_.merge(t,e)}t=await this.askForOption(this.getResourceTypeOptions(s),t);let a=_.get(t,QuestionType.Option);e=this.context.getResourceTemplateOption(a),this.requestFileResources=[];let i=await this.processResourceOption(e,t),n=_.get(i.parameters,QuestionType.FullName,"");_.isEmpty(n)&&(n=_.get(i.parameters,QuestionType.Name));let c=_.get(i.parameters,QuestionType.Type);r.Name=n,r.Type=c;let p=this.canCreateResources(i.resources,c,n);if(p.success){t=await this.askForConfirmation(t),!0===_.get(t,QuestionType.Confirmation)?(this.createResources(i.resources),r.State=TemplateEngineState.DONE,r.Files=_.uniq(_.compact(_.map(i.resources,(e=>e.type===ResourceType.File?e.target:null))))):r.State=TemplateEngineState.ABORTED}else r.State=TemplateEngineState.FAILED,r.Message=p.message}}catch(e){r.State=TemplateEngineState.FAILED,r.Message=e.toString(),r.Type=r.Type||t?.TYPE,r.Name=r.Name||t?.NAME}return r}}exports.TemplateEngine=TemplateEngine;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getTemplateReadmeFileData=exports.getTemplateGitIgnoreFileData=exports.getTemplateApplicationConfig=exports.getTemplateDefinitionsFilePath=exports.getContractTemplatesPath=exports.getTemplateFilePath=exports.TemplateFile=void 0;const config_1=require("../types/config"),fsHelper_1=require("./fsHelper");var TemplateFile;function getTemplateFilePath(e){return(0,fsHelper_1.joinPaths)(__dirname,"../../templates",e)}function getContractTemplatesPath(){return(0,fsHelper_1.joinPaths)(__dirname,"../../templates","contractTemplates")}function getTemplateDefinitionsFilePath(){return(0,fsHelper_1.joinPaths)(__dirname,"../../templates","templateDefinitions.json")}function getTemplateApplicationConfig(){return{application:{sfConsumerKey:"",uniqueID:""},server:{port:3e3,referenceImagePath:"",logLevel:config_1.LogLevel.INFO},generator:{logLevel:config_1.LogLevel.ERROR}}}function getTemplateGitIgnoreFileData(){let e=getTemplateFilePath(TemplateFile.GIT_IGNORE);return(0,fsHelper_1.readTextFile)(e)}function getTemplateReadmeFileData(){let e=getTemplateFilePath(TemplateFile.README);return(0,fsHelper_1.readTextFile)(e)}!function(e){e.GIT_IGNORE=".gitignore.tmp",e.README="README.md.tmp"}(TemplateFile=exports.TemplateFile||(exports.TemplateFile={})),exports.getTemplateFilePath=getTemplateFilePath,exports.getContractTemplatesPath=getContractTemplatesPath,exports.getTemplateDefinitionsFilePath=getTemplateDefinitionsFilePath,exports.getTemplateApplicationConfig=getTemplateApplicationConfig,exports.getTemplateGitIgnoreFileData=getTemplateGitIgnoreFileData,exports.getTemplateReadmeFileData=getTemplateReadmeFileData;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getTemplateReadmeFileData=exports.getTemplateGitIgnoreFileData=exports.getTemplateApplicationConfig=exports.getTemplateDefinitionsFilePath=exports.getContractTemplatesPath=exports.getTemplateFilePath=exports.TemplateFile=void 0;const config_1=require("../types/config"),fsHelper_1=require("./fsHelper");var TemplateFile;function getTemplateFilePath(e){return(0,fsHelper_1.joinPaths)(__dirname,"../../templates",e)}function getContractTemplatesPath(){return(0,fsHelper_1.joinPaths)(__dirname,"../../templates","contractTemplates")}function getTemplateDefinitionsFilePath(){return(0,fsHelper_1.joinPaths)(__dirname,"../../templates","templateDefinitions.json")}function getTemplateApplicationConfig(){return{application:{sfConsumerKey:"",sfSubDomainURL:"https://test.salesforce.com/",uniqueID:""},server:{port:3e3,referenceImagePath:"",logLevel:config_1.LogLevel.INFO},generator:{logLevel:config_1.LogLevel.ERROR}}}function getTemplateGitIgnoreFileData(){let e=getTemplateFilePath(TemplateFile.GIT_IGNORE);return(0,fsHelper_1.readTextFile)(e)}function getTemplateReadmeFileData(){let e=getTemplateFilePath(TemplateFile.README);return(0,fsHelper_1.readTextFile)(e)}!function(e){e.GIT_IGNORE=".gitignore.tmp",e.README="README.md.tmp"}(TemplateFile=exports.TemplateFile||(exports.TemplateFile={})),exports.getTemplateFilePath=getTemplateFilePath,exports.getContractTemplatesPath=getContractTemplatesPath,exports.getTemplateDefinitionsFilePath=getTemplateDefinitionsFilePath,exports.getTemplateApplicationConfig=getTemplateApplicationConfig,exports.getTemplateGitIgnoreFileData=getTemplateGitIgnoreFileData,exports.getTemplateReadmeFileData=getTemplateReadmeFileData;
@@ -1 +1 @@
1
- "use strict";let libxmljs;var XmlTemplatingError;function applyXmlTemplating(r,l){libxmljs||(libxmljs=require("libxmljs"));let t,e,m,o=null;try{t=libxmljs.parseXmlString(l)}catch(r){throw new Error(XmlTemplatingError.XML_DOCUMENT_PARSING_ERROR)}try{if(e=t.get(r.xpath),!e)throw new Error}catch(r){throw new Error(XmlTemplatingError.XML_ELEMENT_LOOKUP_ERROR)}try{m=libxmljs.parseXmlString(r.data)}catch(r){throw new Error(XmlTemplatingError.XML_FRAGMENT_PARSING_ERROR)}try{e.addChild(m.root()),o=t.root().toString({declaration:!1,selfCloseEmpty:!0,whitespace:!1,type:"xml"})}catch(r){throw new Error(XmlTemplatingError.XML_MANIPULATION_ERROR)}return o}Object.defineProperty(exports,"__esModule",{value:!0}),exports.applyXmlTemplating=exports.XmlTemplatingError=void 0,function(r){r.XML_DOCUMENT_PARSING_ERROR="Error parsing xmlDocument.",r.XML_ELEMENT_LOOKUP_ERROR="Error getting xmlElement.",r.XML_FRAGMENT_PARSING_ERROR="Error parsing xmlFragment.",r.XML_MANIPULATION_ERROR="Error adding xmlFragment to xmlElement."}(XmlTemplatingError=exports.XmlTemplatingError||(exports.XmlTemplatingError={})),exports.applyXmlTemplating=applyXmlTemplating;
1
+ "use strict";let libxmljs;var XmlTemplatingError;function getXmlDocument(r){libxmljs||(libxmljs=require("libxmljs"));try{return libxmljs.parseXmlString(r)}catch(r){throw new Error(XmlTemplatingError.XML_DOCUMENT_PARSING_ERROR)}}function applyXmlTemplating(r,t){let e,l,o=getXmlDocument(t),m=null;try{if(e=o.get(r.xpath),!e)throw new Error}catch(r){throw new Error(XmlTemplatingError.XML_ELEMENT_LOOKUP_ERROR)}try{l=libxmljs.parseXmlString(r.data)}catch(r){throw new Error(XmlTemplatingError.XML_FRAGMENT_PARSING_ERROR)}try{e.addChild(l.root()),m=o.root().toString({declaration:!1,selfCloseEmpty:!0,whitespace:!1,type:"xml"})}catch(r){throw new Error(XmlTemplatingError.XML_MANIPULATION_ERROR)}return m}function getRootName(r){let t=getXmlDocument(r);return t?.root()?.attr("name")?.value()}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRootName=exports.applyXmlTemplating=exports.XmlTemplatingError=void 0,function(r){r.XML_DOCUMENT_PARSING_ERROR="Error parsing xmlDocument.",r.XML_ELEMENT_LOOKUP_ERROR="Error getting xmlElement.",r.XML_FRAGMENT_PARSING_ERROR="Error parsing xmlFragment.",r.XML_MANIPULATION_ERROR="Error adding xmlFragment to xmlElement."}(XmlTemplatingError=exports.XmlTemplatingError||(exports.XmlTemplatingError={})),exports.applyXmlTemplating=applyXmlTemplating,exports.getRootName=getRootName;
@@ -0,0 +1,50 @@
1
+ # commandDescription
2
+
3
+ Imports design contracts to the specified workspace.
4
+
5
+ # inputFlagDescription
6
+
7
+ Path to the Modeler Content Package (MCP) zip.
8
+
9
+ # coreFlagDescription
10
+
11
+ Use the flag to import only the core contracts (.core.xml) from a custom Modeler Content Package (MCP) zip. Custom
12
+ contracts are skipped during import. If this flag is not set, only the custom contracts (*.xml) are imported from the
13
+ custom MCP.zip.
14
+
15
+ # invalidFilePath
16
+
17
+ Invalid file path: %s. Make sure that the design contracts zip file exists at the specified location and has necessary
18
+ permissions to read.
19
+
20
+ # invalidWorkSpace
21
+
22
+ Invalid workspace at: %s. Ensure that a valid workspace exists at the specified location. To create a workspace, run:
23
+ modeler workspace create
24
+
25
+ # invalidContractsType
26
+
27
+ The src/manifest.json file is missing or src/version.xml file contains invalid attributes.
28
+ For the VS Code based Modeler design contracts, ensure that src/manifest.json exists.
29
+ For the Windows based Modeler contracts, ensure that these attributes are configured in src/version.xml:
30
+ - Mode="Complete"
31
+ - ModelerMode="Salesforce"
32
+ - Type="Cust" or "Core"
33
+
34
+ # importContractsSuccess
35
+
36
+ Successfully imported the design contracts.
37
+
38
+ # unexpectedError
39
+
40
+ Unexpected error occured while importing contracts.
41
+
42
+ # extractingInputMessage
43
+ Extracting input file
44
+
45
+ # importContractsMessage
46
+
47
+ Importing contracts
48
+
49
+ # cleanupMessage
50
+ Cleanup
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "246.1049.0",
2
+ "version": "248.1029.0",
3
3
  "commands": {
4
4
  "modeler:workspace:add": {
5
5
  "id": "modeler:workspace:add",
@@ -398,6 +398,49 @@
398
398
  "args": {},
399
399
  "FINGERPRINT_KEY": "fingerprints"
400
400
  },
401
+ "modeler:workspace:utils:importContracts": {
402
+ "id": "modeler:workspace:utils:importContracts",
403
+ "description": "Imports design contracts to the specified workspace.",
404
+ "strict": true,
405
+ "pluginName": "@ind-rcg/modeler-sfdx-cli-plugin",
406
+ "pluginAlias": "@ind-rcg/modeler-sfdx-cli-plugin",
407
+ "pluginType": "core",
408
+ "aliases": [],
409
+ "flags": {
410
+ "json": {
411
+ "name": "json",
412
+ "type": "boolean",
413
+ "description": "Format output as json.",
414
+ "helpGroup": "GLOBAL",
415
+ "allowNo": false
416
+ },
417
+ "path": {
418
+ "name": "path",
419
+ "type": "option",
420
+ "char": "p",
421
+ "description": "path to the Modeler workspace",
422
+ "required": false,
423
+ "multiple": false
424
+ },
425
+ "input": {
426
+ "name": "input",
427
+ "type": "option",
428
+ "char": "i",
429
+ "summary": "Path to the Modeler Content Package (MCP) zip.",
430
+ "required": true,
431
+ "multiple": false
432
+ },
433
+ "core": {
434
+ "name": "core",
435
+ "type": "boolean",
436
+ "char": "c",
437
+ "summary": "Use the flag to import only the core contracts (.core.xml) from a custom Modeler Content Package (MCP) zip. Custom\ncontracts are skipped during import. If this flag is not set, only the custom contracts (*.xml) are imported from the\ncustom MCP.zip.",
438
+ "required": false,
439
+ "allowNo": false
440
+ }
441
+ },
442
+ "args": {}
443
+ },
401
444
  "modeler:workspace:utils:migrateContracts": {
402
445
  "id": "modeler:workspace:utils:migrateContracts",
403
446
  "description": "Migrate existing contracts in your Modeler workspace to support the latest version of Modeler.",
package/package.json CHANGED
@@ -1,19 +1,20 @@
1
1
  {
2
2
  "name": "@ind-rcg/modeler-sfdx-cli-plugin",
3
3
  "displayName": "modeler-sfdx-cli-plugin",
4
- "version": "246.1049.0",
4
+ "version": "248.1029.0",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "description": "This plugin is an enhancement of the sfdx cli and provide you features to customize the Consumer Goods Cloud Mobility application. This version will be the replacement for the Consumer Goods Mobile Modeler which was hosted on a Windows Server machine.",
8
8
  "dependencies": {
9
- "@ind-rcg/backend": "246.1008.0",
10
- "@ind-rcg/framework": "246.1015.0",
11
- "@ind-rcg/generator": "246.1021.0",
9
+ "@ind-rcg/backend": "248.1006.0",
10
+ "@ind-rcg/framework": "248.1029.0",
11
+ "@ind-rcg/generator": "248.1006.0",
12
12
  "@oclif/core": "2.9.4",
13
13
  "@salesforce/core": "4.1.0",
14
14
  "@salesforce/sf-plugins-core": "3.1.3",
15
15
  "cross-spawn": "6.0.5",
16
- "crypto-js": "4.1.1",
16
+ "crypto-js": "4.2.0",
17
+ "decompress": "4.2.1",
17
18
  "fs-extra": "10.0.0",
18
19
  "inquirer": "8.2.5",
19
20
  "jszip": "3.10.1",
@@ -85,23 +86,23 @@
85
86
  }
86
87
  },
87
88
  "scripts": {
88
- "build": "rm -rf lib && yarn lint && tsc -p . && yarn uglify",
89
+ "build": "rimraf lib && yarn lint && tsc -p . && yarn uglify",
89
90
  "lint": "eslint src/**/*.ts test/**/*.ts",
90
- "prepack": "rm -rf lib && tsc -b && yarn uglify && oclif manifest && oclif readme",
91
- "postpack": "rm -f oclif.manifest.json",
92
- "pretest": "rm -rf lib && yarn build",
91
+ "prepack": "rimraf lib && tsc -b && yarn uglify && oclif manifest && oclif readme",
92
+ "postpack": "rimraf oclif.manifest.json",
93
+ "pretest": "rimraf lib && yarn build",
93
94
  "test": "yarn test-unit",
94
95
  "test-all": "nyc mocha --extension .ts --require ts-node/register --forbid-only \"test/**/*.test.ts\" \"test/**/*.test.nut.ts\"",
95
96
  "test-unit": "nyc mocha --extension .ts --require ts-node/register --forbid-only \"test/**/*.test.ts\"",
96
97
  "test-nut": "nyc mocha --extension .ts --require ts-node/register --forbid-only \"test/**/*.test.nut.ts\"",
97
- "test-single": "nyc mocha --extension .ts --require ts-node/register --forbid-only \"test/**/xmlHelper.test.ts\"",
98
+ "test-single": "nyc mocha --extension .ts --require ts-node/register --forbid-only \"test/**/templateEngine.test.ts\" ",
98
99
  "posttest": "yarn lint",
99
100
  "version": "oclif readme && git add README.md",
100
101
  "readme": "oclif readme",
101
102
  "uglify": "uglifyjs-folder lib -e -x .js -o lib --log-level error"
102
103
  },
103
104
  "sfdx": {
104
- "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@ind-rcg/modeler-sfdx-cli-plugin/246.1049.0.crt",
105
- "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@ind-rcg/modeler-sfdx-cli-plugin/246.1049.0.sig"
105
+ "publicKeyUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@ind-rcg/modeler-sfdx-cli-plugin/248.1029.0.crt",
106
+ "signatureUrl": "https://developer.salesforce.com/media/salesforce-cli/security/@ind-rcg/modeler-sfdx-cli-plugin/248.1029.0.sig"
106
107
  }
107
108
  }
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function afterCreateAsync
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function beforeCreateAsync
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function afterDoValidateAsync
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function beforeDoValidateAsync
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function afterInitialize
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function beforeInitialize
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function afterLoadAsync
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject
@@ -22,9 +22,11 @@
22
22
  * -> async: If declared as async then the function should return a promise.
23
23
  * -> param: List of parameters the function accepts. Make sure the parameters match the function signature.
24
24
  * -> namespace: Use CORE or CUSTOM. If you are a Salesforce client or an implementation partner, always use CUSTOM to enable a seamless release upgrade.
25
- * -> extends: Base class of the LO, BO, and LU objects that this function belongs to.
25
+
26
26
  * -> maxRuntime: Maximum time this function is allowed to run, takes integer value in ms. If the max time is exceeded, error is logged.
27
27
  * -> returns: Type and variable name in which the return value is stored.
28
+ *
29
+ * ------- METHOD RELEVANT GENERATOR PARAMETERS BELOW - ADAPT WITH CAUTION -------
28
30
  * @function beforeLoadAsync
29
31
  * @this Bo${NAME}
30
32
  * @kind businessobject